bibliothecary 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bibliothecary.gemspec +1 -0
- data/lib/bibliothecary/parsers/carthage.rb +69 -3
- data/lib/bibliothecary/version.rb +1 -1
- data/lib/cartfile_parser.rb +29 -0
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2de900a7b2537246834228f5cebbae0aaadc98b
|
4
|
+
data.tar.gz: 7149d4a8e47ba273f06f480ab9b88154f1f88405
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7c20722b36918a752199520b563fde442fed3c56fbd8dfa77c23e67dd7ea15902d72c3adaa70c694a7a740a438a707a0dde481ddd6fe4e7f44b7458e343599b
|
7
|
+
data.tar.gz: 6eb481f28a6e5df3a0ce70c80039de825a104116b48bb524ab0574a6c1632f0b18b98b4c314a1151d6f93f625436a8bc26c08b51026427bfcf670e9a0ff056f8
|
data/bibliothecary.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency "toml-rb", "~> 0.3.9"
|
22
22
|
spec.add_dependency "librariesio-gem-parser"
|
23
|
+
spec.add_dependency "rogdl"
|
23
24
|
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.11"
|
25
26
|
spec.add_development_dependency "rake", "~> 11.0"
|
@@ -1,3 +1,69 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require 'cartfile_parser'
|
2
|
+
|
3
|
+
module Bibliothecary
|
4
|
+
module Parsers
|
5
|
+
class Carthage
|
6
|
+
PLATFORM_NAME = 'Carthage'
|
7
|
+
|
8
|
+
def self.parse(filename, file_contents)
|
9
|
+
if filename.match(/^Cartfile$/)
|
10
|
+
manifest = CartfileParser.new(:runtime, file_contents).dependencies
|
11
|
+
elsif filename.match(/^Cartfile\.private$/)
|
12
|
+
manifest = CartfileParser.new(:runtime, file_contents).dependencies
|
13
|
+
elsif filename.match(/^Cartfile\.resolved$/)
|
14
|
+
manifest = CartfileParser.new(:runtime, file_contents).dependencies
|
15
|
+
else
|
16
|
+
[]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.analyse(folder_path, file_list)
|
21
|
+
[
|
22
|
+
analyse_cartfile(folder_path, file_list),
|
23
|
+
analyse_cartfile_private(folder_path, file_list),
|
24
|
+
analyse_cartfile_resolved(folder_path, file_list)
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.analyse_cartfile(folder_path, file_list)
|
29
|
+
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^Cartfile$/) }
|
30
|
+
return unless path
|
31
|
+
|
32
|
+
manifest = CartfileParser.new(:runtime, File.open(path).read)
|
33
|
+
|
34
|
+
{
|
35
|
+
platform: PLATFORM_NAME,
|
36
|
+
path: path,
|
37
|
+
dependencies: manifest.dependencies
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.analyse_cartfile_private(folder_path, file_list)
|
42
|
+
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^Cartfile\.private$/) }
|
43
|
+
return unless path
|
44
|
+
|
45
|
+
manifest = CartfileParser.new(:runtime, File.open(path).read)
|
46
|
+
|
47
|
+
{
|
48
|
+
platform: PLATFORM_NAME,
|
49
|
+
path: path,
|
50
|
+
dependencies: manifest.dependencies
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.analyse_cartfile_resolved(folder_path, file_list)
|
55
|
+
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^Cartfile\.resolved$/) }
|
56
|
+
return unless path
|
57
|
+
|
58
|
+
manifest = CartfileParser.new(:runtime, File.open(path).read)
|
59
|
+
|
60
|
+
{
|
61
|
+
platform: PLATFORM_NAME,
|
62
|
+
path: path,
|
63
|
+
dependencies: manifest.dependencies
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rogdl'
|
2
|
+
|
3
|
+
class CartfileParser
|
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.inject([]) do |deps, dep|
|
16
|
+
deps.push({
|
17
|
+
name: dep[1],
|
18
|
+
version: [dep[2],dep[3]].join(' ') || ">= 0",
|
19
|
+
type: type,
|
20
|
+
})
|
21
|
+
end.uniq
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse
|
25
|
+
parser = Rogdl::Parser.new
|
26
|
+
parser.translate(contents)
|
27
|
+
parser.lines.reject { |line| line.empty? }
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibliothecary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Nesbitt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: toml-rb
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rogdl
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,6 +134,7 @@ files:
|
|
120
134
|
- lib/bibliothecary/parsers/pypi.rb
|
121
135
|
- lib/bibliothecary/parsers/rubygems.rb
|
122
136
|
- lib/bibliothecary/version.rb
|
137
|
+
- lib/cartfile_parser.rb
|
123
138
|
homepage: https://github.com/librariesio/bibliothecary
|
124
139
|
licenses:
|
125
140
|
- AGPL-3.0
|
@@ -140,8 +155,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
155
|
version: '0'
|
141
156
|
requirements: []
|
142
157
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.6.4
|
144
159
|
signing_key:
|
145
160
|
specification_version: 4
|
146
161
|
summary: Find and parse manifests
|
147
162
|
test_files: []
|
163
|
+
has_rdoc:
|