Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: itsmattking/dm-geokit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: adamstrickland/dm-geokit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 9 commits
  • 7 files changed
  • 2 contributors

Commits on Nov 11, 2009

  1. Copy the full SHA
    65b0424 View commit details
  2. Copy the full SHA
    049fa9a View commit details
  3. Silence noisy specs

    dkubb committed Nov 11, 2009
    Copy the full SHA
    144d93c View commit details
  4. Added "rake spec" task

    dkubb committed Nov 11, 2009
    Copy the full SHA
    b2ebb51 View commit details

Commits on Dec 22, 2009

  1. Copy the full SHA
    d0103d4 View commit details
  2. rm'g address as property to pass validation. one spec still fails, bu…

    …t was failing previously anyway, due to bad sql
    adamstrickland committed Dec 22, 2009
    Copy the full SHA
    d37ae6f View commit details
  3. set query[:unique] to false to force not using distance calc column i…

    …n group by; thinking this will cause other problems not accounted for in the spec, but passes current spec
    adamstrickland committed Dec 22, 2009
    Copy the full SHA
    07f0eca View commit details

Commits on Dec 23, 2009

  1. Version bump to 0.10.2

    adamstrickland committed Dec 23, 2009
    Copy the full SHA
    4354162 View commit details
  2. bumped patch ver

    adamstrickland committed Dec 23, 2009
    Copy the full SHA
    9fc09e0 View commit details
Showing with 114 additions and 54 deletions.
  1. +27 −11 Rakefile
  2. +2 −1 VERSION.yml
  3. +56 −14 dm-geokit.gemspec
  4. +1 −1 lib/dm-geokit.rb
  5. +11 −25 lib/dm-geokit/resource.rb
  6. +6 −1 spec/dm_geokit_spec.rb
  7. +11 −1 spec/spec_helper.rb
38 changes: 27 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
begin
require 'jeweler'
Jeweler::Tasks.new do |s|
s.name = 'dm-geokit'
begin
require 'jeweler'
Jeweler::Tasks.new do |s|
s.name = 'dm-geokit'
s.summary = "DataMapper plugin for geokit stuff forked from Foy Savas's project. Now relies on the geokit gem rather than Foy's gem."
s.authors = ['Foy Savas', 'Daniel Higginbotham', 'Matt King']
s.email = 'matt@mattking.org'
s.homepage = "http://github.com/mattking17/dm-geokit/tree/master"
s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
s.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore']
s.homepage = "http://github.com/mattking17/dm-geokit/tree/master"
s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
s.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore']
s.require_path = 'lib'
s.has_rdoc = true
s.platform = Gem::Platform::RUBY
s.extra_rdoc_files = %w[ README LICENSE TODO ]
s.add_dependency 'dm-core'
s.add_dependency 'andre-geokit'
end
rescue LoadError
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
end
end
rescue LoadError
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
end

require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:spec) do |spec|
spec.libs << 'lib' << 'spec'
spec.spec_files = FileList['spec/**/*_spec.rb']
end

Spec::Rake::SpecTask.new(:rcov) do |spec|
spec.libs << 'lib' << 'spec'
spec.pattern = 'spec/**/*_spec.rb'
spec.rcov = true
end

task :spec => :check_dependencies

task :default => :spec
3 changes: 2 additions & 1 deletion VERSION.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
:patch: 2
:major: 0
:minor: 10
:patch: 1
:build:
70 changes: 56 additions & 14 deletions dm-geokit.gemspec
Original file line number Diff line number Diff line change
@@ -1,23 +1,65 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = %q{dm-geokit}
s.version = "0.10.1"
s.rubyforge_project = 'dm-geokit'
s.version = "0.10.2"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Matt King"]
s.date = %q{2009-10-25}
s.description = %q{Adds geographic functionality to DataMapper objects}
s.authors = ["Foy Savas", "Daniel Higginbotham", "Matt King"]
s.date = %q{2009-12-23}
s.description = %q{Simple and opinionated helper for creating Rubygem projects on GitHub}
s.email = %q{matt@mattking.org}
s.extra_rdoc_files = ["README", "LICENSE", "TODO"]
s.files = ["LICENSE", "Rakefile", "README", "TODO", "VERSION.yml", "lib/dm-geokit", "lib/dm-geokit/ip_geocode_lookup.rb", "lib/dm-geokit/resource.rb", "lib/dm-geokit.rb", "lib/skeleton", "lib/skeleton/api_keys_template", "lib/jeweler/templates/.gitignore", "lib/dm-geokit/support/distance_measurement.rb", "lib/dm-geokit/support/distance_support.rb", "lib/dm-geokit/support/float.rb", "lib/dm-geokit/support/integer.rb", "lib/dm-geokit/support/symbol.rb"]
s.has_rdoc = true
s.extra_rdoc_files = [
"LICENSE",
"README",
"TODO"
]
s.files = [
"LICENSE",
"README",
"Rakefile",
"TODO",
"VERSION.yml",
"lib/dm-geokit.rb",
"lib/dm-geokit/acts_as_mappable.rb",
"lib/dm-geokit/ip_geocode_lookup.rb",
"lib/dm-geokit/merbtasks.rb",
"lib/dm-geokit/resource.rb",
"lib/dm-geokit/support/distance_measurement.rb",
"lib/dm-geokit/support/distance_support.rb",
"lib/dm-geokit/support/float.rb",
"lib/dm-geokit/support/integer.rb",
"lib/dm-geokit/support/symbol.rb",
"lib/jeweler/templates/.gitignore",
"lib/skeleton/api_keys_template"
]
s.homepage = %q{http://github.com/mattking17/dm-geokit/tree/master}
s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.1}
s.summary = %q{Adds geographic functionality to DataMapper objects, relying on the Geokit gem for geocoding and searching by geographic location.}
s.rubygems_version = %q{1.3.5}
s.summary = %q{DataMapper plugin for geokit stuff forked from Foy Savas's project. Now relies on the geokit gem rather than Foy's gem.}
s.test_files = [
"spec/dm_geokit_spec.rb",
"spec/spec_helper.rb"
]

