Skip to content

Commit

Permalink
Rubocop on specs and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Scott Lewis committed Jul 12, 2015
1 parent b86587a commit 82c8e3f
Show file tree
Hide file tree
Showing 33 changed files with 354 additions and 363 deletions.
13 changes: 7 additions & 6 deletions Gemfile
@@ -1,11 +1,12 @@
source 'https://rubygems.org'
source "https://rubygems.org"

group :development do
gem 'rubocop', '~> 0.32.1', require: false
gem 'rake', '~> 10.4.2'
gem 'rspec', '~> 3.3.0'
gem 'fuubar', '~> 2.0.0'
gem 'yard', '~> 0.8.7.6'
gem "rubocop", "~> 0.32.1"
gem "rake", "~> 10.4.2"
gem "rspec", "~> 3.3.0"
gem "fuubar", "~> 2.0.0"
gem "yard", "~> 0.8.7.6"
gem "reek", "~> 3.0.4"
# s.add_development_dependency 'guard-rspec', '~> 3.1.0'
# s.add_development_dependency 'rb-fsevent', '~> 0.9.0'
end
2 changes: 1 addition & 1 deletion Guardfile
@@ -1,5 +1,5 @@
guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
watch("spec/spec_helper.rb") { "spec" }
end
16 changes: 8 additions & 8 deletions Rakefile
@@ -1,13 +1,13 @@
require 'pathname'
require 'rubygems/package_task'
require 'yard'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require "pathname"
require "rubygems/package_task"
require "yard"
require "rspec/core/rake_task"
require "rubocop/rake_task"

gemspec = Pathname.glob( Pathname.new(__FILE__).join('..', '*.gemspec') ).first
$spec = Gem::Specification.load( gemspec.to_s )
gemspec = Pathname.glob(Pathname.new(__FILE__).join("..", "*.gemspec")).first
spec = Gem::Specification.load(gemspec.to_s)

Gem::PackageTask.new($spec) do |task|
Gem::PackageTask.new(spec) do |task|
task.need_zip = false
end

Expand Down
24 changes: 11 additions & 13 deletions cura.gemspec
@@ -1,25 +1,23 @@
require 'pathname'
require_relative 'lib/cura/version.rb'
require "pathname"
require_relative "lib/cura/version.rb"

# cura : management, administration, care, concern, charge
Gem::Specification.new do |s|

# Variables
s.author = 'Ryan Scott Lewis'
s.email = 'ryan@rynet.us'
s.summary = 'A library written in pure Ruby for building user interfaces.'
s.license = 'MIT'
s.author = "Ryan Scott Lewis"
s.email = "ryan@rynet.us"
s.summary = "A library written in pure Ruby for building user interfaces."
s.license = "MIT"
s.version = Cura::VERSION

# Dependencies
s.add_development_dependency 'builder', '~> 3.2.2'
s.add_development_dependency "builder", "~> 3.2.2"

# Pragmatically set variables
s.homepage = "http://github.com/RyanScottLewis/#{s.name}"
s.description = s.summary
s.name = Pathname.new(__FILE__).basename('.gemspec').to_s
s.require_paths = ['lib']
s.files = Dir['{{Rake,Gem}file{.lock,},README*,VERSION,LICENSE,*.gemspec,{lib,bin,spec}/**/*.rb}']
s.test_files = Dir['{examples,spec,test}/**/*']

s.name = Pathname.new(__FILE__).basename(".gemspec").to_s
s.require_paths = ["lib"]
s.files = Dir["{{Rake,Gem}file{.lock,},README*,VERSION,LICENSE,*.gemspec,{lib,bin,spec}/**/*.rb}"]
s.test_files = Dir["{examples,spec,test}/**/*"]
end
12 changes: 6 additions & 6 deletions examples/box_model/bin/box_model
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby

require 'pathname'
$:.unshift( Pathname.new(__FILE__).join( '..', '..', '..', '..', 'lib' ).expand_path.to_s )
$:.unshift( Pathname.new(__FILE__).join( '..', '..', '..', '..', '..', 'ruby-cura-termbox_ffi', 'lib' ).expand_path.to_s )
$:.unshift( Pathname.new(__FILE__).join( '..', '..', 'lib' ).expand_path.to_s )
require "pathname"
$LOAD_PATH.unshift(Pathname.new(__FILE__).join("..", "..", "..", "..", "lib").expand_path.to_s)
$LOAD_PATH.unshift(Pathname.new(__FILE__).join("..", "..", "..", "..", "..", "ruby-cura-termbox_ffi", "lib").expand_path.to_s)
$LOAD_PATH.unshift(Pathname.new(__FILE__).join("..", "..", "lib").expand_path.to_s)

require 'box_model'
require 'cura/termbox_ffi/adapter'
require "box_model"
require "cura/termbox_ffi/adapter"

BoxModel.run
8 changes: 4 additions & 4 deletions examples/box_model/lib/box_model.rb
@@ -1,12 +1,12 @@
require 'pathname'
require "pathname"

LOG_PATH = Pathname.new(__FILE__).join( '..', '..', 'debug.log' )
LOG_PATH = Pathname.new(__FILE__).join("..", "..", "debug.log")
LOG_PATH.truncate(0) if LOG_PATH.exist?

require 'logger'
require "logger"
LOGGER = Logger.new(LOG_PATH)

require 'box_model/application'
require "box_model/application"

module BoxModel

Expand Down
12 changes: 6 additions & 6 deletions examples/box_model/lib/box_model/application.rb
@@ -1,4 +1,4 @@
require 'cura'
require "cura"

module BoxModel

Expand All @@ -10,13 +10,13 @@ def initialize(attributes={})
super

window = Cura::Window.new
add_window( window )
add_window(window)

group = Cura::Component::Group.new( background: Cura::Color.red, margin: 1, padding: 1 )
window.add_child( group )
group = Cura::Component::Group.new(background: Cura::Color.red, margin: 1, padding: 1)
window.add_child(group)

label = Cura::Component::Label.new( text: 'Hello, world!', background: Cura::Color.blue, padding: 1 )
group.add_child( label )
label = Cura::Component::Label.new(text: "Hello, world!", background: Cura::Color.blue, padding: 1)
group.add_child(label)
end

end
Expand Down
10 changes: 5 additions & 5 deletions examples/hello_world/bin/hello_world
@@ -1,10 +1,10 @@
#!/usr/bin/env ruby

require 'pathname'
$:.unshift( Pathname.new(__FILE__).join( '..', '..', '..', '..', 'lib' ).expand_path.to_s )
$:.unshift( Pathname.new(__FILE__).join( '..', '..', '..', '..', '..', 'ruby-cura-termbox_ffi', 'lib' ).expand_path.to_s )
$:.unshift( Pathname.new(__FILE__).join( '..', '..', 'lib' ).expand_path.to_s )
require "pathname"
$LOAD_PATH.unshift(Pathname.new(__FILE__).join("..", "..", "..", "..", "lib").expand_path.to_s)
$LOAD_PATH.unshift(Pathname.new(__FILE__).join("..", "..", "..", "..", "..", "ruby-cura-termbox_ffi", "lib").expand_path.to_s)
$LOAD_PATH.unshift(Pathname.new(__FILE__).join("..", "..", "lib").expand_path.to_s)

require 'hello_world'
require "hello_world"

HelloWorld.run
12 changes: 6 additions & 6 deletions examples/hello_world/lib/hello_world.rb
@@ -1,14 +1,14 @@
require 'cura'
require "cura"
# require 'cura-adapter-termbox'
require 'cura/termbox_ffi/adapter'
require "cura/termbox_ffi/adapter"
# require 'cura-adapter-curses'
# require 'cura-adapter-sdl'
# require 'cura-adapter-sdl-ffi'
# require 'cura-adapter-opengl'
# require 'cura-adapter-opengl-ffi'
# require 'cura-adapter-gosu'

require 'hello_world/application'
require "hello_world/application"

module HelloWorld

Expand All @@ -18,7 +18,7 @@ def run
# adapter = choose_adapter
#
# Application.run( adapter: adapter )
Application.run( adapter: Cura::TermboxFFI::Adapter.new )
Application.run(adapter: Cura::TermboxFFI::Adapter.new)
end

protected
Expand All @@ -34,11 +34,11 @@ def choose_adapter
end

puts "\nChoose adapter or type 'exit'"
print '> '
print "> "

answer = gets.downcase.strip

exit if answer == 'exit'
exit if answer == "exit"

index = answer.to_i

Expand Down
55 changes: 25 additions & 30 deletions examples/hello_world/lib/hello_world/application.rb
@@ -1,17 +1,16 @@
require 'pathname'
require "pathname"

LOG_PATH = Pathname.new(__FILE__).join( '..', '..', '..', 'debug.log' )
LOG_PATH = Pathname.new(__FILE__).join("..", "..", "..", "debug.log")
LOG_PATH.truncate(0) if LOG_PATH.exist?

require 'logger'
require "logger"
LOGGER = Logger.new(LOG_PATH)

require 'cura'
require "cura"

module HelloWorld

class Application < Cura::Application

on_event(:key_down) do |event|
stop if event.control? && event.name == :C # CTRL+C
end
Expand All @@ -35,24 +34,23 @@ def initialize(attributes={})
self.focused_index -= 1 if event.control? && event.name == :B
end

pack = Cura::Component::Pack.new( width: window.width, height: window.height, fill: true )
pack = Cura::Component::Pack.new(width: window.width, height: window.height, fill: true)
window.add_child(pack)

label_header = Cura::Component::Label.new( text: 'Cura', bold: true, underline: true, alignment: { horizontal: :center }, margin: { top: 1 } )
label_header = Cura::Component::Label.new(text: "Cura", bold: true, underline: true, alignment: { horizontal: :center }, margin: { top: 1 })
pack.add_child(label_header)

label_help = Cura::Component::Label.new( text: 'Press CTRL-C to exit', alignment: { horizontal: :center }, margin: { bottom: 1 } )
label_help = Cura::Component::Label.new(text: "Press CTRL-C to exit", alignment: { horizontal: :center }, margin: { bottom: 1 })
pack.add_child(label_help)

label_hello = Cura::Component::Label.new( text: 'Hello, world!', alignment: { horizontal: :center } )
label_hello = Cura::Component::Label.new(text: "Hello, world!", alignment: { horizontal: :center })
pack.add_child(label_hello)

label_hello_kanji = Cura::Component::Label.new( text: '今日は', alignment: { horizontal: :center }, margin: { bottom: 1 } )
label_hello_kanji = Cura::Component::Label.new(text: "今日は", alignment: { horizontal: :center }, margin: { bottom: 1 })
pack.add_child(label_hello_kanji)


input_pack = Cura::Component::Pack.new( fill: true )
input_header_label = Cura::Component::Label.new( text: 'Type and press Enter to echo for 5 seconds:' )
input_pack = Cura::Component::Pack.new(fill: true)
input_header_label = Cura::Component::Label.new(text: "Type and press Enter to echo for 5 seconds:")
input_pack.add_child(input_header_label)

input_textbox = Cura::Component::Textbox.new
Expand All @@ -76,47 +74,45 @@ def initialize(attributes={})

pack.add_child(input_pack)

form_pack = Cura::Component::Pack.new(orientation: :horizontal)


form_pack = Cura::Component::Pack.new( orientation: :horizontal )

form_first_name_label = Cura::Component::Label.new( text: 'First Name:', margin: { right: 1 } )
form_first_name_label = Cura::Component::Label.new(text: "First Name:", margin: { right: 1 })
form_pack.add_child(form_first_name_label)

@form_first_name_textbox = Cura::Component::Textbox.new( width: 20, margin: { right: 1 } )
@form_first_name_textbox = Cura::Component::Textbox.new(width: 20, margin: { right: 1 })
form_pack.add_child(@form_first_name_textbox)
@form_first_name_textbox.on_event(:key_down) { |event| application.form_submit_button.click if event.name == :enter }

form_last_name_label = Cura::Component::Label.new( text: 'Last Name:', margin: { right: 1 } )
form_last_name_label = Cura::Component::Label.new(text: "Last Name:", margin: { right: 1 })
form_pack.add_child(form_last_name_label)

@form_last_name_textbox = Cura::Component::Textbox.new( width: 20, margin: { right: 1 } )
@form_last_name_textbox = Cura::Component::Textbox.new(width: 20, margin: { right: 1 })
form_pack.add_child(@form_last_name_textbox)
@form_last_name_textbox.on_event(:key_down) { |event| application.form_submit_button.click if event.name == :enter }

form_age_label = Cura::Component::Label.new( text: 'Age:', margin: { right: 1 } )
form_age_label = Cura::Component::Label.new(text: "Age:", margin: { right: 1 })
form_pack.add_child(form_age_label)

@form_age_textbox = Cura::Component::Textbox.new( width: 20, margin: { right: 1 } )
@form_age_textbox = Cura::Component::Textbox.new(width: 20, margin: { right: 1 })
form_pack.add_child(@form_age_textbox)
@form_age_textbox.on_event(:key_down) { |event| application.form_submit_button.click if event.name == :enter }

form_zip_label = Cura::Component::Label.new( text: 'ZIP:', margin: { right: 1 } )
form_zip_label = Cura::Component::Label.new(text: "ZIP:", margin: { right: 1 })
form_pack.add_child(form_zip_label)

@form_zip_textbox = Cura::Component::Textbox.new( width: 20 )
@form_zip_textbox = Cura::Component::Textbox.new(width: 20)
form_pack.add_child(@form_zip_textbox)
@form_zip_textbox.on_event(:key_down) { |event| application.form_submit_button.click if event.name == :enter }

form_clear_button = Cura::Component::Button.new( text: 'Clear', padding: { left: 1, right: 1 }, margin: { left: 1 } )
form_clear_button = Cura::Component::Button.new(text: "Clear", padding: { left: 1, right: 1 }, margin: { left: 1 })
form_pack.add_child(form_clear_button)

form_clear_button.on_event(:click) { application.clear_form }

@form_submit_button = Cura::Component::Button.new( text: 'Submit', padding: { left: 1, right: 1 }, margin: { left: 1 } )
@form_submit_button = Cura::Component::Button.new(text: "Submit", padding: { left: 1, right: 1 }, margin: { left: 1 })
form_pack.add_child(@form_submit_button)

@form_submit_button.on_event(:click) do |event|
@form_submit_button.on_event(:click) do |_event|
first = application.form_first_name_textbox.text
last = application.form_last_name_textbox.text
age = application.form_age_textbox.text
Expand All @@ -130,12 +126,12 @@ def initialize(attributes={})
label_text_segments << "Age: #{age}" unless age.empty?
label_text_segments << "ZIP: #{zip}" unless zip.empty?

label = Cura::Component::Label.new( text: label_text_segments.join(' - ') )
label = Cura::Component::Label.new(text: label_text_segments.join(" - "))
application.people_listbox.add_child(label)
end
pack.add_child(form_pack)

people_label = Cura::Component::Label.new( text: 'People:' )
people_label = Cura::Component::Label.new(text: "People:")
pack.add_child(people_label)

@people_listbox = Cura::Component::Listbox.new
Expand Down Expand Up @@ -165,7 +161,6 @@ def clear_form

@form_first_name_textbox.focus
end

end

end
12 changes: 6 additions & 6 deletions examples/todo_list/bin/todo_list
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby

require 'pathname'
$:.unshift( Pathname.new(__FILE__).join( '..', '..', '..', '..', 'lib' ).expand_path.to_s )
$:.unshift( Pathname.new(__FILE__).join( '..', '..', '..', '..', '..', 'ruby-cura-termbox_ffi', 'lib' ).expand_path.to_s )
$:.unshift( Pathname.new(__FILE__).join( '..', '..', 'lib' ).expand_path.to_s )
require "pathname"
$LOAD_PATH.unshift(Pathname.new(__FILE__).join("..", "..", "..", "..", "lib").expand_path.to_s)
$LOAD_PATH.unshift(Pathname.new(__FILE__).join("..", "..", "..", "..", "..", "ruby-cura-termbox_ffi", "lib").expand_path.to_s)
$LOAD_PATH.unshift(Pathname.new(__FILE__).join("..", "..", "lib").expand_path.to_s)

require 'todo_list'
require 'cura/termbox_ffi/adapter'
require "todo_list"
require "cura/termbox_ffi/adapter"

TodoList.run
12 changes: 6 additions & 6 deletions examples/todo_list/lib/todo_list.rb
@@ -1,20 +1,20 @@
require 'pathname'
require "pathname"

LOG_PATH = Pathname.new(__FILE__).join( '..', '..', 'debug.log' )
LOG_PATH = Pathname.new(__FILE__).join("..", "..", "debug.log")
LOG_PATH.truncate(0) if LOG_PATH.exist?

require 'logger'
require "logger"
LOGGER = Logger.new(LOG_PATH)

require 'todo_list/database'
require 'todo_list/application'
require "todo_list/database"
require "todo_list/application"

module TodoList

class << self

def root
@root ||= Pathname.new(__FILE__).join( '..', '..' ).expand_path
@root ||= Pathname.new(__FILE__).join("..", "..").expand_path
end

def run
Expand Down

0 comments on commit 82c8e3f

Please sign in to comment.