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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4e6a8c0142506698e1bf725a68e5a6c3f0328fa
4
- data.tar.gz: 3690e76c5ed4a6b6c554b4abf7d0c56d122fb6d0
3
+ metadata.gz: 360cb547141b8b6cb7530276cee8937fc3d67eeb
4
+ data.tar.gz: e5258d2ab83ccf065bed3c366ce915ad3b499f22
5
5
  SHA512:
6
- metadata.gz: b379370f8a533d69fa872c1224726eebce304ffc643b03826d451ba252486fca6e287c4db79c8109a0550a8d34f1024d869bc5f9ac33006bf705dd66c9c382d7
7
- data.tar.gz: 83d8bde56db5cbe2c6de78c6eefe368b992e91d04d9d5c852608d490db27b34c93d0e2eef111acab684c7ec7aaa19c48c97f1740cb9f5bf4828643c9b4e6b250
6
+ metadata.gz: 05fe9b1d724b0fa2290b1fbd93338eda26819e6bfe2ebaaf27fae5b49a9c8c3fb1eac37377be484280ccf713ac10db897605195337146fe7c8285a2ff066b60a
7
+ data.tar.gz: 729a5aa7351f1ffd3777194370bb5a6beb59eed6407c00506baa1a0312eccdfd424d679552a91f555935080faf564a754c8305449c1bc1d3c4c42914d2c69dc9
@@ -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'
@@ -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(parser, argv)
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(parser, argv)
72
+ argv = execute_parser(argv)
73
73
  opts[:argv] = argv
74
74
  opts
75
75
  end
@@ -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
- write_result Prmd.init(name, options), options
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 |_, value|
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'])
@@ -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
@@ -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, 10, nil
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
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helpers'))
1
+ require_relative '../helpers'
2
2
  require 'prmd/cli/combine'
3
3
 
4
4
  class PrmdCliCombineTest < Minitest::Test
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helpers'))
1
+ require_relative '../helpers'
2
2
  require 'prmd/cli/doc'
3
3
 
4
4
  class PrmdCliDocTest < Minitest::Test
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helpers'))
1
+ require_relative '../helpers'
2
2
  require 'prmd/cli/generate'
3
3
 
4
4
  class PrmdCliGenerateTest < Minitest::Test
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helpers'))
1
+ require_relative '../helpers'
2
2
  require 'prmd/cli/render'
3
3
 
4
4
  class PrmdCliRenderTest < Minitest::Test
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helpers'))
1
+ require_relative '../helpers'
2
2
  require 'prmd/cli/verify'
3
3
 
4
4
  class PrmdCliVerifyTest < Minitest::Test
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helpers'))
1
+ require_relative '../helpers'
2
2
 
3
3
  require 'json_pointer'
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helpers'))
1
+ require_relative '../helpers'
2
2
 
3
3
  class PrmdInitTest < Minitest::Test
4
4
  def test_init
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helpers'))
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 /An app in our PaaS ecosystem./, markdown
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 /version.*v10\.9\.rc1/, markdown
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 /\*\*options\/\[OPTION1\]\.type\*\*/, markdown
32
- assert_match /\*\*options\/\[OPTION2\]\.type\*\*/, markdown
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
  ]
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helpers'))
1
+ require_relative '../helpers'
2
2
 
3
3
  require 'json_pointer'
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path('../helpers', File.dirname(__FILE__))
1
+ require_relative '../helpers'
2
2
 
3
3
  module Prmd
4
4
  class ReferenceLocalizerTest < Minitest::Test
@@ -1,4 +1,5 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '.', 'helpers'))
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
  }
@@ -1,4 +1,4 @@
1
- require File.expand_path('../helpers', File.dirname(__FILE__))
1
+ require_relative '../helpers'
2
2
 
3
3
  module PrmdLoaderTests
4
4
  # @abstrac
@@ -1,4 +1,4 @@
1
- require File.expand_path('common', File.dirname(__FILE__))
1
+ require_relative 'common'
2
2
  require 'prmd/multi_loader/json'
3
3
 
4
4
  class PrmdMultiLoaderJsonTest < Minitest::Test
@@ -1,4 +1,4 @@
1
- require File.expand_path('common', File.dirname(__FILE__))
1
+ require_relative 'common'
2
2
  begin
3
3
  require 'prmd/multi_loader/toml'
4
4
  rescue LoadError
@@ -1,4 +1,4 @@
1
- require File.expand_path('common', File.dirname(__FILE__))
1
+ require_relative 'common'
2
2
  begin
3
3
  require 'prmd/multi_loader/yajl'
4
4
  rescue LoadError
@@ -1,4 +1,4 @@
1
- require File.expand_path('common', File.dirname(__FILE__))
1
+ require_relative 'common'
2
2
  require 'prmd/multi_loader/yaml'
3
3
 
4
4
  class PrmdMultiLoaderYamlTest < Minitest::Test
@@ -1,4 +1,4 @@
1
- require File.expand_path('../helpers', File.dirname(__FILE__))
1
+ require_relative '../helpers'
2
2
  require 'prmd/rake_tasks/combine'
3
3
  require 'rake'
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path('../helpers', File.dirname(__FILE__))
1
+ require_relative '../helpers'
2
2
  require 'prmd/rake_tasks/doc'
3
3
  require 'rake'
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path('../helpers', File.dirname(__FILE__))
1
+ require_relative '../helpers'
2
2
  require 'prmd/rake_tasks/verify'
3
3
  require 'rake'
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helpers'))
1
+ require_relative 'helpers'
2
2
 
3
3
  class SchemaTest < Minitest::Test
4
4
  def test_dereference_with_ref
@@ -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.10
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-16 00:00:00.000000000 Z
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