Skip to content

Commit

Permalink
updaged gemspec
Browse files Browse the repository at this point in the history
  • Loading branch information
kapkaev committed Sep 5, 2013
1 parent ebb2471 commit 1cb7a4d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
39 changes: 17 additions & 22 deletions heatmap.gemspec
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
# -*- encoding: utf-8 -*-
require File.expand_path("../lib/heatmap/version", __FILE__)
Gem::Specification.new do |s|
s.name = "heatmap"
s.version = Heatmap::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Andrew Louis"]
s.email = ["andrew@hyfen.net"]
s.homepage = "https://github.com/hyfen/heatmap"
s.summary = "A tool to generate heatmaps"
s.description = "Generate heatmaps from a series of points (either x,y pixel values or coordinates)."

s.required_rubygems_version = ">= 1.3.6"

s.add_dependency("rmagick")
$LOAD_PATH.push File.expand_path("../lib", __FILE__)

s.add_development_dependency("rspec", "~> 2.0.1")
s.add_development_dependency("watchr", "~> 0.6")
s.add_development_dependency("bundler", ">= 1.0.0")
Gem::Specification.new do |s|
s.name = "heatmap"
s.version = "0.0.2"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.6") if s.respond_to? :required_rubygems_version=
s.authors = ["Andrew Louis"]
s.date = "2013-08-30"
s.description = "Generate heatmaps from a series of points (either x,y pixel values or coordinates)."
s.email = ["andrew@hyfen.net"]
s.files = [".gitignore", "Gemfile", "Rakefile", "examples/dots/dot.png", "examples/dots/dot15.png", "examples/gradients/classic.png", "examples/gradients/fire.png", "examples/gradients/purple-to-yellow.png", "examples/test.rb", "heatmap.gemspec", "lib/heatmap.rb", "lib/heatmap/map.rb", "lib/heatmap/mercator.rb", "lib/heatmap/point.rb", "lib/heatmap/version.rb", "readme.md"]
s.homepage = "https://github.com/hyfen/heatmap"
s.require_paths = ["lib"]
end
s.rubygems_version = "2.0.6"
s.summary = "A tool to generate heatmaps"

s.add_dependency('rmagick')
s.add_dependency('bundler')
end
10 changes: 6 additions & 4 deletions lib/heatmap/map.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Heatmap

require 'RMagick'
require 'RMagick' unless defined?(Magick)

class Map
ASSET_DIR = File.expand_path(File.join(File.dirname(__FILE__), '../..', 'examples'))
Expand All @@ -25,13 +24,12 @@ def clut_image=(clut_image)
@clut_image_file = Magick::Image.read(clut_image)[0] if File.exists?(clut_image)
end

def output(format = "png", filename=nil)
def output(filename=nil)
@dot_image_file || self.dot_image=DEFAULT_DOT_IMAGE
unless @width && @height
@width, @height = self.points_bounds
end
@heatmap = Magick::Image.new(@width, @height)
@heatmap.format = format
generate_map
colorize
if filename
Expand All @@ -45,6 +43,10 @@ def output(format = "png", filename=nil)

def generate_map
@points.each do |point|
if @height and @height
# restrict adding point's that not belong to `map area`
next unless (point.x <= @width and point.y <= @height) or [point.y, point.x].min >= 0
end
@heatmap = @heatmap.dissolve(@dot_image_file, point.intensity, 1, Magick::NorthWestGravity, point.x, point.y)
GC.start # prevent rmagick from leaking memory
end
Expand Down

0 comments on commit 1cb7a4d

Please sign in to comment.