gem-wrappers 1.2.7 → 1.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
- SHA1:
3
- data.tar.gz: e3c4b6e90e5eb8b635169e54b0c976962c082222
4
- metadata.gz: 38d025a4910fed667ee8de884032a87729e549e0
5
2
  SHA512:
6
- data.tar.gz: 13d86554a5436703e8215f875811db78ecbab2b200cb01272845acc227ac850ff0e87029dd8a8974f0fd3609c6e17cf5c9c03e6fac22b5f582855c2545bc4bb8
7
- metadata.gz: 3413b198ab7c93a41c7b4a1a5f27100d30dfb50fe54a918b927cdcbffe907841bbc99eff6e10267f9ecc1ca8b64912d849523450811d3fe6acb4a5d35d661e6a
3
+ metadata.gz: f04d42e70ec2f1b65a3167be83d17b22f08e7d419a4c8c4675140df95cee9f382dbc9a3537d64598029f3b0048e9fe2965ee692141844eb016d351147b656a83
4
+ data.tar.gz: 9b8d907ec0e80f40330183cf43f8f3c73aeffe51d80c1d94cc9195ba6c7e1d66c9e7ffb712bfb03d0c8b5324341d0ce15e4b12a62fe899e4982721fcc3f9387a
5
+ SHA1:
6
+ metadata.gz: 3da6f9a3645a2a752f684fa30ba1e514725505ce
7
+ data.tar.gz: c9c8d345caa1e083d3da736731ef61e0dc47291a
@@ -5,10 +5,12 @@ rvm:
5
5
  - jruby
6
6
  - ruby-head
7
7
  - 1.8.7
8
- - 1.9.2
9
8
  - 1.9.3
10
9
  - 2.0.0
11
10
  - 2.1
11
+ - 2.2
12
+ - 2.3
13
+ - 2.4.1
12
14
  - rbx
13
15
  notifications:
14
16
  irc:
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0
4
+ date: 2017-07-08
5
+
6
+ - add check if target files actually exist and are executable, fix #9
7
+ - silence ivar warning in rubygems test suite, fix #7
8
+
9
+ ## 1.2.7
10
+ date: 2014-10-10
11
+
12
+ - improved command handling
13
+
14
+ ## 1.2.6.1
15
+ date: 2014-10-10
16
+
17
+ - improved output of listing executables
18
+
19
+ ## 1.2.6
20
+ date: 2014-10-10
21
+
22
+ - show list of executables
23
+ - show info when `$GEM_WRAPPERS_DEBUG` is set
24
+
3
25
  ## 1.2.5
4
26
  date: 2014-05-27
5
27
 
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.extensions = %w( ext/wrapper_generator/extconf.rb )
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.add_development_dependency("rake")
18
- s.add_development_dependency("minitest")
17
+ s.add_development_dependency("rake", "<11")
18
+ s.add_development_dependency("minitest", "<6")
19
19
  # s.add_development_dependency("smf-gem")
20
20
  end
@@ -17,7 +17,7 @@ module GemWrappers
17
17
  end
18
18
 
19
19
  def path_take
20
- return @path_take if @path_take
20
+ return @path_take if defined? @path_take
21
21
  @path_take = Gem.configuration && Gem.configuration[:wrappers_path_take] || 1
22
22
  @path_take += gem_path.size
23
23
  end
@@ -22,7 +22,12 @@ module GemWrappers
22
22
  def ensure
23
23
  FileUtils.mkdir_p(wrappers_path) unless File.exist?(wrappers_path)
24
24
  # exception based on Gem::Installer.generate_bin
25
- raise Gem::FilePermissionError.new(wrappers_path) unless File.writable?(wrappers_path)
25
+ unless File.writable?(wrappers_path)
26
+ raise Gem::FilePermissionError.new(wrappers_path)
27
+ end
28
+ unless @environment_file
29
+ raise "Missing environment file for initialize!"
30
+ end
26
31
  end
27
32
 
