Skip to content

Commit

Permalink
Merge pull request #1 from pmaccamp/no-chozo
Browse files Browse the repository at this point in the history
drop chozo+extlib in configuration parsing (fixes RiotGamesMinions#123)
  • Loading branch information
pmaccamp authored Mar 25, 2021
2 parents 85a4e0e + be06943 commit 378cb89
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
44 changes: 25 additions & 19 deletions lib/nexus_cli/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'extlib'
require 'chozo'
require 'yaml'

module NexusCli
class Configuration
Expand Down Expand Up @@ -68,28 +67,35 @@ def validate!
self.class.validate!(self)
end

include Chozo::VariaModel
def valid?
errors.empty?
end

attribute :url,
type: String,
required: true
def errors
result = Hash.new
result[:url] = ["url required"] unless url.is_a?(String) && url.size > 0
result[:repository] = ["repository required"] unless repository.is_a?(String) && repository.size > 0
result
end

attribute :repository,
type: String,
required: true,
coerce: lambda { |m|
m = m.is_a?(String) ? m.gsub(' ', '_') : m
}
attr_accessor :url
attr_accessor :repository
attr_accessor :username
attr_accessor :password

attribute :username,
type: String
def initialize(options)
@url = options[:url]
@repository = options[:repository]
@username = options[:username]
@password = options[:password]

attribute :password,
type: String
if @repository.is_a?(String)
@repository = @repository.gsub(' ', '_')
end
end

def initialize(options)
mass_assign(options)
self.repository = options[:repository]
def [](attr)
self.instance_variable_get('@' + attr.to_s)
end
end
end
2 changes: 0 additions & 2 deletions nexus_cli.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ Gem::Specification.new do |s|

s.add_dependency 'thor'
s.add_dependency 'httpclient', '~> 2.8.0'
s.add_dependency 'extlib'
s.add_dependency 'json'
s.add_dependency 'highline'
s.add_dependency 'jsonpath'
s.add_runtime_dependency 'chozo', '>= 0.6.0'
s.add_runtime_dependency 'activesupport', '~> 3.2.0'

s.add_development_dependency 'rspec'
Expand Down

0 comments on commit 378cb89

Please sign in to comment.