mongo_doc 0.6.0 → 0.6.1

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.
data/README.textile CHANGED
@@ -1,6 +1,6 @@
1
1
  h1. MongoDoc
2
2
 
3
- Version: Hurricane (0.6.0) 2010/05/14
3
+ Version: Hurricane (0.6.1) 2010/05/16
4
4
 
5
5
  h2. Notes
6
6
 
@@ -115,7 +115,7 @@ h2. Installation
115
115
 
116
116
  MongoDoc *requires* mongoDB v1.4.0 or later.
117
117
 
118
- bc. sudo gem install mongo_doc
118
+ bc. % gem install mongo_doc
119
119
 
120
120
  h2. Connecting
121
121
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.6.1
@@ -6,10 +6,10 @@ module MongoDoc
6
6
 
7
7
  extend self
8
8
 
9
- attr_writer :config_path, :env, :host, :name, :options, :port, :strict
9
+ attr_writer :config_path, :default_name, :env, :host, :name, :options, :port, :strict
10
10
 
11
11
  def config_path
12
- @config_path || default_path
12
+ @config_path || './mongodb.yml'
13
13
  end
14
14
 
15
15
  def configuration
@@ -24,12 +24,12 @@ module MongoDoc
24
24
  @database ||= connection.db(name, :strict => strict)
25
25
  end
26
26
 
27
+ def default_name
28
+ @default_name ||= "mongo_doc"
29
+ end
30
+
27
31
  def env
28
- if rails?
29
- Rails.env
30
- else
31
- @env ||= 'development'
32
- end
32
+ @env ||= 'development'
33
33
  end
34
34
 
35
35
  def host
@@ -61,26 +61,6 @@ module MongoDoc
61
61
  connection
62
62
  end
63
63
 
64
- def default_name
65
- if rails?
66
- "#{Rails.root.basename}_#{Rails.env}"
67
- else
68
- "mongo_doc"
69
- end
70
- end
71
-
72
- def default_path
73
- if rails?
74
- Rails.root + 'config/mongodb.yml'
75
- else
76
- './mongodb.yml'
77
- end
78
- end
79
-
80
- def rails?
81
- Object.const_defined?("Rails")
82
- end
83
-
84
64
  def verify_server_version(connection)
85
65
  raise UnsupportedServerVersionError.new('MongoDoc requires at least mongoDB version 1.4.0') unless connection.server_version >= "1.4.0"
86
66
  end
@@ -0,0 +1,11 @@
1
+ require 'mongo_doc'
2
+ require 'rails'
3
+ require 'mongo_doc/railties/config'
4
+
5
+ module MongoDoc
6
+ class Railtie < Rails::Railtie
7
+ initializer "mongo_doc db configuration" do |app|
8
+ MongoDoc::Railties::Config.config(app)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module MongoDoc
2
+ module Railties
3
+ module Config
4
+ extend self
5
+
6
+ def config(app)
7
+ MongoDoc::Connection.config_path = app.root + 'config/mongodb.yml'
8
+ MongoDoc::Connection.default_name = "#{app.root.basename}_#{Rails.env}"
9
+ MongoDoc::Connection.env = Rails.env
10
+ end
11
+ end
12
+ end
13
+ end
data/lib/mongo_doc.rb CHANGED
@@ -4,9 +4,11 @@ require 'active_support/core_ext'
4
4
  require 'will_paginate/collection'
5
5
 
6
6
  module MongoDoc
7
- VERSION = '0.6.0'
7
+ VERSION = '0.6.1'
8
8
  end
9
9
 
10
10
  require 'mongo_doc/connection'
11
11
  require 'mongo_doc/collection'
12
12
  require 'mongo_doc/document'
13
+
14
+ require 'mongo_doc/railtie' if defined?(Rails)
data/mongo_doc.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongo_doc}
8
- s.version = "0.6.0"
8
+ s.version = "0.6.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Les Hill"]
12
- s.date = %q{2010-05-14}
12
+ s.date = %q{2010-05-16}
13
13
  s.description = %q{ODM for MongoDB}
14
14
  s.email = %q{leshill@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -96,6 +96,8 @@ Gem::Specification.new do |s|
96
96
  "lib/mongo_doc/finders.rb",
97
97
  "lib/mongo_doc/index.rb",
98
98
  "lib/mongo_doc/matchers.rb",
99
+ "lib/mongo_doc/railtie.rb",
100
+ "lib/mongo_doc/railties/config.rb",
99
101
  "lib/mongo_doc/root.rb",
100
102
  "lib/mongo_doc/scope.rb",
101
103
  "lib/mongo_doc/validations.rb",
@@ -53,23 +53,30 @@ describe "MongoDoc::Connection.Connections" do
53
53
 
54
54
  context "Rails environment" do
55
55
 
56
+ class FauxApp
57
+ def root
58
+ Pathname.new('faux_app')
59
+ end
60
+ end
61
+
56
62
  module FauxRails
57
63
  extend self
58
64
 
59
65
  def env
60
- 'development'
66
+ 'staging'
61
67
  end
68
+ end
62
69
 
63
- def root
64
- Pathname.new('rails_root')
65
- end
70
+ before(:all) do
71
+ Object.const_set('Rails', FauxRails)
72
+ require 'mongo_doc/railties/config'
66
73
  end
67
74
 
68
75
  before do
69
- Object.const_set('Rails', FauxRails)
76
+ MongoDoc::Railties::Config.config(FauxApp.new)
70
77
  end
71
78
 
72
- after do
79
+ after(:all) do
73
80
  Object.send(:remove_const, 'Rails')
74
81
  end
75
82
 
@@ -78,7 +85,7 @@ describe "MongoDoc::Connection.Connections" do
78
85
  end
79
86
 
80
87
  it "default the configuration location to Rails.root + '/config/mongodb.yml'" do
81
- MongoDoc::Connection.config_path.should == FauxRails.root + 'config/mongodb.yml'
88
+ MongoDoc::Connection.config_path.to_s.should == 'faux_app/config/mongodb.yml'
82
89
  end
83
90
 
84
91
  context "without a configuration" do
@@ -95,7 +102,7 @@ describe "MongoDoc::Connection.Connections" do
95
102
  end
96
103
 
97
104
  it "creates a default database with strict false" do
98
- connection.should_receive(:db).with("rails_root_development", :strict => false)
105
+ connection.should_receive(:db).with("faux_app_staging", :strict => false)
99
106
  MongoDoc::Connection.database
100
107
  end
101
108
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 0
9
- version: 0.6.0
8
+ - 1
9
+ version: 0.6.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Les Hill
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-14 00:00:00 -04:00
17
+ date: 2010-05-16 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -220,6 +220,8 @@ files:
220
220
  - lib/mongo_doc/finders.rb
221
221
  - lib/mongo_doc/index.rb
222
222
  - lib/mongo_doc/matchers.rb
223
+ - lib/mongo_doc/railtie.rb
224
+ - lib/mongo_doc/railties/config.rb
223
225
  - lib/mongo_doc/root.rb
224
226
  - lib/mongo_doc/scope.rb
225
227
  - lib/mongo_doc/validations.rb