Skip to content

Commit

Permalink
Merge branch 'rubocop2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanstout committed May 6, 2015
2 parents 147fc94 + b41d947 commit 47bed5a
Show file tree
Hide file tree
Showing 152 changed files with 533 additions and 654 deletions.
56 changes: 56 additions & 0 deletions .rubocop.yml
@@ -1,3 +1,54 @@
AllCops:
Include:
- "**/*.gemspec"
- "**/*.podspec"
- "**/*.jbuilder"
- "**/*.rake"
- "**/*.opal"
- "**/Gemfile"
- "**/Rakefile"
- "**/Capfile"
- "**/Guardfile"
- "**/Podfile"
- "**/Thorfile"
- "**/Vagrantfile"
- "**/Berksfile"
- "**/Cheffile"
- "**/Vagabondfile"
Exclude:
- "vendor/**/*"
- "db/schema.rb"
RunRailsCops: false
DisplayCopNames: false
StyleGuideCopsOnly: false


Style/AccessModifierIndentation:
Description: Check indentation of private/protected visibility modifiers.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#indent-public-private-protected
Enabled: true
EnforcedStyle: indent
SupportedStyles:
- outdent
- indent

# Metrics/LineLength:
# Description: Limit lines to 80 characters.
# StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
# Enabled: false
# Max: 80
# AllowURI: true
# URISchemes:
# - http
# - https
# Style/GlobalVars:
# Description: Do not introduce global variables.
# StyleGuide: https://github.com/bbatsov/ruby-style-guide#instance-vars
# Enabled: false
# AllowedVariables: []

# ^ From hound

Style/Documentation:
Enabled: false

Expand All @@ -12,3 +63,8 @@ UnderscorePrefixedVariableName:

UnusedBlockArgument:
Enabled: false

Lint/UselessAssignment:
Description: Checks for useless assignment to a local variable.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars
Enabled: false
1 change: 0 additions & 1 deletion Rakefile
Expand Up @@ -19,7 +19,6 @@ Opal::RSpec::RakeTask.new('opal:rspec') do |s|
s.append_path('app')
end


task default: [:test]

require 'rspec/core/rake_task'
Expand Down
4 changes: 1 addition & 3 deletions app/volt/models/user.rb
@@ -1,6 +1,4 @@
unless RUBY_PLATFORM == 'opal'
require 'bcrypt'
end
require 'bcrypt' unless RUBY_PLATFORM == 'opal'

module Volt
class User < Model
Expand Down
2 changes: 1 addition & 1 deletion app/volt/tasks/live_query/live_query.rb
Expand Up @@ -129,6 +129,6 @@ def model_for_filter(data)
end

def inspect
"<#{self.class.to_s} #{@collection}: #{@query.inspect}>"
"<#{self.class} #{@collection}: #{@query.inspect}>"
end
end
7 changes: 3 additions & 4 deletions app/volt/tasks/store_tasks.rb
Expand Up @@ -50,10 +50,9 @@ def save(collection, path, data)
# who sent the update.
#
# return another promise
return promise.then do |model|
promise.then do |model|
Thread.current['in_channel'] = @channel
save_promise = model.save!.then do |result|

next nil
end.fail do |err|
# An error object, convert to hash
Expand All @@ -79,12 +78,12 @@ def delete(collection, id)
if model.can_delete?
db.delete('_id' => id)
else
raise "Permissions did not allow #{collection} #{id} to be deleted."
fail "Permissions did not allow #{collection} #{id} to be deleted."
end

QueryTasks.live_query_pool.updated_collection(collection, @channel)
else
raise "Could not find #{id} in #{collection}"
fail "Could not find #{id} in #{collection}"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/volt/tasks/user_tasks.rb
Expand Up @@ -34,4 +34,4 @@ def login(login_info)
def salty_user_id(user_id)
"#{Volt.config.app_secret}::#{user_id}"
end
end
end
8 changes: 2 additions & 6 deletions lib/volt.rb
Expand Up @@ -7,9 +7,7 @@
require 'volt/utils/boolean_patch'

require 'volt/config'
unless RUBY_PLATFORM == 'opal'
require 'volt/data_stores/data_store'
end
require 'volt/data_stores/data_store' unless RUBY_PLATFORM == 'opal'
require 'volt/volt/users'

module Volt
Expand All @@ -23,9 +21,7 @@ module Volt

class << self
def root
if self.client?
raise "Volt.root can not be called from the client."
end
fail 'Volt.root can not be called from the client.' if self.client?
@root ||= File.expand_path(Dir.pwd)
end

Expand Down
2 changes: 0 additions & 2 deletions lib/volt/boot.rb
Expand Up @@ -21,6 +21,4 @@ def self.boot(app_path)
# Boot the app
App.new(app_path)
end


end
1 change: 0 additions & 1 deletion lib/volt/cli.rb
Expand Up @@ -72,7 +72,6 @@ def server
server.timeout = 0
end
end

end

desc 'runner FILEPATH', 'Runs a ruby file at FILEPATH in the volt app'
Expand Down
2 changes: 0 additions & 2 deletions lib/volt/cli/asset_compile.rb
Expand Up @@ -19,7 +19,6 @@ def compile
require 'volt/volt/core'
require 'volt/boot'


@root_path ||= Dir.pwd
Volt.root = @root_path

Expand All @@ -31,7 +30,6 @@ def compile
require 'volt/server/rack/index_files'
require 'volt/server/component_handler'


@app_path = File.expand_path(File.join(@root_path, 'app'))

@component_paths = ComponentPaths.new(@root_path)
Expand Down
7 changes: 3 additions & 4 deletions lib/volt/cli/console.rb
Expand Up @@ -9,13 +9,13 @@ def repl
loop do
case val = read
when :control_c
output.puts ""
output.puts ''
pry.reset_eval_string
when :no_more_input
output.puts "" if output.tty?
output.puts '' if output.tty?
break
else
output.puts "" if val.nil? && output.tty?
output.puts '' if val.nil? && output.tty?
return pry.exit_value unless pry.eval(val)
end

Expand All @@ -39,7 +39,6 @@ def page
end
end


def self.start
require 'pry'

Expand Down
7 changes: 3 additions & 4 deletions lib/volt/cli/generate.rb
Expand Up @@ -22,7 +22,6 @@ def component(name)
directory('component_specs', component_spec_folder)
end


desc 'gem GEM', 'Creates a component gem where you can share a component'
method_option :bin, type: :boolean, default: false, aliases: '-b', banner: 'Generate a binary for your library.'
method_option :test, type: :string, lazy_default: 'rspec', aliases: '-t', banner: "Generate a test directory for your library: 'rspec' is the default, but 'minitest' is also supported."
Expand All @@ -35,7 +34,7 @@ def gem(name)
require 'volt/cli/new_gem'

if name =~ /[-]/
Volt.logger.error("Gem names should use underscores for their names. Currently volt only supports a single namespace for a component.")
Volt.logger.error('Gem names should use underscores for their names. Currently volt only supports a single namespace for a component.')
return
end

Expand Down Expand Up @@ -68,7 +67,7 @@ def controller(name, component = 'main')
spec_file = Dir.pwd + "/spec/app/#{component.underscore}/integration/#{name.underscore.pluralize}_spec.rb"

template('controller/model_controller.rb.tt', output_file, component_module: component.camelize, model_controller_name: controller_name.camelize)
template('controller/model_controller_spec.rb.tt', spec_file, describe: name.underscore.pluralize )
template('controller/model_controller_spec.rb.tt', spec_file, describe: name.underscore.pluralize)
end

desc 'task NAME COMPONENT', 'Creates a task named NAME in the app folder of the component named COMPONENT.'
Expand Down Expand Up @@ -96,6 +95,6 @@ def view(name, component = 'main')

def controller_exists?(name, component = 'main')
dir = Dir.pwd + "/app/#{component}/controllers/"
File.exists?(dir + name.downcase.underscore.singularize + '.rb')
File.exist?(dir + name.downcase.underscore.singularize + '.rb')
end
end
4 changes: 1 addition & 3 deletions lib/volt/cli/new_gem.rb
Expand Up @@ -56,9 +56,7 @@ def copy_files
end

