gem-wrappers 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +11 -0
- data/README.md +47 -0
- data/lib/gem-wrappers/command.rb +15 -4
- data/lib/gem-wrappers/version.rb +1 -1
- data/test/gem-wrappers/command_test.rb +60 -1
- data/test/gem-wrappers_test.rb +1 -0
- metadata +2 -2
- data/lib/gem/wrappers/specification.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 673d219add58a7492ba395ea130428a2d8745df0
|
4
|
+
data.tar.gz: 452373a2edc81fafc8572388124fb64d10488688
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b9582b731703a665511e074ac84fb0e50075cff296966cfa1efada3f4b282fc9f45b3346f61374b8a7e1d22dd02c73baa5ba28702f25195b5676ae087ef6cec
|
7
|
+
data.tar.gz: c8c72999d79fd387afc99e311c7a79039f9b7480932e6ba566ac2de82959ed3643539200254212892bec8c08215fb8a7c51422d0502c788fdf2a567d437c1758
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -8,3 +8,50 @@
|
|
8
8
|
[![Documentation](http://b.repl.ca/v1/yard-docs-blue.png)](http://rubydoc.info/gems/gem-wrappers/frames)
|
9
9
|
|
10
10
|
Create gem wrappers for easy use of gems in cron and other system locations.
|
11
|
+
|
12
|
+
## Configuration / Defaults
|
13
|
+
|
14
|
+
In `~/.gemrc` you can overwrite this defaults:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
wrappers_path: GEM_HOME/wrappers
|
18
|
+
wrappers_environment_file: GEM_HOME/environment
|
19
|
+
wrappers_path_take: 1
|
20
|
+
```
|
21
|
+
|
22
|
+
It is not yet possible to put variables in the configuration,
|
23
|
+
only relative and full paths will work, open a ticket if you need variables.
|
24
|
+
|
25
|
+
## Generating wrappers
|
26
|
+
|
27
|
+
By default wrappers are installed when a gem is installed,
|
28
|
+
to rerun the process for all gems in `GEM_HOME` use:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
gem wrappers regenerate
|
32
|
+
```
|
33
|
+
|
34
|
+
## Showing current configuration
|
35
|
+
|
36
|
+
To see paths that are used by gem run:
|
37
|
+
|
38
|
+
```bash
|
39
|
+
gem wrappers
|
40
|
+
```
|
41
|
+
|
42
|
+
## Environment file
|
43
|
+
|
44
|
+
User can provide his own `environment` file,
|
45
|
+
in case it is not available during generating wrappers it will be created using this template:
|
46
|
+
|
47
|
+
```erb
|
48
|
+
export PATH="<%= path.join(":") %>:$PATH"
|
49
|
+
export GEM_PATH="<%= gem_path.join(":") %>"
|
50
|
+
export GEM_HOME="<%= gem_home %>"
|
51
|
+
```
|
52
|
+
|
53
|
+
The path elements are calculated using this algorithm:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
ENV['PATH'].split(":").take(Gem.path.size + path_take)
|
57
|
+
```
|
data/lib/gem-wrappers/command.rb
CHANGED
@@ -51,14 +51,25 @@ DOC
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def execute_regenerate
|
54
|
-
|
54
|
+
GemWrappers.install(gem_dir_executables)
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def gem_dir_executables
|
60
|
+
@gem_dir_executables ||= gem_dir_specs_executables.inject(&:+).reject(&:nil?)
|
61
|
+
end
|
62
|
+
|
63
|
+
def gem_dir_specs_executables
|
64
|
+
gem_dir_specs.map(&:executables).reject(&:nil?)
|
65
|
+
end
|
66
|
+
|
67
|
+
def gem_dir_specs
|
68
|
+
installed_gems.select { |spec|
|
55
69
|
File.exists?( File.join( Gem.dir, 'gems', spec.full_name ) )
|
56
70
|
}
|
57
|
-
executables = gem_dir_specs.map(&:executables).reject(&:nil?).inject(&:+).reject(&:nil?)
|
58
|
-
GemWrappers.install(executables)
|
59
71
|
end
|
60
72
|
|
61
|
-
private
|
62
73
|
def installed_gems
|
63
74
|
if Gem::VERSION > '1.8' then
|
64
75
|
Gem::Specification.to_a
|
data/lib/gem-wrappers/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'tempfile'
|
3
|
-
require 'gem-wrappers/
|
3
|
+
require 'gem-wrappers/command'
|
4
4
|
|
5
5
|
describe WrappersCommand do
|
6
6
|
subject do
|
@@ -28,6 +28,65 @@ describe WrappersCommand do
|
|
28
28
|
it "shows help on unknown command" do
|
29
29
|
subject.options[:args] = ['wrong']
|
30
30
|
subject.execute
|
31
|
+
$stderr.string.must_equal("Unknown wrapper subcommand: wrong\n")
|
32
|
+
$stdout.string.must_equal(subject.description)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "does show" do
|
36
|
+
Gem.configuration[:wrappers_environment_file] = "/path/to/environment"
|
37
|
+
Gem.configuration[:wrappers_path] = "/path/to/wrappers"
|
38
|
+
|
39
|
+
subject.options[:args] = []
|
40
|
+
subject.execute
|
41
|
+
|
42
|
+
Gem.configuration[:wrappers_environment_file] = nil
|
43
|
+
Gem.configuration[:wrappers_path] = nil
|
44
|
+
|
45
|
+
$stderr.string.must_equal("")
|
46
|
+
$stdout.string.must_equal(<<-EXPECTED)
|
47
|
+
#{subject.description.strip}
|
48
|
+
Wrappers path: /path/to/wrappers
|
49
|
+
Environment file: /path/to/environment
|
50
|
+
EXPECTED
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
describe "wrappers" do
|
55
|
+
before do
|
56
|
+
file = Tempfile.new('command-wrappers')
|
57
|
+
@test_path = file.path
|
58
|
+
file.close
|
59
|
+
file.unlink
|
60
|
+
end
|
61
|
+
|
62
|
+
after do
|
63
|
+
FileUtils.rm_rf(@test_path)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "regenerates wrappers" do
|
67
|
+
Gem.configuration[:wrappers_environment_file] = File.join(@test_path, "environment")
|
68
|
+
Gem.configuration[:wrappers_path] = File.join(@test_path, "wrappers")
|
69
|
+
|
70
|
+
subject.instance_variable_set(:@gem_dir_executables, %w{rake})
|
71
|
+
subject.options[:args] = ['regenerate']
|
72
|
+
subject.execute
|
73
|
+
|
74
|
+
Gem.configuration[:wrappers_environment_file] = nil
|
75
|
+
Gem.configuration[:wrappers_path] = nil
|
76
|
+
|
77
|
+
File.exist?(File.join(@test_path, "environment")).must_equal(true)
|
78
|
+
File.exist?(File.join(@test_path, "wrappers", "gem")).must_equal(true)
|
79
|
+
File.exist?(File.join(@test_path, "wrappers", "rake")).must_equal(true)
|
80
|
+
File.exist?(File.join(@test_path, "wrappers", "ruby")).must_equal(true)
|
81
|
+
File.exist?(File.join(@test_path, "wrappers", "test")).must_equal(false)
|
82
|
+
|
83
|
+
$stderr.string.must_equal("")
|
84
|
+
$stdout.string.must_equal("")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it "finds gem executables" do
|
89
|
+
subject.send(:gem_dir_executables).must_include('coveralls')
|
31
90
|
end
|
32
91
|
|
33
92
|
end
|
data/test/gem-wrappers_test.rb
CHANGED
@@ -37,6 +37,7 @@ describe GemWrappers do
|
|
37
37
|
File.exist?(File.join(@test_path, "wrappers", "rake")).must_equal(true)
|
38
38
|
File.exist?(File.join(@test_path, "wrappers", "ruby")).must_equal(true)
|
39
39
|
File.exist?(File.join(@test_path, "wrappers", "test")).must_equal(true)
|
40
|
+
File.exist?(File.join(@test_path, "wrappers", "other")).must_equal(false)
|
40
41
|
end
|
41
42
|
|
42
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem-wrappers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Papis
|
@@ -88,6 +88,7 @@ extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
91
92
|
- Gemfile
|
92
93
|
- LICENSE
|
93
94
|
- README.md
|
@@ -99,7 +100,6 @@ files:
|
|
99
100
|
- lib/gem-wrappers/installer.rb
|
100
101
|
- lib/gem-wrappers/specification.rb
|
101
102
|
- lib/gem-wrappers/version.rb
|
102
|
-
- lib/gem/wrappers/specification.rb
|
103
103
|
- lib/rubygems_plugin.rb
|
104
104
|
- test/gem-wrappers/command_test.rb
|
105
105
|
- test/gem-wrappers/environment_test.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Gem
|
2
|
-
module Wrappers
|
3
|
-
module Specification
|
4
|
-
def self.find
|
5
|
-
@executable_hooks_spec ||=
|
6
|
-
if Gem::Specification.respond_to?(:find_by_name)
|
7
|
-
Gem::Specification.find_by_name("gem-wrappers")
|
8
|
-
else
|
9
|
-
Gem.source_index.find_name("gem-wrappers").last
|
10
|
-
end
|
11
|
-
rescue Gem::LoadError
|
12
|
-
nil
|
13
|
-
end
|
14
|
-
def self.version
|
15
|
-
find ? find.version.to_s : nil
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|