Skip to content

Commit

Permalink
rubocop auto correct
Browse files Browse the repository at this point in the history
  • Loading branch information
vanakenm committed Dec 25, 2017
1 parent 2ac1653 commit 907f711
Show file tree
Hide file tree
Showing 19 changed files with 101 additions and 109 deletions.
16 changes: 8 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'

git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
"https://github.com/#{repo_name}.git"
end

Expand All @@ -14,13 +14,13 @@ gem 'pg_search'
gem 'omniauth'
gem 'omniauth-slack'

gem 'bcrypt'
gem 'bootstrap-sass', '~> 3.3.7'
gem 'devise'
gem 'httparty'
gem 'figaro'
gem 'twitter'
gem 'bootstrap-sass', '~> 3.3.7'
gem 'httparty'
gem 'jquery-rails'
gem 'bcrypt'
gem 'twitter'

# Use Puma as the app server
gem 'puma', '~> 3.7'
Expand All @@ -47,20 +47,20 @@ gem 'jbuilder', '~> 2.5'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'byebug', platforms: %i[mri mingw x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'web-console', '>= 3.3.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
5 changes: 2 additions & 3 deletions app/controllers/effin_quotes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ def logs
@logs = EffinLog.all
end

def home
end
def home; end

def check
@quote = EffinQuote.incomplete.first
Expand Down Expand Up @@ -49,6 +48,6 @@ def destroy
end

def quote_params
params.require(:effin_quote).permit(:contents)
params.require(:effin_quote).permit(:contents)
end
end
48 changes: 23 additions & 25 deletions app/controllers/oauth_controller.rb
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
class OauthController < ApplicationController
def authorize
options = {
site: 'https://slack.com/oauth/authorize'
}
client ||= OAuth2::Client.new(
'12060783617.285877762837',
ENV('SLACK_CLIENT_SECRET'),
options
)
params = {
scope: 'commands',
redirect_uri: 'https://www.effinbot.com/oauth/callback'
}
redirect_to client.auth_code.authorize_url(params)
end

def success
def authorize
options = {
site: 'https://slack.com/oauth/authorize'
}
client ||= OAuth2::Client.new(
'12060783617.285877762837',
ENV('SLACK_CLIENT_SECRET'),
options
)
params = {
scope: 'commands',
redirect_uri: 'https://www.effinbot.com/oauth/callback'
}
redirect_to client.auth_code.authorize_url(params)
end

def error
end
def success; end

def error; end

def authorize_callback
code = params["code"]
def authorize_callback
code = params['code']
puts code
response = HTTParty.get("https://slack.com/api/oauth.access?code=#{code}&client_id=12060783617.285877762837&client_secret=#{ENV['SLACK_CLIENT_SECRET']}")

if response["ok"] && response["ok"] == true
redirect_to '/success'
if response['ok'] && response['ok'] == true
redirect_to '/success'
else
redirect_to '/error'
redirect_to '/error'
end
end
end
end
6 changes: 3 additions & 3 deletions app/models/effin_quote.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
class EffinQuote < ApplicationRecord
include PgSearch
pg_search_scope :search_by_word, against: [ :contents ]
pg_search_scope :search_by_word, against: [:contents]

def complete?
url && twitter_url && contents
end

def self.complete
where("url is not null and twitter_url is not null and contents is not null")
where('url is not null and twitter_url is not null and contents is not null')
end

def self.incomplete
where("url is null or twitter_url is null or contents is null")
where('url is null or twitter_url is null or contents is null')
end

def self.find_by_word(word)
Expand Down
2 changes: 1 addition & 1 deletion app/views/effin_quotes/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1 +1 @@
json.extract! @quote, :id, :contents, :url, :twitter_url
json.extract! @quote, :id, :contents, :url, :twitter_url
1 change: 0 additions & 1 deletion bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ chdir APP_ROOT do
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')


# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
Expand Down
2 changes: 1 addition & 1 deletion bin/spring
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ unless defined?(Spring)
require 'bundler'

lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
spring = lockfile.specs.detect { |spec| spec.name == "spring" }
spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
if spring
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
gem 'spring', spring.version
Expand Down
6 changes: 3 additions & 3 deletions bin/yarn
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
VENDOR_PATH = File.expand_path('..', __dir__)
Dir.chdir(VENDOR_PATH) do
begin
exec "yarnpkg #{ARGV.join(" ")}"
exec "yarnpkg #{ARGV.join(' ')}"
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
$stderr.puts 'Yarn executable was not detected in the system.'
$stderr.puts 'Download Yarn at https://yarnpkg.com/en/docs/install'
exit 1
end
end
4 changes: 2 additions & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
config.log_level = :debug

# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
config.log_tags = [:request_id]

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
Expand Down Expand Up @@ -80,7 +80,7 @@
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV["RAILS_LOG_TO_STDOUT"].present?
if ENV['RAILS_LOG_TO_STDOUT'].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
Expand Down
6 changes: 3 additions & 3 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
threads threads_count, threads_count

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
port ENV.fetch('PORT') { 3000 }

# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
environment ENV.fetch('RAILS_ENV') { 'development' }

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
Expand Down
10 changes: 5 additions & 5 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Rails.application.routes.draw do
devise_for :users
root to: "effin_quotes#home"
root to: 'effin_quotes#home'

get 'commands/create'
get '/authorize', to: 'oauth#authorize'
get '/oauth/callback', to: 'oauth#authorize_callback'
get '/authorize', to: 'oauth#authorize'
get '/oauth/callback', to: 'oauth#authorize_callback'
get '/success', to: 'oauth#success'
get '/error', to: 'oauth#error'

resources :effin_quotes, only: [:index, :show, :destroy, :update] do
resources :effin_quotes, only: %i[index show destroy update] do
collection do
get :find
get :incomplete
Expand Down
4 changes: 2 additions & 2 deletions config/spring.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%w(
%w[
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
).each { |path| Spring.watch(path) }
].each { |path| Spring.watch(path) }
14 changes: 7 additions & 7 deletions db/from_tweets.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV("TWITTER_CONSUMER_KEY")
config.consumer_secret = ENV("TWITTER_CONSUMER_SECRET")
config.access_token = ENV("TWITTER_ACCESS_TOKEN")
config.access_token_secret = ENV("TWITTER_ACCESS_TOKEN_SECRET")
config.consumer_key = ENV('TWITTER_CONSUMER_KEY')
config.consumer_secret = ENV('TWITTER_CONSUMER_SECRET')
config.access_token = ENV('TWITTER_ACCESS_TOKEN')
config.access_token_secret = ENV('TWITTER_ACCESS_TOKEN_SECRET')
end

tweets = client.get_all_tweets("effinbirds")
tweets = client.get_all_tweets('effinbirds')

raw = tweets.map do |t|
next unless t.media && t.media.first && t.media.first.uri
Expand All @@ -21,15 +21,15 @@
EffinQuote.create(url: r.first.to_s, twitter_url: r.second.to_s)
end

def collect_with_max_id(collection=[], max_id=nil, &block)
def collect_with_max_id(collection = [], max_id = nil, &block)
response = yield(max_id)
collection += response
response.empty? ? collection.flatten : collect_with_max_id(collection, response.last.id - 1, &block)
end

def client.get_all_tweets(user)
collect_with_max_id do |max_id|
options = {count: 200, include_rts: true}
options = { count: 200, include_rts: true }
options[:max_id] = max_id unless max_id.nil?
user_timeline(user, options)
end
Expand Down
5 changes: 2 additions & 3 deletions db/migrate/20171220175659_devise_create_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class DeviseCreateUsers < ActiveRecord::Migration[5.1]
def change
create_table :users do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
t.string :email, null: false, default: ''
t.string :encrypted_password, null: false, default: ''

## Recoverable
t.string :reset_password_token
Expand All @@ -30,7 +30,6 @@ def change
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at


t.timestamps null: false
end

Expand Down
65 changes: 32 additions & 33 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,44 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20171221102153) do

