prmd 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CONTRIBUTORS.md +1 -0
- data/Gemfile.lock +1 -1
- data/bin/prmd +3 -0
- data/lib/prmd.rb +1 -0
- data/lib/prmd/commands/combine.rb +15 -4
- data/lib/prmd/commands/init.rb +5 -1
- data/lib/prmd/schema.rb +9 -1
- data/lib/prmd/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGFhZTI3Yjc0OTA3ZWI5Mzc4NzBlNWQzMWY4YmQ5ZmRmNjAzZGIwMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTZlMzFjMDhjMWYyYmRlM2YxZjIyNjNkZjRjOWI0NmZkNDk4ZmU1MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDM1ZTE1MTI1YWNiMDMzZmQ4YmRhYzQ0MDI4Nzc4ZmI1ODM3NTUyODEzYjZm
|
10
|
+
YTY5NGU3Mjk1ZmVhZDQ3Mjg2OTMwZjA2NmRlYzc3OTNkNWEyOWZjYTM4NzI2
|
11
|
+
OWU5OTZjMTU4ZmNiYzUyMTg5NmE4NGM0MTgyN2QxMzFiNzEyMDY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjI0ZWJjOTRjNTA5YTM4MzI4NzI0ZDc2ZTYyZDQyNzRlYmM2MzIwOWQ2MDMy
|
14
|
+
NWVlYmExZDNhNTJiMDkxYmU5ZmRiNzRiZGNhYjA1NDUwZjcwOGQ0NDhhZmY0
|
15
|
+
Yjg4MDMwYmFlOWJkMDY0ZDljOTdiMWRhY2Q0NzA4ZmQ3YWFkMDU=
|
data/CONTRIBUTORS.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
* Brandur <brandur@mutelight.org>
|
2
2
|
* Chris Continanza <christopher.continanza@gmail.com>
|
3
3
|
* Dane Harrigan <dane.harrigan@gmail.com>
|
4
|
+
* Kousuke Ebihara <kousuke@co3k.org>
|
4
5
|
* Mark McGranaghan <mmcgrana@gmail.com>
|
5
6
|
* Olivier Lance <olance@users.noreply.github.com>
|
6
7
|
* Timothée Peignier <timothee.peignier@tryphon.org>
|
data/Gemfile.lock
CHANGED
data/bin/prmd
CHANGED
@@ -19,6 +19,9 @@ commands = {
|
|
19
19
|
end,
|
20
20
|
init: OptionParser.new do |opts|
|
21
21
|
opts.banner = "prmd init [options] <resource name>"
|
22
|
+
opts.on("-y", "--yaml", "Generate YAML") do |y|
|
23
|
+
options[:yaml] = y
|
24
|
+
end
|
22
25
|
end,
|
23
26
|
verify: OptionParser.new do |opts|
|
24
27
|
opts.banner = "prmd verify [options] <combined schema>"
|
data/lib/prmd.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
module Prmd
|
2
2
|
def self.combine(path, options={})
|
3
3
|
files = if File.directory?(path)
|
4
|
-
Dir.glob(File.join(path, '**', '*.json'))
|
4
|
+
Dir.glob(File.join(path, '**', '*.json')) +
|
5
|
+
Dir.glob(File.join(path, '**', '*.yaml')) -
|
6
|
+
[options[:meta]]
|
5
7
|
else
|
6
8
|
[path]
|
7
9
|
end
|
8
|
-
|
10
|
+
# sort for stable loading on any platform
|
11
|
+
schemas = files.sort.map { |file| [file, YAML.load(File.read(file))] }
|
9
12
|
|
10
13
|
data = {
|
11
14
|
'$schema' => 'http://json-schema.org/draft-04/hyper-schema',
|
@@ -14,16 +17,24 @@ module Prmd
|
|
14
17
|
'type' => ['object']
|
15
18
|
}
|
16
19
|
|
20
|
+
# tracks which entities where defined in which file
|
21
|
+
definitions_map = {}
|
22
|
+
|
17
23
|
if options[:meta] && File.exists?(options[:meta])
|
18
|
-
data.merge!(
|
24
|
+
data.merge!(YAML.load(File.read(options[:meta])))
|
19
25
|
end
|
20
26
|
|
21
|
-
schemas.each do |schema_data|
|
27
|
+
schemas.each do |schema_file, schema_data|
|
22
28
|
id = if schema_data['id']
|
23
29
|
schema_data['id'].split('/').last
|
24
30
|
end
|
25
31
|
next if id.nil? || id[0..0] == '_' # FIXME: remove this exception?
|
26
32
|
|
33
|
+
if file = definitions_map[id]
|
34
|
+
$stderr.puts "`#{id}` (from #{schema_file}) was already defined in `#{file}` and will overwrite the first definition"
|
35
|
+
end
|
36
|
+
definitions_map[id] = schema_file
|
37
|
+
|
27
38
|
data['definitions'][id] = schema_data
|
28
39
|
reference_localizer = lambda do |datum|
|
29
40
|
case datum
|
data/lib/prmd/commands/init.rb
CHANGED
data/lib/prmd/schema.rb
CHANGED
@@ -55,12 +55,20 @@ module Prmd
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
58
|
+
def to_json
|
59
59
|
new_json = JSON.pretty_generate(@data)
|
60
60
|
# nuke empty lines
|
61
61
|
new_json = new_json.split("\n").delete_if {|line| line.empty?}.join("\n") + "\n"
|
62
62
|
new_json
|
63
63
|
end
|
64
64
|
|
65
|
+
def to_yaml
|
66
|
+
YAML.dump(@data)
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_s
|
70
|
+
to_json
|
71
|
+
end
|
72
|
+
|
65
73
|
end
|
66
74
|
end
|
data/lib/prmd/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prmd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- geemus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erubis
|