thermite 0.1.0 → 0.2.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: 3eebbdde4fa61f1296c77482a2829de788c43af6
4
- data.tar.gz: c18fc5b50c72c8a2df3f715a31e2ccdce1e3f0e0
3
+ metadata.gz: 947e1f3888fa02e99c72dc31814d37588e2e70ab
4
+ data.tar.gz: 623b3ca4569f631b615af1ae78405e2142b55fa9
5
5
  SHA512:
6
- metadata.gz: cc80fcb27a298be17c79241672c905f4d45f4eb9de4d660398e16e0bbea81b22edfee06611327436772d828066989d5a7f6d84cda6f16e7b6421f5baf73dd275
7
- data.tar.gz: 7405ebd134cc09ae927c4a81aa5790ddfcb9feac862f9de455273d46a1e28b4de5f8acf94fab914e8b10a7af4d31fdb814cece4c32dcc343e339344b267bb1ac
6
+ metadata.gz: c053764f561253ca63e9bf6fed628a97d7b2afea8819f2cc55039c7ce7f059b86004db47440a95982d24231f6a0752319d864cbfcf3e1b985d1aedbb5ac75523
7
+ data.tar.gz: 5cbd681ec63085d09863f4c95b3424c046f6fa89e1342c559775005e8ae503f2936a0efe0183a98249c91495e28777cdfbe73235e079df389900c8dca1e98f21
data/.travis.yml CHANGED
@@ -1,3 +1,6 @@
1
1
  language: ruby
