Skip to content

Commit

Permalink
Use Chefstyle
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Smith <tsmith@chef.io>
  • Loading branch information
tas50 committed Sep 29, 2016
1 parent 94ff1a0 commit ad0f0e8
Show file tree
Hide file tree
Showing 25 changed files with 380 additions and 399 deletions.
25 changes: 3 additions & 22 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
AbcSize:
Enabled: false
BracesAroundHashParameters:
Enabled: false
ClassLength:
Enabled: false
CyclomaticComplexity:
Enabled: false
Documentation:
Enabled: false
Encoding:
Enabled: false
LineLength:
Enabled: false
MethodLength:
Enabled: false
PerceivedComplexity:
Enabled: false
RescueModifier:
Enabled: false
TrailingComma:
EnforcedStyleForMultiline: comma
Lint/DuplicatedKey:
Exclude:
- 'spec/mixlib/versioning/versioning_spec.rb'
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
source 'https://rubygems.org'
source "https://rubygems.org"
gemspec

group :docs do
gem 'yard', '~> 0.8'
gem 'redcarpet', '~> 2.2'
gem 'github-markup', '~> 0.7'
gem "yard", "~> 0.8"
gem "redcarpet", "~> 2.2"
gem "github-markup", "~> 0.7"
end
12 changes: 6 additions & 6 deletions lib/mixlib/versioning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# limitations under the License.
#

require 'mixlib/versioning/exceptions'
require 'mixlib/versioning/format'
require "mixlib/versioning/exceptions"
require "mixlib/versioning/format"

module Mixlib
# @author Seth Chisamore (<schisamo@chef.io>)
Expand Down Expand Up @@ -135,7 +135,7 @@ def self.find_target_version(all_versions,
# attempt to parse a `Mixlib::Versioning::Format` instance if we were
# passed a string
unless filter_version.nil? ||
filter_version.is_a?(Mixlib::Versioning::Format)
filter_version.is_a?(Mixlib::Versioning::Format)
filter_version = Mixlib::Versioning.parse(filter_version)
end

Expand Down Expand Up @@ -181,13 +181,13 @@ def self.find_target_version(all_versions,
in_release_line && if use_prerelease_versions && use_build_versions
v.prerelease_build?
elsif !use_prerelease_versions &&
use_build_versions
use_build_versions
v.release_build?
elsif use_prerelease_versions &&
!use_build_versions
!use_build_versions
v.prerelease?
elsif !use_prerelease_versions &&
!use_build_versions
!use_build_versions
v.release?
end
end.max # select the most recent version
Expand Down
34 changes: 17 additions & 17 deletions lib/mixlib/versioning/format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
# limitations under the License.
#

require 'mixlib/versioning/format/git_describe'
require 'mixlib/versioning/format/opscode_semver'
require 'mixlib/versioning/format/rubygems'
require 'mixlib/versioning/format/semver'
require "mixlib/versioning/format/git_describe"
require "mixlib/versioning/format/opscode_semver"
require "mixlib/versioning/format/rubygems"
require "mixlib/versioning/format/semver"

module Mixlib
class Versioning
Expand Down Expand Up @@ -60,17 +60,17 @@ class Format
#
def self.for(format_type)
if format_type.is_a?(Class) &&
format_type.ancestors.include?(Mixlib::Versioning::Format)
format_type.ancestors.include?(Mixlib::Versioning::Format)
format_type
else
case format_type.to_s
when 'semver' then Mixlib::Versioning::Format::SemVer
when 'opscode_semver' then Mixlib::Versioning::Format::OpscodeSemVer
when 'git_describe' then Mixlib::Versioning::Format::GitDescribe
when 'rubygems' then Mixlib::Versioning::Format::Rubygems
when "semver" then Mixlib::Versioning::Format::SemVer
when "opscode_semver" then Mixlib::Versioning::Format::OpscodeSemVer
when "git_describe" then Mixlib::Versioning::Format::GitDescribe
when "rubygems" then Mixlib::Versioning::Format::Rubygems
else
msg = "'#{format_type}' is not a supported Mixlib::Versioning format"
fail Mixlib::Versioning::UnknownFormatError, msg
raise Mixlib::Versioning::UnknownFormatError, msg
end
end
end
Expand All @@ -90,7 +90,7 @@ def initialize(version_string)
# @param version_string [String] string representation of the version
# @raise [Mixlib::Versioning::ParseError] raised if parsing fails
def parse(_version_string)
fail Error, 'You must override the #parse'
raise Error, "You must override the #parse"
end

# @return [Boolean] Whether or not this is a release version
Expand Down Expand Up @@ -153,7 +153,7 @@ def inspect
vars = instance_variables.map do |n|
"#{n}=#{instance_variable_get(n).inspect}"
end
format('#<%s:0x%x %s>', self.class, object_id, vars.join(', '))
format("#<%s:0x%x %s>", self.class, object_id, vars.join(", "))
end

# Returns SemVer compliant string representation of this {Format}
Expand All @@ -167,7 +167,7 @@ def inspect
# {Format} instance
# @todo create a proper serialization abstraction
def to_semver_string
s = [@major, @minor, @patch].join('.')
s = [@major, @minor, @patch].join(".")
s += "-#{@prerelease}" if @prerelease
s += "+#{@build}" if @build
s
Expand All @@ -184,7 +184,7 @@ def to_semver_string
# {Format} instance
# @todo create a proper serialization abstraction
def to_rubygems_string
s = [@major, @minor, @patch].join('.')
s = [@major, @minor, @patch].join(".")
s += ".#{@prerelease}" if @prerelease
s
end
Expand Down Expand Up @@ -269,7 +269,7 @@ def eql?(other)
end

def hash
[@major, @minor, @patch, @prerelease, @build].compact.join('.').hash
[@major, @minor, @patch, @prerelease, @build].compact.join(".").hash
end

#########################################################################
Expand Down Expand Up @@ -303,8 +303,8 @@ def maybe_int(n)
# Both `a_item` and `b_item` should be Strings; `nil` is not a
# valid input.
def compare_dot_components(a_item, b_item)
a_components = a_item.split('.')
b_components = b_item.split('.')
a_components = a_item.split(".")
b_components = b_item.split(".")

max_length = [a_components.length, b_components.length].max

Expand Down
2 changes: 1 addition & 1 deletion lib/mixlib/versioning/format/git_describe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def parse(version_string)
match = version_string.match(GIT_DESCRIBE_REGEX) rescue nil

unless match
fail Mixlib::Versioning::ParseError, "'#{version_string}' is not a valid #{self.class} version string!"
raise Mixlib::Versioning::ParseError, "'#{version_string}' is not a valid #{self.class} version string!"
end

@major, @minor, @patch, @prerelease, @commits_since, @commit_sha, @iteration = match[1..7]
Expand Down
6 changes: 3 additions & 3 deletions lib/mixlib/versioning/format/opscode_semver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# limitations under the License.
#

require 'mixlib/versioning/format/semver'
require "mixlib/versioning/format/semver"

module Mixlib
class Versioning
Expand Down Expand Up @@ -71,8 +71,8 @@ class OpscodeSemVer < SemVer
def parse(version_string)
super(version_string)

fail Mixlib::Versioning::ParseError, "'#{@prerelease}' is not a valid Opscode pre-release signifier!" unless @prerelease.nil? || @prerelease.match(OPSCODE_PRERELEASE_REGEX)
fail Mixlib::Versioning::ParseError, "'#{@build}' is not a valid Opscode build signifier!" unless @build.nil? || @build.match(OPSCODE_BUILD_REGEX)
raise Mixlib::Versioning::ParseError, "'#{@prerelease}' is not a valid Opscode pre-release signifier!" unless @prerelease.nil? || @prerelease.match(OPSCODE_PRERELEASE_REGEX)
raise Mixlib::Versioning::ParseError, "'#{@build}' is not a valid Opscode build signifier!" unless @build.nil? || @build.match(OPSCODE_BUILD_REGEX)
end
end # class OpscodeSemVer
end # class Format
Expand Down
2 changes: 1 addition & 1 deletion lib/mixlib/versioning/format/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def parse(version_string)
match = version_string.match(RUBYGEMS_REGEX) rescue nil

unless match
fail Mixlib::Versioning::ParseError, "'#{version_string}' is not a valid #{self.class} version string!"
raise Mixlib::Versioning::ParseError, "'#{version_string}' is not a valid #{self.class} version string!"
end

@major, @minor, @patch, @prerelease, @iteration = match[1..5]
Expand Down
2 changes: 1 addition & 1 deletion lib/mixlib/versioning/format/semver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def parse(version_string)
match = version_string.match(SEMVER_REGEX) rescue nil

unless match
fail Mixlib::Versioning::ParseError, "'#{version_string}' is not a valid #{self.class} version string!"
raise Mixlib::Versioning::ParseError, "'#{version_string}' is not a valid #{self.class} version string!"
end

@major, @minor, @patch, @prerelease, @build = match[1..5]
Expand Down
2 changes: 1 addition & 1 deletion lib/mixlib/versioning/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@

module Mixlib
class Versioning
VERSION = '1.1.0'
VERSION = "1.1.0"
end
end
26 changes: 13 additions & 13 deletions mixlib-versioning.gemspec
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'mixlib/versioning/version'
require "mixlib/versioning/version"

Gem::Specification.new do |spec|
spec.name = 'mixlib-versioning'
spec.name = "mixlib-versioning"
spec.version = Mixlib::Versioning::VERSION
spec.authors = ['Seth Chisamore', 'Christopher Maier']
spec.email = ['schisamo@chef.io', 'cm@chef.io']
spec.description = 'General purpose Ruby library that allows you to parse, compare and manipulate version strings in multiple formats.'
spec.authors = ["Seth Chisamore", "Christopher Maier"]
spec.email = ["schisamo@chef.io", "cm@chef.io"]
spec.description = "General purpose Ruby library that allows you to parse, compare and manipulate version strings in multiple formats."
spec.summary = spec.description
spec.homepage = 'https://github.com/chef/mixlib-versioning'
spec.license = 'Apache 2.0'
spec.homepage = "https://github.com/chef/mixlib-versioning"
spec.license = "Apache 2.0"

spec.required_ruby_version = ">= 2.2"

spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']
spec.require_paths = ["lib"]

# Development dependencies
spec.add_development_dependency 'rubocop', '= 0.31.0'
spec.add_development_dependency 'rspec', '~> 2.14'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake'
spec.add_development_dependency "chefstyle", "= 0.4.0"
spec.add_development_dependency "rspec", "~> 2.14"
spec.add_development_dependency "bundler"
spec.add_development_dependency "rake"
end
Loading

0 comments on commit ad0f0e8

Please sign in to comment.