Class: Commandline
- Inherits:
-
Thor
- Object
- Thor
- Commandline
- Includes:
- Thor::Actions
- Defined in:
- lib/babelish/commandline.rb
Constant Summary collapse
- CSVCLASSES =
[ {:name => "CSV2Strings", :ext => ".strings"}, {:name => "CSV2Android", :ext => ".xml"}, {:name => "CSV2JSON", :ext => ".json"}, {:name => "CSV2Php", :ext => ".php"}, ]
- BASECLASSES =
[ {:name => "Strings2CSV", :ext => ".strings"}, {:name => "Android2CSV", :ext => ".xml"}, {:name => "JSON2CSV", :ext => ".json"}, {:name => "Php2CSV", :ext => ".php"}, ]
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
171 172 173 |
# File 'lib/babelish/commandline.rb', line 171 def self.exit_on_failure? true end |
Instance Method Details
#csv_download ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/babelish/commandline.rb', line 66 def csv_download all = [:sheet] ? false : [:all] filename = ['gd_filename'] raise ArgumentError.new("csv_download command : missing file to download") unless filename if all download(filename) else download(filename, ['output_filename'], ['sheet']) end end |
#init ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/babelish/commandline.rb', line 91 def init if File.exists?(".babelish") say "Config file '.babelish' already exists." else say "Creating new config file '.babelish'." config_file = File.("../../../.babelish.sample", __FILE__) if File.exists?(config_file) system "cp #{config_file} .babelish" else say "Template '#{config_file}' not found." end end end |
#open(file = "translations.csv") ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/babelish/commandline.rb', line 78 def open(file = "translations.csv") filename = file || ["filename"] if File.exists?(filename) say "Opening local file '#{filename}'" system "open \"#{filename}\"" else say "Opening Google Drive file '#{filename}'" gd = Babelish::GoogleDoc.new gd.open filename.to_s end end |