thermite 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 947e1f3888fa02e99c72dc31814d37588e2e70ab
4
- data.tar.gz: 623b3ca4569f631b615af1ae78405e2142b55fa9
3
+ metadata.gz: f7e1fdf35d72e4e54a4fb1f473bc907cac1369b3
4
+ data.tar.gz: 587855f223d66731edfcc00ef37c9cf9ef1619a1
5
5
  SHA512:
6
- metadata.gz: c053764f561253ca63e9bf6fed628a97d7b2afea8819f2cc55039c7ce7f059b86004db47440a95982d24231f6a0752319d864cbfcf3e1b985d1aedbb5ac75523
7
- data.tar.gz: 5cbd681ec63085d09863f4c95b3424c046f6fa89e1342c559775005e8ae503f2936a0efe0183a98249c91495e28777cdfbe73235e079df389900c8dca1e98f21
6
+ metadata.gz: 7360723b5236c7142c5875ef9c695c67eea913bcaa3e532d035fbcdbca634e47ecc5e56807a6c608847c521c9866e94e5fbc4bb4bdccd75174d2974ecd5d0059
7
+ data.tar.gz: f8189cb6cbee4bd8e7cf523a5327d74a824f7444fdd1c968170617326d7fbc8f0f121249b85712840f21edfa73bb30248d738522e713101b175328f5f356bdd3
data/NEWS.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ### Added
6
+
7
+ * `github_release_type`, to add `'cargo'` releases via `Cargo.toml` (default) in addition to the
8
+ existing `'latest'` functionality
9
+
10
+ ### Changed
11
+
12
+ * `git_tag_format` option introduced in 0.2.0 renamed to `git_tag_regex` - `git_tag_format` is
13
+ specific to `github_release_type: 'cargo'`, while `git_tag_regex` is specific to
14
+ `github_release_type: 'latest'`
15
+
5
16
  ## [0.2.0] - 2016-06-30
6
17
 
7
18
  ### Added
data/README.md CHANGED
@@ -44,11 +44,19 @@ Possible options:
44
44
  * `cargo_project_path` - the path to the Cargo project. Defaults to the current working directory.
45
45
  * `github_releases` - whether to look for Rust binaries via GitHub releases when installing
46
46
  the gem, and `cargo` is not found. Defaults to `false`.
