active_geo_db 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,8 +3,8 @@ require File.expand_path("../lib/active_geo_db/version", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.add_dependency("activerecord")
6
+ gem.add_dependency("open_geo_db")
6
7
  gem.add_dependency("rails")
7
- gem.add_development_dependency("open_geo_db")
8
8
  gem.authors = ["Kostiantyn Kahanskyi"]
9
9
  gem.description = %q{Rails (ActiveRecord) lib for accessing OpenGeoDb}
10
10
  gem.email = %w(kostiantyn.kahanskyi@googlemail.com)
@@ -9,8 +9,8 @@ module ActiveGeoDb
9
9
  # * Establish connection to OpenGeoDb database
10
10
  def self.initialize(application)
11
11
  connection_configuration_path = application.paths["config/database"].first
12
- connection_configuration = ConnectionConfiguration.load_file(connection_configuration_path)
13
- ConnectionProvider.establish_connection(connection_configuration.to_hash)
12
+ ConnectionConfiguration.instance.load_file(connection_configuration_path)
13
+ ConnectionProvider.establish_connection(ConnectionConfiguration.instance.to_hash)
14
14
  end
15
15
 
16
16
  # Find coordinates for a specific location
@@ -0,0 +1,17 @@
1
+ require "open_geo_db/database"
2
+
3
+ namespace(:active_geo_db) do
4
+ def database
5
+ OpenGeoDb::Database.new(ActiveGeoDb::ConnectionConfiguration.instance.to_hash)
6
+ end
7
+
8
+ desc("Create and populate database")
9
+ task(:create => :environment) do
10
+ database.execute(:create)
11
+ end
12
+
13
+ desc("Destroy database")
14
+ task(:destroy => :environment) do
15
+ database.execute(:destroy)
16
+ end
17
+ end
@@ -1,18 +1,17 @@
1
+ require "singleton"
1
2
  require "yaml"
2
3
 
3
4
  module ActiveGeoDb
4
5
  class ConnectionConfiguration
6
+ include Singleton
7
+
5
8
  # Key in Rails database configuration under which the configuration for OpenGeoDb database
6
9
  # can be found
7
10
  CONFIGURATION_KEY = "open_geo_db"
8
11
 
9
- class << self
10
- # Read configuration file and load appropriate section
11
- def load_file(path)
12
- @configuration_data = YAML.load_file(path)[CONFIGURATION_KEY]
13
- end
14
-
15
- alias_method(:new, :load_file) # For convenience reasons only...
12
+ # Read configuration file and load appropriate section
13
+ def load_file(path)
14
+ @configuration_data = YAML.load_file(path)[CONFIGURATION_KEY]
16
15
  end
17
16
 
18
17
  # Return previously loaded configuration
@@ -3,5 +3,9 @@ module ActiveGeoDb
3
3
  initializer("active_geo_db.initialize") do |application|
4
4
  ActiveGeoDb.initialize(application)
5
5
  end
6
+
7
+ rake_tasks do
8
+ load "active_geo_db/active_geo_db.rake"
9
+ end
6
10
  end
7
11
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveGeoDb
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_geo_db
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kostiantyn Kahanskyi
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-12 00:00:00 Z
18
+ date: 2012-01-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activerecord
@@ -32,7 +32,7 @@ dependencies:
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  - !ruby/object:Gem::Dependency
35
- name: rails
35
+ name: open_geo_db
36
36
  prerelease: false
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
38
  none: false
@@ -46,7 +46,7 @@ dependencies:
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
48
  - !ruby/object:Gem::Dependency
49
- name: open_geo_db
49
+ name: rails
50
50
  prerelease: false
51
51
  requirement: &id003 !ruby/object:Gem::Requirement
52
52
  none: false
@@ -57,7 +57,7 @@ dependencies:
57
57
  segments:
58
58
  - 0
59
59
  version: "0"
60
- type: :development
60
+ type: :runtime
61
61
  version_requirements: *id003
62
62
  description: Rails (ActiveRecord) lib for accessing OpenGeoDb
63
63
  email:
@@ -77,6 +77,7 @@ files:
77
77
  - Rakefile
78
78
  - active_geo_db.gemspec
79
79
  - lib/active_geo_db.rb
80
+ - lib/active_geo_db/active_geo_db.rake
80
81
  - lib/active_geo_db/connection_configuration.rb
81
82
  - lib/active_geo_db/connection_provider.rb
82
83
  - lib/active_geo_db/railtie.rb