bibliothecary 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bibliothecary/parsers/swift.rb +48 -0
- data/lib/bibliothecary/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eee3f05283c3cbba1a10f3a156b753c88a24c677
|
4
|
+
data.tar.gz: 3ece01befaf1d08f314edaf35db031b2819f2d55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92709fddf36ec030c321f7dbc8644880db2a0d7a953c04c4940205346d4dbc98c2ae3b48a112787f31b6ed4d8f5648700f44d217dea5de2d1184cb27e21f4619
|
7
|
+
data.tar.gz: 34fc86ed2f88031d5b44e04d4a1b162e661a39477a07a1291946dcefbbb4c0df4a64bbea6c428f2dd36be76bd1d8771ecc89b33f32d34991b5f61d447729642e
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Bibliothecary
|
2
|
+
module Parsers
|
3
|
+
class Swift
|
4
|
+
PLATFORM_NAME = 'swift'
|
5
|
+
|
6
|
+
def self.parse(filename, file_contents)
|
7
|
+
if filename.match(/^Package\.swift$/i)
|
8
|
+
parse_package_swift(file_contents)
|
9
|
+
else
|
10
|
+
[]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.analyse(folder_path, file_list)
|
15
|
+
[analyse_package_swift(folder_path, file_list)]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.analyse_package_swift(folder_path, file_list)
|
19
|
+
path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^Package\.swift$/i) }
|
20
|
+
return unless path
|
21
|
+
|
22
|
+
manifest = File.open(path).read
|
23
|
+
|
24
|
+
{
|
25
|
+
platform: PLATFORM_NAME,
|
26
|
+
path: path,
|
27
|
+
dependencies: parse_package_swift(manifest)
|
28
|
+
}
|
29
|
+
rescue
|
30
|
+
[]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.parse_package_swift(manifest)
|
34
|
+
response = Typhoeus.post("http://46.101.24.4:8080/to-json", body: manifest)
|
35
|
+
json = JSON.parse(response.body)
|
36
|
+
json["dependencies"].map do |dependency|
|
37
|
+
name = dependency['url'].gsub(/^https?:\/\//, '').gsub(/\.git$/,'')
|
38
|
+
version = "#{dependency['version']['lowerBound']} - #{dependency['version']['upperBound']}"
|
39
|
+
{
|
40
|
+
name: name,
|
41
|
+
version: version,
|
42
|
+
type: 'runtime'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
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: 1.
|
4
|
+
version: 1.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-07-
|
11
|
+
date: 2016-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: toml-rb
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/bibliothecary/parsers/pypi.rb
|
178
178
|
- lib/bibliothecary/parsers/rubygems.rb
|
179
179
|
- lib/bibliothecary/parsers/shard.rb
|
180
|
+
- lib/bibliothecary/parsers/swift.rb
|
180
181
|
- lib/bibliothecary/version.rb
|
181
182
|
- lib/sdl_parser.rb
|
182
183
|
homepage: https://github.com/librariesio/bibliothecary
|