47
- * `git_tag_format` - when `github_releases` is enabled, a regular expression (expressed as a
48
- `String`) that determines which tagged releases to look for precompiled Rust tarballs. One group
49
- must be specified that indicates the version number to be used in the tarball filename. Defaults
50
- to `vN.N.N`, where `N` is any n-digit number. In this case, the group is around the
51
- entire expression.
47
+ * `github_release_type` - when `github_releases` is `true`, the mode to use to download the Rust
48
+ binary from GitHub releases. `'cargo'` (the default) uses the version in `Cargo.toml`, along with
49
+ the `git_tag_format` option (described below) to determine the download URI. `'latest'` takes the
50
+ latest release matching the `git_tag_regex` option (described below) to determine the download
51
+ URI.
52
+ * `git_tag_format` - when `github_release_type` is `'cargo'` (the default), the
53
+ [format string](http://ruby-doc.org/core/String.html#method-i-25) used to determine the tag used
54
+ in the GitHub download URI. Defaults to `v%s`, where `%s` is the version in `Cargo.toml`.
55
+ * `git_tag_regex` - when `github_releases` is enabled and `github_release_type` is `'latest'`, a
56
+ regular expression (expressed as a `String`) that determines which tagged releases to look for
57
+ precompiled Rust tarballs. One group must be specified that indicates the version number to be
58
+ used in the tarball filename. Defaults to `vN.N.N`, where `N` is any n-digit number. In this case,
59
+ the group is around the entire expression.
52
60
  * `ruby_project_path` - the top-level directory of the Ruby gem's project. Defaults to the
53
61
  current working directory.
54
62
 
@@ -137,18 +137,18 @@ module Thermite
137
137
  #
138
138
  # The basic semantic versioning format.
139
139
  #
140
- DEFAULT_TAG_FORMAT = /^(v\d+\.\d+\.\d+)$/
140
+ DEFAULT_TAG_REGEX = /^(v\d+\.\d+\.\d+)$/
141
141
 
142
142
  #
143
143
  # The format (as a regular expression) that git tags containing Rust binary
144
144
  # tarballs are supposed to match. Defaults to `DEFAULT_TAG_FORMAT`.
145
145
  #
146
- def git_tag_format
147
- @git_tag_format ||= begin
148
- if @options[:git_tag_format]
149
- Regexp.new(@options[:git_tag_format])
146
+ def git_tag_regex
147
+ @git_tag_regex ||= begin
148
+ if @options[:git_tag_regex]
149
+ Regexp.new(@options[:git_tag_regex])
150
150
  else
151
- DEFAULT_TAG_FORMAT
151
+ DEFAULT_TAG_REGEX
152
152
  end
153
153
  end
154
154
  end
@@ -30,19 +30,46 @@ module Thermite
30
30
  #
31
31
  module GithubReleaseBinary
32
32
  #
33
- # Downloads and unpacks the latest binary from GitHub releases, given the target OS
34
- # and architecture.
33
+ # Downloads a Rust binary from GitHub releases, given the target OS and architecture.
35
34
  #
36
35
  # Requires the `github_releases` option to be `true`. It uses the `repository` value in the
37
36
  # project's `Cargo.toml` (in the `package` section) to determine where the releases
38
37
  # are located.
39
38
  #
39
+ # If the `github_release_type` is `'latest'`, it will attempt to use the appropriate binary for
40
+ # the latest version in GitHub releases. Otherwise, it will download the appropriate binary for
41
+ # the crate version given in `Cargo.toml`.
42
+ #
40
43
  # Returns whether a binary was found and unpacked.
41
44
  #
42
- def download_latest_binary_from_github_release
45
+ def download_binary
43
46
  return false unless options[:github_releases]
47
+
48
+ case options[:github_release_type]
49
+ when 'latest'
50
+ download_latest_binary_from_github_release
51
+ else # 'cargo'
52
+ download_cargo_version_from_github_release
53
+ end
54
+ end
55
+
56
+ private
57
+
58
+ def download_cargo_version_from_github_release
59
+ version = config.toml[:package][:version]
60
+ tag = options.fetch(:git_tag_format, 'v%s') % version
61
+ if (tgz = download_binary_from_github_release(github_download_uri(tag, version), version))
62
+ unpack_tarball(tgz)
63
+ true
64
+ end
65
+ end
66
+
67
+ #
68
+ # Downloads and unpacks the latest binary from GitHub releases, given the target OS
69
+ # and architecture.
70
+ #
71
+ def download_latest_binary_from_github_release
44
72
  installed_binary = false
45
- github_uri = config.toml[:package][:repository]
46
73
  each_github_release(github_uri) do |version, download_uri|
47
74
  tgz = download_binary_from_github_release(download_uri, version)
48
75
  next unless tgz
@@ -54,7 +81,13 @@ module Thermite
54
81
  installed_binary
55
82
  end
56
83
 
57
- private
84
+ def github_uri
85
+ @github_uri ||= config.toml[:package][:repository]
86
+ end
87
+
88
+ def github_download_uri(tag, version)
89
+ "#{github_uri}/releases/download/#{tag}/#{config.tarball_filename(version)}"
90
+ end
58
91
 
59
92
  def http_get(uri)
60
93
  Net::HTTP.get(URI(uri))
@@ -64,12 +97,11 @@ module Thermite
64
97
  releases_uri = "#{github_uri}/releases.atom"
65
98
  feed = REXML::Document.new(http_get(releases_uri))
66
99
  REXML::XPath.each(feed, '//entry/title/text()') do |tag|
67
- match = config.git_tag_format.match(tag.to_s)
100
+ match = config.git_tag_regex.match(tag.to_s)
68
101
  next unless match
69
102
  version = match[1]
70
- download_uri = "#{github_uri}/releases/download/#{tag}/#{config.tarball_filename(version)}"
71
103
 
72
- yield(version, download_uri)
104
+ yield(version, github_download_uri(tag, version))
73
105
  end
74
106
  end
75
107
 
@@ -54,11 +54,20 @@ module Thermite
54
54
  # working directory.
55
55
  # * `github_releases` - whether to look for rust binaries via GitHub releases when installing
56
56
  # the gem, and `cargo` is not found. Defaults to `false`.
57
- # * `git_tag_format` - when `github_releases` is enabled, a regular expression (expressed as a
58
- # `String`) that determines which tagged releases to look for precompiled Rust tarballs.
59
- # One group must be specified that indicates the version number to be used in the tarball
60
- # filename. Defaults to `vN.N.N`, where `N` is any n-digit number. In this case, the group is
61
- # around the entire expression.
57
+ # * `github_release_type` - when `github_releases` is `true`, the mode to use to download the
58
+ # Rust binary from GitHub releases. `'cargo'` (the default) uses the version in `Cargo.toml`,
59
+ # along with the `git_tag_format` option (described below) to determine the download URI.
60
+ # `'latest'` takes the latest release matching the `git_tag_regex` option (described below) to
61
+ # determine the download URI.
62
+ # * `git_tag_format` - when `github_release_type` is `'cargo'` (the default), the
63
+ # [format string](http://ruby-doc.org/core/String.html#method-i-25) used to determine the
64
+ # tag used in the GitHub download URI. Defaults to `v%s`, where `%s` is the version in
65
+ # `Cargo.toml`.
66
+ # * `git_tag_regex` - when `github_releases` is enabled and `github_release_type` is
67
+ # `'latest'`, a regular expression (expressed as a `String`) that determines which tagged
68
+ # releases to look for precompiled Rust tarballs. One group must be specified that indicates
69
+ # the version number to be used in the tarball filename. Defaults to `vN.N.N`, where `N` is
70
+ # any n-digit number. In this case, the group is around the entire expression.
62
71
  # * `ruby_project_path` - the toplevel directory of the Ruby gem's project. Defaults to the
63
72
  # current working directory.
64
73
  #
@@ -97,7 +106,7 @@ module Thermite
97
106
  run_cargo_build(target)
98
107
  FileUtils.cp(config.rust_path('target', target, config.shared_library),
99
108
  config.ruby_path('lib'))
100
- elsif !download_latest_binary_from_github_release
109
+ elsif !download_binary
101
110
  raise cargo_required_msg
102
111
  end
103
112
  end
@@ -3,7 +3,7 @@ require 'English'
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'thermite'
6
- s.version = '0.2.0'
6
+ s.version = '0.3.0'
7
7
  s.summary = 'Rake helpers for Rust+Ruby'
8
8
  s.description = 'A Rake-based helper for building and distributing Rust-based Ruby extensions'
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thermite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-30 00:00:00.000000000 Z
11
+ date: 2016-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake