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

Run rubocop auto-correct. #236

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
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ gem 'volt-mongo'
gem 'rbnacl', require: false
gem 'rbnacl-libsodium', require: false


group :development do
# For testing the kitchen sink app
# Twitter bootstrap
Expand Down Expand Up @@ -59,5 +58,4 @@ platform :mri do
# TODO: Move out of MRI block once jruby 9k is outs
gem 'sauce', '~> 3.5.3', require: false
gem 'sauce-connect', '~> 3.5.0', require: false

end
2 changes: 1 addition & 1 deletion app/volt/tasks/live_query/live_query_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def lookup(collection, query)
super(collection, query)
end

def updated_collection(collection, skip_channel, from_message_bus=false)
def updated_collection(collection, skip_channel, from_message_bus = false)
# collection = collection.to_sym
lookup_all(collection).each do |live_query|
live_query.run(skip_channel)
Expand Down
1 change: 0 additions & 1 deletion lib/volt/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
end
require 'volt/volt/app'


module Volt
def self.boot(app_path)
# Boot the app
Expand Down
9 changes: 4 additions & 5 deletions lib/volt/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ def new(name)
bundle_command('install')
end

say ""
say ''
say "Your app is now ready in the #{name} directory.", :green
say ""
say "To run your app: "
say ''
say 'To run your app: '
say " cd #{name}"
say " bundle exec volt server"
say ' bundle exec volt server'
end


desc 'console', 'run the console on the project in the current directory'

def console
Expand Down
17 changes: 8 additions & 9 deletions lib/volt/cli/asset_compile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def compile
puts 'Write index files'
write_index

puts "compiled"
puts 'compiled'
end

def logical_paths_and_full_paths
Expand All @@ -54,17 +54,16 @@ def logical_paths_and_full_paths

yield(logical_path, full_path.to_s)
end

end

