bindeps 0.0.10 → 0.0.11

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: eefc4b0d6a9dd94e3c31c67291affeb55384da4f
4
- data.tar.gz: 189932cf2ea2d1d46219be9323aa679378b60f6a
3
+ metadata.gz: 34d7ec015d12ca506a57940e13e144ce06803d64
4
+ data.tar.gz: c6872d2030aae9d49149dbf43e72212125f7bdb9
5
5
  SHA512:
6
- metadata.gz: 333fc976974665a29e85728a5c53eb3729709bf8e68401481b7e36b965f475a8ec8d83649d06e81d6ebf9aa69e413f44fa6223c47bfcb8cd417f88257655b462
7
- data.tar.gz: 4e0eba4b5b947c57cf105e662e8a7e32b246d325941bc13c475da888657413e9c80119f93c296ad8a2eef881f5307c5e2f0162a3678f0ead7a01ddd055374246
6
+ metadata.gz: cdc0b071ce6677c9702a7b96cea5bf16f406fdd5141604e4fb41f2c0f811f5783c7b7cba9c8a3e267dcc9f5ff7ab29e8515c4717bb85eefe512c890f4a1b0ca3
7
+ data.tar.gz: 3de04bfe9067f95d0daf62139d693abc161fdf05af7f01dadf93a34d81d30a8a640cc485973dec7ccfbce394b376955c56e89b31f83ad425f19b952fa1e80cde
data/README.md CHANGED
@@ -11,21 +11,29 @@ Simple binary dependency management for Ruby gems
11
11
 
12
12
  ## Installation
13
13
 
14
- `gem install bindeps`
14
+ ```bash
15
+ $ gem install bindeps
16
+ ```
15
17
 
16
18
  ### Using Bundler
17
19
 
18
20
  Add this line to your application's Gemfile:
19
21
 
20
- gem 'bindeps'
22
+ ```
23
+ gem 'bindeps'
24
+ ```
21
25
 
22
26
  And then execute:
23
27
 
24
- $ bundle
28
+ ```bash
29
+ $ bundle
30
+ ```
25
31
 
26
32
  Or install it yourself as:
27
33
 
28
- $ gem install bindeps
34
+ ```bash
35
+ $ gem install bindeps
36
+ ```
29
37
 
30
38
  ## Usage
31
39
 
data/bindeps.gemspec CHANGED
@@ -18,13 +18,14 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency 'which', '~> 0.0', '>= 0.0.2'
21
22
  spec.add_dependency "which_works"
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 1.3"
24
- spec.add_development_dependency "rake"
25
- spec.add_development_dependency 'turn'
26
- spec.add_development_dependency 'minitest'
27
- spec.add_development_dependency 'simplecov'
28
- spec.add_development_dependency 'shoulda-context'
29
- spec.add_development_dependency 'coveralls', '>= 0.6.7'
25
+ spec.add_development_dependency 'rake', '~> 10.3', '>= 10.3.2'
26
+ spec.add_development_dependency 'turn', '~> 0.9', '>= 0.9.7'
27
+ spec.add_development_dependency 'minitest', '~> 4', '>= 4.7.5'
28
+ spec.add_development_dependency 'simplecov', '~> 0.8', '>= 0.8.2'
29
+ spec.add_development_dependency 'shoulda-context', '~> 1.2', '>= 1.2.1'
30
+ spec.add_development_dependency 'coveralls', '~> 0.7'
30
31
  end
data/lib/bindeps.rb CHANGED
@@ -89,8 +89,20 @@ module Bindeps
89
89
  end
90
90
 
91
91
  def download
92
- `curl -O -J -L #{@url}`
93
- unless $?.to_i == 0
92
+ curl = which('curl').first
93
+ wget = which('wget').first
94
+ if curl
95
+ cmd = "#{curl} -O -J -L #{@url}"
96
+ stdout, stderr, status = Open3.capture3 cmd
97
+ elsif wget
98
+ cmd = "#{wget} #{@url}"
99
+ stdout, stderr, status = Open3.capture3 cmd
100
+ else
101
+ msg = "You don't have curl or wget?! What kind of computer is "
102
+ msg << "this?! Windows?! BeOS? OS/2?"
103
+ raise DownloadFailedError.new(msg)
104
+ end
105
+ if !status.success?
94
106
  raise DownloadFailedError,
95
107
  "download of #{@url} for #{@name} failed"
96
108
  end
@@ -98,6 +110,7 @@ module Bindeps
98
110
 
