bindeps 0.0.8 → 0.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09a22034ecfb472bbf143443a4241f92e1bcd9a9
4
- data.tar.gz: e867e4eaec47e2c02c26916191daef168ef2c55d
3
+ metadata.gz: ba2bd3ec00323dc75661e16bc266e0b1d202b0f4
4
+ data.tar.gz: e37fc32f751c0c180b2268fc211ef7e62db980f4
5
5
  SHA512:
6
- metadata.gz: 7de37d58bb9a9b14f6767a7d34ad025ecad3077269d85bd832c988345b6672e3030f6fd70219d4b411604d1ba2b27db40bc9b907c2b49668891522e9766deafb
7
- data.tar.gz: a9f18935a0be780f5df054e5a5570a21bfe5594f724cb52ec46af27ba557f6eb17e7c241f2bf32e76f89e86542bceb8a3027eebb06a52f009a70f84789dd0ed3
6
+ metadata.gz: bae6e6b44f6b00bd1969179b0def3926ef8759b0dad9482ec856d18337fce9d48c3b53ce4f9b30a8fb50e11504a5d8666a30946620325f6b19606ebf2ddcfe2b
7
+ data.tar.gz: 5ccf3296ea9243c62477354271bb9cf3311cce11d6f06f2a85e3a231079020a34fbe66c23148942abcb7db3a12b96899db976bd8329b97eb777f1a0621a54618
@@ -1,3 +1,3 @@
1
1
  module Bindeps
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
data/lib/bindeps.rb CHANGED
@@ -19,7 +19,8 @@ module Bindeps
19
19
  d = Dependency.new(name,
20
20
  config['binaries'],
21
21
  config['version'],
22
- config['url'])
22
+ config['url'],
23
+ config['unpack'])
23
24
  d.install_missing
24
25
  end
25
26
  end
@@ -38,7 +39,8 @@ module Bindeps
38
39
  d = Dependency.new(name,
39
40
  config['binaries'],
40
41
  config['version'],
41
- config['url'])
42
+ config['url'],
43
+ config['unpack'])
42
44
  missing << name unless d.all_installed?
43
45
  end
44
46
  end
@@ -47,7 +49,7 @@ module Bindeps
47
49
 
48
50
  class Dependency
49
51
 
50
- def initialize(name, binaries, versionconfig, urlconfig)
52
+ def initialize(name, binaries, versionconfig, urlconfig, unpack)
51
53
  @name = name
52
54
  unless binaries.is_a? Array
53
55
  raise ArgumentError,
@@ -57,6 +59,7 @@ module Bindeps
57
59
  @version = versionconfig['number']
58
60
  @version_cmd = versionconfig['command']
59
61
  @url = choose_url urlconfig
62
+ @unpack = unpack
60
63
  end
61
64
 
62
65
  def install_missing
@@ -93,14 +96,18 @@ module Bindeps
93
96
 
94
97
  def unpack
95
98
  archive = File.basename(@url)
96
- Unpacker.unpack(archive) do |dir|
97
- Dir.chdir dir do
98
- Dir['**/*'].each do |extracted|
99
- if @binaries.include? File.basename(extracted)
100
- install(extracted) unless File.directory?(extracted)
99
+ if @unpack
100
+ Unpacker.unpack(archive) do |dir|
101
+ Dir.chdir dir do
102
+ Dir['**/*'].each do |extracted|
103
+ if @binaries.include? File.basename(extracted)
104
+ install(extracted) unless File.directory?(extracted)
105
+ end
101
106
  end
102
107
  end
103
108
  end
109
+ else
110
+ install(@binaries.first)
104
111
  end
105
112
  end
106
113
 
@@ -126,7 +133,8 @@ module Bindeps
126
133
 
127
134
  def install bin
128
135
  bindir = File.join(ENV['GEM_HOME'], 'bin')
129
- FileUtils.cp(bin, File.join(bindir, File.basename(bin)))
136
+ install_location = File.join(bindir, File.basename(bin))
137
+ FileUtils.install(bin, install_location, :mode => 0775)
130
138
  end
131
139
 
132
140
  end
data/lib/unpacker.rb CHANGED
@@ -23,6 +23,7 @@
23
23
 
24
24
  require 'fileutils'
25
25
  require 'tmpdir'
26
+ require 'open3'
26
27
 
27
28
  module Unpacker
28
29
 
@@ -44,8 +45,10 @@ module Unpacker
44
45
  else
45
46
  raise UnrecognizedArchiveError
46
47
  end
47
- puts cmd
48
- puts `#{cmd}`
48
+ stdout, stderr, status = Open3.capture3 cmd
49
+ if !status.success?
50
+ raise RuntimeError.new("There was a problem unpacking #{file}\n#{stderr}")
51
+ end
49
52
  block.call Dir.new(dir)
50
53
  end
51
54
  end
@@ -13,3 +13,4 @@ fakebin:
13
13
  macosx: https://github.com/Blahah/bindeps/raw/master/test/data/fakebin.tgz
14
14
  linux: https://github.com/Blahah/bindeps/raw/master/test/data/fakebin.tgz
15
15
  unix: https://github.com/Blahah/bindeps/raw/master/test/data/fakebin.tgz
16
+ unpack: true
@@ -13,3 +13,4 @@ fakebin:
13
13
  macosx: https://github.com/Blahah/bindeps/raw/master/test/data/fakebin2.tgz
14
14
  linux: https://github.com/Blahah/bindeps/raw/master/test/data/fakebin2.tgz
15
15
  unix: https://github.com/Blahah/bindeps/raw/master/test/data/fakebin2.tgz
16
+ unpack: true
@@ -13,3 +13,4 @@ fakebin:
13
13
  macosx: https://github.com/Blahah/bindeps/raw/master/test/data/fakebin3.tgz
14
14
  linux: https://github.com/Blahah/bindeps/raw/master/test/data/fakebin3.tgz
15
15
  unix: https://github.com/Blahah/bindeps/raw/master/test/data/fakebin3.tgz
16
+ unpack: true
@@ -0,0 +1,5 @@
1
+ #! /bin/sh
2
+ # all output to stderr (some programs show version this way)
3
+ echo 'this is a non-matching line' 1>&2
4
+ echo 'fakebin v4.0.1' 1>&2
5
+ echo 'more non-matching stuff' 1>&2
@@ -0,0 +1,16 @@
1
+ fakebin:
2
+ binaries:
3
+ - fakebin4
4
+ version:
5
+ number: 4.0.1
6
+ command: fakebin4
7
+ url:
8
+ 64bit:
9
+ macosx: https://github.com/cboursnell/bindeps/raw/master/test/data/fakebin4
10
+ linux: https://github.com/cboursnell/bindeps/raw/master/test/data/fakebin4
11
+ unix: https://github.com/cboursnell/bindeps/raw/master/test/data/fakebin4
12
+ 32bit:
13
+ macosx: https://github.com/cboursnell/bindeps/raw/master/test/data/fakebin4
14
+ linux: https://github.com/cboursnell/bindeps/raw/master/test/data/fakebin4
15
+ unix: https://github.com/cboursnell/bindeps/raw/master/test/data/fakebin4
16
+ unpack: false
data/test/test_bindeps.rb CHANGED
@@ -9,6 +9,15 @@ class TestBinDeps < Test::Unit::TestCase
9
9
  @data_dir = File.join(test_dir, 'data')
10
10
  end
11
11
 
12
+ teardown do
13
+ # delete fake binaries from
14
+ bindir = File.join(ENV['GEM_HOME'], 'bin')
15
+ `rm #{bindir}/fakebin` if File.exist?("#{bindir}/fakebin")
16
+ `rm #{bindir}/fakebin2` if File.exist?("#{bindir}/fakebin2")
17
+ `rm #{bindir}/fakebin3` if File.exist?("#{bindir}/fakebin3")
18
+ `rm #{bindir}/fakebin4` if File.exist?("#{bindir}/fakebin4")
19
+ end
20
+
12
21
  should "identify and install missing dependencies" do
13
22
  test_yaml = File.join(@data_dir, 'fakebin.yaml')
14
23
  Bindeps.require test_yaml
@@ -32,7 +41,8 @@ class TestBinDeps < Test::Unit::TestCase
32
41
  d = Bindeps::Dependency.new(name,
33
42
  config['binaries'],
34
43
  config['version'],
35
- config['url'])
44
+ config['url'],
45
+ config['unpack'])
36
46
  assert d.installed?('fakebin2')
37
47
  end
38
48
  end
@@ -47,11 +57,26 @@ class TestBinDeps < Test::Unit::TestCase
47
57
  d = Bindeps::Dependency.new(name,
48
58
  config['binaries'],
49
59
  config['version'],
50
- config['url'])
60
+ config['url'],
61
+ config['unpack'])
51
62
  assert d.installed?('fakebin3')
52
63
  end
53
64
  end
54
65
 
66
+ should "handle binaries that don't need to be unpacked" do
67
+ test_yaml = File.join(@data_dir, 'fakebin4.yaml')
68
+ Bindeps.require test_yaml
69
+ deps = YAML.load_file test_yaml
70
+ deps.each_pair do |name, config|
71
+ d = Bindeps::Dependency.new(name,
72
+ config['binaries'],
73
+ config['version'],
74
+ config['url'],
75
+ config['unpack'])
76
+ assert d.installed?('fakebin4'), "fakebin4 installed"
77
+ end
78
+ end
79
+
55
80
  end
56
81
 
57
82
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bindeps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Smith-Unna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-25 00:00:00.000000000 Z
11
+ date: 2014-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: which_works
@@ -149,6 +149,8 @@ files:
149
149
  - test/data/fakebin3
150
150
  - test/data/fakebin3.tgz
151
151
  - test/data/fakebin3.yaml
152
+ - test/data/fakebin4
153
+ - test/data/fakebin4.yaml
152
154
  - test/data/neverinstalled.yaml
153
155
  - test/helper.rb
154
156
  - test/test_bindeps.rb
@@ -172,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
174
  version: '0'
173
175
  requirements: []
174
176
  rubyforge_project:
175
- rubygems_version: 2.1.4
177
+ rubygems_version: 2.0.6
176
178
  signing_key:
177
179
  specification_version: 4
178
180
  summary: binary dependency management for ruby gems
@@ -187,6 +189,8 @@ test_files:
187
189
  - test/data/fakebin3
188
190
  - test/data/fakebin3.tgz
189
191
  - test/data/fakebin3.yaml
192
+ - test/data/fakebin4
193
+ - test/data/fakebin4.yaml
190
194
  - test/data/neverinstalled.yaml
191
195
  - test/helper.rb
192
196
  - test/test_bindeps.rb