prmd 0.11.10 → 0.11.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/prmd.rb +1 -0
- data/lib/prmd/cli/base.rb +4 -4
- data/lib/prmd/cli/generate.rb +6 -1
- data/lib/prmd/templates/schemata/helper.erb +2 -1
- data/lib/prmd/utils.rb +19 -0
- data/lib/prmd/version.rb +1 -1
- data/test/cli/combine_test.rb +1 -1
- data/test/cli/doc_test.rb +1 -1
- data/test/cli/generate_test.rb +1 -1
- data/test/cli/render_test.rb +1 -1
- data/test/cli/verify_test.rb +1 -1
- data/test/commands/combine_test.rb +1 -1
- data/test/commands/init_test.rb +1 -1
- data/test/commands/render_test.rb +14 -14
- data/test/commands/verify_test.rb +1 -1
- data/test/core/reference_localizer_test.rb +1 -1
- data/test/link_test.rb +3 -2
- data/test/multi_loader/common.rb +1 -1
- data/test/multi_loader/json_test.rb +1 -1
- data/test/multi_loader/toml_test.rb +1 -1
- data/test/multi_loader/yajl_test.rb +1 -1
- data/test/multi_loader/yaml_test.rb +1 -1
- data/test/rake_tasks/combine_test.rb +1 -1
- data/test/rake_tasks/doc_test.rb +1 -1
- data/test/rake_tasks/verify_test.rb +1 -1
- data/test/schema_test.rb +1 -1
- data/test/utils_test.rb +16 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 360cb547141b8b6cb7530276cee8937fc3d67eeb
|
4
|
+
data.tar.gz: e5258d2ab83ccf065bed3c366ce915ad3b499f22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05fe9b1d724b0fa2290b1fbd93338eda26819e6bfe2ebaaf27fae5b49a9c8c3fb1eac37377be484280ccf713ac10db897605195337146fe7c8285a2ff066b60a
|
7
|
+
data.tar.gz: 729a5aa7351f1ffd3777194370bb5a6beb59eed6407c00506baa1a0312eccdfd424d679552a91f555935080faf564a754c8305449c1bc1d3c4c42914d2c69dc9
|
data/lib/prmd.rb
CHANGED
@@ -3,6 +3,7 @@ require_relative 'prmd/load_schema_file'
|
|
3
3
|
require_relative 'prmd/commands'
|
4
4
|
require_relative 'prmd/schema'
|
5
5
|
require_relative 'prmd/link'
|
6
|
+
require_relative 'prmd/utils'
|
6
7
|
require_relative 'prmd/template'
|
7
8
|
require_relative 'prmd/url_generator'
|
8
9
|
require_relative 'prmd/hash_helpers'
|
data/lib/prmd/cli/base.rb
CHANGED
@@ -33,8 +33,8 @@ module Prmd
|
|
33
33
|
# @param [Array<String>] argv
|
34
34
|
# @return [Array<String>] remaining arguments
|
35
35
|
# @private
|
36
|
-
def execute_parser(
|
37
|
-
parser.parse(argv)
|
36
|
+
def execute_parser(argv)
|
37
|
+
@parser.parse(argv)
|
38
38
|
end
|
39
39
|
|
40
40
|
# Set the given key and value in the given options Hash.
|
@@ -66,10 +66,10 @@ module Prmd
|
|
66
66
|
# @return [Hash<Symbol, Object>] parsed options
|
67
67
|
def parse_options(argv, options = {})
|
68
68
|
opts = {}
|
69
|
-
parser = make_parser(options) do |key, value|
|
69
|
+
@parser = make_parser(options) do |key, value|
|
70
70
|
set_option(opts, key, value)
|
71
71
|
end
|
72
|
-
argv = execute_parser(
|
72
|
+
argv = execute_parser(argv)
|
73
73
|
opts[:argv] = argv
|
74
74
|
opts
|
75
75
|
end
|
data/lib/prmd/cli/generate.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative 'base'
|
2
2
|
require_relative '../commands/init'
|
3
|
+
require_relative '../utils'
|
3
4
|
|
4
5
|
module Prmd
|
5
6
|
module CLI
|
@@ -40,7 +41,11 @@ module Prmd
|
|
40
41
|
# @return (see Prmd::CLI::Base#execute)
|
41
42
|
def self.execute(options = {})
|
42
43
|
name = options.fetch(:argv).first
|
43
|
-
|
44
|
+
if Prmd::Utils.blank?(name)
|
45
|
+
abort @parser
|
46
|
+
else
|
47
|
+
write_result Prmd.init(name, options), options
|
48
|
+
end
|
44
49
|
end
|
45
50
|
end
|
46
51
|
end
|
@@ -81,7 +81,8 @@
|
|
81
81
|
|
82
82
|
def extract_schemata_refs(schema, properties)
|
83
83
|
ret = []
|
84
|
-
properties.each do |
|
84
|
+
properties.keys.sort.each do |key|
|
85
|
+
value = properties[key]
|
85
86
|
ref, value = schema.dereference(value)
|
86
87
|
if value['properties']
|
87
88
|
refs = extract_schemata_refs(schema, value['properties'])
|
data/lib/prmd/utils.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Prmd
|
2
|
+
# For any tid bits, or core extension methods, without the "core" extension
|
3
|
+
module Utils
|
4
|
+
# For checking if the string contains only spaces
|
5
|
+
BLANK_REGEX = /\A\s+\z/
|
6
|
+
|
7
|
+
def self.blank?(obj)
|
8
|
+
if obj.nil?
|
9
|
+
true
|
10
|
+
elsif obj.is_a?(String)
|
11
|
+
obj.empty? || !!(obj =~ BLANK_REGEX)
|
12
|
+
elsif obj.respond_to?(:empty?)
|
13
|
+
obj.empty?
|
14
|
+
else
|
15
|
+
false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/prmd/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
module Prmd
|
3
3
|
# Well, duh, its a Version module, what did you expect?
|
4
4
|
module Version
|
5
|
-
MAJOR, MINOR, TEENY, PATCH = 0, 11,
|
5
|
+
MAJOR, MINOR, TEENY, PATCH = 0, 11, 11, nil
|
6
6
|
# version string
|
7
7
|
# @return [String]
|
8
8
|
STRING = [MAJOR, MINOR, TEENY, PATCH].compact.join('.').freeze
|
data/test/cli/combine_test.rb
CHANGED
data/test/cli/doc_test.rb
CHANGED
data/test/cli/generate_test.rb
CHANGED
data/test/cli/render_test.rb
CHANGED
data/test/cli/verify_test.rb
CHANGED
data/test/commands/init_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../helpers'
|
2
2
|
|
3
3
|
require 'json_pointer'
|
4
4
|
|
@@ -6,7 +6,7 @@ class InteragentRenderTest < Minitest::Test
|
|
6
6
|
def test_render_for_valid_schema
|
7
7
|
markdown = render
|
8
8
|
|
9
|
-
assert_match
|
9
|
+
assert_match(/An app in our PaaS ecosystem./, markdown)
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_render_for_schema_with_property_defined_with_anyOf
|
@@ -21,15 +21,15 @@ class InteragentRenderTest < Minitest::Test
|
|
21
21
|
}
|
22
22
|
})
|
23
23
|
markdown = render
|
24
|
-
assert_match
|
24
|
+
assert_match(/version.*v10\.9\.rc1/, markdown)
|
25
25
|
end
|
26
26
|
|
27
27
|
|
28
28
|
def test_render_for_schema_with_property_defined_with_oneOf
|
29
29
|
markdown = render
|
30
30
|
|
31
|
-
assert_match
|
32
|
-
assert_match
|
31
|
+
assert_match(/\*\*options\/\[OPTION1\]\.type\*\*/, markdown)
|
32
|
+
assert_match(/\*\*options\/\[OPTION2\]\.type\*\*/, markdown)
|
33
33
|
end
|
34
34
|
|
35
35
|
|
@@ -95,37 +95,37 @@ class InteragentRenderTest < Minitest::Test
|
|
95
95
|
'example' => 'example'
|
96
96
|
},
|
97
97
|
'option-type1' => {
|
98
|
-
'type' => 'string',
|
99
|
-
'example' => 'OPTION1',
|
100
|
-
'enum' => 'OPTION1'
|
98
|
+
'type' => 'string',
|
99
|
+
'example' => 'OPTION1',
|
100
|
+
'enum' => 'OPTION1'
|
101
101
|
},
|
102
102
|
'option-type2' => {
|
103
|
-
'type' => 'string',
|
103
|
+
'type' => 'string',
|
104
104
|
'example' => 'OPTION2',
|
105
105
|
'enum' => 'OPTION2'
|
106
106
|
},
|
107
107
|
'option1' => {
|
108
108
|
'properties' => {
|
109
109
|
'type' => {
|
110
|
-
'$ref' => '#/definitions/config-var/definitions/option-type1'
|
110
|
+
'$ref' => '#/definitions/config-var/definitions/option-type1'
|
111
111
|
}
|
112
112
|
}
|
113
113
|
},
|
114
114
|
'option2' => {
|
115
115
|
'properties' => {
|
116
116
|
'type' => {
|
117
|
-
'$ref' => '#/definitions/config-var/definitions/option-type2'
|
117
|
+
'$ref' => '#/definitions/config-var/definitions/option-type2'
|
118
118
|
}
|
119
119
|
}
|
120
120
|
},
|
121
|
-
'options' => {
|
121
|
+
'options' => {
|
122
122
|
'items' => {
|
123
123
|
'example'=> 'CHOICE1',
|
124
124
|
'oneOf' => [
|
125
|
-
{
|
125
|
+
{
|
126
126
|
'$ref' => '#/definitions/config-var/definitions/option1'
|
127
127
|
},
|
128
|
-
{
|
128
|
+
{
|
129
129
|
'$ref' => '#/definitions/config-var/definitions/option2'
|
130
130
|
}
|
131
131
|
]
|
data/test/link_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
require_relative 'helpers'
|
2
|
+
|
2
3
|
module Prmd
|
3
4
|
class LinkTest < MiniTest::Test
|
4
5
|
include PrmdLinkTestHelpers
|
@@ -22,7 +23,7 @@ module Prmd
|
|
22
23
|
{
|
23
24
|
title: "multiple_nested_required" ,
|
24
25
|
optional: {"user:name" => "string"},
|
25
|
-
required: {"user:email" => "string",
|
26
|
+
required: {"user:email" => "string",
|
26
27
|
"address:street" => "string",
|
27
28
|
"address:zip" => "string"}
|
28
29
|
}
|
data/test/multi_loader/common.rb
CHANGED
data/test/rake_tasks/doc_test.rb
CHANGED
data/test/schema_test.rb
CHANGED
data/test/utils_test.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'helpers'
|
2
|
+
|
3
|
+
class UtilsTest < Minitest::Test
|
4
|
+
def test_blank?
|
5
|
+
assert_equal true, Prmd::Utils.blank?(nil)
|
6
|
+
assert_equal true, Prmd::Utils.blank?([])
|
7
|
+
assert_equal true, Prmd::Utils.blank?({})
|
8
|
+
assert_equal true, Prmd::Utils.blank?("")
|
9
|
+
assert_equal true, Prmd::Utils.blank?(" ")
|
10
|
+
assert_equal true, Prmd::Utils.blank?(" ")
|
11
|
+
assert_equal false, Prmd::Utils.blank?([nil])
|
12
|
+
assert_equal false, Prmd::Utils.blank?({ a: nil })
|
13
|
+
assert_equal false, Prmd::Utils.blank?("A")
|
14
|
+
assert_equal false, Prmd::Utils.blank?(Object.new)
|
15
|
+
end
|
16
|
+
end
|
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.11.
|
4
|
+
version: 0.11.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- geemus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erubis
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- lib/prmd/url_generator.rb
|
153
153
|
- lib/prmd/url_generators/generators/default.rb
|
154
154
|
- lib/prmd/url_generators/generators/json.rb
|
155
|
+
- lib/prmd/utils.rb
|
155
156
|
- lib/prmd/version.rb
|
156
157
|
- prmd.gemspec
|
157
158
|
- schemas/hyper-schema.json
|
@@ -189,6 +190,7 @@ files:
|
|
189
190
|
- test/schemata/input/rake_doc.json
|
190
191
|
- test/schemata/input/rake_verify.json
|
191
192
|
- test/schemata/input/user.json
|
193
|
+
- test/utils_test.rb
|
192
194
|
homepage: https://github.com/heroku/prmd
|
193
195
|
licenses:
|
194
196
|
- MIT
|
@@ -246,3 +248,4 @@ test_files:
|
|
246
248
|
- test/schemata/input/rake_doc.json
|
247
249
|
- test/schemata/input/rake_verify.json
|
248
250
|
- test/schemata/input/user.json
|
251
|
+
- test/utils_test.rb
|