Skip to content

Commit

Permalink
Merge pull request #64 from sickill/fix/rubocop-0-49-1
Browse files Browse the repository at this point in the history
RuboCop 0.49.1; rake task; linting
  • Loading branch information
olleolleolle authored Jul 2, 2017
2 parents 8907d4a + d31c031 commit 1a61b33
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
inherit_from: .rubocop_todo.yml

AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
TargetRubyVersion: "2.1"
Exclude:
- "spec/**/*"
- "vendor/**/*"
Documentation:
Enabled: false

Expand Down
14 changes: 1 addition & 13 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-05-15 22:22:19 +0200 using RuboCop version 0.48.1.
# on 2017-06-30 12:37:52 +0200 using RuboCop version 0.49.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -14,12 +14,6 @@ Metrics/AbcSize:
Metrics/CyclomaticComplexity:
Max: 9

# Offense count: 2
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 85

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/MethodLength:
Expand All @@ -33,9 +27,3 @@ Metrics/ModuleLength:
# Offense count: 1
Metrics/PerceivedComplexity:
Max: 8

# Offense count: 2
Style/MethodMissing:
Exclude:
- 'lib/rainbow/null_presenter.rb'
- 'lib/rainbow/presenter.rb'
11 changes: 9 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in rainbow.gemspec
gemspec

gem 'coveralls', require: false
gem 'rake'
gem 'rspec'

group :test do
gem 'coveralls', require: false
gem 'rspec'
end

group :development do
gem 'mutant-rspec'
end

group :test, :development do
gem 'rubocop', '~> 0.49.1'
end

group :guard do
gem 'guard'
gem 'guard-rspec'
Expand Down
7 changes: 5 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
require "bundler/gem_tasks"

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new

RSpec::Core::RakeTask.new(:spec)
require 'rubocop/rake_task'
RuboCop::RakeTask.new

task :default => :spec
task default: %i[spec rubocop]
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ install:

build: off

init:
- git config --global core.autocrlf true

test_script:
- bundle exec rake

Expand Down
12 changes: 10 additions & 2 deletions lib/rainbow/color.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ def self.color_names
NAMES.keys
end

def self.valid_names
color_names.join(', ')
end

def initialize(ground, name)
unless Named.color_names.include?(name)
raise ArgumentError,
"Unknown color name, valid names: #{Named.color_names.join(', ')}"
"Unknown color name, valid names: #{self.class.valid_names}"
end

super(ground, NAMES[name])
Expand Down Expand Up @@ -122,10 +126,14 @@ def self.color_names
NAMES.keys
end

def self.valid_names
color_names.join(', ')
end

def initialize(ground, name)
unless X11Named.color_names.include?(name)
raise ArgumentError,
"Unknown color name, valid names: #{X11Named.color_names.join(', ')}"
"Unknown color name, valid names: #{self.class.valid_names}"
end

super(ground, *NAMES[name])
Expand Down
4 changes: 4 additions & 0 deletions lib/rainbow/null_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def method_missing(method_name, *args)
end
end

def respond_to_missing?(method_name, *args)
Color::X11Named.color_names.include?(method_name) && args.empty? || super
end

alias foreground color
alias fg color
alias bg background
Expand Down
4 changes: 4 additions & 0 deletions lib/rainbow/presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ def method_missing(method_name, *args)
end
end

def respond_to_missing?(method_name, *args)
Color::X11Named.color_names.include?(method_name) && args.empty? || super
end

private

def wrap_with_sgr(codes) #:nodoc:
Expand Down

0 comments on commit 1a61b33

Please sign in to comment.