def write_sprockets
# Serve the opal files
logical_paths_and_full_paths do |logical_path, full_path|
# Only include files that aren't compiled elsewhere, like fonts
if !logical_path[/[.](y|css|js|html|erb)$/] &&
File.extname(logical_path) != '' &&
# opal includes some node modules in the standard lib that we don't need to compile in
(full_path !~ /\/opal/ && full_path !~ /\/stdlib\// && logical_path !~ /^node_js\//)
File.extname(logical_path) != '' &&
# opal includes some node modules in the standard lib that we don't need to compile in
(full_path !~ /\/opal/ && full_path !~ /\/stdlib\// && logical_path !~ /^node_js\//)
write_sprocket_file(logical_path)
end
end
Expand All @@ -85,10 +84,10 @@ def write_sprocket_file(logical_path)
begin
# Only write out the assets
# if logical_path =~ /\/assets\//
content = @opal_files.environment[logical_path].to_s
write_file(path, content)
# end
rescue Sprockets::FileNotFound, SyntaxError => e
content = @opal_files.environment[logical_path].to_s
write_file(path, content)
# end
rescue Sprockets::FileNotFound, SyntaxError => e
# ignore
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/volt/cli/bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def bundle_command(command)

require 'bundler'
Bundler.with_clean_env do
full_command = %Q["#{Gem.ruby}" "#{_bundle_command}" #{command}]
full_command = %("#{Gem.ruby}" "#{_bundle_command}" #{command})
if options[:quiet]
system(full_command, out: File::NULL)
else
Expand All @@ -26,4 +26,4 @@ def bundle_command(command)
end
end
end
end
end
4 changes: 1 addition & 3 deletions lib/volt/cli/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def evaluate_ruby(code)

result = current_binding.eval(code, Pry.eval_path, Pry.current_line)

if result.is_a?(Promise)
result = result.sync
end
result = result.sync if result.is_a?(Promise)

set_last_result(result, code)
ensure
Expand Down
4 changes: 2 additions & 2 deletions lib/volt/cli/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def component(name)
lazy_default: [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find { |e| !e.nil? && !e.empty? },
required: false, banner: '/path/to/your/editor',
desc: 'Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)'
method_option :coc, :type => :boolean, :desc => "Generate a code of conduct file. Set a default with `bundle config gem.coc true`."
method_option :mit, :type => :boolean, :desc => "Generate an MIT license file"
method_option :coc, type: :boolean, desc: 'Generate a code of conduct file. Set a default with `bundle config gem.coc true`.'
method_option :mit, type: :boolean, desc: 'Generate an MIT license file'

def gem(name)
require 'volt/cli/new_gem'
Expand Down
4 changes: 2 additions & 2 deletions lib/volt/cli/new_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def copy_files
end

def copy_options
if @options[:coc] or yes?("\nDo you want to include a code of conduct in this gem?\n\n\
if @options[:coc] || yes?("\nDo you want to include a code of conduct in this gem?\n\n\
Codes of conduct can increase contributions to your project by contributors who \
prefer collaborative, safe spaces. You can read more about the code of conduct at \
contributor-covenant.org. Having a code of conduct means agreeing to the responsibility \
Expand All @@ -67,7 +67,7 @@ def copy_options
copy('newgem/CODE_OF_CONDUCT.md.tt', 'CODE_OF_CONDUCT.md')
end

if @options[:mit] or yes?("\nDo you want to license your code permissively under the MIT license?\n\n\
if @options[:mit] || yes?("\nDo you want to license your code permissively under the MIT license?\n\n\
This means that any other developer or company will be legally allowed to use your code \
for free as long as they admit you created it. You can read more about the MIT license \
at choosealicense.com/licenses/mit.\n\ny/(n):")
Expand Down
3 changes: 1 addition & 2 deletions lib/volt/controllers/collection_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# @page is expected to be defined and a Volt::Page
module Volt
module CollectionHelpers

def url_for(params)
@page.url.url_for(params)
end
Expand All @@ -15,4 +14,4 @@ def store
@page.store
end
end
end
end
6 changes: 2 additions & 4 deletions lib/volt/controllers/http_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def cookies
@cookies ||= Volt::Model.new(request.cookies, persistor: Volt::Persistors::HttpCookiePersistor)
end

def perform(action='index')
def perform(action = 'index')
filtered = run_callbacks(:before_action, action)
send(action.to_sym) unless filtered
run_callbacks(:after_action, action) unless filtered
Expand Down Expand Up @@ -75,9 +75,7 @@ def respond
new_cookies = cookies.persistor.changed_cookies

new_cookies.each_pair do |key, value|
if value.is_a?(String)
value = {value: value}
end
value = { value: value } if value.is_a?(String)
value[:path] = '/'

resp.set_cookie(key.to_s, value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ def changed(attribute_name)
end
end
end
end
end
11 changes: 4 additions & 7 deletions lib/volt/controllers/model_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,18 @@ def first_element
node = `nodes[index]`

# Return if an element
if `node.nodeType === 1`
return node
end
return node if `node.nodeType === 1`
end

return nil
nil
end

# the u method provides an easy helper to render an unbonud binding. This
# means that the binding will not reactively update. If no bindings are
# bound on any model's from a query, the query will not be reactively
# listened to.
def u
raise "the 'u' method requires a block" unless block_given?
fail "the 'u' method requires a block" unless block_given?
Volt::Computation.run_without_tracking { yield }
end

Expand Down Expand Up @@ -134,7 +132,7 @@ def self.new(volt_app, *args, &block)
else
# Initialize was not called, we should warn since this is probably not
# the intended behavior.
Volt.logger.warn("super should be called when creating a custom initialize on class #{inst.class.to_s}")
Volt.logger.warn("super should be called when creating a custom initialize on class #{inst.class}")
end

inst
Expand All @@ -159,7 +157,6 @@ def initialize(volt_app, *args)
# If a model attribute is passed in, we assign it directly
self.model = attrs.locals[:model] if attrs.respond_to?(:model)
end

end

def go(url)
Expand Down
4 changes: 1 addition & 3 deletions lib/volt/controllers/template_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@ def self.included(base)
base.send :extend, ClassMethods
end
end


end
end
8 changes: 4 additions & 4 deletions lib/volt/data_stores/data_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def self.fetch
adaptor_name = root.const_get(adaptor_name)
@adaptor = adaptor_name.new
else
raise "#{database_name} is not a supported database, you might be missing a volt-#{database_name} gem"
fail "#{database_name} is not a supported database, you might be missing a volt-#{database_name} gem"
end

@adaptor
Expand All @@ -25,10 +25,10 @@ def self.adaptor_client
@adaptor_client ||= begin
ds_name = Volt.config.public.datastore_name
unless ds_name
raise "No data store configured, please include volt-mongo or " +
"another similar gem."
fail 'No data store configured, please include volt-mongo or ' \
'another similar gem.'
end
adaptor_class_name = ds_name.capitalize + "AdaptorClient"
adaptor_class_name = ds_name.capitalize + 'AdaptorClient'
Volt::DataStore.const_get(adaptor_class_name)
end
end
Expand Down
14 changes: 7 additions & 7 deletions lib/volt/extra_core/inflector/inflections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ def human(rule, replacement)
# clear :plurals
def clear(scope = :all)
case scope
when :all
@plurals = []
@singulars = []
@uncountables = []
@humans = []
else
instance_variable_set "@#{scope}", []
when :all
@plurals = []
@singulars = []
@uncountables = []
@humans = []
else
instance_variable_set "@#{scope}", []
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/volt/extra_core/object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def try(*a, &b)
end

private

def promisify_and_run_method(method_name, &block)
promise = Promise.new.resolve(self)

Expand Down
19 changes: 7 additions & 12 deletions lib/volt/models/array_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require 'volt/data_stores/data_store'

module Volt
class RecordNotFoundException < Exception ; end
class RecordNotFoundException < Exception; end

class ArrayModel < ReactiveArray
include ModelWrapper
Expand All @@ -31,7 +31,7 @@ def self.proxy_with_load(*method_names)
persistor.try(:root_dep).try(:depend)

if persistor.respond_to?(:run_once_loaded) &&
!Volt.in_mode?(:no_model_promises)
!Volt.in_mode?(:no_model_promises)
persistor.run_once_loaded(block) do
send(old_method_name, *args)
end
Expand Down Expand Up @@ -94,9 +94,8 @@ def <<(model)
model = wrap_values([model]).first
end


if model.is_a?(Model)
if !model.can_create?
unless model.can_create?
fail "permissions did not allow create for #{model.inspect}"
end

Expand All @@ -112,8 +111,7 @@ def <<(model)

# Mark the model as loaded
model.change_state_to(:loaded_state, :loaded)

end.fail do |err|
end.fail do |err|
# remove from the collection because it failed to save on the server
# we don't need to call delete on the server.
index = @array.index(model)
Expand Down Expand Up @@ -149,7 +147,7 @@ def append(model)
end

# Create does append with a default empty model
def create(model={})
def create(model = {})
append(model)
end

Expand Down Expand Up @@ -203,9 +201,7 @@ def select
new_array = []
@array.size.times do |index|
value = @array[index]
if yield(value)
new_array << value
end
new_array << value if yield(value)
end

new_array
Expand Down Expand Up @@ -281,7 +277,6 @@ def to_json
end
end


def inspect
Computation.run_without_tracking do
# Track on size
Expand Down Expand Up @@ -312,7 +307,7 @@ def fail_not_found_if_nil(promise)
if val
val
else
raise RecordNotFoundException.new
fail RecordNotFoundException.new
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/volt/models/associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def has_many(method_name, remote_key_name = nil)
# to get the associated model.
def has_one(method_name)
if method_name.plural?
raise NameError, "has_one takes a singluar association name"
fail NameError, 'has_one takes a singluar association name'
end

define_method(method_name) do
Expand Down
Loading