28
33
  def uninstall(executable)
@@ -31,19 +36,36 @@ module GemWrappers
31
36
  end
32
37
 
33
38
  def install(executable)
34
- raise "Missing environment file for initialize!" unless @environment_file
39
+ target_path = find_executable_path(executable)
40
+ unless target_path
41
+ warn "GemWrappers: Can not wrap missing file: #{executable}"
42
+ return
43
+ end
44
+ unless File.executable?(target_path)
45
+ warn "GemWrappers: Can not wrap not executable file: #{target_path}"
46
+ return
47
+ end
35
48
  @executable = executable
36
49
  content = ERB.new(template).result(binding)
37
50
  install_file(executable, content)
38
- install_ty_formatted(executable, content)
51
+ install_to_formatted(executable, content)
52
+ end
53
+
54
+ def find_executable_path(executable)
55
+ return executable if File.exist?(executable)
56
+ ENV['PATH'].split(File::PATH_SEPARATOR).each { |dir|
57
+ full_path = File.join(dir, executable)
58
+ return full_path if File.exist?(full_path)
59
+ }
60
+ nil
39
61
  end
40
62
 
41
- def install_ty_formatted(executable, content)
42
- formated_executble = @executable_format % executable
63
+ def install_to_formatted(executable, content)
64
+ formatted_executable = @executable_format % executable
43
65
  if
44
- formated_executble != executable
66
+ formatted_executable != executable
45
67
  then
46
- install_file(formated_executble, content)
68
+ install_file(formatted_executable, content)
47
69
  end
48
70
  end
49
71
 
@@ -1,3 +1,3 @@
1
1
  module GemWrappers
2
- VERSION = "1.2.7"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -89,14 +89,52 @@ describe GemWrappers::Installer do
89
89
  end
90
90
  end
91
91
 
92
+ it "does not creates wrapper if target missing" do
93
+ subject.instance_variable_set(:@wrappers_path, @test_path)
94
+ script_path = File.join(subject.wrappers_path, "example", "test.ksh")
95
+ full_path = File.join(subject.wrappers_path, "test.ksh")
96
+ File.exist?(full_path).must_equal(false)
97
+ subject.ensure
98
+ mock_method = MiniTest::Mock.new
99
+ mock_method.expect :call, nil, ["GemWrappers: Can not wrap missing file: #{script_path}"]
100
+ subject.stub(:warn, mock_method) do
101
+ subject.install(script_path)
102
+ end
103
+ mock_method.verify
104
+ File.exist?(full_path).must_equal(false)
105
+ end
106
+
107
+ it "does not creates wrapper if file not executable" do
108
+ subject.instance_variable_set(:@wrappers_path, @test_path)
109
+ scripts_path = File.join(subject.wrappers_path, "example")
110
+ FileUtils.mkdir_p(scripts_path)
111
+ script_path = File.join(scripts_path, "test.sh")
112
+ FileUtils.mkdir_p(File.join(subject.wrappers_path, "example"))
113
+ File.open(script_path, "w") do |file|
114
+ file.write("echo test")
115
+ end
116
+ full_path = File.join(subject.wrappers_path, "test.sh")
117
+ File.exist?(full_path).must_equal(false)
118
+ subject.ensure
119
+ mock_method = MiniTest::Mock.new
120
+ mock_method.expect :call, nil, ["GemWrappers: Can not wrap not executable file: #{script_path}"]
121
+ subject.stub(:warn, mock_method) do
122
+ subject.install(script_path)
123
+ end
124
+ mock_method.verify
125
+ File.exist?(full_path).must_equal(false)
126
+ end
92
127
 
93
128
  it "creates shell script wrapper" do
94
129
  subject.instance_variable_set(:@wrappers_path, @test_path)
95
- script_path = File.join(subject.wrappers_path, "example", "test.sh")
130
+ scripts_path = File.join(subject.wrappers_path, "example")
131
+ FileUtils.mkdir_p(scripts_path)
132
+ script_path = File.join(scripts_path, "test.sh")
96
133
  FileUtils.mkdir_p(File.join(subject.wrappers_path, "example"))
