Class: SparkleAppcast::Cli
- Inherits:
-
Thor
- Object
- Thor
- SparkleAppcast::Cli
- Defined in:
- lib/sparkle_appcast/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #appcast(file) ⇒ Object
- #info(file) ⇒ Object
- #markdown(file = nil) ⇒ Object
- #sign(file = nil) ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
8 9 10 |
# File 'lib/sparkle_appcast/cli.rb', line 8 def self.exit_on_failure? true end |
Instance Method Details
#appcast(file) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sparkle_appcast/cli.rb', line 22 def appcast(file) params = {} [ :title, :publish_date, :channel_title, :channel_description, :channel_language ].each do |key| params[key] = [key] if [key] && ![key].empty? end appcast = Appcast.new( Archive.new(file), Signer.new([:key]), [:url], ReleaseNote.new([:release_note]), params ) rss = appcast.rss.to_s if [:output] File.open([:output], "w") do |output| output.puts(rss) end else STDOUT.puts(rss) end end |
#info(file) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/sparkle_appcast/cli.rb', line 56 def info(file) bundle_info = if File.file?(file) Archive.new(file).bundle_info else Bundle.new(file).info end include_keys = [] exclude_keys = [] Bundle::INFO_KEYS.each do |key| case [key] when true include_keys << key when false exclude_keys << key end end keys = if include_keys.empty? Bundle::INFO_KEYS else include_keys end keys = keys - exclude_keys if keys.count > 1 info = {} keys.each do |key| info[key] = bundle_info[key] end puts info.map{|key, value| "#{key} #{value}"}.join("\n") else keys.each do |key| puts bundle_info[key] end end end |
#markdown(file = nil) ⇒ Object
106 107 108 109 110 111 112 113 |
# File 'lib/sparkle_appcast/cli.rb', line 106 def markdown(file = nil) text = if file File.read(file) else STDIN.read end puts ReleaseNote.markdown(text) end |