Class: SparkleAppcast::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/sparkle_appcast/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (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



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
# File 'lib/sparkle_appcast/cli.rb', line 25

def appcast(file)
  params = {
    channel_title: options[:channel_title],
    channel_description: options[:channel_description]
  }
  params[:title] = options[:title] if options[:title]
  params[:publish_date] = Time.parse(options[:publish_date]) if options[:publish_date]

  appcast = Appcast.new(
    Archive.new(file),
    Signer.new(options[:key]),
    options[:url],
    ReleaseNote.new(options[:release_note]),
    params
  )

  rss = appcast.rss.to_s
  if options[:output]
    File.open(options[:output], "w") do |output|
      output.puts(rss)
    end
  else
    STDOUT.puts(rss)
  end
end

#markdown(file = nil) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/sparkle_appcast/cli.rb', line 63

def markdown(file = nil)
  text = if file
    File.read(file)
  else
    STDIN.read
  end
  puts ReleaseNote.markdown(text)
end

#sign(file = nil) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/sparkle_appcast/cli.rb', line 53

def sign(file = nil)
  source = if file
    File.binread(file)
  else
    STDIN.read
  end
  puts Signer.new(options[:key]).sign(source)
end