bump-cli 0.6.1 → 0.7.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
  SHA256:
3
- metadata.gz: 165f19120b51a189b1f7428e00901fed5ea5b91bfb5f21bc2f9fe983adc3cc31
4
- data.tar.gz: 724ec534aff1c7d264b185ca8c9d6bf46db552d8149d39fe2a2cf3c2185a341d
3
+ metadata.gz: 00d797137b0dae0f38a0a9106badd11c90ffacd37648eb7d2bdcdc4370e0e2b0
4
+ data.tar.gz: 1cd3d2d72d423284a9a0ffc3c0f86fd577b2ece23acf68f0fa36e43896aae730
5
5
  SHA512:
6
- metadata.gz: 5a5df45b5a14cb7e79063504ce1a5dc5e5342088840de2dcf6eca79928712b46115ed590765e4a516c497e461eb12cdeaa65ce052f217decfb5eb5e9075bfc7a
7
- data.tar.gz: 3c3ab329ab7c5bd4d0bada3147cd4fdb8c61131fcc32efb3e980811e48bdecef868d1d99823e099b7b612b4b18755c1b7706cc71adb129e717dc2ddfa265e43c
6
+ metadata.gz: 0e2a0eaa1fb62b4f9b7b5f88883e8f00ded7653467d80f3776a8aadf6f0190e32fdb620acc3e8568e30be88fa4e7f5370ec7e777137ecda72cc7e77a6cdd5576
7
+ data.tar.gz: c3f88a2d70ff4f893a13b985beb3f8198f349a02fed67f93e7949527867acc9655409a586db8f13a364b145b467c70d5cede4c4f74e3aa42b92c558140afc5a5
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: CLI runtime error
3
+ about: Create a report of an exception happening when running a CLI command
4
+ title: "[ERROR MESSAGE]"
5
+ labels: ""
6
+ assignees: ""
7
+ ---
8
+
9
+ **Describe the bug**
10
+ A clear and concise description of what the bug is.
11
+
12
+ **Command**
13
+ Paste here the exact command executed (with arguments and options) which led to the bug.
14
+
15
+ **Stack trace**
16
+ Paste here the stack trace displayed by the CLI, if available.
17
+
18
+ **Screenshots**
19
+ If applicable, add screenshots to help explain your problem.
20
+
21
+ **Desktop (please complete the following information):**
22
+ - OS: [e.g. macOS Catalina 10.15.7]
23
+ - Ruby version [e.g. 2.7]
24
+
25
+ **Additional context**
26
+ Add any other context about the problem here. If publishable, do not hesitate to join the specification you were trying to deploy/preview on Bump.
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in bump-cli.gemspec
6
6
  gemspec
data/README.md CHANGED
@@ -29,7 +29,10 @@ Bump tries to identify your file specification and format automatically. You can
29
29
  * `asyncapi/v2/json`
30
30
  * `asyncapi/v2/yaml`
31
31
 
32
- `doc` and `token` options used below can be found in your documentation settings page on https://bump.sh. Note that you can replace the token option by an environment variable, to keep it secret: `--token` can by replaced by `BUMP_TOKEN`.
32
+ Both the `--doc` and `--token` options used below can be found in your documentation settings page on https://bump.sh. Note that you can replace both the `--doc` and `--token` option by an environment variable. This will help to keep those values secret:
33
+
34
+ - `--doc` can by replaced by `BUMP_ID`.
35
+ - `--token` can by replaced by `BUMP_TOKEN`.
33
36
 
34
37
  ### Preview
35
38
 
data/bump-cli.gemspec CHANGED
@@ -1,38 +1,38 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "bump/cli/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "bump-cli"
8
- spec.version = Bump::CLI::VERSION
9
- spec.authors = ["Mehdi Lahmam", "Sébastien Charrier"]
10
- spec.email = ["mehdi@lahmam.com", "sebastien@bump.sh"]
6
+ spec.name = "bump-cli"
7
+ spec.version = Bump::CLI::VERSION
8
+ spec.authors = ["Mehdi Lahmam", "Sébastien Charrier"]
9
+ spec.email = ["mehdi@lahmam.com", "sebastien@bump.sh"]
11
10
 
