thermite 0.5.0 → 0.6.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: 4298855469a6d6a12e9dd7d33df5a95cfe8b4c9f
4
- data.tar.gz: e793be7663705a076bdcfb81bc4157d4ba10466b
3
+ metadata.gz: de41ccc420e335d2285e1a8d803e4ce55c669564
4
+ data.tar.gz: 360be899c1e2c3e5162017de866811e50c7381de
5
5
  SHA512:
6
- metadata.gz: d6fe53f8a54d8617d1578cf71619687734d447bd42ec2a37fdde84bc1b2eaf17045232f30d71fc5f47d9ece3ebab95dbfc79ddae22407421ed43e267c7a93832
7
- data.tar.gz: 8475eaa3cfc6a52aaaf2fef3eb514a79f8a02f56e2c95ba6f3c7f8f8d6f8a557a43837c8cd0b34c41800eeb102a342631d86513ef48f3c332ac4ceb9f229ea43
6
+ metadata.gz: ada2a16519da8c1fd2361ec8b364bd0e3aaea4c6e750a6a8f877bfcf87275b590203df1bcc2ee33047e17c19fd34501c746667f4cc137361cd4baf39fbaee841
7
+ data.tar.gz: 3966c01620f0e8d0b214c87c92c5731c5b5d0b164b685d7083a8eebdefe52512c132b1daa4b74251507fac0dfa285497e95a579411c8fd594c3ec9257353370c
data/.appveyor.yml CHANGED
@@ -24,4 +24,4 @@ install:
24
24
  - bundle install
25
25
  build: false
26
26
  test_script:
27
- - bundle exec rake
27
+ - bundle exec rake test
data/.rubocop.yml CHANGED
@@ -1,3 +1,8 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'vendor/**/*'
4
+ TargetRubyVersion: 2.1
5
+
1
6
  Metrics/AbcSize:
2
7
  Max: 20
3
8
 
data/CONTRIBUTING.md CHANGED
@@ -44,8 +44,8 @@ etc.:
44
44
  bad:
45
45
 
46
46
  ```
47
- commit 1: add foo algorithm
48
- commit 2: run rustfmt
47
+ commit 1: add foo
48
+ commit 2: run rubocop
49
49
  commit 3: add test
50
50
  commit 4: add docs
51
51
  commit 5: add bar
@@ -55,9 +55,13 @@ commit 6: add test + docs
55
55
  good:
56
56
 
57
57
  ```
58
- commit 1: add foo algorithm
58
+ commit 1: add foo
59
59
  commit 2: add bar
60
60
  ```
61
61
 
62
+ Squashing commits during discussion of the pull request is almost always unnecessary, and makes it
63
+ more difficult for both the submitters and reviewers to understand what changed in between comments.
64
+ However, rebasing is encouraged when practical, particularly when there's a merge conflict.
65
+
62
66
  If you are continuing the work of another person's PR and need to rebase/squash, please retain the
63
67
  attribution of the original author(s) and continue the work in subsequent commits.
data/NEWS.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [0.6.0] - 2016-09-12
6
+
7
+ ### Added
8
+
9
+ * `optional_rust_extension` option - prints a warning to STDERR instead of raising an exception, if
10
+ Cargo is unavailable and `github_releases` is either disabled or unavailable. Useful for projects
11
+ where either fallback code exists, or a native extension is desirable but not required. (#4, #6)
12
+
13
+ ### Fixed
14
+
15
+ * `cargo` was not being run in the context of the rust project toplevel directory (#7, #8)
16
+
5
17
  ## [0.5.0] - 2016-07-18
6
18
 
7
19
  ### Added
data/README.md CHANGED
@@ -60,6 +60,10 @@ Possible options:
60
60
  precompiled Rust tarballs. One group must be specified that indicates the version number to be
61
61
  used in the tarball filename. Defaults to `vN.N.N`, where `N` is any n-digit number. In this case,
62
62
  the group is around the entire expression.
63
+ * `optional_rust_extension` - prints a warning to STDERR instead of raising an exception, if Cargo
64
+ is unavailable and `github_releases` is either disabled or unavailable. Useful for projects where
65
+ either fallback code exists, or a native extension is desirable but not required. Defaults
66
+ to `false`.
63
67
  * `ruby_project_path` - the top-level directory of the Ruby gem's project. Defaults to the
64
68
  current working directory.
65
69
 
@@ -37,7 +37,9 @@ module Thermite
37
37
  # Run `cargo` with the given `args` and return `STDOUT`.
38
38
  #
39
39
  def run_cargo(*args)
40
- sh "#{cargo} #{Shellwords.join(args)}"
40
+ Dir.chdir(config.rust_toplevel_dir) do
41
+ sh "#{cargo} #{Shellwords.join(args)}"
42
+ end
41
43
  end
42
44
 
43
45
  #
@@ -56,18 +58,43 @@ module Thermite
56
58
  run_cargo(*cargo_args)
57
59
  end
58
60
 
59
- # :nocov:
61
+ #
62
+ # Inform the user about cargo if it doesn't exist.
63
+ #
64
+ # If `optional_rust_extension` is true, print message to STDERR. Otherwise, raise an exception.
65
+ #
66
+ def inform_user_about_cargo
67
+ raise cargo_required_msg unless options[:optional_rust_extension]
68
+
69
+ $stderr.write(cargo_recommended_msg)
70
+ end
60
71
 
61
72
  #
62
- # Message used when cargo is required but not found.
73
+ # Message used when cargo is not found.
63
74
  #
64
- def cargo_required_msg
75
+ # `require_severity` is the verb that indicates how important Rust is to the library.
76
+ #
77
+ def cargo_msg(require_severity)
65
78
  <<EOM
66
79
  ****
67
- Rust's Cargo is required to build this extension. Please install Rust and put
68
- it in the PATH, or set the CARGO environment variable appropriately.
80
+ Rust's Cargo is #{require_severity} to build this extension. Please install
81
+ Rust and put it in the PATH, or set the CARGO environment variable appropriately.
69
82
  ****
70
83
  EOM
71
84
  end
85
+
86
+ #
87
+ # Message used when cargo is required but not found.
88
+ #
89
+ def cargo_required_msg
90
+ cargo_msg('required')
91
+ end
92
+
93
+ #
94
+ # Message used when cargo is recommended but not found.
95
+ #
96
+ def cargo_recommended_msg
97
+ cargo_msg('recommended (but not required)')
98
+ end
72
99
  end
73
100
  end
@@ -70,6 +70,10 @@ module Thermite
70
70
  # releases to look for precompiled Rust tarballs. One group must be specified that indicates
71
71
  # the version number to be used in the tarball filename. Defaults to `vN.N.N`, where `N` is
72
72
  # any n-digit number. In this case, the group is around the entire expression.
73
+ # * `optional_rust_extension` - prints a warning to STDERR instead of raising an exception, if
74
+ # Cargo is unavailable and `github_releases` is either disabled or unavailable. Useful for
75
+ # projects where either fallback code exists, or a native extension is desirable but not
76
+ # required. Defaults to `false`.
73
77
  # * `ruby_project_path` - the toplevel directory of the Ruby gem's project. Defaults to the
74
78
  # current working directory.
75
79
  #
@@ -109,7 +113,7 @@ module Thermite
109
113
  FileUtils.cp(config.rust_path('target', target, config.shared_library),
110
114
  config.ruby_path('lib'))
111
115
  elsif !download_binary
112
- raise cargo_required_msg
116
+ inform_user_about_cargo
113
117
  end
114
118
  end
115
119
  end
@@ -32,6 +32,24 @@ module Thermite
32
32
  mock_module.run_cargo_build('release')
33
33
  end
34
34
 
35
+ def test_inform_user_about_cargo_exception
36
+ _, err = capture_io do
37
+ assert_raises RuntimeError do
38
+ mock_module(optional_rust_extension: false).inform_user_about_cargo
39
+ end
40
+ end
41
+
42
+ assert_equal '', err
43
+ end
44
+
45
+ def test_inform_user_about_cargo_warning
46
+ _, err = capture_io do
47
+ mock_module(optional_rust_extension: true).inform_user_about_cargo
48
+ end
49
+
50
+ assert_equal mock_module.cargo_recommended_msg, err
51
+ end
52
+
35
53
  def described_class
36
54
  Tester
37
55
  end
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.5.0'
6
+ s.version = '0.6.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.5.0
4
+ version: 0.6.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-07-19 00:00:00.000000000 Z
11
+ date: 2016-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake