natives 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +2 -3
- data/Gemfile.lock +12 -53
- data/README.md +126 -29
- data/Rakefile +4 -5
- data/VERSION +1 -1
- data/bin/natives +1 -0
- data/catalogs/rubygems.yaml +50 -0
- data/lib/natives/apps/detect.rb +21 -0
- data/lib/natives/apps/list.rb +39 -0
- data/lib/natives/apps.rb +2 -0
- data/lib/natives/catalog/loader.rb +30 -0
- data/lib/natives/catalog/merger.rb +26 -0
- data/lib/natives/catalog/selector.rb +79 -0
- data/lib/natives/catalog/validator.rb +18 -0
- data/lib/natives/catalog.rb +56 -0
- data/lib/natives/cli.rb +27 -42
- data/lib/natives/gemfile_viewer.rb +19 -16
- data/lib/natives/host_detection/package_provider.rb +83 -0
- data/lib/natives/host_detection/platform.rb +34 -0
- data/lib/natives/host_detection.rb +25 -0
- data/lib/natives.rb +1 -0
- data/spec/fixtures/dir_with_matching_files/invalid1.yml +9 -0
- data/spec/fixtures/dir_with_matching_files/not_matching.json +0 -0
- data/spec/fixtures/dir_with_matching_files/valid1.yaml +21 -0
- data/spec/fixtures/dir_with_matching_files/valid2.yml +9 -0
- data/spec/fixtures/dir_without_matching_file/not_matching.json +0 -0
- data/spec/natives/apps/detect_spec.rb +26 -0
- data/spec/natives/apps/list_spec.rb +58 -0
- data/spec/natives/catalog/loader_spec.rb +101 -0
- data/spec/natives/catalog/merger_spec.rb +60 -0
- data/spec/natives/catalog/selector_spec.rb +124 -0
- data/spec/natives/catalog/validator_spec.rb +44 -0
- data/spec/natives/catalog_spec.rb +133 -0
- data/spec/natives/gemfile_viewer_spec.rb +3 -3
- data/spec/natives/host_detection/package_provider_spec.rb +33 -0
- data/spec/natives/host_detection/platform_spec.rb +21 -0
- data/spec/natives/host_detection_spec.rb +45 -0
- data/spec/spec_helper.rb +17 -2
- metadata +44 -66
- data/chef/.kitchen.yml +0 -27
- data/chef/Berksfile +0 -4
- data/chef/Berksfile.lock +0 -10
- data/chef/cookbooks/natives/Berksfile +0 -3
- data/chef/cookbooks/natives/Gemfile +0 -5
- data/chef/cookbooks/natives/LICENSE +0 -3
- data/chef/cookbooks/natives/README.md +0 -13
- data/chef/cookbooks/natives/chefignore +0 -96
- data/chef/cookbooks/natives/libraries/natives_recipe_helper.rb +0 -37
- data/chef/cookbooks/natives/metadata.rb +0 -9
- data/chef/cookbooks/natives/recipes/default.rb +0 -31
- data/chef/solo.rb +0 -17
- data/chef/vendored-cookbooks/apt/CHANGELOG.md +0 -144
- data/chef/vendored-cookbooks/apt/README.md +0 -247
- data/chef/vendored-cookbooks/apt/attributes/default.rb +0 -27
- data/chef/vendored-cookbooks/apt/files/default/apt-proxy-v2.conf +0 -50
- data/chef/vendored-cookbooks/apt/libraries/helpers.rb +0 -47
- data/chef/vendored-cookbooks/apt/libraries/network.rb +0 -33
- data/chef/vendored-cookbooks/apt/metadata.json +0 -54
- data/chef/vendored-cookbooks/apt/metadata.rb +0 -34
- data/chef/vendored-cookbooks/apt/providers/preference.rb +0 -61
- data/chef/vendored-cookbooks/apt/providers/repository.rb +0 -141
- data/chef/vendored-cookbooks/apt/recipes/cacher-client.rb +0 -81
- data/chef/vendored-cookbooks/apt/recipes/cacher-ng.rb +0 -43
- data/chef/vendored-cookbooks/apt/recipes/default.rb +0 -83
- data/chef/vendored-cookbooks/apt/resources/preference.rb +0 -30
- data/chef/vendored-cookbooks/apt/resources/repository.rb +0 -41
- data/chef/vendored-cookbooks/apt/templates/debian-6.0/acng.conf.erb +0 -173
- data/chef/vendored-cookbooks/apt/templates/default/01proxy.erb +0 -5
- data/chef/vendored-cookbooks/apt/templates/default/acng.conf.erb +0 -275
- data/chef/vendored-cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb +0 -269
- data/chef/vendored-cookbooks/homebrew/CHANGELOG.md +0 -36
- data/chef/vendored-cookbooks/homebrew/README.md +0 -110
- data/chef/vendored-cookbooks/homebrew/attributes/default.rb +0 -22
- data/chef/vendored-cookbooks/homebrew/libraries/homebrew_mixin.rb +0 -53
- data/chef/vendored-cookbooks/homebrew/libraries/homebrew_package.rb +0 -104
- data/chef/vendored-cookbooks/homebrew/metadata.json +0 -32
- data/chef/vendored-cookbooks/homebrew/metadata.rb +0 -10
- data/chef/vendored-cookbooks/homebrew/providers/tap.rb +0 -48
- data/chef/vendored-cookbooks/homebrew/recipes/default.rb +0 -46
- data/chef/vendored-cookbooks/homebrew/resources/tap.rb +0 -35
- data/lib/natives/app.rb +0 -71
- data/natives.gemspec +0 -125
- data/spec/natives/app_spec.rb +0 -153
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTFiNjcxMTE5N2I2NGU5NjkwNTc4NmUyMDRkMmVhZTJiOGViMTBkZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Nzg2M2Q5MWIxOTdjMGJmMDQ0Y2Y3YTUzNmJlZWI4Nzc1ZGM2MmY0NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDRhZjJiMTQ0MmFkNjA4Y2NkOGYwY2VjMjExYWY2YTgxN2M1ODg4YzU0MDQz
|
10
|
+
OGQ4MzFhOTBlNjllNDA2MTBhY2IzMzI2MmJkZTZlYThmZGMxODU4YzRlNmY3
|
11
|
+
OTgyYzQyMmMyYWVmMzMzNjZmNWY3YWQ2YTMzZDg4NDA1MzU0NGQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmY3YjBmNjZlNjdlYjEzNjU2MTIxOWRkNzg4MjgzYTJmNjJkMDRmNDJhYzNi
|
14
|
+
MmQxZDEwZTI2ZjkxOTMzYjViOWI4YmMzOTczZTgwMTcwY2QwZjEzNDIyZDNh
|
15
|
+
MDExMzhhODM0YWExYTNjNmMwZWQ1NWY4NTY3MzdiNzk4YjAyMjk=
|
data/Gemfile
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
# Add dependencies required to use your gem here.
|
3
|
-
|
4
|
-
gem "chef", ">= 11.6.2"
|
5
|
-
gem "natives-catalog", ">= 0.3.4"
|
3
|
+
gem "ohai"
|
6
4
|
gem "thor"
|
7
5
|
|
8
6
|
# Add dependencies to develop your gem here.
|
@@ -13,5 +11,6 @@ group :development do
|
|
13
11
|
gem "rdoc"
|
14
12
|
gem "bundler"
|
15
13
|
gem "jeweler"
|
14
|
+
gem "debugger"
|
16
15
|
gem "simplecov"
|
17
16
|
end
|
data/Gemfile.lock
CHANGED
@@ -3,34 +3,14 @@ GEM
|
|
3
3
|
specs:
|
4
4
|
addressable (2.3.5)
|
5
5
|
builder (3.2.2)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
mixlib-authentication (~> 1.3)
|
14
|
-
mixlib-cli (~> 1.3)
|
15
|
-
mixlib-config (~> 2.0)
|
16
|
-
mixlib-log (~> 1.3)
|
17
|
-
mixlib-shellout (~> 1.2)
|
18
|
-
net-ssh (~> 2.6)
|
19
|
-
net-ssh-multi (~> 1.1.0)
|
20
|
-
ohai (~> 6.0)
|
21
|
-
pry (~> 0.9)
|
22
|
-
puma (~> 1.6)
|
23
|
-
rest-client (>= 1.0.4, < 1.7.0)
|
24
|
-
yajl-ruby (~> 1.1)
|
25
|
-
chef-zero (1.7)
|
26
|
-
hashie (~> 2.0)
|
27
|
-
json
|
28
|
-
mixlib-log (~> 1.3)
|
29
|
-
moneta (< 0.7.0)
|
30
|
-
rack
|
31
|
-
coderay (1.0.9)
|
6
|
+
columnize (0.3.6)
|
7
|
+
debugger (1.6.1)
|
8
|
+
columnize (>= 0.3.1)
|
9
|
+
debugger-linecache (~> 1.2.0)
|
10
|
+
debugger-ruby_core_source (~> 1.2.3)
|
11
|
+
debugger-linecache (1.2.0)
|
12
|
+
debugger-ruby_core_source (1.2.3)
|
32
13
|
diff-lcs (1.2.4)
|
33
|
-
erubis (2.7.0)
|
34
14
|
faraday (0.8.8)
|
35
15
|
multipart-post (~> 1.2.0)
|
36
16
|
git (1.2.6)
|
@@ -42,7 +22,7 @@ GEM
|
|
42
22
|
nokogiri (~> 1.5.2)
|
43
23
|
oauth2
|
44
24
|
hashie (2.0.5)
|
45
|
-
highline (1.6.
|
25
|
+
highline (1.6.19)
|
46
26
|
httpauth (0.2.0)
|
47
27
|
ipaddress (0.8.0)
|
48
28
|
jeweler (1.8.8)
|
@@ -57,25 +37,13 @@ GEM
|
|
57
37
|
json (1.7.7)
|
58
38
|
jwt (0.1.8)
|
59
39
|
multi_json (>= 1.5)
|
60
|
-
method_source (0.8.2)
|
61
|
-
mime-types (1.25)
|
62
|
-
mixlib-authentication (1.3.0)
|
63
|
-
mixlib-log
|
64
40
|
mixlib-cli (1.3.0)
|
65
41
|
mixlib-config (2.0.0)
|
66
42
|
mixlib-log (1.6.0)
|
67
43
|
mixlib-shellout (1.2.0)
|
68
|
-
moneta (0.6.0)
|
69
44
|
multi_json (1.8.2)
|
70
45
|
multi_xml (0.5.5)
|
71
46
|
multipart-post (1.2.0)
|
72
|
-
natives-catalog (0.3.4)
|
73
|
-
net-ssh (2.7.0)
|
74
|
-
net-ssh-gateway (1.2.0)
|
75
|
-
net-ssh (>= 2.6.5)
|
76
|
-
net-ssh-multi (1.1)
|
77
|
-
net-ssh (>= 2.1.4)
|
78
|
-
net-ssh-gateway (>= 0.99.0)
|
79
47
|
nokogiri (1.5.10)
|
80
48
|
oauth2 (0.9.2)
|
81
49
|
faraday (~> 0.8)
|
@@ -92,31 +60,22 @@ GEM
|
|
92
60
|
mixlib-shellout
|
93
61
|
systemu (~> 2.5.2)
|
94
62
|
yajl-ruby
|
95
|
-
pry (0.9.12.2)
|
96
|
-
coderay (~> 1.0.5)
|
97
|
-
method_source (~> 0.8)
|
98
|
-
slop (~> 3.4)
|
99
|
-
puma (1.6.3)
|
100
|
-
rack (~> 1.2)
|
101
63
|
rack (1.5.2)
|
102
64
|
rake (10.1.0)
|
103
65
|
rdoc (4.0.1)
|
104
66
|
json (~> 1.4)
|
105
|
-
rest-client (1.6.7)
|
106
|
-
mime-types (>= 1.16)
|
107
67
|
rspec (2.14.1)
|
108
68
|
rspec-core (~> 2.14.0)
|
109
69
|
rspec-expectations (~> 2.14.0)
|
110
70
|
rspec-mocks (~> 2.14.0)
|
111
|
-
rspec-core (2.14.
|
71
|
+
rspec-core (2.14.5)
|
112
72
|
rspec-expectations (2.14.3)
|
113
73
|
diff-lcs (>= 1.1.3, < 2.0)
|
114
|
-
rspec-mocks (2.14.
|
74
|
+
rspec-mocks (2.14.3)
|
115
75
|
simplecov (0.7.1)
|
116
76
|
multi_json (~> 1.0)
|
117
77
|
simplecov-html (~> 0.7.1)
|
118
78
|
simplecov-html (0.7.1)
|
119
|
-
slop (3.4.6)
|
120
79
|
systemu (2.5.2)
|
121
80
|
thor (0.18.1)
|
122
81
|
yajl-ruby (1.1.0)
|
@@ -127,9 +86,9 @@ PLATFORMS
|
|
127
86
|
|
128
87
|
DEPENDENCIES
|
129
88
|
bundler
|
130
|
-
|
89
|
+
debugger
|
131
90
|
jeweler
|
132
|
-
|
91
|
+
ohai
|
133
92
|
rdoc
|
134
93
|
rspec
|
135
94
|
simplecov
|
data/README.md
CHANGED
@@ -1,69 +1,166 @@
|
|
1
|
-
# natives
|
1
|
+
# natives-catalog
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/natives.png)](http://badge.fury.io/rb/natives)
|
4
|
-
[![Code Climate](https://codeclimate.com/github/teohm/natives.png)](https://codeclimate.com/github/teohm/natives)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/natives-catalog.png)](http://badge.fury.io/rb/natives-catalog)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/teohm/natives-catalog.png)](https://codeclimate.com/github/teohm/natives-catalog)
|
5
5
|
|
6
|
-
|
6
|
+
Maintains a catalog of native library packages required by Ruby gems, and a parser to load catalog files.
|
7
7
|
|
8
|
-
It
|
8
|
+
It can be extended to maintain additional catalogs e.g. for other package dependency manager such as `npm`.
|
9
|
+
|
10
|
+
It is currently used by [natives](https://github.com/teohm/natives) gem to install native packages on multiple platforms.
|
11
|
+
|
12
|
+
-----
|
13
|
+
### Calling for rubygems catalog contributors!
|
14
|
+
|
15
|
+
We need your help to populate and maintain the [rubygems catalog](https://github.com/teohm/natives-catalog/blob/master/catalogs/rubygems.yaml)! :-)
|
16
|
+
|
17
|
+
-----
|
9
18
|
|
10
19
|
## Install
|
11
20
|
|
12
21
|
```
|
13
|
-
gem install natives
|
22
|
+
gem install natives-catalog
|
14
23
|
```
|
15
24
|
|
16
25
|
## Use
|
26
|
+
|
17
27
|
```
|
18
|
-
natives
|
28
|
+
require 'natives/catalog'
|
29
|
+
|
30
|
+
catalog = Natives::Catalog.new(
|
31
|
+
'rubygems',
|
32
|
+
'mac_os_x', '10.7.5',
|
33
|
+
'homebrew')
|
34
|
+
|
35
|
+
catalog.to_hash # returns the loaded catalog hash
|
36
|
+
|
37
|
+
catalog.reload # reloads catalog files
|
38
|
+
|
39
|
+
catalog.native_packages_for('webcapybara', 'sqlite3')
|
40
|
+
# => ["qt", "sqlite"]
|
19
41
|
```
|
20
|
-
It will lookup and install native packages (e.g. curl, qt, sqlite) required by the following gems: curb, capybara-webkit, nokogiri, sqlite3.
|
21
42
|
|
22
43
|
|
23
|
-
|
24
|
-
|
44
|
+
## Catalog
|
45
|
+
|
46
|
+
### Supported catalogs
|
47
|
+
|
48
|
+
* **[rubygems](https://github.com/teohm/natives-catalog/blob/master/catalogs/rubygems.yaml) (calling for your PR contributions!)**
|
49
|
+
* (new catalog contributors e.g. for `npm` are welcomed :-)
|
50
|
+
|
51
|
+
### Catalog load paths
|
52
|
+
|
53
|
+
It loads YAML files (.yaml, .yml) from the following paths in this order:
|
54
|
+
|
55
|
+
1. `catalogs/` in this gem.
|
56
|
+
2. `natives-catalogs/` in current working directory, if any.
|
25
57
|
|
58
|
+
When there are several YAML files in a path, they are **sorted by filename** and loaded in the same order.
|
59
|
+
|
60
|
+
### Catalog file format
|
61
|
+
|
62
|
+
A catalog file is written in YAML, based on this format:
|
63
|
+
|
64
|
+
```
|
65
|
+
catalog_name:
|
66
|
+
entry_name:
|
67
|
+
platform/package_provider:
|
68
|
+
version:
|
69
|
+
- package_name
|
26
70
|
```
|
27
|
-
natives install
|
28
|
-
natives # run 'install' task by default
|
29
71
|
|
30
|
-
|
31
|
-
|
72
|
+
For example,
|
73
|
+
|
74
|
+
```
|
75
|
+
rubygems:
|
76
|
+
capybara-webkit:
|
77
|
+
mac_os_x/homebrew:
|
78
|
+
10.7.5:
|
79
|
+
- libqtwebkit-dev
|
32
80
|
```
|
33
81
|
|
34
|
-
|
82
|
+
#### Use `default` when apply to all platforms
|
35
83
|
|
36
84
|
```
|
37
|
-
|
85
|
+
rubygems:
|
86
|
+
curb:
|
87
|
+
default:
|
88
|
+
- curl
|
38
89
|
```
|
39
|
-
By default, it uses `rubygems` catalog, but it's easy to tell `natives` to use another catalog.
|
40
90
|
|
41
|
-
|
91
|
+
#### Use `default` when apply to all versions
|
42
92
|
|
43
93
|
```
|
44
|
-
|
45
|
-
|
46
|
-
|
94
|
+
rubygems:
|
95
|
+
capybara-webkit:
|
96
|
+
mac_os_x/homebrew:
|
97
|
+
default:
|
98
|
+
- libqtwebkit-dev
|
47
99
|
```
|
48
100
|
|
49
|
-
|
101
|
+
#### Use array to group platforms
|
50
102
|
|
51
|
-
|
103
|
+
```
|
104
|
+
rubygems:
|
105
|
+
capybara-webkit:
|
106
|
+
[ubuntu/apt, debian/apt]:
|
107
|
+
default:
|
108
|
+
- libqtwebkit-dev
|
109
|
+
```
|
110
|
+
|
111
|
+
#### Use array to group versions
|
52
112
|
|
53
|
-
By default, it uses [the catalog](https://github.com/teohm/natives-catalog/blob/master/catalogs/rubygems.yaml) shipped with [natives-catalog](https://github.com/teohm/natives-catalog) gem.
|
54
113
|
|
55
|
-
To update the catalogs:
|
56
114
|
|
57
115
|
```
|
58
|
-
|
116
|
+
rubygems:
|
117
|
+
capybara-webkit:
|
118
|
+
ubuntu/apt:
|
119
|
+
[10.04, 10.04.1, 10.04.2, 10.04.3, 10.04.4]:
|
120
|
+
- libqt4-dev
|
121
|
+
default:
|
122
|
+
- libqtwebkit-dev
|
59
123
|
```
|
60
124
|
|
61
|
-
### Project-specific
|
62
125
|
|
63
|
-
|
126
|
+
#### Supported values for platform/package_provider
|
127
|
+
|
128
|
+
The values are limited to the platforms and package providers [supported by Chef](https://github.com/opscode/chef/blob/master/lib/chef/platform/provider_mapping.rb), so that Chef can be used to perform the package installation (see [natives](https://github.com/teohm/natives) gem).
|
129
|
+
|
130
|
+
```
|
131
|
+
aix/aix
|
132
|
+
amazon/yum
|
133
|
+
arch/pacman
|
134
|
+
centos/yum
|
135
|
+
debian/apt
|
136
|
+
fedora/yum
|
137
|
+
freebsd/freebsd
|
138
|
+
gcel/apt
|
139
|
+
gentoo/portage
|
140
|
+
linaro/apt
|
141
|
+
linuxmint/apt
|
142
|
+
mac_os_x/homebrew
|
143
|
+
mac_os_x/macports
|
144
|
+
mac_os_x_server/macports
|
145
|
+
nexentacore/solaris
|
146
|
+
omnios/ips
|
147
|
+
openindiana/ips
|
148
|
+
opensolaris/ips
|
149
|
+
opensuse/zypper
|
150
|
+
oracle/yum
|
151
|
+
raspbian/apt
|
152
|
+
redhat/yum
|
153
|
+
scientific/yum
|
154
|
+
smartos/smartos
|
155
|
+
solaris2/ips
|
156
|
+
suse/zypper
|
157
|
+
ubuntu/apt
|
158
|
+
xcp/yum
|
159
|
+
xenserver/yum
|
160
|
+
```
|
64
161
|
|
65
162
|
|
66
|
-
## Contributing to natives
|
163
|
+
## Contributing to natives-catalog
|
67
164
|
|
68
165
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
69
166
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
data/Rakefile
CHANGED
@@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
|
|
17
17
|
gem.name = "natives"
|
18
18
|
gem.homepage = "http://github.com/teohm/natives"
|
19
19
|
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{
|
21
|
-
gem.description = %Q{
|
20
|
+
gem.summary = %Q{Lookup native packages required by gems.}
|
21
|
+
gem.description = %Q{Lookup native package dependencies required by gems.}
|
22
22
|
gem.email = "teohuiming@gmail.com"
|
23
23
|
gem.authors = ["Huiming Teo"]
|
24
24
|
# dependencies defined in Gemfile
|
@@ -31,9 +31,8 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
31
31
|
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
32
|
end
|
33
33
|
|
34
|
-
RSpec::Core::RakeTask.new(:
|
35
|
-
|
36
|
-
spec.rcov = true
|
34
|
+
RSpec::Core::RakeTask.new(:coverage) do |spec|
|
35
|
+
ENV['COVERAGE'] = 'true'
|
37
36
|
end
|
38
37
|
|
39
38
|
task :default => :spec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/bin/natives
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
rubygems:
|
2
|
+
capybara-webkit:
|
3
|
+
mac_os_x/macports:
|
4
|
+
default:
|
5
|
+
- qt4-mac-devel
|
6
|
+
mac_os_x/homebrew:
|
7
|
+
default:
|
8
|
+
- qt
|
9
|
+
ubuntu/apt:
|
10
|
+
default:
|
11
|
+
- libqtwebkit-dev
|
12
|
+
curb:
|
13
|
+
ubuntu/apt:
|
14
|
+
default:
|
15
|
+
- libcurl4-openssl-dev
|
16
|
+
nokogiri:
|
17
|
+
ubuntu/apt:
|
18
|
+
default:
|
19
|
+
- libxslt-dev
|
20
|
+
- libxml2-dev
|
21
|
+
pg:
|
22
|
+
mac_os_x/homebrew:
|
23
|
+
default:
|
24
|
+
- postgres
|
25
|
+
ubuntu/apt:
|
26
|
+
default:
|
27
|
+
- libpq-dev
|
28
|
+
rmagick:
|
29
|
+
mac_os_x/homebrew:
|
30
|
+
default:
|
31
|
+
- imagemagick
|
32
|
+
ubuntu/apt:
|
33
|
+
default:
|
34
|
+
- imagemagick
|
35
|
+
- libmagickwand-dev
|
36
|
+
tesseract-ocr:
|
37
|
+
mac_os_x/homebrew:
|
38
|
+
default:
|
39
|
+
- tesseract
|
40
|
+
ubuntu/apt:
|
41
|
+
default:
|
42
|
+
- libtesseract-dev
|
43
|
+
- libleptonica-dev
|
44
|
+
sqlite3:
|
45
|
+
ubuntu/apt:
|
46
|
+
default:
|
47
|
+
- libsqlite3-dev
|
48
|
+
fedora/yum:
|
49
|
+
default:
|
50
|
+
- sqlite-devel
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'natives/host_detection'
|
2
|
+
|
3
|
+
module Natives
|
4
|
+
module Apps
|
5
|
+
class Detect
|
6
|
+
|
7
|
+
def detection_info
|
8
|
+
host = new_host_detection
|
9
|
+
return [
|
10
|
+
"platform: #{host.platform}",
|
11
|
+
"platform_version: #{host.platform_version}",
|
12
|
+
"package_provider: #{host.package_provider}",
|
13
|
+
].join("\n")
|
14
|
+
end
|
15
|
+
|
16
|
+
def new_host_detection
|
17
|
+
HostDetection.new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'natives/host_detection'
|
2
|
+
require 'natives/catalog'
|
3
|
+
require 'natives/gemfile_viewer'
|
4
|
+
|
5
|
+
module Natives
|
6
|
+
module Apps
|
7
|
+
class List
|
8
|
+
|
9
|
+
def natives_for(catalog_name, entry_names)
|
10
|
+
host = new_host_detection
|
11
|
+
catalog = new_catalog(catalog_name,
|
12
|
+
host.platform, host.platform_version,
|
13
|
+
host.package_provider)
|
14
|
+
catalog.native_packages_for(entry_names)
|
15
|
+
end
|
16
|
+
|
17
|
+
def natives_for_gemfile(gemfile_path)
|
18
|
+
host = new_host_detection
|
19
|
+
gem_names = new_gemfile_viewer(gemfile_path).gem_names
|
20
|
+
catalog = new_catalog('rubygems',
|
21
|
+
host.platform, host.platform_version,
|
22
|
+
host.package_provider)
|
23
|
+
catalog.native_packages_for(gem_names)
|
24
|
+
end
|
25
|
+
|
26
|
+
def new_gemfile_viewer(gemfile_path)
|
27
|
+
GemfileViewer.new(gemfile_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def new_catalog(catalog_name, platform, platform_version, package_provider)
|
31
|
+
Catalog.new(catalog_name, platform, platform_version, package_provider)
|
32
|
+
end
|
33
|
+
|
34
|
+
def new_host_detection
|
35
|
+
HostDetection.new
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/natives/apps.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'natives/catalog/merger'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Natives
|
5
|
+
class Catalog
|
6
|
+
class Loader
|
7
|
+
def initialize(opts={})
|
8
|
+
@merger = opts.fetch(:merger, Merger.new)
|
9
|
+
end
|
10
|
+
|
11
|
+
def load_from_paths(paths)
|
12
|
+
master_hash = {}
|
13
|
+
Array(paths).each do |path|
|
14
|
+
yaml_files_in_path(path).sort.each do |file|
|
15
|
+
@merger.merge_catalog!(master_hash, load_yaml_file(file))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
master_hash
|
19
|
+
end
|
20
|
+
|
21
|
+
def yaml_files_in_path(path)
|
22
|
+
Dir.glob(File.join(path, '*.{yml,yaml}'))
|
23
|
+
end
|
24
|
+
|
25
|
+
def load_yaml_file(filename)
|
26
|
+
YAML.load_file(filename)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'natives/catalog/validator'
|
2
|
+
|
3
|
+
module Natives
|
4
|
+
class Catalog
|
5
|
+
class Merger
|
6
|
+
def initialize(opts={})
|
7
|
+
@validator = opts.fetch(:validator, Validator.new)
|
8
|
+
end
|
9
|
+
|
10
|
+
def merge_catalog!(master_hash, hash_to_merge)
|
11
|
+
@validator.ensure_valid_catalog_groups(master_hash)
|
12
|
+
@validator.ensure_valid_catalog_groups(hash_to_merge)
|
13
|
+
|
14
|
+
hash_to_merge.each do |group_name, entries|
|
15
|
+
if master_hash.key? group_name
|
16
|
+
master_hash[group_name].merge! entries
|
17
|
+
else
|
18
|
+
master_hash[group_name] = entries
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
master_hash
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Natives
|
2
|
+
class Catalog
|
3
|
+
class Selector
|
4
|
+
def initialize(platform_hash)
|
5
|
+
assert_valid_platform_hash(platform_hash)
|
6
|
+
@values = normalize_platform_hash(platform_hash)
|
7
|
+
end
|
8
|
+
|
9
|
+
def value_for(platform, platform_version, package_provider)
|
10
|
+
key = "#{platform.to_s}/#{package_provider.to_s}"
|
11
|
+
if @values.key?(key) && @values[key].key?(platform_version)
|
12
|
+
@values[key][platform_version]
|
13
|
+
elsif @values.key?(key) && @values[key].key?('default')
|
14
|
+
@values[key]['default']
|
15
|
+
elsif @values.key?('default')
|
16
|
+
@values['default']
|
17
|
+
else
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def normalize_platform_hash(platform_hash)
|
25
|
+
normalized_hash = {}
|
26
|
+
platform_hash.each do |keys, value|
|
27
|
+
if keys.to_s == 'default'
|
28
|
+
normalized_hash['default'] = value
|
29
|
+
else
|
30
|
+
Array(keys).each do |key|
|
31
|
+
normalized_hash[key.to_s] = normalize_keys(value)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
normalized_hash
|
36
|
+
end
|
37
|
+
|
38
|
+
def normalize_keys(hash)
|
39
|
+
normalized_hash = {}
|
40
|
+
hash.each do |keys, value|
|
41
|
+
Array(keys).each do |key|
|
42
|
+
normalized_hash[key.to_s] = value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
normalized_hash
|
46
|
+
end
|
47
|
+
|
48
|
+
def assert_valid_platform_hash(platform_hash)
|
49
|
+
unless platform_hash.kind_of? Hash
|
50
|
+
raise ArgumentError, 'catalog entry should be a hash'
|
51
|
+
end
|
52
|
+
|
53
|
+
platform_hash.each do |platforms, value|
|
54
|
+
assert_valid_key_and_value(platforms, value)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def assert_valid_key_and_value(platforms, value)
|
59
|
+
return if platforms.to_s == 'default'
|
60
|
+
|
61
|
+
keys = platforms.kind_of?(Array) ? platforms : [platforms]
|
62
|
+
keys.each do |key|
|
63
|
+
if (%r{\A.+/.+\Z} =~ key.to_s) == nil && key.to_s != 'default'
|
64
|
+
msg = "Found an invalid key: #{key.inspect}. "
|
65
|
+
msg << "A valid key should be in this format: 'platform/package_provider'."
|
66
|
+
raise ArgumentError, msg
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
unless value.kind_of? Hash
|
71
|
+
msg = "Found an invalid value: #{value.inspect} "
|
72
|
+
msg << "for key: #{platforms.inspect}. The value should be a Hash."
|
73
|
+
raise ArgumentError, msg
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Natives
|
2
|
+
class Catalog
|
3
|
+
class Validator
|
4
|
+
def ensure_valid_catalog_groups(hash)
|
5
|
+
unless hash.kind_of? Hash
|
6
|
+
raise ArgumentError, 'catalog should be a Hash'
|
7
|
+
end
|
8
|
+
|
9
|
+
invalid_groups = hash.select {|key, value| !value.kind_of?(Hash) }
|
10
|
+
unless invalid_groups.empty?
|
11
|
+
group_names = invalid_groups.keys
|
12
|
+
raise ArgumentError,
|
13
|
+
"The following catalog group(s) should be a Hash: #{group_names.join(', ')}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|