bibliothecary 0.13.1 → 0.14.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: 95b0ef5a2bb4dc170843b315106a0680b13f07ab
4
- data.tar.gz: 60d939f8557151e8fbea4820d9dd4c976f4c3c6e
3
+ metadata.gz: 687c305ca930c9357f00bc25c9285b7fe277b2ae
4
+ data.tar.gz: 42aae84d7863c00e53580efc3c2f92882fec4546
5
5
  SHA512:
6
- metadata.gz: 8a4f7f0d9d748bc4f4e873efed6e849cff2207b82347411d860d363418f9b584c294bb1aad30087075b6f6244002031bd90426d9ef181f2128e25b570ac6035e
7
- data.tar.gz: e149b956abf03ede171550c56d8ea19b713bc46ae3c7af4de454caa81454f4d1a2cb54c5c7c09412d99676bbcd909bf015635cca0f42a5167da8cb1417213130
6
+ metadata.gz: 733a97827e27d99f5414479f180c8c2d425e23548d832942f3ef6196329eada6edb0893b4d1a5818b3f137b6a71545730f42dc0322505632141ea034fa5e8b3f
7
+ data.tar.gz: a80d0be71e6898470e76cff823be82a34f13768bf27d4985de6d60d768a23cd45559b8d3269b01d403828432a4fb65fb2e5d5dd08cc35d417cb454c14ea2669f
@@ -0,0 +1,71 @@
1
+ require 'yaml'
2
+
3
+ module Bibliothecary
4
+ module Parsers
5
+ class Shard
6
+ PLATFORM_NAME = 'shard'
7
+
8
+ def self.parse(filename, file_contents)
9
+ if filename.match(/^shard\.yml$/i)
10
+ yaml = YAML.load file_contents
11
+ parse_yaml_manifest(yaml)
12
+ elsif filename.match(/^shard\.lock$/i)
13
+ yaml = YAML.load file_contents
14
+ parse_yaml_lockfile(yaml)
15
+ else
16
+ []
17
+ end
18
+ end
19
+
20
+ def self.analyse(folder_path, file_list)
21
+ [analyse_yaml_manifest(folder_path, file_list),
22
+ analyse_yaml_lockfile(folder_path, file_list)]
23
+ end
24
+
25
+ def self.analyse_yaml_manifest(folder_path, file_list)
26
+ path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^shard\.yml$/i) }
27
+ return unless path
28
+
29
+ manifest = YAML.load File.open(path).read
30
+
31
+ {
32
+ platform: PLATFORM_NAME,
33
+ path: path,
34
+ dependencies: parse_yaml_manifest(manifest)
35
+ }
36
+ end
37
+
38
+ def self.analyse_yaml_lockfile(folder_path, file_list)
39
+ path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^shard\.lock$/i) }
40
+ return unless path
41
+
42
+ manifest = YAML.load File.open(path).read
43
+
44
+ {
45
+ platform: PLATFORM_NAME,
46
+ path: path,
47
+ dependencies: parse_yaml_lockfile(manifest)
48
+ }
49
+ end
50
+
51
+ def self.parse_yaml_lockfile(manifest)
52
+ map_dependencies(manifest, 'shards', 'runtime')
53
+ end
54
+
55
+ def self.parse_yaml_manifest(manifest)
56
+ map_dependencies(manifest, 'dependencies', 'runtime') +
57
+ map_dependencies(manifest, 'development_dependencies', 'runtime')
58
+ end
59
+
60
+ def self.map_dependencies(hash, key, type)
61
+ hash.fetch(key,[]).map do |name, requirement|
62
+ {
63
+ name: name,
64
+ requirement: requirement['version'] || '*',
65
+ type: type
66
+ }
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "0.13.1"
2
+ VERSION = "0.14.0"
3
3
  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.13.1
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
@@ -190,6 +190,7 @@ files:
190
190
  - lib/bibliothecary/parsers/pub.rb
191
191
  - lib/bibliothecary/parsers/pypi.rb
192
192
  - lib/bibliothecary/parsers/rubygems.rb
193
+ - lib/bibliothecary/parsers/shard.rb
193
194
  - lib/bibliothecary/version.rb
194
195
  - lib/cartfile_parser.rb
195
196
  - lib/sdl_parser.rb