Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed May 20, 2016
1 parent b241a22 commit 3cfbd8a
Show file tree
Hide file tree
Showing 32 changed files with 271 additions and 150 deletions.
9 changes: 6 additions & 3 deletions lib/nanoc/base/compilation/compiler.rb
Expand Up @@ -105,9 +105,11 @@ def run
store
ensure
Nanoc::Int::TempFilenameFactory.instance.cleanup(
Nanoc::Filter::TMP_BINARY_ITEMS_DIR)
Nanoc::Filter::TMP_BINARY_ITEMS_DIR,
)
Nanoc::Int::TempFilenameFactory.instance.cleanup(
Nanoc::Int::ItemRepWriter::TMP_TEXT_ITEMS_DIR)
Nanoc::Int::ItemRepWriter::TMP_TEXT_ITEMS_DIR,
)
end

def load_stores
Expand Down Expand Up @@ -136,7 +138,8 @@ def store

def build_reps
builder = Nanoc::Int::ItemRepBuilder.new(
site, action_provider, @reps)
site, action_provider, @reps
)
builder.run
end

Expand Down
21 changes: 14 additions & 7 deletions lib/nanoc/base/compilation/outdatedness_reasons.rb
Expand Up @@ -17,24 +17,31 @@ def initialize(message)
end

CodeSnippetsModified = Generic.new(
'The code snippets have been modified since the last time the site was compiled.')
'The code snippets have been modified since the last time the site was compiled.',
)

ConfigurationModified = Generic.new(
'The site configuration has been modified since the last time the site was compiled.')
'The site configuration has been modified since the last time the site was compiled.',
)

DependenciesOutdated = Generic.new(
'This item uses content or attributes that have changed since the last time the site was compiled.')
'This item uses content or attributes that have changed since the last time the site was compiled.',
)

NotEnoughData = Generic.new(
'Not enough data is present to correctly determine whether the item is outdated.')
'Not enough data is present to correctly determine whether the item is outdated.',
)

NotWritten = Generic.new(
'This item representation has not yet been written to the output directory (but it does have a path).')
'This item representation has not yet been written to the output directory (but it does have a path).',
)

RulesModified = Generic.new(
'The rules file has been modified since the last time the site was compiled.')
'The rules file has been modified since the last time the site was compiled.',
)

SourceModified = Generic.new(
'The source file of this item has been modified since the last time the site was compiled.')
'The source file of this item has been modified since the last time the site was compiled.',
)
end
end
3 changes: 2 additions & 1 deletion lib/nanoc/base/repos/config_loader.rb
Expand Up @@ -39,7 +39,8 @@ def new_from_cwd
# Read
apply_parent_config(
Nanoc::Int::Configuration.new(YAML.load_file(filename)),
[filename]).with_defaults
[filename],
).with_defaults
end

# @api private
Expand Down
6 changes: 4 additions & 2 deletions lib/nanoc/base/services/item_rep_writer.rb
Expand Up @@ -12,7 +12,8 @@ def write(item_rep, raw_path)

# Notify
Nanoc::Int::NotificationCenter.post(
:will_write_rep, item_rep, raw_path)
:will_write_rep, item_rep, raw_path
)

content = item_rep.snapshot_contents[:last]
if content.binary?
Expand All @@ -32,7 +33,8 @@ def write(item_rep, raw_path)

# Notify
Nanoc::Int::NotificationCenter.post(
:rep_written, item_rep, raw_path, is_created, is_modified)
:rep_written, item_rep, raw_path, is_created, is_modified
)
end

def temp_filename
Expand Down
10 changes: 4 additions & 6 deletions lib/nanoc/cli/commands/compile.rb
Expand Up @@ -326,15 +326,13 @@ def start
Nanoc::Int::NotificationCenter.on(:rep_written) do |_rep, path, is_created, is_modified|
duration = path && @start_times[path] ? Time.now - @start_times[path] : nil
action =
case
when is_created then :create
when is_modified then :update
if is_created then :create
elsif is_modified then :update
else :identical
end
level =
case
when is_created then :high
when is_modified then :high
if is_created then :high
elsif is_modified then :high
else :low
end
log(level, action, path, duration)
Expand Down
5 changes: 2 additions & 3 deletions lib/nanoc/cli/commands/deploy.rb
Expand Up @@ -15,10 +15,9 @@ class Deploy < ::Nanoc::CLI::CommandRunner
def run
prepare

case
when options[:'list-deployers']
if options[:'list-deployers']
list_deployers
when options[:list]
elsif options[:list]
list_deploy_configs
else
deploy
Expand Down
8 changes: 3 additions & 5 deletions lib/nanoc/data_sources/filesystem.rb
Expand Up @@ -234,9 +234,7 @@ def parse(content_filename, meta_filename, _kind)
# Split data
pieces = data.split(/^(-{5}|-{3})[ \t]*\r?\n?/, 3)
if pieces.size < 4
raise RuntimeError.new(
"The file '#{content_filename}' appears to start with a metadata section (three or five dashes at the top) but it does not seem to be in the correct format.",
)
raise "The file '#{content_filename}' appears to start with a metadata section (three or five dashes at the top) but it does not seem to be in the correct format."
end

# Parse
Expand Down Expand Up @@ -273,7 +271,7 @@ def read(filename)
begin
data = File.read(filename)
rescue => e
raise RuntimeError.new("Could not read #{filename}: #{e.inspect}")
raise "Could not read #{filename}: #{e.inspect}"
end

# Fix
Expand Down Expand Up @@ -304,7 +302,7 @@ def read(filename)

# Raises an invalid encoding error for the given filename and encoding.
def raise_encoding_error(filename, encoding)
raise RuntimeError.new("Could not read #{filename} because the file is not valid #{encoding}.")
raise "Could not read #{filename} because the file is not valid #{encoding}."
end
end
end
3 changes: 2 additions & 1 deletion lib/nanoc/extra/checking/checks/external_links.rb
Expand Up @@ -24,7 +24,8 @@ def run
filenames.each do |filename|
add_issue(
"broken reference to #{res.href}: #{res.explanation}",
subject: filename)
subject: filename,
)
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/nanoc/extra/checking/checks/internal_links.rb
Expand Up @@ -21,7 +21,8 @@ def run

add_issue(
"broken reference to #{href}",
subject: filename)
subject: filename,
)
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/nanoc/extra/checking/checks/mixed_content.rb
Expand Up @@ -15,7 +15,8 @@ def run
fns.each do |filename|
add_issue(
"mixed content include: #{uri}",
subject: filename)
subject: filename,
)
end
end
end
Expand Down
6 changes: 4 additions & 2 deletions lib/nanoc/extra/checking/checks/stale.rb
Expand Up @@ -10,7 +10,8 @@ def run

add_issue(
'file without matching item',
subject: f)
subject: f,
)
end
end

Expand All @@ -23,7 +24,8 @@ def item_rep_paths
.flat_map(&:reps)
.map(&:unwrap)
.flat_map(&:raw_paths)
.flat_map(&:values))
.flat_map(&:values),
)
end

def pruner
Expand Down
5 changes: 3 additions & 2 deletions lib/nanoc/extra/deployers/fog.rb
Expand Up @@ -117,7 +117,8 @@ def upload(key, file_path, etags, keys_to_destroy, keys_to_invalidate, dir)
dir.files.create(
key: key,
body: File.open(file_path),
public: true)
public: true,
)
keys_to_invalidate.push(key)
end

Expand Down Expand Up @@ -149,7 +150,7 @@ def calc_local_etag(file_path)

# Prints the given message on stderr and exits.
def error(msg)
raise RuntimeError.new(msg)
raise msg
end
end
end
5 changes: 2 additions & 3 deletions lib/nanoc/filters/relativize_paths.rb
Expand Up @@ -39,10 +39,9 @@ def run(content, params = {})
when :html, :xml, :xhtml
relativize_html_like(content, params)
else
raise RuntimeError.new(
'The relativize_paths needs to know the type of content to ' \
raise 'The relativize_paths needs to know the type of content to ' \
'process. Pass a :type to the filter call (:html for HTML, ' \
':xhtml for XHTML, :xml for XML, or :css for CSS).')
':xhtml for XHTML, :xml for XML, or :css for CSS).'
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nanoc/helpers/xml_sitemap.rb
Expand Up @@ -48,7 +48,7 @@ def xml_sitemap(params = {})

# Check for required attributes
if @config[:base_url].nil?
raise RuntimeError.new('The Nanoc::Helpers::XMLSitemap helper requires the site configuration to specify the base URL for the site.')
raise 'The Nanoc::Helpers::XMLSitemap helper requires the site configuration to specify the base URL for the site.'
end

# Build sitemap
Expand Down
3 changes: 2 additions & 1 deletion lib/nanoc/rule_dsl/action_provider.rb
Expand Up @@ -10,7 +10,8 @@ def self.for(site)

rule_memory_calculator =
Nanoc::RuleDSL::RuleMemoryCalculator.new(
rules_collection: rules_collection, site: site)
rules_collection: rules_collection, site: site,
)

action_provider = new(rules_collection, rule_memory_calculator)

Expand Down
3 changes: 2 additions & 1 deletion lib/nanoc/rule_dsl/rule.rb
Expand Up @@ -54,7 +54,8 @@ def applicable_to?(item)
# @return [void]
def apply_to(rep, site:, executor:, view_context:)
context = Nanoc::RuleDSL::RuleContext.new(
rep: rep, executor: executor, site: site, view_context: view_context)
rep: rep, executor: executor, site: site, view_context: view_context,
)
context.instance_exec(matches(rep.item.identifier), &@block)
end

Expand Down
6 changes: 3 additions & 3 deletions nanoc.gemspec
Expand Up @@ -13,9 +13,9 @@ Gem::Specification.new do |s|

