thermite 0.2.0 → 0.3.0
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 +4 -4
- data/NEWS.md +11 -0
- data/README.md +13 -5
- data/lib/thermite/config.rb +6 -6
- data/lib/thermite/github_release_binary.rb +40 -8
- data/lib/thermite/tasks.rb +15 -6
- data/thermite.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7e1fdf35d72e4e54a4fb1f473bc907cac1369b3
|
4
|
+
data.tar.gz: 587855f223d66731edfcc00ef37c9cf9ef1619a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
* `
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
|
data/lib/thermite/config.rb
CHANGED
@@ -137,18 +137,18 @@ module Thermite
|
|
137
137
|
#
|
138
138
|
# The basic semantic versioning format.
|
139
139
|
#
|
140
|
-
|
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
|
147
|
-
@
|
148
|
-
if @options[:
|
149
|
-
Regexp.new(@options[:
|
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
|
-
|
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
|
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
|
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
|
-
|
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.
|
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,
|
104
|
+
yield(version, github_download_uri(tag, version))
|
73
105
|
end
|
74
106
|
end
|
75
107
|
|
data/lib/thermite/tasks.rb
CHANGED
@@ -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
|
-
# * `
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
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 !
|
109
|
+
elsif !download_binary
|
101
110
|
raise cargo_required_msg
|
102
111
|
end
|
103
112
|
end
|
data/thermite.gemspec
CHANGED
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.
|
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-
|
11
|
+
date: 2016-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|