lib/fir-cli.utils.ext.rb in fir-cli-0.1.8 vs lib/fir-cli.utils.ext.rb in fir-cli-0.1.9

- old
+ new

@@ -43,20 +43,20 @@ end def _path(path) path = Pathname.new(Dir.pwd).join(path).cleanpath end no_commands do - %w(token email verbose).each do |_m| + %w(token email verbose origin branch).each do |_m| define_method "_opt_#{_m}" do unless instance_variable_get("@#{_m}") instance_variable_set("@#{_m}", options[_m.to_sym] || @config[_m] ) end instance_variable_get("@#{_m}") end private "_opt_#{_m}".to_sym end - %w(resign quiet color trim).each do |_m| + %w(publish resign quiet color trim).each do |_m| define_method "_opt_#{_m}" do return false if options[_m.to_sym] == false unless instance_variable_get("@#{_m}") instance_variable_set("@#{_m}", options[_m.to_sym] || @config[_m] ) end @@ -129,10 +129,11 @@ _ipa_info path, more elsif _is_apk path _apk_info path, more else _puts "! #{Paint['只能支持后缀为 ipa 和 apk 的文件', :red]}" + exit 1 end end def _apk_info(path, more = false) path = _path path apk = Android::Apk.new path @@ -198,9 +199,28 @@ if path.end_with? '/' path.chop else path end + end + end + def _os + return 'mac' if /darwin/ =~ RUBY_PLATFORM + return 'windows' if /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM + return 'linux' + end + def _exec(cmd, code=1) + output = `#{cmd}` + if $?.exitstatus != 0 + puts output + exit code + end + end + def _convert_settings(*settings) + settings.reduce({}) do |hash, setting| + key,val = setting.split('=', 2).map(&:strip) + hash[key.to_sym] = val + hash end end end end