Pr0d1r2-active_record_geocodable 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Marcin Nowicki
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,18 @@
1
+ = active_record_geocodable
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but
13
+ bump version in a commit by itself I can ignore when I pull)
14
+ * Send me a pull request. Bonus points for topic branches.
15
+
16
+ == Copyright
17
+
18
+ Copyright (c) 2009 Marcin Nowicki. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,48 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "active_record_geocodable"
8
+ gem.summary = %Q{ActiveRecord is_geocodable method}
9
+ gem.description = %Q{Allow any active record model to be geocoded by geokit gem and contain geodata}
10
+ gem.email = "pr0d1r2@ragnarson.com"
11
+ gem.homepage = "http://github.com/Pr0d1r2/active_record_geocodable"
12
+ gem.authors = ["Marcin Nowicki"]
13
+ gem.add_development_dependency "rspec"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ require 'spec/rake/spectask'
21
+ Spec::Rake::SpecTask.new(:spec) do |spec|
22
+ spec.libs << 'lib' << 'spec'
23
+ spec.spec_files = FileList['spec/**/*_spec.rb']
24
+ end
25
+
26
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
27
+ spec.libs << 'lib' << 'spec'
28
+ spec.pattern = 'spec/**/*_spec.rb'
29
+ spec.rcov = true
30
+ end
31
+
32
+ task :spec => :check_dependencies
33
+
34
+ task :default => :spec
35
+
36
+ require 'rake/rdoctask'
37
+ Rake::RDocTask.new do |rdoc|
38
+ if File.exist?('VERSION')
39
+ version = File.read('VERSION')
40
+ else
41
+ version = ""
42
+ end
43
+
44
+ rdoc.rdoc_dir = 'rdoc'
45
+ rdoc.title = "active_record_geocodable #{version}"
46
+ rdoc.rdoc_files.include('README*')
47
+ rdoc.rdoc_files.include('lib/**/*.rb')
48
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'active_record'
3
+ require 'active_record_geocodable/model'
4
+ require 'active_record_geocodable/base'
@@ -0,0 +1,80 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require 'active_record_connectionless'
3
+
4
+ class GeocodableModel < ActiveRecord::Base
5
+ is_geocodable
6
+ end
7
+
8
+
9
+ describe GeocodableModel do
10
+
11
+ before(:each) do
12
+ @geocodable_model = GeocodableModel.new
13
+ end
14
+
15
+ it 'geo should return geocoded address from multigeocoder' do
16
+ @geocodable_model.should_receive(:address).and_return(:address)
17
+ Geokit::Geocoders::MultiGeocoder.should_receive(:geocode).with(:address).and_return(:geo)
18
+ @geocodable_model.geo.should == :geo
19
+ end
20
+
21
+ describe 'geocoding_occured?' do
22
+ it 'should be true when geocoding occured' do
23
+ Geokit::Geocoders::MultiGeocoder.should_receive(:geocode).and_return(:geo)
24
+ @geocodable_model.stub!(:address)
25
+ @geocodable_model.geo
26
+ @geocodable_model.geocoding_occured?.should be_true
27
+ end
28
+
29
+ it 'should be false when geocoding not occured' do
30
+ Geokit::Geocoders::MultiGeocoder.should_receive(:geocode).and_return(nil)
31
+ @geocodable_model.stub!(:address)
32
+ @geocodable_model.geo
33
+ @geocodable_model.geocoding_occured?.should be_false
34
+ end
35
+ end
36
+
37
+ describe 'lat?' do
38
+ it 'should be true when lat is not nil' do
39
+ @geocodable_model.should_receive(:lat).and_return(47)
40
+ @geocodable_model.lat?.should be_true
41
+ end
42
+
43
+ it 'should be false when lat is nil' do
44
+ @geocodable_model.should_receive(:lat).and_return(nil)
45
+ @geocodable_model.lat?.should be_false
46
+ end
47
+ end
48
+
49
+ describe 'lng?' do
50
+ it 'should be true when lng is not nil' do
51
+ @geocodable_model.should_receive(:lng).and_return(47)
52
+ @geocodable_model.lng?.should be_true
53
+ end
54
+
55
+ it 'should be false when lng is nil' do
56
+ @geocodable_model.should_receive(:lng).and_return(nil)
57
+ @geocodable_model.lng?.should be_false
58
+ end
59
+ end
60
+
61
+ describe 'success?' do
62
+ it 'should be true when lat and lng are ok' do
63
+ @geocodable_model.should_receive(:lat?).and_return(true)
64
+ @geocodable_model.should_receive(:lng?).and_return(true)
65
+ @geocodable_model.success?.should be_true
66
+ end
67
+
68
+ it 'should be false when lng is not ok' do
69
+ @geocodable_model.should_receive(:lat?).and_return(true)
70
+ @geocodable_model.should_receive(:lng?).and_return(false)
71
+ @geocodable_model.success?.should be_false
72
+ end
73
+
74
+ it 'should be false when lat is not ok' do
75
+ @geocodable_model.should_receive(:lat?).and_return(false)
76
+ @geocodable_model.success?.should be_false
77
+ end
78
+ end
79
+
80
+ end
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'active_record_geocodable'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Pr0d1r2-active_record_geocodable
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Marcin Nowicki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-22 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Allow any active record model to be geocoded by geokit gem and contain geodata
26
+ email: pr0d1r2@ragnarson.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.rdoc
34
+ files:
35
+ - .document
36
+ - .gitignore
37
+ - LICENSE
38
+ - README.rdoc
39
+ - Rakefile
40
+ - lib/active_record_geocodable.rb
41
+ - spec/active_record_geocodable_spec.rb
42
+ - spec/spec_helper.rb
43
+ has_rdoc: true
44
+ homepage: http://github.com/Pr0d1r2/active_record_geocodable
45
+ licenses:
46
+ post_install_message:
47
+ rdoc_options:
48
+ - --charset=UTF-8
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.3.5
67
+ signing_key:
68
+ specification_version: 2
69
+ summary: ActiveRecord is_geocodable method
70
+ test_files:
71
+ - spec/active_record_geocodable_spec.rb
72
+ - spec/spec_helper.rb