Skip to content

Commit

Permalink
rubocop -a & bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jasl committed Oct 4, 2017
1 parent 416f6bc commit 35b8154
Show file tree
Hide file tree
Showing 43 changed files with 135 additions and 63 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
source 'https://rubygems.org'
# frozen_string_literal: true

source "https://rubygems.org"

# Declare your gem's dependencies in options_model.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
Expand Down
32 changes: 14 additions & 18 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
# frozen_string_literal: true

begin
require 'bundler/setup'
require "bundler/setup"
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
end

require 'rdoc/task'
require "rdoc/task"

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'OptionsModel'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.md')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_dir = "rdoc"
rdoc.title = "OptionsModel"
rdoc.options << "--line-numbers"
rdoc.rdoc_files.include("README.md")
rdoc.rdoc_files.include("lib/**/*.rb")
end

require "bundler/gem_tasks"





require 'bundler/gem_tasks'

require 'rake/testtask'
require "rake/testtask"

Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.libs << "test"
t.pattern = "test/**/*_test.rb"
t.verbose = false
end


task default: :test
2 changes: 2 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

$: << File.expand_path(File.expand_path("../../test", __FILE__))

require "bundler/setup"
Expand Down
3 changes: 2 additions & 1 deletion lib/options_model.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_model"
require "active_model/type"

Expand All @@ -9,5 +11,4 @@
require "options_model/base"

module OptionsModel

end
2 changes: 2 additions & 0 deletions lib/options_model/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module OptionsModel
class Base
include ActiveModel::Model
Expand Down
2 changes: 2 additions & 0 deletions lib/options_model/concerns/attribute_assignment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module OptionsModel
module Concerns
module AttributeAssignment
Expand Down
2 changes: 2 additions & 0 deletions lib/options_model/concerns/attributes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module OptionsModel
module Concerns
module Attributes
Expand Down
2 changes: 2 additions & 0 deletions lib/options_model/concerns/name_hacking.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module OptionsModel
module Concerns
module NameHacking
Expand Down
8 changes: 6 additions & 2 deletions lib/options_model/concerns/serialization.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module OptionsModel
module Concerns
module Serialization
Expand All @@ -8,9 +10,11 @@ def to_h

hash.merge! unused_attributes if self.class.with_unused_attributes?
self.class.attribute_names_for_inlining.each do |name|
hash[name] = send(:"#{name}")
hash[name] = send(name)
end
self.class.attribute_names_for_nesting.each do |name|
hash[name] = send(name).to_h
end
hash.merge! nested_attributes.reduce({}) { |h, (k, v)| h[k] = v.to_h; h }

hash
end
Expand Down
2 changes: 2 additions & 0 deletions lib/options_model/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module OptionsModel
VERSION = "0.0.5".freeze
end
1 change: 1 addition & 0 deletions lib/tasks/options_model_tasks.rake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# desc "Explaining what the task does"
# task :options_model do
# # Task goes here
Expand Down
2 changes: 2 additions & 0 deletions options_model.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$:.push File.expand_path("../lib", __FILE__)

# Maintain your gem's version:
Expand Down
4 changes: 3 additions & 1 deletion test/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'
require_relative "config/application"

Rails.application.load_tasks
2 changes: 2 additions & 0 deletions test/dummy/app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
end
2 changes: 2 additions & 0 deletions test/dummy/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module ApplicationHelper
end
2 changes: 2 additions & 0 deletions test/dummy/app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
end
6 changes: 4 additions & 2 deletions test/dummy/bin/bundle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
# frozen_string_literal: true

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
load Gem.bin_path("bundler", "bundle")
8 changes: 5 additions & 3 deletions test/dummy/bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
# frozen_string_literal: true

APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
6 changes: 4 additions & 2 deletions test/dummy/bin/rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
# frozen_string_literal: true

require_relative "../config/boot"
require "rake"
Rake.application.run
19 changes: 10 additions & 9 deletions test/dummy/bin/setup
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
# frozen_string_literal: true

require "pathname"
require "fileutils"
include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
APP_ROOT = Pathname.new File.expand_path("../../", __FILE__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
Expand All @@ -14,17 +16,16 @@ chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "== Installing dependencies =="
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")

# Install JavaScript dependencies if using Yarn
# system('bin/yarn')


puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
system! "bin/rails log:clear tmp:clear"

puts "\n== Restarting application server =="
system! 'bin/rails restart'
system! "bin/rails restart"
end
18 changes: 10 additions & 8 deletions test/dummy/bin/update
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
# frozen_string_literal: true

require "pathname"
require "fileutils"
include FileUtils

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
APP_ROOT = Pathname.new File.expand_path("../../", __FILE__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
Expand All @@ -14,13 +16,13 @@ chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "== Installing dependencies =="
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
system! "bin/rails log:clear tmp:clear"

puts "\n== Restarting application server =="
system! 'bin/rails restart'
system! "bin/rails restart"
end
4 changes: 3 additions & 1 deletion test/dummy/bin/yarn
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env ruby
VENDOR_PATH = File.expand_path('..', __dir__)
# frozen_string_literal: true

VENDOR_PATH = File.expand_path("..", __dir__)
Dir.chdir(VENDOR_PATH) do
begin
exec "yarnpkg #{ARGV.join(" ")}"
Expand Down
4 changes: 3 additions & 1 deletion test/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

# This file is used by Rack-based servers to start the application.

require_relative 'config/environment'
require_relative "config/environment"

run Rails.application
5 changes: 3 additions & 2 deletions test/dummy/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require_relative 'boot'
# frozen_string_literal: true

require_relative "boot"

# Pick the frameworks you want:
# require "active_record/railtie"
Expand All @@ -23,4 +25,3 @@ class Application < Rails::Application
# -- all .rb files in that directory are automatically loaded.
end
end

8 changes: 5 additions & 3 deletions test/dummy/config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)

require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
4 changes: 3 additions & 1 deletion test/dummy/config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

# Load the Rails application.
require_relative 'application'
require_relative "application"

# Initialize the Rails application.
Rails.application.initialize!
7 changes: 4 additions & 3 deletions test/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

Expand All @@ -13,12 +15,12 @@
config.consider_all_requests_local = true

# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
if Rails.root.join("tmp/caching-dev.txt").exist?
config.action_controller.perform_caching = true

config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
"Cache-Control" => "public, max-age=#{2.days.seconds.to_i}"
}
else
config.action_controller.perform_caching = false
Expand All @@ -29,7 +31,6 @@
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log


# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true

Expand Down
5 changes: 3 additions & 2 deletions test/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

Expand All @@ -21,8 +23,7 @@

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
Expand Down
4 changes: 3 additions & 1 deletion test/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

Expand All @@ -15,7 +17,7 @@
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
"Cache-Control" => "public, max-age=#{1.hour.seconds.to_i}"
}

# Show full error reports and disable caching.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.

# ApplicationController.renderer.defaults.merge!(
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/initializers/backtrace_silencers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.

# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
Expand Down
Loading

0 comments on commit 35b8154

Please sign in to comment.