bibliothecary 0.11.0 → 0.12.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
2
  SHA1:
3
- metadata.gz: 7bf47b342e3e120a20a0c6e4350db00f92e0aed2
4
- data.tar.gz: 21402eed4e826e858d5ea3e0e6bb343199089957
3
+ metadata.gz: 614edadd0894b35bb2599ea0bef84078df87b201
4
+ data.tar.gz: 9d837c4936dea64fa206b4de605bc31e2b814936
5
5
  SHA512:
6
- metadata.gz: f6469739fcc77d598619710296d94db027d3dc08276ec71f779aae2f754b615316decfdaf73f61b4590fd80ec7d41a60d2dc026419902e6da6a70ab215469d2f
7
- data.tar.gz: 635c482aa015cd395d1b706ca9c1e7bdefc9cd9114769ec3f7ed68a959b60b59e05e72c06b259134312217dcdaaac7b62f777f8dfa4ae076107a2b15a094e8a3
6
+ metadata.gz: acf798c3417d77018ea09bf7abe60a479ef5dd08aab70b343a6c7d4196254f779f37ba83be03090dc6148a2c8b5442d5b13fe385f08c93284aad2caff9648ba6
7
+ data.tar.gz: 5cc623960af7395951a333c09f6c20a38be1a1ef399d0c16afd94865c90e601774a53a393c19626a40452c22ea92a66cab1cf57fac8dfb972241f49523ba5439
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "ox"
25
25
  spec.add_dependency "typhoeus"
26
26
  spec.add_dependency "deb_control"
27
+ spec.add_dependency "sdl4r"
27
28
 
28
29
  spec.add_development_dependency "bundler", "~> 1.11"
29
30
  spec.add_development_dependency "rake", "~> 11.0"
@@ -1,4 +1,65 @@
1
- # dub.json
2
- # dub.sdl
1
+ require 'json'
2
+ require 'sdl_parser'
3
3
 
4
- # http://sdl4r.rubyforge.org/
4
+ module Bibliothecary
5
+ module Parsers
6
+ class Dub
7
+ PLATFORM_NAME = 'dub'
8
+
9
+ def self.parse(filename, file_contents)
10
+ if filename.match(/^dub\.json$/)
11
+ json = JSON.parse(file_contents)
12
+ parse_manifest(json)
13
+ elsif filename.match(/^dub\.sdl$/)
14
+ parse_sdl_manifest(file_contents)
15
+ else
16
+ []
17
+ end
18
+ end
19
+
20
+ def self.analyse_json(folder_path, file_list)
21
+ path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^dub\.json$/) }
22
+ return unless path
23
+
24
+ manifest = JSON.parse File.open(path).read
25
+
26
+ {
27
+ platform: PLATFORM_NAME,
28
+ path: path,
29
+ dependencies: parse_manifest(manifest)
30
+ }
31
+ end
32
+
33
+ def self.analyse_sdl(folder_path, file_list)
34
+ path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^dub\.sdl$/) }
35
+ return unless path
36
+
37
+ manifest = File.open(path).read
38
+
39
+ {
40
+ platform: PLATFORM_NAME,
41
+ path: path,
42
+ dependencies: parse_sdl_manifest(manifest)
43
+ }
44
+ end
45
+
46
+ def self.parse_manifest(manifest)
47
+ map_dependencies(manifest, 'dependencies', 'runtime')
48
+ end
49
+
50
+ def self.parse_sdl_manifest(manifest)
51
+ SdlParser.new(:runtime, manifest).dependencies
52
+ end
53
+
54
+ def self.map_dependencies(hash, key, type)
55
+ hash.fetch(key,[]).map do |name, requirement|
56
+ {
57
+ name: name,
58
+ requirement: requirement,
59
+ type: type
60
+ }
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "0.11.0"
2
+ VERSION = "0.12.0"
3
3
  end
data/lib/sdl_parser.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'sdl4r'
2
+
3
+ class SdlParser
4
+ attr_reader :contents, :type
5
+ def initialize(type, contents)
6
+ @contents = contents
7
+ @type = type || 'runtime'
8
+ end
9
+
10
+ def to_json
11
+ Oj.dump(dependencies, mode: :compat) unless contents.nil?
12
+ end
13
+
14
+ def dependencies
15
+ parse.children('dependency').inject([]) do |deps, dep|
16
+ deps.push({
17
+ name: dep.value,
18
+ version: dep.attribute('version') || ">= 0",
19
+ type: type,
20
+ })
21
+ end.uniq
22
+ end
23
+
24
+ def parse
25
+ SDL4R::read(contents)
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibliothecary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sdl4r
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: bundler
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -178,6 +192,7 @@ files:
178
192
  - lib/bibliothecary/parsers/rubygems.rb
179
193
  - lib/bibliothecary/version.rb
180
194
  - lib/cartfile_parser.rb
195
+ - lib/sdl_parser.rb
181
196
  homepage: https://github.com/librariesio/bibliothecary
182
197
  licenses:
183
198
  - AGPL-3.0