Skip to content

Commit

Permalink
Rubocop fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gravitystorm committed Mar 17, 2015
1 parent 6eb4914 commit 61af303
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Gemfile
@@ -1,4 +1,4 @@
# A sample Gemfile
source "https://rubygems.org"
source 'https://rubygems.org'

gemspec
2 changes: 1 addition & 1 deletion bin/mapnik_legendary
Expand Up @@ -25,7 +25,7 @@ optparse = OptionParser.new do |opts|
exit
end

opts.on_tail("--version", "Show version") do
opts.on_tail('--version', 'Show version') do
puts MapnikLegendary::VERSION
exit
end
Expand Down
3 changes: 1 addition & 2 deletions lib/mapnik_legendary.rb
Expand Up @@ -37,7 +37,6 @@ def self.generate_legend(legend_file, map_file, options)
docs = Docwriter.new

legend['features'].each_with_index do |feature, idx|

# TODO: use a proper csv library rather than .join(",") !
zoom = options.zoom || feature['zoom'] || DEFAULT_ZOOM
feature = Feature.new(feature, zoom, map, legend['extra_tags'])
Expand Down Expand Up @@ -69,7 +68,7 @@ def self.generate_legend(legend_file, map_file, options)
id = feature.name || "legend-#{idx}"
filename = File.join(Dir.pwd, 'output', "#{id}-#{zoom}.png")
i = 0
while File.exists?(filename) && !options.overwrite
while File.exist?(filename) && !options.overwrite
i += 1
filename = File.join(Dir.pwd, 'output', "#{id}-#{zoom}-#{i}.png")
end
Expand Down
3 changes: 1 addition & 2 deletions lib/mapnik_legendary/docwriter.rb
Expand Up @@ -4,7 +4,6 @@

module MapnikLegendary
class Docwriter

def initialize
@entries = []
end
Expand All @@ -28,7 +27,7 @@ def to_pdf(filename, title)
font_families.update(
'Ubuntu' => { bold: '/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-B.ttf',
italic: '/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-RI.ttf',
normal: '/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf'}
normal: '/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf' }
)
font 'Ubuntu'
font_size 12
Expand Down
7 changes: 3 additions & 4 deletions lib/mapnik_legendary/feature.rb
Expand Up @@ -3,16 +3,15 @@
require 'mapnik_legendary/part'

module MapnikLegendary

# A feature has a name, description, and one or more parts holding geometries, tags and layers
class Feature
attr_reader :name, :parts, :description

def initialize(feature, zoom, map, extra_tags)
@name = feature['name']
@description = feature.has_key?('description') ? feature['description'] : @name.capitalize
@description = feature.key?('description') ? feature['description'] : @name.capitalize
@parts = []
if feature.has_key? 'parts'
if feature.key? 'parts'
feature['parts'].each do |part|
@parts << Part.new(part, zoom, map, extra_tags)
end
Expand All @@ -25,4 +24,4 @@ def envelope
@parts.first.geom.envelope
end
end
end
end
2 changes: 1 addition & 1 deletion lib/mapnik_legendary/geometry.rb
Expand Up @@ -24,7 +24,7 @@ def initialize(type, zoom, map)
end

def to_csv
%Q{"#{@geom}"}
%("#{@geom}")
end

def envelope
Expand Down
3 changes: 1 addition & 2 deletions lib/mapnik_legendary/part.rb
Expand Up @@ -4,7 +4,6 @@
require 'mapnik_legendary/geometry'

module MapnikLegendary

# A part is a combination of tags, geometry and layers.
class Part
attr_reader :tags, :geom, :layers
Expand All @@ -13,7 +12,7 @@ def initialize(h, zoom, map, extra_tags)
@tags = Tags.merge_nulls(h['tags'], extra_tags)
@geom = Geometry.new(h['type'], zoom, map)
if h['layer']
@layers = [ h['layer'] ]
@layers = [h['layer']]
else
@layers = h['layers']
end
Expand Down
20 changes: 10 additions & 10 deletions mapnik_legendary.gemspec
@@ -1,16 +1,16 @@
require File.expand_path("../lib/mapnik_legendary/version", __FILE__)
require File.expand_path('../lib/mapnik_legendary/version', __FILE__)

Gem::Specification.new do |s|
s.name = "mapnik_legendary"
s.name = 'mapnik_legendary'
s.version = MapnikLegendary::VERSION
s.author = "Andy Allan"
s.email = "andy@gravitystorm.co.uk"
s.homepage = "https://github.com/gravitystorm/mapnik-legendary"
s.summary = "Create legends (map keys) for mapnik stylesheets"
s.description = "Creating legends by hand is tedious. This software allows you to generate them automatically."
s.default_executable = "bin/mapnik_legendary"
s.files = Dir["{lib}/**/*.rb", "bin/*", "*.md"]
s.license = "MIT"
s.author = 'Andy Allan'
s.email = 'andy@gravitystorm.co.uk'
s.homepage = 'https://github.com/gravitystorm/mapnik-legendary'
s.summary = 'Create legends (map keys) for mapnik stylesheets'
s.description = 'Creating legends by hand is tedious. This software allows you to generate them automatically.'
s.default_executable = 'bin/mapnik_legendary'
s.files = Dir['{lib}/**/*.rb', 'bin/*', '*.md']
s.license = 'MIT'

s.add_runtime_dependency 'mapnik', ['>= 0.1.4'] # which hasn't been released yet...
s.add_runtime_dependency 'yaml'
Expand Down

0 comments on commit 61af303

Please sign in to comment.