Class: Commandline

Inherits:
Thor
  • Object
show all
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

Returns:

  • (Boolean)


152
153
154
# File 'lib/babelish/commandline.rb', line 152

def self.exit_on_failure?
  true
end

Instance Method Details

#csv_downloadObject

Raises:

  • (ArgumentError)


63
64
65
66
67
68
69
70
71
72
# File 'lib/babelish/commandline.rb', line 63

def csv_download
  all = options[:sheet] ? false : options[:all]
  filename = options['gd_filename']
  raise ArgumentError.new("csv_download command : missing file to download") unless filename
  if all
    download(filename)
  else
    download(filename, options['output_filename'], options['sheet'])
  end
end

#open(file = "translations.csv") ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/babelish/commandline.rb', line 75

def open(file = "translations.csv")
  filename = file || options["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

#versionObject



88
89
90
91
# File 'lib/babelish/commandline.rb', line 88

def version
  require "babelish/version"
  say "Babelish #{Babelish::VERSION}"
end