Skip to content

Commit

Permalink
Style tidyup;
Browse files Browse the repository at this point in the history
- Prefer single-quoted strings when you don't need string interpolation or special symbols.
- Remove redundant return.
- Use proc instead of Proc.new.
- Remove unused block arguments.
- Use array literal instead of Array.new.
- Use fail instead of raise.
  • Loading branch information
Gavin Laking committed Jun 17, 2014
1 parent 99a11fd commit c0a33d4
Show file tree
Hide file tree
Showing 24 changed files with 62 additions and 59 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Documentation:
Enabled: false
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Rake::TestTask.new(:minitest) do |t|
t.verbose = false
end

task :default => :minitest
task default: :minitest

Rake::Task['minitest'].execute

Expand Down
2 changes: 1 addition & 1 deletion lib/vedeu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
module Vedeu
def self.logger
@logger ||= Logger.new(root_path + '/logs/vedeu.log').tap do |log|
log.formatter = proc do |mode, time, prog, msg|
log.formatter = proc do |_, time, _, msg|
"\n#{time.iso8601}: #{msg}\n"
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/vedeu/output/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def each(&block)
end

def cell(y, x)
raise OutOfRangeError if invalid_reference?(y, x)
fail OutOfRangeError if invalid_reference?(y, x)
buffer[y][x]
end

def set_cell(y, x, v = '')
raise OutOfRangeError if invalid_reference?(y, x)
fail OutOfRangeError if invalid_reference?(y, x)
buffer[y][x] = v
end

Expand Down
2 changes: 1 addition & 1 deletion lib/vedeu/output/compositor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def composition
output.map do |lines|
if lines.size < height
remaining = height - lines.size
remaining.times { |i| lines << "" }
remaining.times { |i| lines << '' }
end

lines.each_with_index do |stream, index|
Expand Down
2 changes: 1 addition & 1 deletion lib/vedeu/process/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def evaluate
def initialize; end

def evaluate
raise Collapse if result == :stop
fail Collapse if result == :stop

Compositor.arrange(result) unless no_result?
end
Expand Down
6 changes: 3 additions & 3 deletions lib/vedeu/repository/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def initialize(attributes = {})
@attributes = attributes || {}
@name = attributes[:name]
@klass = attributes[:klass]
@keyword = attributes.fetch(:options, {}).fetch(:keyword, "")
@keypress = attributes.fetch(:options, {}).fetch(:keypress, "")
@keyword = attributes.fetch(:options, {}).fetch(:keyword, '')
@keypress = attributes.fetch(:options, {}).fetch(:keypress, '')
end

def create
Expand All @@ -26,7 +26,7 @@ def execute(args = [])
end

def executable
Proc.new { |*args| attributes[:klass].dispatch(*args) }
proc { |*args| attributes[:klass].dispatch(*args) }
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/vedeu/repository/interface_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def activated
def find_by_name(value)
interface = query(klass, :name, value)

raise UndefinedInterface if interface.nil?
fail UndefinedInterface if interface.nil?

interface
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vedeu/support/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def view
private

def store
@store ||= Array.new
@store ||= []
end
end
end
14 changes: 7 additions & 7 deletions lib/vedeu/support/terminal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def clear_screen
end

def clear_line(index)
output(Position.set(index, 1) + (" " * width) + Position.set(index, 1))
output(Position.set(index, 1) + (' ' * width) + Position.set(index, 1))
end

def show_cursor
Expand Down Expand Up @@ -103,15 +103,15 @@ def initial_setup!

def terminal_mode(&block)
{
cooked: Proc.new { Terminal.cooked(self, &block) },
raw: Proc.new { Terminal.raw(self, &block) }
cooked: proc { Terminal.cooked(self, &block) },
raw: proc { Terminal.raw(self, &block) }
}
end

def cursor_mode
{
show: Proc.new { Terminal.show_cursor },
hide: Proc.new { Terminal.hide_cursor }
show: proc { Terminal.show_cursor },
hide: proc { Terminal.hide_cursor }
}
end

Expand All @@ -128,11 +128,11 @@ def mode
end

def clear_screen?
return options.fetch(:clear)
options.fetch(:clear)
end

def noop
Proc.new {}
proc {}
end

def options
Expand Down
2 changes: 1 addition & 1 deletion lib/vedeu/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Vedeu
VERSION = "0.0.18"
VERSION = '0.0.18'
end
2 changes: 1 addition & 1 deletion test/lib/vedeu/input/input_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Vedeu
describe Input do
let(:described_class) { Input }
let(:input) { "" }
let(:input) { '' }
let(:subject) { described_class.new }

before { Terminal.stubs(:input).returns(input) }
Expand Down
2 changes: 1 addition & 1 deletion test/lib/vedeu/output/buffer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Vedeu
end

it 'sets an instance variable' do
subject.instance_variable_get("@options").must_equal(options)
subject.instance_variable_get('@options').must_equal(options)
end

describe '#to_s' do
Expand Down
2 changes: 1 addition & 1 deletion test/lib/vedeu/output/colour_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Vedeu
end

it 'sets an instance variable' do
subject.instance_variable_get("@pair").must_equal([])
subject.instance_variable_get('@pair').must_equal([])
end

describe '.set' do
Expand Down
4 changes: 2 additions & 2 deletions test/lib/vedeu/output/compositor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ module Vedeu
end

it 'sets an instance variable' do
subject.instance_variable_get("@output").must_equal([[]])
subject.instance_variable_get('@output').must_equal([[]])
end

it 'sets an instance variable' do
subject.instance_variable_get("@interface").must_equal("dummy")
subject.instance_variable_get('@interface').must_equal('dummy')
end

