Skip to content

Commit

Permalink
update ruby, run rubocop, add coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
msimonborg committed May 8, 2017
1 parent 6321a7a commit 4544cd4
Show file tree
Hide file tree
Showing 32 changed files with 150 additions and 37 deletions.
12 changes: 12 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
AllCops:
TargetRubyVersion: 2.4.1

Style/DotPosition:
EnforcedStyle: trailing

Expand Down Expand Up @@ -26,3 +29,12 @@ Style/Documentation:
- 'spec/**/*'
- 'test/**/*'
- 'db/**/*'

Lint/AmbiguousBlockAssociation:
Exclude:
- 'app/models/*'

Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%i': '[]'
'%w': '[]'
2 changes: 1 addition & 1 deletion .ruby-gemset
Original file line number Diff line number Diff line change
@@ -1 +1 @@
learn-co
rate-your-rep
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.3.3
ruby-2.4.1
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
language: ruby

rvm:
- 2.4.1

sudo: false

cache: bundler

bundler_args: --without development --retry=3 --jobs=3

before_install:
- gem update --system
- gem install bundler
- gem update bundler

notifications:
email:
on_success: change
on_failure: always
30 changes: 17 additions & 13 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
# frozen_string_literal: true

source 'http://rubygems.org'

ruby '2.3.3'
ruby '2.4.1'

gem 'sinatra'
gem 'activerecord', require: 'active_record'
gem 'sinatra-activerecord', require: 'sinatra/activerecord'
gem 'rake'
gem 'require_all'
gem 'activerecord', '~> 5.1.0', require: 'active_record'
gem 'bcrypt'
gem 'rack-flash3'
gem 'httparty'
gem 'tux'
gem 'pyr', '~> 0.1.0'
gem 'rack-flash3'
gem 'rake'
gem 'require_all'
gem 'sinatra'
gem 'sinatra-activerecord', require: 'sinatra/activerecord'
gem 'tux'

group :development, :test do
gem 'sqlite3'
gem 'thin'
gem 'coveralls', '~> 0.8.0', require: false
gem 'pry', '~> 0.10.4'
gem 'rubocop', '~> 0.48.0', '>= 0.48.1'
gem 'shotgun'
gem 'pry'
gem 'simplecov', '~> 0.14.0', require: false
gem 'sqlite3', platform: %i[ruby mswin mingw]
gem 'thin'
end

group :test do
gem 'rspec'
gem 'capybara'
gem 'rack-test'
gem 'database_cleaner', git: 'https://github.com/bmabey/database_cleaner.git'
gem 'rack-test'
gem 'rspec'
end

group :production do
Expand Down
66 changes: 50 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ GIT
GEM
remote: http://rubygems.org/
specs:
activemodel (5.0.1)
activesupport (= 5.0.1)
activerecord (5.0.1)
activemodel (= 5.0.1)
activesupport (= 5.0.1)
arel (~> 7.0)
activesupport (5.0.1)
activemodel (5.1.0)
activesupport (= 5.1.0)
activerecord (5.1.0)
activemodel (= 5.1.0)
activesupport (= 5.1.0)
arel (~> 8.0)
activesupport (5.1.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
arel (7.1.4)
arel (8.0.0)
ast (2.3.0)
bcrypt (3.1.11)
bond (0.5.1)
capybara (2.12.1)
Expand All @@ -31,13 +32,21 @@ GEM
rack-test (>= 0.5.4)
xpath (~> 2.0)
coderay (1.1.1)
concurrent-ruby (1.0.4)
concurrent-ruby (1.0.5)
coveralls (0.8.21)
json (>= 1.8, < 3)
simplecov (~> 0.14.1)
term-ansicolor (~> 1.3)
thor (~> 0.19.4)
tins (~> 1.6)
daemons (1.2.4)
diff-lcs (1.3)
docile (1.1.5)
eventmachine (1.2.2)
httparty (0.14.0)
multi_xml (>= 0.5.2)
i18n (0.8.0)
i18n (0.8.1)
json (2.1.0)
lazy_record (0.3.0)
activesupport
method_source (0.8.2)
Expand All @@ -49,7 +58,10 @@ GEM
multi_xml (0.6.0)
nokogiri (1.7.0.1)
mini_portile2 (~> 2.1.0)
parser (2.4.0.0)
ast (~> 2.2)
pg (0.19.0)
powerpack (0.1.1)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
Expand All @@ -66,6 +78,8 @@ GEM
rack
rack-test (0.6.3)
rack (>= 1.0)
rainbow (2.2.2)
rake
rake (12.0.0)
require_all (1.4.0)
ripl (0.7.1)
Expand All @@ -89,8 +103,20 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
rubocop (0.48.1)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
shotgun (0.9.2)
rack (>= 1.0)
simplecov (0.14.1)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
sinatra (1.4.8)
rack (~> 1.5)
rack-protection (~> 1.4)
Expand All @@ -100,49 +126,57 @@ GEM
sinatra (>= 1.0)
slop (3.6.0)
sqlite3 (1.3.13)
term-ansicolor (1.6.0)
tins (~> 1.0)
thin (1.7.0)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thread_safe (0.3.5)
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.6)
tins (1.13.2)
tux (0.3.0)
ripl (>= 0.3.5)
ripl-multi_line (>= 0.2.4)
ripl-rack (>= 0.2.0)
sinatra (>= 1.2.1)
tzinfo (1.2.2)
tzinfo (1.2.3)
thread_safe (~> 0.1)
unicode-display_width (1.2.1)
xpath (2.0.0)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
activerecord
activerecord (~> 5.1.0)
bcrypt
capybara
coveralls (~> 0.8.0)
database_cleaner!
httparty
pg
pry
pry (~> 0.10.4)
puma
pyr (~> 0.1.0)
rack-flash3
rack-test
rake
require_all
rspec
rubocop (~> 0.48.0, >= 0.48.1)
shotgun
simplecov (~> 0.14.0)
sinatra
sinatra-activerecord
sqlite3
thin
tux

RUBY VERSION
ruby 2.3.3p222
ruby 2.4.1p111

BUNDLED WITH
1.13.6
1.14.6
7 changes: 5 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# frozen_string_literal: true

ENV['SINATRA_ENV'] ||= 'development'

require_relative './config/environment'
require 'sinatra/activerecord/rake'

begin
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

task default: :spec
require 'rubocop/rake_task'
RuboCop::RakeTask.new

task default: %i[spec rubocop]
rescue LoadError
# no rspec available
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require './config/environment'
require 'rack-flash'
# Main app controller
Expand Down
1 change: 1 addition & 0 deletions app/models/office_location.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# The OfficeLocation has the phone data and is the object on which
# a call is made.
class OfficeLocation < ActiveRecord::Base
Expand Down
5 changes: 4 additions & 1 deletion app/models/rep.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Rep object is created from data retrieved by an API call
class Rep < ActiveRecord::Base
include APIFindable
Expand Down Expand Up @@ -36,7 +37,9 @@ class Rep < ActiveRecord::Base
scope :democratic, -> { where party_identification: 'Democrat' }
scope :republican, -> { where party_identification: 'Republican' }
scope :senators, -> { where honorific_prefix: 'United States Senator' }
scope :representatives, -> { where honorific_prefix: 'United States Representative' }
scope :representatives, -> {
where honorific_prefix: 'United States Representative'
}

def office_locations_count
office_locations.count
Expand Down
1 change: 1 addition & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require './config/environment'

if ActiveRecord::Migrator.needs_migration?
Expand Down
13 changes: 10 additions & 3 deletions config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
# frozen_string_literal: true

ENV['SINATRA_ENV'] ||= 'development'

require 'bundler/setup'
Bundler.require(:default, ENV['SINATRA_ENV'])

if development?
if production?
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
elsif test?
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: ':memory:',
timeout: 500
)
else
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: "db/#{ENV['SINATRA_ENV']}.sqlite"
)
elsif production?
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
end

require_all 'app'
Binary file modified db/development.sqlite
Binary file not shown.
1 change: 1 addition & 0 deletions db/migrate/20170220034533_create_users.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class CreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20170220143228_create_reps.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class CreateReps < ActiveRecord::Migration[5.0]
def change
create_table :reps do |t|
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20170220145933_create_office_locations.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class CreateOfficeLocations < ActiveRecord::Migration[5.0]
def change
create_table :office_locations do |t|
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20170220153558_create_calls.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class CreateCalls < ActiveRecord::Migration[5.0]
def change
create_table :calls do |t|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class AddColumnsToOfficeLocations < ActiveRecord::Migration[5.0]
def change
add_column :office_locations, :phone, :string
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20170221004104_add_slug_to_users.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class AddSlugToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :slug, :string
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20170228125359_add_columns_to_reps.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class AddColumnsToReps < ActiveRecord::Migration[5.0]
def change
add_column :reps, :state, :string
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20170328220009_add_active_column_to_reps.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class AddActiveColumnToReps < ActiveRecord::Migration[5.0]
def change
add_column :reps, :active, :boolean, default: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class AddActiveColumnToOfficeLocations < ActiveRecord::Migration[5.0]
def change
add_column :office_locations, :active, :boolean, default: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class AddOfficeIdToOfficeLocations < ActiveRecord::Migration[5.0]
def change
add_column :office_locations, :office_id, :string
Expand Down
Loading

0 comments on commit 4544cd4

Please sign in to comment.