aboutsummaryrefslogtreecommitdiffstats
path: root/guides/rails_guides
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2016-08-16 04:30:11 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2016-08-16 04:30:11 -0300
commit55f9b8129a50206513264824abb44088230793c2 (patch)
treeff2f01cabfc7e74b0bd831c2272a5517e4e81e99 /guides/rails_guides
parentd0bdd74d7f6fae3d69b3681d5bc2d5ef6f55a0f8 (diff)
downloadrails-55f9b8129a50206513264824abb44088230793c2.tar.gz
rails-55f9b8129a50206513264824abb44088230793c2.tar.bz2
rails-55f9b8129a50206513264824abb44088230793c2.zip
Add three new rubocop rules
Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
Diffstat (limited to 'guides/rails_guides')
-rw-r--r--guides/rails_guides/helpers.rb2
-rw-r--r--guides/rails_guides/kindle.rb18
2 files changed, 10 insertions, 10 deletions
diff --git a/guides/rails_guides/helpers.rb b/guides/rails_guides/helpers.rb
index c7d3a38ba9..888b51b1ef 100644
--- a/guides/rails_guides/helpers.rb
+++ b/guides/rails_guides/helpers.rb
@@ -19,7 +19,7 @@ module RailsGuides
end
def documents_flat
- documents_by_section.flat_map {|section| section["documents"]}
+ documents_by_section.flat_map { |section| section["documents"] }
end
def finished_documents(documents)
diff --git a/guides/rails_guides/kindle.rb b/guides/rails_guides/kindle.rb
index 675df8e55b..6fb8183cb1 100644
--- a/guides/rails_guides/kindle.rb
+++ b/guides/rails_guides/kindle.rb
@@ -19,7 +19,7 @@ module Kindle
puts "=> Arranging html pages in document order"
toc = File.read("toc.ncx")
doc = Nokogiri::XML(toc).xpath("//ncx:content", "ncx" => "http://www.daisy.org/z3986/2005/ncx/")
- html_pages = doc.select {|c| c[:src]}.map {|c| c[:src]}.uniq
+ html_pages = doc.select { |c| c[:src] }.map { |c| c[:src] }.uniq
generate_front_matter(html_pages)
@@ -37,13 +37,13 @@ module Kindle
def generate_front_matter(html_pages)
frontmatter = []
- html_pages.delete_if {|x|
+ html_pages.delete_if { |x|
if x =~ /(toc|welcome|credits|copyright).html/
frontmatter << x unless x =~ /toc/
true
end
}
- html = frontmatter.map {|x|
+ html = frontmatter.map { |x|
Nokogiri::HTML(File.open(x)).at("body").inner_html
}.join("\n")
@@ -56,7 +56,7 @@ module Kindle
h2["id"] = h2.inner_text.gsub(/\s/, "-")
end
add_head_section fdoc, "Front Matter"
- File.open("frontmatter.html","w") {|f| f.puts fdoc.to_html}
+ File.open("frontmatter.html","w") { |f| f.puts fdoc.to_html }
html_pages.unshift "frontmatter.html"
end
@@ -67,18 +67,18 @@ module Kindle
doc = Nokogiri::HTML(File.open(page))
title = doc.at("title").inner_text.gsub("Ruby on Rails Guides: ", "")
title = page.capitalize.gsub(".html", "") if title.strip == ""
- File.open("sections/%03d/_section.txt" % section_idx, "w") {|f| f.puts title}
+ File.open("sections/%03d/_section.txt" % section_idx, "w") { |f| f.puts title }
doc.xpath("//h3[@id]").each_with_index do |h3,item_idx|
subsection = h3.inner_text
- content = h3.xpath("./following-sibling::*").take_while {|x| x.name != "h3"}.map(&:to_html)
+ content = h3.xpath("./following-sibling::*").take_while { |x| x.name != "h3" }.map(&:to_html)
item = Nokogiri::HTML(h3.to_html + content.join("\n"))
item_path = "sections/%03d/%03d.html" % [section_idx, item_idx]
add_head_section(item, subsection)
item.search("img").each do |img|
img["src"] = "#{Dir.pwd}/#{img['src']}"
end
- item.xpath("//li/p").each {|p| p.swap(p.children); p.remove}
- File.open(item_path, "w") {|f| f.puts item.to_html}
+ item.xpath("//li/p").each { |p| p.swap(p.children); p.remove }
+ File.open(item_path, "w") { |f| f.puts item.to_html }
end
end
end
@@ -101,7 +101,7 @@ module Kindle
"mobi_outfile" => mobi_outfile
}
puts document.to_yaml
- File.open("_document.yml", "w"){|f| f.puts document.to_yaml}
+ File.open("_document.yml", "w") { |f| f.puts document.to_yaml }
end
def add_head_section(doc, title)