def copy_options
if @options[:bin]
copy('newgem/bin/newgem.tt', "bin/#{@name}")
end
copy('newgem/bin/newgem.tt', "bin/#{@name}") if @options[:bin]
case @options[:test]
when 'rspec'
copy('newgem/rspec.tt', '.rspec')
Expand Down
12 changes: 6 additions & 6 deletions lib/volt/controllers/actions.rb
Expand Up @@ -12,7 +12,7 @@ module Volt
module Actions
# StopChainException inherits from Exception directly so it will not be handled by a
# default rescue.
class StopChainException < Exception ; end
class StopChainException < Exception; end

module ClassMethods
# Takes a list of action groups (as symbols). An action group is typically used for before/after, but
Expand All @@ -29,7 +29,7 @@ def setup_action_helpers_in_class(*groups)
# Add the block in place of the symbol
args.unshift(block) if block

raise "No callback symbol or block provided" unless args[0]
fail 'No callback symbol or block provided' unless args[0]

callbacks = send(callbacks_var_name)

Expand Down Expand Up @@ -75,14 +75,15 @@ def run_actions(group, action)
# raise an exception under the hood which will stop the chain and evaluation
# from where stop_chain is called.
def stop_chain
raise StopChainException
fail StopChainException
end

def self.included(base)
base.send :extend, ClassMethods
end

private

# TODO: currently we filter during the call, we could maybe improve performance
# here by storing by action and having an all category as well.
def filter_actions_by_only_exclude(callbacks, action)
Expand All @@ -94,8 +95,7 @@ def filter_actions_by_only_exclude(callbacks, action)
# If no only, include it
true
end
end.map {|v| v[0] }
end.map { |v| v[0] }
end

end
end
end
12 changes: 4 additions & 8 deletions lib/volt/controllers/model_controller.rb
Expand Up @@ -50,7 +50,7 @@ def model=(val)

val.then do |result|
# Only assign if nothing else has been assigned since we started the resolve
self.model = result if self.last_promise == val
self.model = result if last_promise == val
end.fail do |err|
Volt.logger.error("Unable to resolve promise assigned to model on #{inspect}")
end
Expand Down Expand Up @@ -80,9 +80,7 @@ def model
model = self.current_model

# If the model is a proc, call it now
if model && model.is_a?(Proc)
model = model.call
end
model = model.call if model && model.is_a?(Proc)

model
end
Expand All @@ -106,9 +104,7 @@ def initialize(*args)
self.attrs = args[0]

# If a model attribute is passed in, we assign it directly
if attrs.respond_to?(:model)
self.model = attrs.locals[:model]
end
self.model = attrs.locals[:model] if attrs.respond_to?(:model)
end
end

Expand Down Expand Up @@ -191,7 +187,7 @@ def loaded?
end
end

def require_login(message="You must login to access this area.")
def require_login(message = 'You must login to access this area.')
unless Volt.current_user_id
flash._notices << message
go '/login'
Expand Down
3 changes: 1 addition & 2 deletions lib/volt/data_stores/base.rb
@@ -1,7 +1,6 @@
module Volt
class DataStore
class Base

end
end
end
end
4 changes: 2 additions & 2 deletions lib/volt/data_stores/data_store.rb
Expand Up @@ -10,10 +10,10 @@ def self.fetch
driver_name = database_name.camelize + 'Driver'

begin
driver = self.const_get(driver_name)
driver = const_get(driver_name)
@driver = MongoDriver.new
rescue NameError => e
fail "#{database_name} is not a supported database"
raise "#{database_name} is not a supported database"
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/volt/data_stores/mongo_driver.rb
Expand Up @@ -36,19 +36,19 @@ def update(collection, values)
end
end

return nil
nil
end

def query(collection, query)
allowed_methods = ['find', 'skip', 'limit']
allowed_methods = %w(find skip limit)

cursor = @db[collection]

query.each do |query_part|
method_name, *args = query_part

unless allowed_methods.include?(method_name.to_s)
raise "`#{method_name}` is not part of a valid query"
fail "`#{method_name}` is not part of a valid query"
end

cursor = cursor.send(method_name, *args)
Expand Down
2 changes: 1 addition & 1 deletion lib/volt/extra_core/hash.rb
Expand Up @@ -23,4 +23,4 @@
# key.is_a?(String) ? key : key.to_sym
# end
# end
# end
# end

0 comments on commit 47bed5a

Please sign in to comment.