ActiveRecord::Schema.define(version: 20_171_221_102_153) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension 'plpgsql'

create_table "effin_logs", force: :cascade do |t|
t.bigint "effin_quote_id"
t.string "text"
t.boolean "random"
t.string "team_doman"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["effin_quote_id"], name: "index_effin_logs_on_effin_quote_id"
create_table 'effin_logs', force: :cascade do |t|
t.bigint 'effin_quote_id'
t.string 'text'
t.boolean 'random'
t.string 'team_doman'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.index ['effin_quote_id'], name: 'index_effin_logs_on_effin_quote_id'
end

create_table "effin_quotes", force: :cascade do |t|
t.string "contents"
t.string "url"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "twitter_url"
create_table 'effin_quotes', force: :cascade do |t|
t.string 'contents'
t.string 'url'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.string 'twitter_url'
end

create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.inet "current_sign_in_ip"
t.inet "last_sign_in_ip"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
create_table 'users', force: :cascade do |t|
t.string 'email', default: '', null: false
t.string 'encrypted_password', default: '', null: false
t.string 'reset_password_token'
t.datetime 'reset_password_sent_at'
t.datetime 'remember_created_at'
t.integer 'sign_in_count', default: 0, null: false
t.datetime 'current_sign_in_at'
t.datetime 'last_sign_in_at'
t.inet 'current_sign_in_ip'
t.inet 'last_sign_in_ip'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
t.index ['email'], name: 'index_users_on_email', unique: true
t.index ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true
end

add_foreign_key "effin_logs", "effin_quotes"
add_foreign_key 'effin_logs', 'effin_quotes'
end
4 changes: 2 additions & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# {
# contents: "got it you're dim",
# url: "https://pbs.twimg.com/media/DQ117aPW4AEmnWF.jpg"
# },
# },
# {
# contents: "where is your fucking brain",
# url: "https://pbs.twimg.com/media/DQxjO2fWsAEFIMd.jpg"
Expand All @@ -23,4 +23,4 @@
# contents: "I am not your fucking mom",
# url: "https://pbs.twimg.com/media/DQwsRAzXcAAIV-n.jpg"
# }
# ])
# ])
Loading

0 comments on commit 907f711

Please sign in to comment.