s.files =
Dir['[A-Z]*'] +
Dir['doc/yardoc_{templates,handlers}/**/*'] +
Dir['{bin,lib,tasks,test}/**/*'] +
['nanoc.gemspec']
Dir['doc/yardoc_{templates,handlers}/**/*'] +
Dir['{bin,lib,tasks,test}/**/*'] +
['nanoc.gemspec']
s.executables = ['nanoc']
s.require_paths = ['lib']

Expand Down
6 changes: 3 additions & 3 deletions scripts/release
Expand Up @@ -71,9 +71,9 @@ puts
puts "=== Reading release notes…"
release_notes =
File.readlines('NEWS.md')
.drop(4)
.take_while { |l| l !~ /^## / }
.join
.drop(4)
.take_while { |l| l !~ /^## / }
.join
puts

puts "=== Creating release on GitHub…"
Expand Down
12 changes: 8 additions & 4 deletions spec/nanoc/base/repos/config_loader_spec.rb
Expand Up @@ -7,7 +7,8 @@
context 'no config file present' do
it 'errors' do
expect { subject }.to raise_error(
Nanoc::Int::ConfigLoader::NoConfigFileFoundError)
Nanoc::Int::ConfigLoader::NoConfigFileFoundError,
)
end
end

Expand Down Expand Up @@ -108,7 +109,8 @@
context 'parent config file is not present' do
it 'errors' do
expect { subject }.to raise_error(
Nanoc::Int::ConfigLoader::NoParentConfigFileFoundError)
Nanoc::Int::ConfigLoader::NoParentConfigFileFoundError,
)
end
end

Expand All @@ -121,7 +123,8 @@

it 'errors' do
expect { subject }.to raise_error(
Nanoc::Int::ConfigLoader::CyclicalConfigFileError)
Nanoc::Int::ConfigLoader::CyclicalConfigFileError,
)
end
end

Expand All @@ -132,7 +135,8 @@

it 'errors' do
expect { subject }.to raise_error(
Nanoc::Int::ConfigLoader::CyclicalConfigFileError)
Nanoc::Int::ConfigLoader::CyclicalConfigFileError,
)
end
end

Expand Down
3 changes: 2 additions & 1 deletion spec/nanoc/base/repos/site_loader_spec.rb
Expand Up @@ -52,7 +52,8 @@
context 'no config file' do
it 'errors' do
expect { subject }.to raise_error(
Nanoc::Int::ConfigLoader::NoConfigFileFoundError)
Nanoc::Int::ConfigLoader::NoConfigFileFoundError,
)
end
end

Expand Down
12 changes: 8 additions & 4 deletions spec/nanoc/cli/commands/show_rules_spec.rb
Expand Up @@ -19,7 +19,8 @@
:site,
items: items,
layouts: layouts,
compiler: compiler)
compiler: compiler,
)
end

let(:items) do
Expand Down Expand Up @@ -56,11 +57,14 @@
let(:rules_collection) do
Nanoc::RuleDSL::RulesCollection.new.tap do |rc|
rc.add_item_compilation_rule(
Nanoc::RuleDSL::Rule.new(Nanoc::Int::Pattern.from('/dog.*'), :default, proc {}))
Nanoc::RuleDSL::Rule.new(Nanoc::Int::Pattern.from('/dog.*'), :default, proc {}),
)
rc.add_item_compilation_rule(
Nanoc::RuleDSL::Rule.new(Nanoc::Int::Pattern.from('/*.md'), :default, proc {}))
Nanoc::RuleDSL::Rule.new(Nanoc::Int::Pattern.from('/*.md'), :default, proc {}),
)
rc.add_item_compilation_rule(
Nanoc::RuleDSL::Rule.new(Nanoc::Int::Pattern.from('/**/*'), :text, proc {}))
Nanoc::RuleDSL::Rule.new(Nanoc::Int::Pattern.from('/**/*'), :text, proc {}),
)

rc.layout_filter_mapping[Nanoc::Int::Pattern.from('/*.haml')] = [:haml, {}]
rc.layout_filter_mapping[Nanoc::Int::Pattern.from('/*.erb')] = [:erb, {}]
Expand Down
4 changes: 3 additions & 1 deletion spec/nanoc/regressions/gh_804_spec.rb
Expand Up @@ -19,6 +19,8 @@
it 'does not crash' do
expect { Nanoc::CLI.run(%w( check donkey )) }.to(
raise_error(Nanoc::Int::Errors::GenericTrivial, 'One or more checks failed').and(
output(/Issues found!\n \(global\):\n \[ (\e\[31m)?ERROR(\e\[0m)? \] donkey - Not enough donkeys\n \/catlady.md:\n \[ (\e\[31m)?ERROR(\e\[0m)? \] donkey - Too many cats\n/).to_stdout))
output(/Issues found!\n \(global\):\n \[ (\e\[31m)?ERROR(\e\[0m)? \] donkey - Not enough donkeys\n \/catlady.md:\n \[ (\e\[31m)?ERROR(\e\[0m)? \] donkey - Too many cats\n/).to_stdout,
),
)
end
end

0 comments on commit 3cfbd8a

Please sign in to comment.