sparkle_appcast 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d53602018aca02ede32180faa6f1793ce88007cfe917f0b49dd8ff7569dbad34
4
- data.tar.gz: 1cf9b9ac1d6674d4db17ab007da8e3ae9dd37e5ed7bd2d3f13db197358827c37
3
+ metadata.gz: 929419facdaf44c5ea9624ec0eb8229b099e5f63697bccffe903d077d9e90309
4
+ data.tar.gz: 0bb5d457ad0839d7896ebb3ed14a7343e2e6cfaa61da0d4e106e825e5c115ad5
5
5
  SHA512:
6
- metadata.gz: 6c06b95f733b14eca7e27b2d7833946758b35c6a83dc3a8200eb062c0b2844d412582b5a86aabe985d3233376348439837a5d6d33e4d947e8ba98d813437b094
7
- data.tar.gz: ab6beee04561fc1b42490b7e1b825fcdb3ff0dfe8ae8c4649126761717dbda0d49b9379e61d25026580e421960443547bbab22c5787ad73be9e6e24ddc511041
6
+ metadata.gz: a0ae0f9ab4b47e86b7fc1c87345e2d34e6d4d44ea87f26a16222bf32bcd64397a2188441a7ccbad57b2c89afe73928efb68ca1269ee8032170393782d36e11de
7
+ data.tar.gz: 6a4fb943634c2e70dbff76dcab3c36a0e5d0efcf57f444fff4b6cec046560456a65a6b4fa51b74dba81ce87ee48eb9932cc21755858e71aa0bec818705231080
data/README.md CHANGED
@@ -27,6 +27,10 @@ to create and update `appcast.xml` for [Sparkle](https://sparkle-project.org).
27
27
  Create `appcast.xml` with an application archive at `FILE_PATH`.
28
28
  The application archive file must contain exact one application bundle.
29
29
 
30
+ The value or content of each template-enabled key can include [Mustache](https://mustache.github.io/) style (``{{key}}``) template.
31
+ Each template is replaced with the value with the information of application bundle.
32
+ Use `info` command to list all possible template keys.
33
+
30
34
  * `--key=KEY`
31
35
 
32
36
  Path to DSA private key file. Required.
@@ -34,10 +38,12 @@ The application archive file must contain exact one application bundle.
34
38
  * `--url=URL`
35
39
 
36
40
  URL to the application archive file published. Required.
41
+ Template is enabled.
37
42
 
38
43
  * `--release-note=RELEASE_NOTE`
39
44
 
40
- Path to a release note text file in Markdown format. Required.
45
+ Path to a release note text file in [Markdown](https://daringfireball.net/projects/markdown/syntax) format. Required.
46
+ Template is enabled on the content of text file.
41
47
 
42
48
  * `--output=OUTPUT`
43
49
 
@@ -47,7 +53,8 @@ The application archive file must contain exact one application bundle.
47
53
  * `--title=TITLE`
48
54
 
49
55
  Title for the release note. Optional.
50
- Default to `"{{Bundle Name}} {Bundle Short Version String}} ({{Bundle Version}})"`.
56
+ Default to `{{bundle_name}} {{bundle_short_version_string}} ({{bundle_version}})`
57
+ Template is enabled.
51
58
 
52
59
  * `--publish-date=PUBLISH_DATE`
53
60
 
@@ -57,12 +64,27 @@ The application archive file must contain exact one application bundle.
57
64
  * `--channel-title=CHANNEL_TITLE`
58
65
 
59
66
  Title of the channel. Optional.
60
- Default to `"Change log"`.
67
+ Default to `{{bundle_name}} Changelog`.
68
+ Template is enabled.
61
69
 
62
70
  * `--channel-description=CHANNEL_DESCRIPTION`
63
71
 
64
72
  Description of the channel. Optional.
65
- Default to `"The most recent changes."`.
73
+ Default to `Most recent changes with links to updates.`.
74
+ Template is enabled.
75
+
76
+ * `--channel-language=CHANNEL_LANGUAGE`
77
+
78
+ Language of the channel. Optional.
79
+ Default to `en`.
80
+ Template is enabled.
81
+
82
+ ### `info [OPTIONS...] [FILE_PATH]`
83
+
84
+ Print information about the application bundle at `FILE_PATH`.
85
+ `FILE_PATH` can be either an application archive or application bundle.
86
+
87
+ Use `help info` for all possible options.
66
88
 
67
89
  ### `sign [OPTIONS...] [FILE_PATH]`
68
90
 
@@ -1,3 +1,5 @@
1
+ require "mustache"
2
+
1
3
  module SparkleAppcast
2
4
  class Appcast
3
5
  attr_reader :signer, :archive, :release_note, :url, :params
@@ -16,27 +18,50 @@ module SparkleAppcast
16
18
 
17
19
  private
18
20
 
21
+ PARAMS_EXCLUDED_FROM_TEMPLATE = [
22
+ # The template is applied already to `description` value. See `base_params`.
23
+ :description,
24
+ :dsa_signature
25
+ ]
26
+
19
27
  def rss_params
28
+ @rss_params ||= base_params.inject({}) do |params, (key, value)|
29
+ unless PARAMS_EXCLUDED_FROM_TEMPLATE.include?(key)
30
+ case value
31
+ when String
32
+ value = Mustache.render(value, context)
33
+ end
34
+ end
35
+ params[key] = value
36
+ params
37
+ end
38
+ end
39
+
40
+ def base_params
20
41
  {
21
- channel_link: archive.bundle_info[:feed_url],
22
- title: title,
23
- description: release_note.html,
42
+ # channel
43
+ channel_link: "{{feed_url}}",
44
+
45
+ # item
46
+ description: release_note.html(context),
24
47
  publish_date: archive.created_at,
48
+
49
+ # enclosure
25
50
  url: url,
26
51
  length: archive.size,
27
- version: archive.bundle_info[:bundle_version],
28
- short_version_string: archive.bundle_info[:bundle_short_version_string],
29
- minimum_system_version: archive.bundle_info[:minimum_system_version],
52
+ version: "{{bundle_version}}",
53
+ short_version_string: "{{bundle_short_version_string}}",
54
+ minimum_system_version: "{{minimum_system_version}}",
30
55
  dsa_signature: dsa_signature
31
56
  }.merge(params)
32
57
  end
33
58
 
34
- def title
35
- "#{archive.bundle_info[:bundle_name]} #{archive.bundle_info[:bundle_short_version_string]} (#{archive.bundle_info[:bundle_version]})"
36
- end
37
-
38
59
  def dsa_signature
39
60
  @dsa_signature ||= signer.sign(archive.data)
40
61
  end
62
+
63
+ def context
64
+ @context ||= archive.bundle_info
65
+ end
41
66
  end
42
67
  end
@@ -10,25 +10,26 @@ module SparkleAppcast
10
10
  end
11
11
 
12
12
  desc "appcast FILE", "Create `appcast.xml` with an application archive file."
13
- long_desc <<-END_OF_DESCRIPTION
14
- Create `appcast.xml` with an application archive file.
15
- The application archive file must contain exact one application bundle.
16
- END_OF_DESCRIPTION
17
13
  option :key, type: :string, required: true, desc: "Path to a DSA private key."
18
14
  option :url, type: :string, required: true, desc: "URL to the application archive file published."
19
15
  option :release_note, type: :string, required: true, desc: "Path to a release note text file in Markdown format."
20
16
  option :output, type: :string, desc: "Path to an output `appcast.xml`."
21
- option :title, type: :string, desc: "Title for the release note."
17
+ option :title, type: :string, default: "{{bundle_name}} {{bundle_short_version_string}} ({{bundle_version}})", desc: "Title for the release note."
22
18
  option :publish_date, type: :string, desc: "Publish date time in local timezone."
23
- option :channel_title, type: :string, default: "Change log", desc: "Title of the channel."
24
- option :channel_description, type: :string, default: "The most recent changes.", desc: "Description of the channel."
19
+ option :channel_title, type: :string, default: "{{bundle_name}} Changelog", desc: "Title of the channel."
20
+ option :channel_description, type: :string, default: "Most recent changes with links to updates.", desc: "Description of the channel."
21
+ option :channel_language, type: :string, default: "en", desc: "Language of the channel."
25
22
  def appcast(file)
26
- params = {
27
- channel_title: options[:channel_title],
28
- channel_description: options[:channel_description]
29
- }
30
- params[:title] = options[:title] if options[:title]
31
- params[:publish_date] = Time.parse(options[:publish_date]) if options[:publish_date]
23
+ params = {}
24
+ [
25
+ :title,
26
+ :publish_date,
27
+ :channel_title,
28
+ :channel_description,
29
+ :channel_language
30
+ ].each do |key|
31
+ params[key] = options[key] if options[key] && !options[key].empty?
32
+ end
32
33
 
33
34
  appcast = Appcast.new(
34
35
  Archive.new(file),
@@ -48,7 +49,7 @@ module SparkleAppcast
48
49
  end
49
50
  end
50
51
 
51
- desc "info FILE", "Print info about the application bundle."
52
+ desc "info FILE", "Print information about the application bundle."
52
53
  Bundle::INFO_KEYS.each do |key|
53
54
  option key, type: :boolean, desc: "Print #{key}."
54
55
  end
@@ -63,7 +64,6 @@ module SparkleAppcast
63
64
  exclude_keys = []
64
65
  Bundle::INFO_KEYS.each do |key|
65
66
  case options[key]
66
- when nil
67
67
  when true
68
68
  include_keys << key
69
69
  when false
@@ -1,3 +1,5 @@
1
+ require "mustache"
2
+
1
3
  module SparkleAppcast
2
4
  class ReleaseNote
3
5
  def self.markdown(text)
@@ -10,8 +12,8 @@ module SparkleAppcast
10
12
  @path = path
11
13
  end
12
14
 
13
- def html
14
- @html ||= self.class.markdown(text)
15
+ def html(context = {})
16
+ self.class.markdown(Mustache.render(text, context))
15
17
  end
16
18
 
17
19
  def text
@@ -50,7 +50,7 @@ module SparkleAppcast
50
50
  channel.add_element("title").add_text(params[:channel_title]) if params[:channel_title]
51
51
  channel.add_element("description").add_text(params[:channel_description]) if params[:channel_description]
52
52
  channel.add_element("link").add_text(params[:channel_link]) if params[:channel_link]
53
- channel.add_element("language").add_text(params[:language]) if params[:language]
53
+ channel.add_element("language").add_text(params[:channel_language]) if params[:channel_language]
54
54
 
55
55
  # <item> ... </item>
56
56
  channel.add_element("item").tap do |item|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparkle_appcast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshimasa Niwa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-17 00:00:00.000000000 Z
11
+ date: 2018-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mustache
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: plist
43
57
  requirement: !ruby/object:Gem::Requirement