2
- rvm: 2.3.1
2
+ rvm:
3
+ - 2.1.10
4
+ - 2.2.5
5
+ - 2.3.1
3
6
  cache: bundler
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,63 @@
1
+ # Contributing to Thermite
2
+
3
+ Thermite is a part of the Rust ecosystem. As such, all contributions to this project follow the
4
+ [Rust language's code of conduct](https://www.rust-lang.org/conduct.html) where appropriate.
5
+
6
+ This project is hosted at [GitHub](https://github.com/malept/thermite). Both pull requests and
7
+ issues of many different kinds are accepted.
8
+
9
+ ## Filing Issues
10
+
11
+ Issues include bugs, questions, feedback, and feature requests. Before you file a new issue, please
12
+ make sure that your issue has not already been filed by someone else.
13
+
14
+ ### Filing Bugs
15
+
16
+ When filing a bug, please include the following information:
17
+
18
+ * Operating system and version. If on Linux, please also include the distribution name.
19
+ * System architecture. Examples include: x86-64, x86, and ARMv7.
20
+ * Ruby and Rake versions that run Thermite.
21
+ * The version (and/or git revision) of Thermite.
22
+ * If it's an error related to Rust, the version of Rust, Cargo, and how you installed it.
23
+ * A detailed list of steps to reproduce the bug. A minimal testcase would be very helpful,
24
+ if possible.
25
+ * If there any any error messages in the console, copying them in the bug summary will be
26
+ very helpful.
27
+
28
+ ## Filing Pull Requests
29
+
30
+ Here are some things to keep in mind as you file a pull request to fix a bug, add a new feature,
31
+ etc.:
32
+
33
+ * Travis CI is used to make sure that the project conforms to the coding standards.
34
+ * If your PR changes the behavior of an existing feature, or adds a new feature, please add/edit
35
+ the RDoc inline documentation (using the Markdown format). You can see what it looks like in the
36
+ rendered documentation by running `bundle exec rake rdoc`.
37
+ * Please ensure that your changes follow the Rubocop-enforced coding standard, by running
38
+ `bundle exec rake rubocop`.
39
+ * If you are contributing a nontrivial change, please add an entry to `NEWS.md`. The format is
40
+ similar to the one described at [Keep a Changelog](http://keepachangelog.com/).
41
+ * Please make sure your commits are rebased onto the latest commit in the master branch, and that
42
+ you limit/squash the number of commits created to a "feature"-level. For instance:
43
+
44
+ bad:
45
+
46
+ ```
47
+ commit 1: add foo algorithm
48
+ commit 2: run rustfmt
49
+ commit 3: add test
50
+ commit 4: add docs
51
+ commit 5: add bar
52
+ commit 6: add test + docs
53
+ ```
54
+
55
+ good:
56
+
57
+ ```
58
+ commit 1: add foo algorithm
59
+ commit 2: add bar
60
+ ```
61
+
62
+ If you are continuing the work of another person's PR and need to rebase/squash, please retain the
63
+ attribution of the original author(s) and continue the work in subsequent commits.
data/NEWS.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changes by Version
2
+
3
+ ## Unreleased
4
+
5
+ ## [0.2.0] - 2016-06-30
6
+
7
+ ### Added
8
+
9
+ * Config options can be set in `Cargo.toml` (and overrides the options set in the `Thermite::Tasks`
10
+ constructor)
11
+
12
+ ### Changed
13
+
14
+ * Git tag formats are configurable via `git_tag_format` - defaults to basic semver format
15
+
16
+ ### Fixed
17
+
18
+ * Accessing the TOML config file when searching for Rust binaries
19
+
20
+ ## [0.1.0] - 2016-06-28
21
+
22
+ Initial release.
23
+
24
+ [0.2.0]: https://github.com/malept/thermite/compare/v0.1.0...v0.2.0
25
+ [0.1.0]: https://github.com/malept/thermite/releases/tag/v0.1.0
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/malept/thermite.svg?branch=master)](https://travis-ci.org/malept/thermite)
4
4
  [![Inline docs](http://inch-ci.org/github/malept/thermite.svg?branch=master)](http://inch-ci.org/github/malept/thermite)
5
+ [![Gem](https://img.shields.io/gem/v/thermite.svg?maxAge=300000)](https://rubygems.org/gems/thermite)
5
6
 
6
7
  Thermite is a Rake-based helper for building and distributing Rust-based Ruby extensions.
7
8
 
@@ -23,12 +24,31 @@ Thermite::Tasks.new
23
24
 
24
25
  Run `rake -T` to view all of the available tasks in the `thermite` namespace.
25
26
 
26
- You can optionally pass arguments to `Thermite::Tasks.new`, which configure the tasks for your
27
- specific project:
27
+ ### Configuration
28
+
29
+ Task configuration for your project can be set in two ways:
30
+
31
+ * passing arguments to `Thermite::Tasks.new`
32
+ * adding a `package.metadata.thermite` section to `Cargo.toml`. These settings override the
33
+ arguments passed to the `Tasks` class. Due to the conflict, it is infeasible for
34
+ `cargo_project_path` to be set in this way. Example section:
35
+
36
+ ```toml
37
+ [package.metadata.thermite]
38
+
39
+ github_releases = true
40
+ ```
41
+
42
+ Possible options:
28
43
 
29
44
  * `cargo_project_path` - the path to the Cargo project. Defaults to the current working directory.
30
45
  * `github_releases` - whether to look for Rust binaries via GitHub releases when installing
31
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.
32
52
  * `ruby_project_path` - the top-level directory of the Ruby gem's project. Defaults to the
33
53
  current working directory.
34
54
 
@@ -50,6 +70,10 @@ According to Wikipedia:
50
70
  * A common thermite reaction uses iron oxide and aluminum to produce iron and aluminum oxide:
51
71
  Fe<sub>2</sub>O<sub>3</sub> + 2Al → 2Fe + Al<sub>2</sub>O<sub>3</sub>
52
72
 
73
+ ## [Release Notes](https://github.com/malept/thermite/blob/master/NEWS.md)
74
+
75
+ ## [Contributing](https://github.com/malept/thermite/blob/master/CONTRIBUTING.md)
76
+
53
77
  ## Legal
54
78
 
55
79
  This gem is licensed under the MIT license.
@@ -134,11 +134,45 @@ module Thermite
134
134
  ruby_path('lib', shared_library)
135
135
  end
136
136
 
137
+ #
138
+ # The basic semantic versioning format.
139
+ #
140
+ DEFAULT_TAG_FORMAT = /^(v\d+\.\d+\.\d+)$/
141
+
142
+ #
143
+ # The format (as a regular expression) that git tags containing Rust binary
144
+ # tarballs are supposed to match. Defaults to `DEFAULT_TAG_FORMAT`.
145
+ #
146
+ def git_tag_format
147
+ @git_tag_format ||= begin
148
+ if @options[:git_tag_format]
149
+ Regexp.new(@options[:git_tag_format])
150
+ else
151
+ DEFAULT_TAG_FORMAT
152
+ end
153
+ end
154
+ end
155
+
137
156
  #
138
157
  # Parsed TOML object (courtesy of `tomlrb`).
139
158
  #
140
159
  def toml
141
160
  @toml ||= Tomlrb.load_file(rust_path('Cargo.toml'), symbolize_keys: true)
142
161
  end
162
+
163
+ #
164
+ # The Thermite-specific config from the TOML file.
165
+ #
166
+ def toml_config
167
+ @toml_config ||= begin
168
+ # Not using .dig to be Ruby < 2.3 compatible
169
+ if toml && toml[:package] && toml[:package][:metadata] &&
170
+ toml[:package][:metadata][:thermite]
171
+ toml[:package][:metadata][:thermite]
172
+ else
173
+ {}
174
+ end
175
+ end
176
+ end
143
177
  end
144
178
  end
@@ -42,7 +42,7 @@ module Thermite
42
42
  def download_latest_binary_from_github_release
43
43
  return false unless options[:github_releases]
44
44
  installed_binary = false
45
- github_uri = toml[:package][:repository]
45
+ github_uri = config.toml[:package][:repository]
46
46
  each_github_release(github_uri) do |version, download_uri|
47
47
  tgz = download_binary_from_github_release(download_uri, version)
48
48
  next unless tgz
@@ -63,8 +63,10 @@ module Thermite
63
63
  def each_github_release(github_uri)
64
64
  releases_uri = "#{github_uri}/releases.atom"
65
65
  feed = REXML::Document.new(http_get(releases_uri))
66
- REXML::XPath.each(feed, '//entry/title[contains(.,"-rust")]/text()') do |tag|
67
- version = tag.to_s.slice(1..-6)
66
+ REXML::XPath.each(feed, '//entry/title/text()') do |tag|
67
+ match = config.git_tag_format.match(tag.to_s)
68
+ next unless match
69
+ version = match[1]
68
70
  download_uri = "#{github_uri}/releases/download/#{tag}/#{config.tarball_filename(version)}"
69
71
 
70
72
  yield(version, download_uri)
@@ -54,9 +54,17 @@ 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
62
  # * `ruby_project_path` - the toplevel directory of the Ruby gem's project. Defaults to the
58
63
  # current working directory.
59
64
  #
65
+ # These values can be overridden by values with the same key name in the
66
+ # `package.metadata.thermite` section of `Cargo.toml`, if that section exists.
67
+ #
60
68
  attr_reader :options
61
69
 
62
70
  #
@@ -71,6 +79,7 @@ module Thermite
71
79
  def initialize(options = {})
72
80
  @options = options
73
81
  @config = Config.new(options)
82
+ @options.merge!(@config.toml_config)
74
83
  define_build_task
75
84
  define_clean_task
76
85
  define_test_task
data/thermite.gemspec CHANGED
@@ -3,7 +3,7 @@ require 'English'
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'thermite'
6
- s.version = '0.1.0'
6
+ s.version = '0.2.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
 
@@ -15,6 +15,8 @@ Gem::Specification.new do |s|
15
15
  s.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
16
16
  s.require_paths = %w(lib)
17
17
 
18
+ # Mostly due to tomlrb
19
+ s.required_ruby_version = '>= 2.0.0'
18
20
  s.add_runtime_dependency 'rake', '~> 11'
19
21
  s.add_runtime_dependency 'minitar', '~> 0.5'
20
22
  s.add_runtime_dependency 'tomlrb', '~> 1.2'
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.1.0
4
+ version: 0.2.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-28 00:00:00.000000000 Z
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -91,8 +91,10 @@ files:
91
91
  - ".rubocop.yml"
92
92
  - ".travis.yml"
93
93
  - ".yardopts"
94
+ - CONTRIBUTING.md
94
95
  - Gemfile
95
96
  - LICENSE
97
+ - NEWS.md
96
98
  - README.md
97
99
  - Rakefile
98
100
  - lib/thermite/cargo.rb
@@ -113,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
115
  requirements:
114
116
  - - ">="
115
117
  - !ruby/object:Gem::Version
116
- version: '0'
118
+ version: 2.0.0
117
119
  required_rubygems_version: !ruby/object:Gem::Requirement
118
120
  requirements:
119
121
  - - ">="