s.add_dependency(%q<dm-core>, [">= 0.10.1"])
s.add_dependency(%q<geokit>, [">= 1.5.0"])
s.add_dependency(%q<dm-aggregates>, [">= 0.10.1"])
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3

if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<dm-core>, [">= 0"])
s.add_runtime_dependency(%q<andre-geokit>, [">= 0"])
else
s.add_dependency(%q<dm-core>, [">= 0"])
s.add_dependency(%q<andre-geokit>, [">= 0"])
end
else
s.add_dependency(%q<dm-core>, [">= 0"])
s.add_dependency(%q<andre-geokit>, [">= 0"])
end
end

2 changes: 1 addition & 1 deletion lib/dm-geokit.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%w(rubygems geokit dm-core dm-aggregates).each{|f| require f}
%w(rubygems geokit dm-core dm-aggregates dm-validations).each{|f| require f}
%w(distance_measurement distance_support symbol integer float).each{|f|
require File.join(File.dirname(__FILE__),'dm-geokit','support',f)
}
36 changes: 11 additions & 25 deletions lib/dm-geokit/resource.rb
Original file line number Diff line number Diff line change
@@ -11,8 +11,7 @@ def has_geographic_location(name, options = {})
return if self.included_modules.include?(DataMapper::GeoKit::InstanceMethods)
send :include, InstanceMethods
send :include, ::GeoKit::Mappable

property name.to_sym, String, :length => 255

property "#{name}_distance".to_sym, Float

PROPERTY_NAMES.each do |p|
@@ -36,11 +35,9 @@ def has_geographic_location(name, options = {})
end

define_method "#{name}" do
if attribute_get(name.to_sym).nil?
nil
else
GeographicLocation.new(name, self)
end
geo = GeographicLocation.new(name, self)
addy = instance_variable_get("@#{name}")
geo.to_s.blank? ? (addy.blank? ? nil : addy) : geo
end

define_method "#{name}=" do |value|
@@ -50,13 +47,13 @@ def has_geographic_location(name, options = {})
if auto_geocode?
geo = ::GeoKit::Geocoders::MultiGeocoder.geocode(value)
if geo.success?
attribute_set(name.to_sym, geo.full_address)
instance_variable_set("@#{name}_geo", geo)
PROPERTY_NAMES.each do |p|
attribute_set("#{name}_#{p}".to_sym, geo.send(p.to_sym))
end
end
else
attribute_set(name.to_sym, value)
instance_variable_set("@#{name}", value)
end
end
end
@@ -97,6 +94,7 @@ def prepare_query(query)
query[:fields] = expand_fields(query[:fields], field, "#{sphere_distance_sql(field, origin, distance.measurement)}")
query.delete(k)
end
query[:unique] = false
query
end

@@ -190,12 +188,13 @@ def self.included(base)
alias property_to_column_name property_to_column_name_with_distance
RUBY
end

def property_to_column_name_with_distance(property, qualify)

def property_to_column_name_with_distance(property, qualify, qualifier = nil)
DataMapper.logger.debug("property_to_column_name_with_distance: #{property.class}, #{property.type}, #{property.field}")
if property.is_a?(DataMapper::Property) and property.type == DataMapper::Types::Distance
property.field
else
property_to_column_name_without_distance(property, qualify)
property_to_column_name_without_distance(property, qualify, qualifier)
end
end
end
@@ -221,17 +220,4 @@ class Distance < DataMapper::Type
primitive Float
end
end

module Aggregates
module Model
def size
count
end
end
module Collection
def size
loaded? ? super : count
end
end
end
end
7 changes: 6 additions & 1 deletion spec/dm_geokit_spec.rb
Original file line number Diff line number Diff line change
@@ -38,6 +38,11 @@
it "should have a geocode method" do
Location.should respond_to(:geocode)
end

it "should pass validation" do
l = ValidatingLocation.create(:address => "1600 Pennsylvania Ave., Washington, D.C.")
l.valid?.should be(true)
end

it "should have the address field return a GeographicLocation object" do
l = Location.create(:address => "5119 NE 27th ave portland, or 97211")
@@ -59,7 +64,7 @@
l.send("address_#{p}").should_not be(nil)
end
end

it "should convert to LatLng" do
l = Location.create(:address => "5119 NE 27th ave portland, or 97211")
l.address.should respond_to(:to_lat_lng)
12 changes: 11 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
%w(dm-geokit).each{|l| require l}

DataMapper::Logger.new(STDOUT, :debug)
#DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, "mysql://root@localhost/dm_geokit_test")
GeoKit::Geocoders::google = 'ABQIAAAAdh4tQvHsPhXZm0lCnIiqQxQK9-uvPXgtXTy8QpRnjVVz0_XBmRQRzegmnZqycC7ewqw26GJSVik0_w'
class Location
@@ -13,6 +13,16 @@ class Location
has n, :comments
end

class ValidatingLocation
include DataMapper::Resource
include DataMapper::GeoKit
property :id, Serial
has_geographic_location :address
validates_with_block do
!self.address_full_address.blank?
end
end

class Comment
include DataMapper::Resource
property :id, Serial