-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' and Update Readme
Conflicts: README.md
- Loading branch information
Showing
13 changed files
with
178 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,49 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
csv2strings (0.2) | ||
csv2strings (0.2.1) | ||
google_drive (= 0.3.6) | ||
nokogiri (= 1.5.10) | ||
thor | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
metaclass (0.0.1) | ||
mocha (0.10.5) | ||
metaclass (~> 0.0.1) | ||
faraday (0.8.8) | ||
multipart-post (~> 1.2.0) | ||
google_drive (0.3.6) | ||
nokogiri (>= 1.4.4, != 1.5.2, != 1.5.1) | ||
oauth (>= 0.3.6) | ||
oauth2 (>= 0.5.0) | ||
httpauth (0.2.0) | ||
jwt (0.1.6) | ||
multi_json (>= 1.0) | ||
multi_json (1.3.6) | ||
multi_xml (0.5.5) | ||
multipart-post (1.2.0) | ||
nokogiri (1.5.10) | ||
oauth (0.4.7) | ||
oauth2 (0.9.2) | ||
faraday (~> 0.8) | ||
httpauth (~> 0.2) | ||
jwt (~> 0.1.4) | ||
multi_json (~> 1.0) | ||
multi_xml (~> 0.5) | ||
rack (~> 1.2) | ||
rack (1.5.2) | ||
rake (0.9.2.2) | ||
simplecov (0.6.4) | ||
multi_json (~> 1.0) | ||
simplecov-html (~> 0.5.3) | ||
simplecov-html (0.5.3) | ||
test-unit (2.4.8) | ||
thor (0.17.0) | ||
thor (0.18.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
csv2strings! | ||
mocha | ||
rake | ||
simplecov | ||
test-unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
#!/usr/bin/env ruby | ||
require File.expand_path('../../lib/command', __FILE__) | ||
require File.expand_path('../../lib/csv2strings_command', __FILE__) | ||
|
||
|
||
if ARGV.count == 1 && ARGV[0] == "help" | ||
Command.start(["help", "csv2strings"],{}) | ||
else | ||
args = ["csv2strings"] | ||
args += ARGV | ||
Command.start(args,{}) | ||
end | ||
CSV2StringsCommand.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
#!/usr/bin/env ruby | ||
require File.expand_path('../../lib/command', __FILE__) | ||
require File.expand_path('../../lib/strings2csv_command', __FILE__) | ||
|
||
if ARGV.count == 1 && ARGV[0] == "help" | ||
Command.start(["help", "strings2csv"],{}) | ||
else | ||
args = ["strings2csv"] | ||
args += ARGV | ||
Command.start(args,{}) | ||
end | ||
|
||
Strings2CSVCommand.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
Gem::Specification.new do |s| | ||
s.name = 'csv2strings' | ||
s.version = '0.2.0' | ||
s.date = '2013-09-02' | ||
s.version = '0.2.1' | ||
s.date = '2013-10-08' | ||
s.summary = "CSV to iOS Localizable.strings converter" | ||
s.description = "ruby script converts a CSV file of translations to Localizable.strings files and vice-versa" | ||
s.authors = ["François Benaiteau"] | ||
s.email = '[email protected]' | ||
s.homepage = 'https://github.com/netbe/CSV-to-iOS-Localizable.strings-converter' | ||
s.license = 'MIT' | ||
|
||
s.add_dependency "thor" | ||
s.add_dependency "fastercsv", :require => 'faster_csv' if RUBY_PLATFORM == 'ruby_19' | ||
s.add_dependency "csv", :require => 'csv' if RUBY_PLATFORM == 'ruby_18' | ||
|
||
|
||
if RUBY_VERSION < '1.9' | ||
s.add_dependency "fastercsv" | ||
end | ||
s.add_dependency "nokogiri", "= 1.5.10" | ||
s.add_dependency "google_drive", '0.3.6' | ||
s.add_development_dependency "rake" | ||
s.add_development_dependency "mocha" | ||
|
||
s.add_development_dependency "test-unit" | ||
s.add_development_dependency "simplecov" | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
$: << File.expand_path(File.join(File.dirname(__FILE__))) | ||
require "command" | ||
class CSV2StringsCommand < Command | ||
default_task :csv2strings | ||
|
||
desc "CSV_FILENAME", "convert CSV file to '.strings' file" | ||
# required options but handled in method because of options read from yaml file | ||
method_option :filename, :type => :string, :desc => "CSV file (CSV_FILENAME) to convert from or name of file in Google Drive" | ||
method_option :fetch, :type => :boolean, :desc => "Download file from Google Drive" | ||
method_option :langs, :type => :hash, :aliases => "-L", :desc => "Languages to convert" | ||
# optional options | ||
method_option :excluded_states, :type => :array, :aliases => "-x", :desc => "Exclude rows with given state" | ||
method_option :state_column, :type => :numeric, :aliases => "-s", :desc => "Position of column for state if any" | ||
method_option :keys_column, :type => :numeric, :aliases => "-k", :desc => "Position of column for keys" | ||
method_option :default_lang, :type => :string, :aliases => "-l", :desc => "Default language to use for empty values if any" | ||
method_option :default_path, :type => :string, :aliases => "-p", :desc => "Path of output files" | ||
def csv2strings(filename = nil) | ||
unless filename || options.has_key?('filename') | ||
say "No value provided for required options '--filename'" | ||
help("csv2strings") | ||
exit | ||
end | ||
|
||
filename ||= options['filename'] | ||
if options['fetch'] | ||
say "Downloading file from Google Drive" | ||
filename = invoke :csv_download, nil, {"gd_filename" => filename} | ||
exit unless filename | ||
end | ||
|
||
unless options.has_key?('langs') | ||
say "No value provided for required options '--langs'" | ||
help("csv2strings") | ||
exit | ||
end | ||
|
||
args = options.dup | ||
args.delete(:langs) | ||
args.delete(:filename) | ||
converter = CSV2Strings::Converter.new(filename, options[:langs], args) | ||
say converter.csv_to_dotstrings | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require "google_drive" | ||
class GoogleDoc | ||
attr_accessor :session | ||
|
||
def authenticate | ||
# will try to get token from ~/.ruby_google_drive.token | ||
@session = GoogleDrive.saved_session | ||
end | ||
|
||
def download(requested_filename, output_filename = "translations.csv") | ||
unless @session | ||
self.authenticate | ||
end | ||
result = @session.file_by_title(requested_filename) | ||
if result.is_a? Array | ||
file = result.first | ||
else | ||
file = result | ||
end | ||
return nil unless file | ||
file.export_as_file(output_filename, "csv") | ||
return output_filename | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
$: << File.expand_path(File.join(File.dirname(__FILE__))) | ||
require "command" | ||
|
||
class Strings2CSVCommand < Command | ||
default_task :strings2csv | ||
|
||
desc "FILENAMES", "convert '.strings' files to CSV file" | ||
# required options but handled in method because of options read from yaml file | ||
method_option :filenames, :type => :array, :aliases => "-i", :desc => "location of strings files (FILENAMES)" | ||
# optional options | ||
method_option :csv_filename, :type => :string, :aliases => "-o", :desc => "location of output file" | ||
method_option :headers, :type => :array, :aliases => "-h", :desc => "override headers of columns, default is name of input files and 'Variables' for reference" | ||
method_option :dryrun, :type => :boolean, :aliases => "-n", :desc => "prints out content of hash without writing file" | ||
def strings2csv | ||
unless options.has_key?('filenames') | ||
say "No value provided for required options '--filenames'" | ||
help("strings2csv") | ||
exit | ||
end | ||
converter = Strings2CSV::Converter.new(options) | ||
debug_values = converter.dotstrings_to_csv(!options[:dryrun]) | ||
say debug_values.inspect if options[:dryrun] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require File.expand_path('../../lib/google_doc', __FILE__) | ||
require File.expand_path('../test_helper', __FILE__) | ||
|
||
class GoogleDocTest < Test::Unit::TestCase | ||
# TODO implement test with mocks | ||
end |
Oops, something went wrong.