bibliothecary 0.12.0 → 0.13.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: 614edadd0894b35bb2599ea0bef84078df87b201
4
- data.tar.gz: 9d837c4936dea64fa206b4de605bc31e2b814936
3
+ metadata.gz: ec3cbad7997b779286b5fbe64cef309126f1850b
4
+ data.tar.gz: fbded52f25368308e345f61896bac20171a0213f
5
5
  SHA512:
6
- metadata.gz: acf798c3417d77018ea09bf7abe60a479ef5dd08aab70b343a6c7d4196254f779f37ba83be03090dc6148a2c8b5442d5b13fe385f08c93284aad2caff9648ba6
7
- data.tar.gz: 5cc623960af7395951a333c09f6c20a38be1a1ef399d0c16afd94865c90e601774a53a393c19626a40452c22ea92a66cab1cf57fac8dfb972241f49523ba5439
6
+ metadata.gz: 6ec15897f011e54553f272408f97c51bb65ce37c9014bc4d9c8aced87a07dee60fca06e60a9453e03d489377f8b129ef4946dabcb8172c440aa699bd9710517c
7
+ data.tar.gz: acc374351eb5315f14062a5712bdd8dde3a4642d4e14c9bbef8b4984d09369ef99b5511cffcb4b49a3f7d9067ded7267c1904bbc23d0b239c923a1ca57a7a91b
@@ -1,3 +1,76 @@
1
- # elm-package.json
2
- # elm_dependencies.json
3
- # elm-stuff/exact-dependencies.json
1
+ require 'json'
2
+
3
+ module Bibliothecary
4
+ module Parsers
5
+ class Elm
6
+ PLATFORM_NAME = 'elm'
7
+
8
+ def self.parse(filename, file_contents)
9
+ if filename.match(/^elm-package\.json$|^elm_dependencies\.json$/)
10
+ json = JSON.parse file_contents
11
+ parse_json_manifest(json)
12
+ elsif filename.match(/^elm-stuff\/exact-dependencies\.json$/)
13
+ json = JSON.parse file_contents
14
+ parse_json_lock(json)
15
+ else
16
+ []
17
+ end
18
+ end
19
+
20
+ def self.analyse(folder_path, file_list)
21
+ [analyse_json(folder_path, file_list),
22
+ analyse_json_lock(folder_path, file_list)]
23
+ end
24
+
25
+ def self.analyse_json(folder_path, file_list)
26
+ path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^elm-package\.json$|^elm_dependencies\.json$/) }
27
+ return unless path
28
+
29
+ manifest = JSON.parse File.open(path).read
30
+
31
+ {
32
+ platform: PLATFORM_NAME,
33
+ path: path,
34
+ dependencies: parse_json_manifest(manifest)
35
+ }
36
+ end
37
+
38
+ def self.analyse_json_lock(folder_path, file_list)
39
+ path = file_list.find{|path| path.gsub(folder_path, '').gsub(/^\//, '').match(/^elm-stuff\/exact-dependencies\.json$/) }
40
+ return unless path
41
+
42
+ manifest = JSON.parse File.open(path).read
43
+
44
+ {
45
+ platform: PLATFORM_NAME,
46
+ path: path,
47
+ dependencies: parse_json_lock(manifest)
48
+ }
49
+ end
50
+
51
+ def self.parse_json_manifest(manifest)
52
+ map_dependencies(manifest, 'dependencies', 'runtime')
53
+ end
54
+
55
+ def self.parse_json_lock(manifest)
56
+ manifest.map do |name, requirement|
57
+ {
58
+ name: name,
59
+ requirement: requirement,
60
+ type: 'runtime'
61
+ }
62
+ end
63
+ end
64
+
65
+ def self.map_dependencies(hash, key, type)
66
+ hash.fetch(key,[]).map do |name, requirement|
67
+ {
68
+ name: name,
69
+ requirement: requirement,
70
+ type: type
71
+ }
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "0.12.0"
2
+ VERSION = "0.13.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.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt