Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi! I cleaned up your code for you! #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 61 additions & 61 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,119 +1,119 @@
---
dependencies:
activerecord:
group:
---
dependencies:
activerecord:
group:
- :default
version: ">= 3.0.0.rc"
require:
require:
- active_record
pg:
group:
pg:
group:
- :default
version: ">= 0"
haml:
group:
haml:
group:
- :default
version: ">= 0"
sqlite3-ruby:
group:
sqlite3-ruby:
group:
- :default
version: ">= 0"
rspec:
group:
rspec:
group:
- :test
version: ">= 0"
require:
require:
- spec/expectations
sinatra:
group:
sinatra:
group:
- :default
version: ">= 0"
factory_girl:
group:
factory_girl:
group:
- :test
version: ">= 0"
postgres:
group:
postgres:
group:
- :default
version: ">= 0"
cucumber:
group:
cucumber:
group:
- :test
version: ">= 0"
launchy:
group:
launchy:
group:
- :test
version: ">= 0"
capybara:
group:
capybara:
group:
- :test
version: ">= 0"
specs:
- rake:
specs:
- rake:
version: 0.8.7
- activesupport:
- activesupport:
version: 3.0.0.rc
- builder:
- builder:
version: 2.1.2
- i18n:
- i18n:
version: 0.4.1
- activemodel:
- activemodel:
version: 3.0.0.rc
- arel:
- arel:
version: 0.4.0
- tzinfo:
- tzinfo:
version: 0.3.23
- activerecord:
- activerecord:
version: 3.0.0.rc
- culerity:
- culerity:
version: 0.2.12
- mime-types:
- mime-types:
version: "1.16"
- nokogiri:
- nokogiri:
version: 1.4.3.1
- rack:
- rack:
version: 1.2.1
- rack-test:
- rack-test:
version: 0.5.4
- ffi:
- ffi:
version: 0.6.3
- json_pure:
- json_pure:
version: 1.4.6
- rubyzip:
- rubyzip:
version: 0.9.4
- selenium-webdriver:
- selenium-webdriver:
version: 0.0.28
- capybara:
- capybara:
version: 0.3.9
- configuration:
- configuration:
version: 1.1.0
- diff-lcs:
- diff-lcs:
version: 1.1.2
- trollop:
- trollop:
version: 1.16.2
- gherkin:
- gherkin:
version: 2.1.5
- term-ansicolor:
- term-ansicolor:
version: 1.0.5
- cucumber:
- cucumber:
version: 0.8.5
- factory_girl:
- factory_girl:
version: 1.3.2
- haml:
- haml:
version: 3.0.17
- launchy:
- launchy:
version: 0.3.7
- pg:
- pg:
version: 0.9.0
- postgres:
- postgres:
version: 0.7.9.2008.01.28
- rspec:
- rspec:
version: 1.3.0
- sinatra:
- sinatra:
version: "1.0"
- sqlite3-ruby:
- sqlite3-ruby:
version: 1.3.1
hash: afe5ad7afc4ebb3571d4f9fe29fbe336146055bc
sources:
- Rubygems:
sources:
- Rubygems:
uri: http://gemcutter.org
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace :db do
ActiveRecord::Migration.verbose = true
ActiveRecord::Migrator.migrate("db/migrate")
end

task(:rollback => :environment) do
require 'logger'
ActiveRecord::Base.logger = Logger.new(STDOUT)
Expand All @@ -24,7 +24,7 @@ desc 'Loads up this project\'s environment'
task :environment do
require File.join(File.dirname(__FILE__), 'environment')
end

desc 'Runs irb in this project\'s context'
task :irb do |t|
exec "irb -I lib -r '#{File.join(File.dirname(__FILE__), 'environment')}'"
Expand Down
4 changes: 2 additions & 2 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ development:
adapter: postgresql
user: user
database: dtc_dev

production:
adapter: sqlite3
database: db/production.sqlite.db

test:
adapter: sqlite3
database: db/test.sqlite.db
2 changes: 1 addition & 1 deletion db/migrate/001_create_cuddlers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def self.up
t.float :long
end
end

def self.down
drop_table :cuddlers
end
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/002_update_lat_and_long_columns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def self.up
change_column :cuddlers, :lat, :decimal, :scale => 14, :precision => 17
change_column :cuddlers, :long, :decimal, :scale => 14, :precision => 17
end

def self.down
change_column :cuddlers, :lat, :float
change_column :cuddlers, :long, :float
Expand Down
12 changes: 6 additions & 6 deletions environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$: << File.dirname(__FILE__)

class Environment

def self.reload!
[:models, :lib].each do |dir|
Dir[File.join(dir.to_s, '*')].each do |file|
Expand All @@ -16,26 +16,26 @@ def self.reload!
end
ActiveRecord::Base.establish_connection Config.database[ENV['RACK_ENV'].downcase.underscore]
end

module Config
class << self
def set(key, value)
@store ||= {}
@store[key.to_sym] = value
end

def get(key)
@store[key.to_sym]
end

def [](key)
get(key)
end

def []=(key, value)
set(key, value)
end

def method_missing(key)
get(key)
end
Expand Down
2 changes: 1 addition & 1 deletion features/hello_world.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Feature: Say Hello World!
In order to get a warm feeling
As a Sinatra and Cucumber User
I want to have a working installation

Scenario: Saying Hello!
When I go to "/"
Then I should see "Hello, world!" within "h1"
6 changes: 3 additions & 3 deletions features/step_definitions/web_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def with_scope(locator)
end
end
end

Then /^(?:|I )should be on "(.+)"$/ do |page_name|
current_path = URI.parse(current_url).path
if current_path.respond_to? :should
Expand All @@ -197,8 +197,8 @@ def with_scope(locator)
query = URI.parse(current_url).query
actual_params = query ? CGI.parse(query) : {}
expected_params = {}
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}

if actual_params.respond_to? :should
actual_params.should == expected_params
else
Expand Down
28 changes: 14 additions & 14 deletions lib/team_fun/form_builder.rb
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
class ::TeamFun::FormBuilder

attr_reader :template, :options, :object

def initialize(options, object, template)
@options, @object, @template = options, object, template
end

[:text, :email, :password].each do |name|
define_method name.to_s + '_field' do |field|
input name, field
end
end

def textarea(field)
"<textarea id='#{obj_id}_#{field.to_s}'" +\
"#{class_with_errors(field)} name='#{input_name(field)}'>"+\
"#{template.preserve object.send(field).to_s}</textarea>"
end

def input(type, field)
"<input id='#{obj_id}_#{field.to_s}'" +\
"#{class_with_errors(field)} name='#{input_name(field)}'"+\
" value='#{object.send(field).to_s}' type='#{type}' />"
end

def submit_button(text=nil)
"<button type='submit'>#{text||save_text}</button>"
end

def label(field, text=nil)
"<label for='#{obj_id}_#{field.to_s}'#{class_with_errors(field)}>#{text||field.to_s.humanize}</label>"
end

private

def class_with_errors(field)
" class='error'" if object.errors[field]
end

def obj_id
@obj_id ||= "#{object_name}#{'_'+object.id.to_s unless object.new_record?}"
end

def object_name
@object_name ||= object.class.name.underscore
end

def input_name(field)
object_name+"[#{field.to_s}]"
end

def save_text
object.new_record? ? 'Create' : 'Update'
end

end
Loading