99
111
  def unpack
100
112
  archive = File.basename(@url)
113
+ Unpacker.archive? archive
101
114
  if @unpack
102
115
  Unpacker.unpack(archive) do |dir|
103
116
  Dir.chdir dir do
@@ -1,3 +1,3 @@
1
1
  module Bindeps
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
data/lib/unpacker.rb CHANGED
@@ -23,14 +23,14 @@
23
23
 
24
24
  require 'fileutils'
25
25
  require 'tmpdir'
26
+ require 'which'
27
+ include Which
26
28
  require 'open3'
27
29
 
28
30
  module Unpacker
29
31
 
30
32
  class UnrecognizedArchiveError < StandardError; end
31
33
 
32
- SUPPORTED_FILEEXTS = %w[tar rar zip gz bz tgz bgz tar]
33
-
34
34
  def self.unpack(file, tmpdir = "/tmp", &block)
35
35
  Dir.mktmpdir 'unpacker' do |dir|
36
36
  cmd = case file
@@ -53,8 +53,43 @@ module Unpacker
53
53
  end
54
54
  end
55
55
 
56
+ # %w[tar rar zip gz bz tgz bgz tar]
56
57
  def self.archive?(file_name)
57
- SUPPORTED_FILEEXTS.include? File.extname(file_name).sub('.', '')
58
+ supported = []
59
+ ext = File.extname(file_name).sub('.', '')
60
+ return true if ext==""
61
+ if !which('unrar').empty?
62
+ supported << "rar"
63
+ end
64
+ if !which('tar').empty?
65
+ %w[tar tgz tgz tar.gz tar.bz tbz].each do |ext|
66
+ supported << ext
67
+ end
68
+ end
69
+ if !which('unzip').empty?
70
+ supported << "zip"
71
+ end
72
+ if !which('gunzip').empty?
73
+ supported << "gz"
74
+ end
75
+ support = supported.include? ext
76
+ if !support
77
+ help = case ext
78
+ when /rar/
79
+ "Please install unrar"
80
+ when /(tar|tgz|tar\.gz|tar\.bz|tbz)$/
81
+ "Please install tar"
82
+ when /zip$/
83
+ "Please install unzip"
84
+ when /gz$/
85
+ "Please install gunzip"
86
+ else
87
+ raise UnrecognizedArchiveError
88
+ end
89
+ msg = "Archive type not supported: #{ext}\n#{help}"
90
+ raise UnrecognizedArchiveError.new(msg)
91
+ end
92
+ support
58
93
  end
59
94
 
60
95
  def self.valid?(file_path, file_name = file_path)
@@ -70,10 +105,12 @@ module Unpacker
70
105
  else
71
106
  raise UnrecognizedArchiveError
72
107
  end
73
- `#{cmd}`
74
- true
75
- rescue
76
- false
108
+ stdout, stderr, status = Open3.capture3 cmd
109
+ if status.success?
110
+ true
111
+ else
112
+ false
113
+ end
77
114
  end
78
115
 
79
116
  end # module Unpacker
data/test/data/wget ADDED
File without changes
data/test/test_bindeps.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class TestBinDeps < Test::Unit::TestCase
3
+ class TestBindeps < Test::Unit::TestCase
4
4
 
5
5
  context "bindeps" do
6
6
 
@@ -60,6 +60,119 @@ class TestBinDeps < Test::Unit::TestCase
60
60
  config['url'],
61
61
  config['unpack'])
62
62
  assert d.installed?('fakebin3')