12
- spec.summary = %q{Bump.sh CLI}
13
- spec.description = %q{Bump.sh CLI to interact with the API}
14
- spec.homepage = "https://bump.sh"
15
- spec.license = "MIT"
11
+ spec.summary = "Bump.sh CLI"
12
+ spec.description = "Bump.sh CLI to interact with the API"
13
+ spec.homepage = "https://bump.sh"
14
+ spec.license = "MIT"
16
15
 
17
16
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
- spec.metadata["source_code_uri"] = "https://github.com/bump-sh/bump-cli"
17
+ spec.metadata["source_code_uri"] = "https://github.com/bump-sh/bump-cli"
19
18
 
20
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
20
  f.match(%r{^(test|spec|features)/})
22
21
  end
23
- spec.bindir = "exe"
24
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
24
  spec.require_paths = ["lib"]
26
25
 
27
- spec.required_ruby_version = '>= 2.3'
26
+ spec.required_ruby_version = ">= 2.3"
28
27
 
29
- spec.add_dependency "dry-cli", '~> 0'
30
- spec.add_dependency "http", '>= 3'
28
+ spec.add_dependency "dry-cli", "~> 0"
29
+ spec.add_dependency "http", ">= 3"
31
30
 
32
31
  spec.add_development_dependency "bundler", ">= 1", "< 3"
33
32
  spec.add_development_dependency "byebug", "~> 11"
34
- spec.add_development_dependency "climate_control", '~> 0'
33
+ spec.add_development_dependency "climate_control", "~> 0"
35
34
  spec.add_development_dependency "rake", "~> 13"
36
35
  spec.add_development_dependency "rspec", "~> 3"
36
+ spec.add_development_dependency "standard"
37
37
  spec.add_development_dependency "webmock", "~> 3"
38
38
  end
@@ -1,5 +1,5 @@
1
- require 'bump/cli/definition'
2
- require 'bump/cli/uuid'
1
+ require "bump/cli/definition"
2
+ require "bump/cli/uuid"
3
3
 
4
4
  module Bump
5
5
  class CLI
@@ -18,9 +18,13 @@ module Bump
18
18
  def body(file, **options)
19
19
  deprecation_warning(options)
20
20
 
21
+ definition = Definition.new(file, import_external_references: !options[:'no-external-references'])
22
+ definition.prepare!
23
+
21
24
  compact(
22
25
  {
23
- definition: prepare_file(file, options),
26
+ definition: definition.content,
27
+ references: prepare_references(definition.external_references),
24
28
  specification: options[:specification],
25
29
  validation: options[:validation],
26
30
  auto_create_documentation: options[:'auto-create']
@@ -28,20 +32,18 @@ module Bump
28
32
  )
29
33
  end
30
34
 
31
- def prepare_file(file, options)
32
- Definition.new(file, import_external_references: options[:'import-external-references']).prepare
35
+ def prepare_references(references)
36
+ references.reduce([]) { |references, (location, content)|
37
+ references << {location: location, content: content}
38
+ }
33
39
  end
34
40
 
35
41
  def deprecation_warning(options)
36
- if present?(options[:id])
37
- puts "[DEPRECATION WARNING] --id option is deprecated. Please use --doc instead."
42
+ if options[:"import-external-references"]
43
+ puts "[DEPRECATION WARNING] --import-external-references option is deprecated. External references are imported by default."
38
44
  end
39
45
  end
40
46
 
41
- def present?(string)
42
- !string.nil? && string != ''
43
- end
44
-
45
47
  def compact(hash)
46
48
  hash.delete_if { |key, value| value.nil? }
47
49
  end
@@ -79,16 +81,24 @@ module Bump
79
81
  yield
80
82
  rescue HTTP::Error, Errno::ENOENT, SocketError => error
81
83
  abort "Error: #{error.message}"
84
+ rescue => error
85
+ warn "An unexpected error occurred. Sorry about that!"
86
+ warn "We don't monitor errors raised by the CLI running on your computer, so we have not been notified."
87
+ warn "You can help us fix this by creating an issue on https://github.com/bump-sh/bump-cli/issues/new?template=cli-runtime-error.md."
88
+ warn "\n"
89
+ warn "#{error.class}: #{error.message}"
90
+ warn error.backtrace.take(10).join("\n")
91
+ exit(1)
82
92
  end
83
93
 
84
- def headers(token: '')
94
+ def headers(token: "")
85
95
  headers = {
86
- 'Content-Type' => 'application/json',
87
- 'User-Agent' => USER_AGENT
96
+ "Content-Type" => "application/json",
97
+ "User-Agent" => USER_AGENT
88
98
  }
89
99
 
90
100
  if token
91
- headers['Authorization'] = "Basic #{Base64.strict_encode64(token + ':')}"
101
+ headers["Authorization"] = "Basic #{Base64.strict_encode64(token + ":")}"
92
102
  end
93
103
 
94
104
  headers
@@ -109,9 +119,9 @@ module Bump
109
119
  end
110
120
 
111
121
  def display_validation_errors(body)
112
- errors = body.dig('errors') || []
122
+ errors = body.dig("errors") || []
113
123
 
114
- $stderr.puts "Invalid request:"
124
+ warn "Invalid request:"
115
125
  errors.each do |attribute, messages|
116
126
  display_attribute_errors(attribute, messages)
117
127
  end
@@ -120,15 +130,14 @@ module Bump
120
130
  end
121
131
 
122
132
  def display_attribute_errors(attribute, messages)
123
- case
124
- when messages.is_a?(String)
125
- $stderr.puts "- #{attribute}: #{messages}"
126
- when messages.is_a?(Array) && messages.count == 1
127
- $stderr.puts "- #{attribute}: #{messages[0]}"
128
- when messages.is_a?(Array)
129
- $stderr.puts "- #{attribute}:"
133
+ if messages.is_a?(String)
134
+ warn "- #{attribute}: #{messages}"
135
+ elsif messages.is_a?(Array) && messages.count == 1
136
+ warn "- #{attribute}: #{messages[0]}"
137
+ elsif messages.is_a?(Array)
138
+ warn "- #{attribute}:"
130
139
  messages.each do |message|
131
- $stderr.puts " #{message}"
140
+ warn " #{message}"
132
141
  end
133
142
  end
134
143
  end
@@ -1,4 +1,4 @@
1
- require 'base64'
1
+ require "base64"
2
2
 
3
3
  module Bump
4
4
  class CLI
@@ -6,15 +6,15 @@ module Bump
6
6
  class Deploy < Base
7
7
  desc "Create a new version"
8
8
  argument :file, required: true, desc: "Path or URL to your API documentation file. OpenAPI (2.0 to 3.0.2) and AsyncAPI (2.0) specifications are currently supported."
9
- option :id, default: ENV.fetch("BUMP_ID", ""), desc: "[DEPRECATED] Documentation id. Use `documentation` option instead"
10
9
  option :doc, default: ENV.fetch("BUMP_ID", ""), desc: "Documentation id or slug"
11
10
  option :'doc-name', desc: "Documentation name. Used with --auto-create flag."
12
11
  option :hub, default: ENV.fetch("BUMP_HUB_ID", ""), desc: "Hub id or slug"
13
12
  option :token, default: ENV.fetch("BUMP_TOKEN", ""), desc: "Documentation or Hub token"
14
13
  option :specification, desc: "Specification of the definition"
15
- option :validation, desc: "Validation mode", values: %w(basic strict), default: 'basic'
16
- option :'auto-create', type: :boolean, default: false, desc: 'Automatically create the documentation if needed (only available with a hub and when specifying a slug for documentation)'
17
- option :'import-external-references', type: :boolean, default: false, desc: 'Import external $refs (URI or file system) into the specification before sending it to Bump servers'
14
+ option :validation, desc: "Validation mode", values: %w[basic strict], default: "basic"
15
+ option :'auto-create', type: :boolean, default: false, desc: "Automatically create the documentation if needed (only available with a hub and when specifying a slug for documentation)"
16
+ option :'no-external-references', type: :boolean, default: false, desc: "Do not import external references ($ref)"
17
+ option :'import-external-references', type: :boolean, default: false, desc: "[DEPRECATED] External references are imported by default"
18
18
 
19
19
  def call(file:, **options)
20
20
  with_errors_rescued do
@@ -5,8 +5,9 @@ module Bump
5
5
  desc "Create a documentation preview for the given file"
6
6
  argument :file, required: true, desc: "Path or URL to your API documentation file. OpenAPI (2.0 to 3.0.2) and AsyncAPI (2.0) specifications are currently supported."
7
7
  option :specification, desc: "Specification of the definition"
8
- option :validation, desc: "Validation mode", values: %w(basic strict), default: 'basic'
9
- option :'import-external-references', type: :boolean, default: false, desc: 'Import external $refs (URI or file system) into the specification before sending it to Bump servers'
8
+ option :validation, desc: "Validation mode", values: %w[basic strict], default: "basic"
9
+ option :'no-external-references', type: :boolean, default: false, desc: "Do not import external references ($ref)"
10
+ option :'import-external-references', type: :boolean, default: false, desc: "[DEPRECATED] External references are imported by default"
10
11
 
11
12
  def call(file:, **options)
12
13
  with_errors_rescued do
@@ -17,7 +18,7 @@ module Bump
17
18
 
18
19
  if response.code == 201
19
20
  body = JSON.parse(response.body)
20
- puts "Preview created : #{ROOT_URL + '/preview/' + body['id']} (expires at #{body['expires_at']})"
21
+ puts "Preview created : #{ROOT_URL + "/preview/" + body["id"]} (expires at #{body["expires_at"]})"
21
22
  else
22
23
  display_error(response)
23
24
  end
@@ -1,4 +1,4 @@
1
- require 'base64'
1
+ require "base64"
2
2
 
3
3
  module Bump
4
4
  class CLI
@@ -6,15 +6,15 @@ module Bump
6
6
  class Validate < Base
7
7
  desc "Validate a given file against its schema definition"
8
8
  argument :file, required: true, desc: "Path or URL to your API documentation file. OpenAPI (2.0 to 3.0.2) and AsyncAPI (2.0) specifications are currently supported."
9
- option :id, default: ENV.fetch("BUMP_ID", ""), desc: "[DEPRECATED] Documentation id. Use `documentation` option instead"
10
9
  option :doc, default: ENV.fetch("BUMP_ID", ""), desc: "Documentation public id or slug"
11
10
  option :'doc-name', desc: "Documentation name. Used with --auto-create flag."
12
11
  option :hub, desc: "Hub id or slug"
13
12
  option :token, default: ENV.fetch("BUMP_TOKEN", ""), desc: "Documentation or Hub token"
14
13
  option :specification, desc: "Specification of the definition"
15
- option :validation, desc: "Validation mode", values: %w(basic strict), default: 'basic'
16
- option :'auto-create', type: :boolean, default: false, desc: 'Automatically create the documentation if needed (only available with a hub and when specifying a slug for documentation)'
17
- option :'import-external-references', type: :boolean, default: false, desc: 'Import external $refs (URI or file system) into the specification before sending it to Bump servers'
14
+ option :validation, desc: "Validation mode", values: %w[basic strict], default: "basic"
15
+ option :'auto-create', type: :boolean, default: false, desc: "Automatically create the documentation if needed (only available with a hub and when specifying a slug for documentation)"
16
+ option :'no-external-references', type: :boolean, default: false, desc: "Do not import external references ($ref)"
17
+ option :'import-external-references', type: :boolean, default: false, desc: "[DEPRECATED] External references are imported by default"
18
18
 
19
19
  def call(file:, **options)
20
20
  with_errors_rescued do
@@ -1,20 +1,22 @@
1
- require 'open-uri'
2
- require 'bump/cli/parser'
3
- require 'bump/cli/references'
1
+ require "bump/cli/references"
2
+ require "bump/cli/resource"
4
3
 
5
4
  module Bump
6
5
  class CLI
7
6
  class Definition
7
+ attr_reader :content, :external_references
8
+
8
9
  def initialize(path, import_external_references: false)
9
10
  @path = path
10
11
  @import_external_references = import_external_references
12
+ @external_references = References.new(root_path: find_base_path(path))
11
13
  end
12
14
 
13
- def prepare
14
- if !import_external_references
15
- read_file
16
- else
17
- parse_file_and_import_external_references
15
+ def prepare!
16
+ @content = Resource.read(path)
17
+
18
+ if import_external_references
19
+ external_references.load(Resource.parse(content))
18
20
  end
19
21
  end
20
22
 
@@ -22,21 +24,8 @@ module Bump
22
24
 
23
25
  attr_reader :path, :import_external_references
24
26
 
25
- def read_file
26
- open(path).read
27
- end
28
-
29
- def parse_file_and_import_external_references
30
- original_format, definition = parser.load(read_file)
31
-
32
- references = References.new(definition, base_path: path)
33
- references.import!
34
-
35
- parser.dump(references.definition, original_format)
36
- end
37
-
38
- def parser
39
- @parser ||= Parser.new
27
+ def find_base_path(path)
28
+ Pathname.new(path.to_s).dirname.to_s + Pathname::SEPARATOR_LIST
40
29
  end
41
30
  end
42
31
  end
@@ -1,91 +1,67 @@
1
- require 'open-uri'
2
- require 'pathname'
1
+ require "open-uri"
2
+ require "pathname"
3
3
 
4
4
  module Bump
5
5
  class CLI
6
- class References
7
- attr_reader :definition
8
-
9
- def initialize(definition, base_path: '')
10
- @definition = definition
11
- @base_path = cleanup(base_path)
12
- @processed = false
13
- @external_references = {}
6
+ class References < Hash
7
+ def initialize(root_path: "")
8
+ @root_path = root_path
14
9
  end
15
10
 
16
- def import!
17
- if !processed
18
- @definition = traverse_and_replace_external_references(definition)
19
- import_references
20
- @processed = true
21
- end
11
+ def load(definition)
12
+ traverse_and_load_external_references(definition) if definition.is_a?(Enumerable)
22
13
  end
23
14
 
24
15
  private
25
16
 
26
- attr_reader :base_path, :processed, :external_references
17
+ attr_reader :root_path
27
18
 
28
- def traverse_and_replace_external_references(current)
19
+ def traverse_and_load_external_references(current)
29
20
  current.each do |key, value|
30
- if key == '$ref'
31
- current[key] = replace_external_reference(value)
21
+ if key == "$ref"
22
+ load_external_reference(value) if external?(value)
32
23
  elsif value.is_a?(Hash)
33
- traverse_and_replace_external_references(value)
24
+ traverse_and_load_external_references(value)
34
25
  elsif value.is_a?(Array)
35
26
  value.each do |array_value|
36
- traverse_and_replace_external_references(array_value)
27
+ if array_value.is_a?(Hash)
28
+ traverse_and_load_external_references(array_value)
29
+ end
37
30
  end
38
31
  end
39
32
  end
40
33
  end
41
34
 
42
- def replace_external_reference(reference)
43
- if external?(reference)
44
- if external_references[reference].nil?
45
- @external_references[reference] = "#{external_references.count + 1}"
46
- end
47
-
48
- subpath = reference[/#(.*)$/, 1]
49
- "#/components/x-imported/#{external_references[reference]}#{ '/' + subpath if !subpath.nil? }"
50
- else
51
- reference
35
+ def load_external_reference(reference)
36
+ if self[reference].nil?
37
+ base_reference = cleanup_reference(reference)
38
+ location = prepare_location(base_reference)
39
+ self[base_reference] = Resource.read(location)
52
40
  end
53
41
  end
54
42
 
55
- def import_references
56
- if external_references.count > 0
57
- @definition['components'] = {} if @definition['components'].nil?
58
- @definition['components']['x-imported'] = {} if @definition['components']['x-imported'].nil?
59
-
60
- external_references.each do |key, value|
61
- _, @definition['components']['x-imported'][value.to_s] = Parser.new.load(open(prepare_path(key)).read)
62
- end
63
- end
43
+ def cleanup_reference(reference)
44
+ reference.sub(/#.*/, "")
64
45
  end
65
46
 
66
- def prepare_path(key)
67
- key = key.sub(/#.*/, '')
68
- if url?(key) || absolute_path?(key)
69
- key
47
+ def prepare_location(reference)
48
+ if url?(reference) || absolute_path?(reference)
49
+ reference
70
50
  else
71
- base_path + key
51
+ root_path + reference
72
52
  end
73
53
  end
74
54
 
75
55
  def external?(reference)
76
- !reference.start_with?('#')
56
+ !reference.start_with?("#")
77
57
  end
78
58
 
79
59
  def url?(path)
80
- path.start_with?('http')
60
+ path.start_with?("http")
81
61
  end
82
62
 
83
63
  def absolute_path?(path)
84
- path.start_with?('/')
85
- end
86
-
87
- def cleanup(path)
88
- Pathname.new(path).dirname.to_s + Pathname::SEPARATOR_LIST
64
+ path.start_with?("/")
89
65
  end
90
66
  end
91
67
  end
@@ -0,0 +1,26 @@
1
+ require "json"
2
+ require "yaml"
3
+
4
+ module Bump
5
+ class CLI
6
+ class Resource
7
+ def self.read(location)
8
+ if location.start_with?("http")
9
+ ::HTTP.get(location).to_s
10
+ else
11
+ ::File.read(location).force_encoding(Encoding::UTF_8)
12
+ end
13
+ end
14
+
15
+ def self.parse(content)
16
+ ::JSON.parse(content)
17
+ rescue ::JSON::ParserError
18
+ begin
19
+ ::YAML.safe_load(content, [Date, Time])
20
+ rescue ::Psych::SyntaxError
21
+ content
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  module Bump
2
2
  class CLI
3
- VERSION = "0.6.1"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bump-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehdi Lahmam
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-10-09 00:00:00.000000000 Z
12
+ date: 2021-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-cli
@@ -115,6 +115,20 @@ dependencies:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '3'
118
+ - !ruby/object:Gem::Dependency
119
+ name: standard
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
118
132
  - !ruby/object:Gem::Dependency
119
133
  name: webmock
120
134
  requirement: !ruby/object:Gem::Requirement
@@ -139,6 +153,7 @@ extensions: []
139
153
  extra_rdoc_files: []
140
154
  files:
141
155
  - ".circleci/config.yml"
156
+ - ".github/ISSUE_TEMPLATE/cli-runtime-error.md"
142
157
  - ".gitignore"
143
158
  - ".travis.yml"
144
159
  - CODE_OF_CONDUCT.md
@@ -156,8 +171,8 @@ files:
156
171
  - lib/bump/cli/commands/preview.rb
157
172
  - lib/bump/cli/commands/validate.rb
158
173
  - lib/bump/cli/definition.rb
159
- - lib/bump/cli/parser.rb
160
174
  - lib/bump/cli/references.rb
175
+ - lib/bump/cli/resource.rb
161
176
  - lib/bump/cli/uuid.rb
162
177
  - lib/bump/cli/version.rb
163
178
  homepage: https://bump.sh
@@ -1,26 +0,0 @@
1
- require 'json'
2
- require 'yaml'
3
-
4
- module Bump
5
- class CLI
6
- class Parser
7
- def load(content)
8
- [:json, ::JSON.parse(content)]
9
- rescue ::JSON::ParserError => e
10
- begin
11
- [:yaml, ::YAML.safe_load(content, [Date, Time])]
12
- rescue ::Psych::SyntaxError
13
- [:text, content]
14
- end
15
- end
16
-
17
- def dump(definition, format)
18
- if format == :yaml
19
- ::YAML.dump(definition)
20
- else
21
- ::JSON.dump(definition)
22
- end
23
- end
24
- end
25
- end
26
- end