97
134
  File.open(script_path, "w") do |file|
98
135
  file.write("echo test")
99
136
  end
137
+ File.chmod(755, script_path)
100
138
  full_path = File.join(subject.wrappers_path, "test.sh")
101
139
  File.exist?(full_path).must_equal(false)
102
140
  subject.ensure
@@ -108,11 +146,15 @@ describe GemWrappers::Installer do
108
146
 
109
147
  it "creates ruby script wrapper" do
110
148
  subject.instance_variable_set(:@wrappers_path, @test_path)
111
- script_path = File.join(subject.wrappers_path, "example", "test.rb")
112
- FileUtils.mkdir_p(File.join(subject.wrappers_path, "example"))
113
- File.open(script_path, "w") do |file|
149
+ scripts_path = File.join(subject.wrappers_path, "example")
150
+ FileUtils.mkdir_p(scripts_path)
151
+ script_path = File.join(scripts_path, "test.rb")
152
+ File.open(script_path, "a") do |file|
114
153
  file.write("puts :test")
115
154
  end
155
+ File.chmod(755, script_path)
156
+ old_path = ENV['PATH']
157
+ ENV['PATH'] += File::PATH_SEPARATOR + scripts_path
116
158
  full_path = File.join(subject.wrappers_path, "test.rb")
117
159
  File.exist?(full_path).must_equal(false)
118
160
  subject.ensure
@@ -121,6 +163,7 @@ describe GemWrappers::Installer do
121
163
  file.read.must_equal(format_content("ruby #{script_path}"))
122
164
  end
123
165
  File.executable?(full_path).must_equal(true)
166
+ ENV['PATH'] = old_path
124
167
  end
125
168
 
126
169
  it "removes wrapper" do
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: 1.2.7
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Papis
@@ -9,27 +9,28 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-10-10 00:00:00 Z
12
+ date: 2017-07-08 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
16
  prerelease: false
17
17
  requirement: &id001 !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - &id002
20
- - ">="
19
+ - - <
21
20
  - !ruby/object:Gem::Version
22
- version: "0"
21
+ version: "11"
23
22
  type: :development
24
23
  version_requirements: *id001
25
24
  - !ruby/object:Gem::Dependency
26
25
  name: minitest
27
26
  prerelease: false
28
- requirement: &id003 !ruby/object:Gem::Requirement
27
+ requirement: &id002 !ruby/object:Gem::Requirement
29
28
  requirements:
30
- - *id002
29
+ - - <
30
+ - !ruby/object:Gem::Version
31
+ version: "6"
31
32
  type: :development
32
- version_requirements: *id003
33
+ version_requirements: *id002
33
34
  description:
34
35
  email:
35
36
  - mpapis@gmail.com
@@ -76,22 +77,19 @@ require_paths:
76
77
  - lib
77
78
  required_ruby_version: !ruby/object:Gem::Requirement
78
79
  requirements:
79
- - *id002
80
+ - &id003
81
+ - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
80
84
  required_rubygems_version: !ruby/object:Gem::Requirement
81
85
  requirements:
82
- - *id002
86
+ - *id003
83
87
  requirements: []
84
88
 
85
89
  rubyforge_project:
86
- rubygems_version: 2.0.14
90
+ rubygems_version: 2.0.17
87
91
  signing_key:
88
92
  specification_version: 4
89
93
  summary: Create gem wrappers for easy use of gems in cron and other system locations.
90
- test_files:
91
- - test/gem-wrappers/command_test.rb
92
- - test/gem-wrappers/environment_test.rb
93
- - test/gem-wrappers/fakes.rb
94
- - test/gem-wrappers/installer_test.rb
95
- - test/gem-wrappers/specification_and_version_test.rb
96
- - test/gem-wrappers_test.rb
97
- - test/test_helper.rb
94
+ test_files: []
95
+