63
+ assert d.all_installed?
64
+ end
65
+ end
66
+
67
+ should "fail when no download is specified for the local system" do
68
+ require 'rbconfig'
69
+ original_os = RbConfig::CONFIG['host_os']
70
+ RbConfig::CONFIG['host_os'] = 'fail'
71
+ assert_raise Bindeps::UnsupportedSystemError do
72
+ Bindeps::System.os
73
+ end
74
+ urlconfig = { '64bit' => { 'unix' => 'url' } }
75
+ versionconfig = { 'number' => 1, 'command' => 'getversion' }
76
+ RbConfig::CONFIG['host_os'] = 'linux'
77
+ assert_raise Bindeps::UnsupportedSystemError do
78
+ Bindeps::Dependency.new('test', ['binary'],
79
+ versionconfig, urlconfig, false)
80
+ end
81
+ RbConfig::CONFIG['host_os'] = 'solaris'
82
+ original_cpu = Gem::Platform.local.cpu
83
+ Gem::Platform.local.cpu = 'fail'
84
+ assert_raise Bindeps::UnsupportedSystemError do
85
+ Bindeps::Dependency.new('test', ['binary'],
86
+ versionconfig, urlconfig, false)
87
+ end
88
+ # set os info back to the truth
89
+ RbConfig::CONFIG['host_os'] = original_os
90
+ Gem::Platform.local.cpu = original_cpu
91
+ end
92
+
93
+ should "fallback to wget when curl is not available" do
94
+ # set up fake OS
95
+ original_os = RbConfig::CONFIG['host_os']
96
+ RbConfig::CONFIG['host_os'] = 'solaris'
97
+ original_cpu = Gem::Platform.local.cpu
98
+ Gem::Platform.local.cpu = 'x86_64'
99
+ # create config
100
+ urlconfig = { '64bit' => { 'unix' => 'url' } }
101
+ versionconfig = { 'number' => 1, 'command' => 'getversion' }
102
+
103
+ # with only wget in the path
104
+ original_path = ENV['PATH']
105
+ ENV['PATH'] = File.expand_path(@data_dir)
106
+ assert_nothing_raised Bindeps::DownloadFailedError do
107
+ dep = Bindeps::Dependency.new('test', ['binary'],
108
+ versionconfig, urlconfig, false)
109
+ dep.download
110
+ end
111
+
112
+ # with neither curl nor wget
113
+ ENV['PATH'] = ""
114
+ assert_raise Bindeps::DownloadFailedError do
115
+ dep = Bindeps::Dependency.new('test', ['binary'],
116
+ versionconfig, urlconfig, false)
117
+ dep.download
118
+ end
119
+
120
+ # restore path
121
+ ENV['PATH'] = original_path
122
+ # when download doesn't actually work
123
+ assert_raise Bindeps::DownloadFailedError do
124
+ dep = Bindeps::Dependency.new('test', ['binary'],
125
+ versionconfig, urlconfig, false)
126
+ dep.download
127
+ end
128
+
129
+ # restore real OS
130
+ RbConfig::CONFIG['host_os'] = original_os
131
+ Gem::Platform.local.cpu = original_cpu
132
+ end
133
+
134
+ should "fail when no downloader is available" do
135
+
136
+ end
137
+
138
+ should "initialize" do
139
+ assert_nothing_raised do
140
+ Bindeps::Dependency.new(
141
+ 'test', # name
142
+ ['binary'], # binaries
143
+ { # versionconfig
144
+ 'number' => 1,
145
+ 'command' => 'getversion'
146
+ },
147
+ { # urlconfig
148
+ '64bit' => {
149
+ 'linux' => 'url',
150
+ 'unix' => 'url',
151
+ 'macosx' => 'url',
152
+ 'windows' => 'url',
153
+ }
154
+ },
155
+ false # unpack
156
+ )
157
+ end
158
+ assert_raise ArgumentError do
159
+ Bindeps::Dependency.new(
160
+ 'test', # name
161
+ 'binary', # binaries is no longer an array
162
+ { # versionconfig
163
+ 'number' => 1,
164
+ 'command' => 'getversion'
165
+ },
166
+ { # urlconfig
167
+ '64bit' => {
168
+ 'linux' => 'url',
169
+ 'unix' => 'url',
170
+ 'macosx' => 'url',
171
+ 'windows' => 'url',
172
+ }
173
+ },
174
+ false # unpack
175
+ )
63
176
  end
64
177
  end
65
178
 
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bindeps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
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-08-03 00:00:00.000000000 Z
11
+ date: 2014-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: which
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.0'
20
+ - - '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.0.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.0'
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.0.2
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: which_works
15
35
  requirement: !ruby/object:Gem::Requirement
@@ -42,86 +62,116 @@ dependencies:
42
62
  name: rake
43
63
  requirement: !ruby/object:Gem::Requirement
44
64
  requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: '10.3'
45
68
  - - '>='
46
69
  - !ruby/object:Gem::Version
47
- version: '0'
70
+ version: 10.3.2
48
71
  type: :development
49
72
  prerelease: false
50
73
  version_requirements: !ruby/object:Gem::Requirement
51
74
  requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '10.3'
52
78
  - - '>='
53
79
  - !ruby/object:Gem::Version
54
- version: '0'
80
+ version: 10.3.2
55
81
  - !ruby/object:Gem::Dependency
56
82
  name: turn