describe '.arrange' do
Expand Down
4 changes: 2 additions & 2 deletions test/lib/vedeu/output/directive_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ module Vedeu
end

it 'sets an instance variable' do
subject.instance_variable_get("@interface").must_be_instance_of(Interface)
subject.instance_variable_get('@interface').must_be_instance_of(Interface)
end

it 'sets an instance variable' do
subject.instance_variable_get("@directives").must_be_instance_of(Hash)
subject.instance_variable_get('@directives').must_be_instance_of(Hash)
end

describe '.enact' do
Expand Down
10 changes: 5 additions & 5 deletions test/lib/vedeu/repository/command_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ module Vedeu
end

it 'sets an instance variable' do
subject.instance_variable_get("@attributes").must_equal(attributes)
subject.instance_variable_get('@attributes').must_equal(attributes)
end

it 'sets an instance variable' do
subject.instance_variable_get("@name").must_equal('dummy')
subject.instance_variable_get('@name').must_equal('dummy')
end

it 'sets an instance variable' do
subject.instance_variable_get("@klass").must_equal(DummyCommand)
subject.instance_variable_get('@klass').must_equal(DummyCommand)
end

it 'sets an instance variable' do
subject.instance_variable_get("@keyword").must_equal('dummy')
subject.instance_variable_get('@keyword').must_equal('dummy')
end

it 'sets an instance variable' do
subject.instance_variable_get("@keypress").must_equal('d')
subject.instance_variable_get('@keypress').must_equal('d')
end

describe '#create' do
Expand Down
6 changes: 3 additions & 3 deletions test/lib/vedeu/repository/interface_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ module Vedeu
end

it 'sets an instance variable' do
subject.instance_variable_get("@attributes").must_equal(attributes)
subject.instance_variable_get('@attributes').must_equal(attributes)
end

it 'sets an instance variable' do
subject.instance_variable_get("@active").must_equal(false)
subject.instance_variable_get('@active').must_equal(false)
end

it 'sets an instance variable' do
subject.instance_variable_get("@name").must_equal('dummy')
subject.instance_variable_get('@name').must_equal('dummy')
end

describe '#create' do
Expand Down
4 changes: 2 additions & 2 deletions test/lib/vedeu/repository/storage_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ module Vedeu
end

it 'sets an instance variable' do
subject.instance_variable_get("@counter").must_equal(0)
subject.instance_variable_get('@counter').must_equal(0)
end

it 'sets an instance variable' do
subject.instance_variable_get("@map").must_equal({})
subject.instance_variable_get('@map').must_equal({})
end

describe '#create' do
Expand Down
2 changes: 1 addition & 1 deletion test/lib/vedeu/support/event_loop_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Vedeu
end

it 'sets an instance variable' do
subject.instance_variable_get("@running").must_equal(true)
subject.instance_variable_get('@running').must_equal(true)
end

describe '.main_sequence' do
Expand Down
2 changes: 1 addition & 1 deletion test/lib/vedeu/support/queue_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module Vedeu
end

it 'returns the queue as a String' do
subject.must_equal("[:result]")
subject.must_equal('[:result]')
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/lib/vedeu/support/terminal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module Vedeu
end

it 'returns the entered string' do
subject.must_equal("test")
subject.must_equal('test')
end
end

Expand All @@ -33,7 +33,7 @@ module Vedeu
end

it 'returns the output' do
subject.must_equal("")
subject.must_equal('')
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
SimpleCov.start do
command_name 'MiniTest::Spec'
add_filter '/test/'
end unless ENV["no_simplecov"]
end unless ENV['no_simplecov']

module MiniTest
class Spec
Expand Down
37 changes: 19 additions & 18 deletions vedeu.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,30 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'vedeu/version'

Gem::Specification.new do |spec|
spec.name = "vedeu"
spec.name = 'vedeu'
spec.version = Vedeu::VERSION
spec.authors = ["Gavin Laking"]
spec.email = ["[email protected]"]
spec.authors = ['Gavin Laking']
spec.email = ['[email protected]']
spec.summary = %q{A terminal case of wonderland.}
spec.homepage = "http://www.gavinlaking.name/"
spec.license = "MIT"
spec.homepage = 'http://www.gavinlaking.name/'
spec.license = 'MIT'

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

spec.add_development_dependency "aruba", "0.5.4"
spec.add_development_dependency "bundler", "~> 1.5"
spec.add_development_dependency "cucumber", "1.3.15"
spec.add_development_dependency "guard-cucumber", "1.4.1"
spec.add_development_dependency "guard", "2.6.1"
spec.add_development_dependency "guard-minitest", "2.3.0"
spec.add_development_dependency "minitest", "5.3.4"
spec.add_development_dependency "minitest-reporters", "1.0.4"
spec.add_development_dependency "mocha", "1.1.0"
spec.add_development_dependency "pry", "0.10.0"
spec.add_development_dependency "rake", "10.3.2"
spec.add_development_dependency "simplecov", "0.8.2"
spec.add_development_dependency 'aruba', '0.5.4'
spec.add_development_dependency 'bundler', '~> 1.5'
spec.add_development_dependency 'cucumber', '1.3.15'
spec.add_development_dependency 'guard-cucumber', '1.4.1'
spec.add_development_dependency 'guard', '2.6.1'
spec.add_development_dependency 'guard-minitest', '2.3.0'
spec.add_development_dependency 'minitest', '5.3.4'
spec.add_development_dependency 'minitest-reporters', '1.0.4'
spec.add_development_dependency 'mocha', '1.1.0'
spec.add_development_dependency 'pry', '0.10.0'
spec.add_development_dependency 'rake', '10.3.2'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'simplecov', '0.8.2'
end

0 comments on commit c0a33d4

Please sign in to comment.