57
83
  requirement: !ruby/object:Gem::Requirement
58
84
  requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '0.9'
59
88
  - - '>='
60
89
  - !ruby/object:Gem::Version
61
- version: '0'
90
+ version: 0.9.7
62
91
  type: :development
63
92
  prerelease: false
64
93
  version_requirements: !ruby/object:Gem::Requirement
65
94
  requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: '0.9'
66
98
  - - '>='
67
99
  - !ruby/object:Gem::Version
68
- version: '0'
100
+ version: 0.9.7
69
101
  - !ruby/object:Gem::Dependency
70
102
  name: minitest
71
103
  requirement: !ruby/object:Gem::Requirement
72
104
  requirements:
105
+ - - ~>
106
+ - !ruby/object:Gem::Version
107
+ version: '4'
73
108
  - - '>='
74
109
  - !ruby/object:Gem::Version
75
- version: '0'
110
+ version: 4.7.5
76
111
  type: :development
77
112
  prerelease: false
78
113
  version_requirements: !ruby/object:Gem::Requirement
79
114
  requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '4'
80
118
  - - '>='
81
119
  - !ruby/object:Gem::Version
82
- version: '0'
120
+ version: 4.7.5
83
121
  - !ruby/object:Gem::Dependency
84
122
  name: simplecov
85
123
  requirement: !ruby/object:Gem::Requirement
86
124
  requirements:
125
+ - - ~>
126
+ - !ruby/object:Gem::Version
127
+ version: '0.8'
87
128
  - - '>='
88
129
  - !ruby/object:Gem::Version
89
- version: '0'
130
+ version: 0.8.2
90
131
  type: :development
91
132
  prerelease: false
92
133
  version_requirements: !ruby/object:Gem::Requirement
93
134
  requirements:
135
+ - - ~>
136
+ - !ruby/object:Gem::Version
137
+ version: '0.8'
94
138
  - - '>='
95
139
  - !ruby/object:Gem::Version
96
- version: '0'
140
+ version: 0.8.2
97
141
  - !ruby/object:Gem::Dependency
98
142
  name: shoulda-context
99
143
  requirement: !ruby/object:Gem::Requirement
100
144
  requirements:
145
+ - - ~>
146
+ - !ruby/object:Gem::Version
147
+ version: '1.2'
101
148
  - - '>='
102
149
  - !ruby/object:Gem::Version
103
- version: '0'
150
+ version: 1.2.1
104
151
  type: :development
105
152
  prerelease: false
106
153
  version_requirements: !ruby/object:Gem::Requirement
107
154
  requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: '1.2'
108
158
  - - '>='
109
159
  - !ruby/object:Gem::Version
110
- version: '0'
160
+ version: 1.2.1
111
161
  - !ruby/object:Gem::Dependency
112
162
  name: coveralls
113
163
  requirement: !ruby/object:Gem::Requirement
114
164
  requirements:
115
- - - '>='
165
+ - - ~>
116
166
  - !ruby/object:Gem::Version
117
- version: 0.6.7
167
+ version: '0.7'
118
168
  type: :development
119
169
  prerelease: false
120
170
  version_requirements: !ruby/object:Gem::Requirement
121
171
  requirements:
122
- - - '>='
172
+ - - ~>
123
173
  - !ruby/object:Gem::Version
124
- version: 0.6.7
174
+ version: '0.7'
125
175
  description: binary dependency management for ruby gems
126
176
  email:
127
177
  - rds45@cam.ac.uk
@@ -152,6 +202,7 @@ files:
152
202
  - test/data/fakebin4
153
203
  - test/data/fakebin4.yaml
154
204
  - test/data/neverinstalled.yaml
205
+ - test/data/wget
155
206
  - test/helper.rb
156
207
  - test/test_bindeps.rb
157
208
  homepage: https://github.com/Blahah/bindeps
@@ -174,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
225
  version: '0'
175
226
  requirements: []
176
227
  rubyforge_project:
177
- rubygems_version: 2.0.6
228
+ rubygems_version: 2.1.4
178
229
  signing_key:
179
230
  specification_version: 4
180
231
  summary: binary dependency management for ruby gems
@@ -192,6 +243,7 @@ test_files:
192
243
  - test/data/fakebin4
193
244
  - test/data/fakebin4.yaml
194
245
  - test/data/neverinstalled.yaml
246
+ - test/data/wget
195
247
  - test/helper.rb
196
248
  - test/test_bindeps.rb
197
249
  has_rdoc: