simply_mongo 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/lib/generators/simply_mongo/install/templates/mongo.rb +1 -1
  2. data/lib/generators/simply_mongo/install/templates/mongo.yml +3 -3
  3. data/lib/simply_mongo/version.rb +1 -1
  4. data/test/cmd_line_client/Enterprise.json +30 -0
  5. data/test/cmd_line_client/client.rb +128 -0
  6. data/test/enterprise/Gemfile +45 -0
  7. data/test/enterprise/Gemfile.lock +122 -0
  8. data/test/{dummy → enterprise}/README.rdoc +4 -0
  9. data/test/{dummy → enterprise}/Rakefile +1 -1
  10. data/test/enterprise/app/assets/images/rails.png +0 -0
  11. data/test/{dummy → enterprise}/app/assets/javascripts/application.js +0 -0
  12. data/test/enterprise/app/assets/javascripts/enterprises.js.coffee +3 -0
  13. data/test/{dummy → enterprise}/app/assets/stylesheets/application.css +1 -1
  14. data/test/enterprise/app/assets/stylesheets/enterprises.css.scss +3 -0
  15. data/test/{dummy → enterprise}/app/controllers/application_controller.rb +0 -0
  16. data/test/enterprise/app/controllers/enterprises_controller.rb +62 -0
  17. data/test/{dummy → enterprise}/app/helpers/application_helper.rb +0 -0
  18. data/test/enterprise/app/helpers/enterprises_helper.rb +2 -0
  19. data/test/enterprise/app/views/enterprises/create.html.erb +2 -0
  20. data/test/enterprise/app/views/enterprises/new.html.erb +2 -0
  21. data/test/{dummy → enterprise}/app/views/layouts/application.html.erb +1 -1
  22. data/test/{dummy → enterprise}/config/application.rb +16 -10
  23. data/test/enterprise/config/boot.rb +6 -0
  24. data/test/{dummy → enterprise}/config/environment.rb +1 -1
  25. data/test/{dummy → enterprise}/config/environments/development.rb +1 -7
  26. data/test/{dummy → enterprise}/config/environments/production.rb +2 -5
  27. data/test/{dummy → enterprise}/config/environments/test.rb +1 -3
  28. data/test/{dummy → enterprise}/config/initializers/backtrace_silencers.rb +0 -0
  29. data/test/{dummy/db/test.sqlite3 → enterprise/config/initializers/databases.rb} +0 -0
  30. data/test/{dummy → enterprise}/config/initializers/inflections.rb +0 -0
  31. data/test/{dummy → enterprise}/config/initializers/mime_types.rb +0 -0
  32. data/test/enterprise/config/initializers/mongo.rb +47 -0
  33. data/test/{dummy → enterprise}/config/initializers/secret_token.rb +1 -1
  34. data/test/{dummy → enterprise}/config/initializers/session_store.rb +2 -2
  35. data/test/{dummy → enterprise}/config/initializers/wrap_parameters.rb +2 -5
  36. data/test/{dummy → enterprise}/config/locales/en.yml +0 -0
  37. data/test/enterprise/config/mongo.yml +45 -0
  38. data/test/{dummy → enterprise}/config/routes.rb +10 -1
  39. data/test/{dummy → enterprise}/config.ru +1 -1
  40. data/test/enterprise/db/seeds.rb +7 -0
  41. data/test/enterprise/doc/README_FOR_APP +2 -0
  42. data/test/enterprise/log/development.log +968 -0
  43. data/test/{dummy → enterprise}/public/404.html +0 -0
  44. data/test/{dummy → enterprise}/public/422.html +0 -0
  45. data/test/{dummy → enterprise}/public/500.html +0 -0
  46. data/test/{dummy → enterprise}/public/favicon.ico +0 -0
  47. data/test/enterprise/public/index.html +241 -0
  48. data/test/enterprise/public/robots.txt +5 -0
  49. data/test/{dummy → enterprise}/script/rails +0 -0
  50. data/test/enterprise/tmp/cache/assets/CF0/DA0/sprockets%2Fd7d5b37686831d37c4dd75e645f5e016 +0 -0
  51. data/test/enterprise/tmp/cache/assets/E25/4C0/sprockets%2Fde2fd9fd11c04a582cdbbe3d84a35ae6 +0 -0
  52. data/test/enterprise/tmp/pids/server.pid +1 -0
  53. metadata +100 -67
  54. data/test/dummy/config/boot.rb +0 -10
  55. data/test/dummy/config/database.yml +0 -25
  56. data/test/dummy/log/test.log +0 -3
  57. data/test/simply_mongo_test.rb +0 -7
  58. data/test/test_helper.rb +0 -15
@@ -26,7 +26,7 @@ module SimplyMongo
26
26
  options = {}
27
27
  end
28
28
 
29
- @@driver = SimplyMongo::Driver.new(db_name, host, port, options);
29
+ @@driver = SimplyMongo::Driver.new(db_name, host, port, options.symbolize_keys);
30
30
  @@connection = @@driver.conn
31
31
  @@db = @@driver.db
32
32
  end
@@ -21,7 +21,7 @@
21
21
 
22
22
  development:
23
23
  adapter: mongodb
24
- database: dyntech-dev
24
+ database: simply-mongo-dev
25
25
  host: localhost
26
26
  port: 27017
27
27
  options:
@@ -30,7 +30,7 @@ development:
30
30
 
31
31
  test:
32
32
  adapter: mongodb
33
- database: dyntech-test
33
+ database: simply-mongo-test
34
34
  host: localhost
35
35
  port: 27017
36
36
  options:
@@ -38,7 +38,7 @@ test:
38
38
 
39
39
  production:
40
40
  adapter: mongodb
41
- database: dyntech
41
+ database: simply-mongo
42
42
  host: localhost
43
43
  port: 27017
44
44
  options:
@@ -1,3 +1,3 @@
1
1
  module SimplyMongo
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -0,0 +1,30 @@
1
+ {
2
+ "enterprise": {
3
+ "city": "Bedrock",
4
+ "contacts": [
5
+ {
6
+ "email": [
7
+ {
8
+ "description": "Work Email",
9
+ "email": "fflintstone@bedrock.com"
10
+ }
11
+ ],
12
+ "first_name": "Fred",
13
+ "last_name": "Flintstone",
14
+ "phone": [
15
+ {
16
+ "description": "Home Phone",
17
+ "number": "1-123-1234"
18
+ }
19
+ ]
20
+ }
21
+ ],
22
+ "country": "US",
23
+ "description": "We dig and move rocks and gravel using the latest technologies",
24
+ "name": "Slate Rock and Gravel",
25
+ "phone": "1.123.1234",
26
+ "street": "123 Quarry Pit",
27
+ "web_site": "http://www.slaterockandgravel.com",
28
+ "zip": "12345"
29
+ }
30
+ }
@@ -0,0 +1,128 @@
1
+ #
2
+ # JSON/Rails/Mongo examples using the only the Mongo Driver in Rails
3
+ # This is a contrived example client sending JSON CRUD request to
4
+ # Mongo in a Rails Server
5
+ #
6
+ # Author:: Robert D. Birch
7
+ #
8
+ require 'json'
9
+ require 'net/http'
10
+
11
+ module SimplyMongoClient
12
+
13
+ BASE_URI= 'http://0.0.0.0:3000/enterprises/'
14
+ INPUT_FILE = './Enterprise.json'
15
+
16
+ # Reads in a JSON Enterprise document from a flat file.
17
+ # The read in JSON document string is sent to the the Rails server as a POST
18
+ def SimplyMongoClient.create(enterprise)
19
+ request = Net::HTTP::Post.new("/enterprises/create")
20
+ request['CONTENT-TYPE'] = 'application/json'
21
+ request.body = enterprise
22
+ response = Net::HTTP.new('0.0.0.0', 3000).start do |http|
23
+ http.request(request)
24
+ end
25
+ raise IOError, "Network Error #{response.message}" if response.code == 200
26
+ return response
27
+ end
28
+
29
+ # From the Rails server return all the enterprise documents stored in the Mongo Database
30
+ def SimplyMongoClient.index
31
+ uri = URI(BASE_URI)
32
+ response = Net::HTTP.get_response(uri)
33
+ raise IOError, "Network Error #{response.message}" if response.code == 200
34
+ j = JSON.parse(response.body)
35
+ end
36
+
37
+ # Get the requested enterprise document
38
+ def SimplyMongoClient.show(id)
39
+ uri = URI(BASE_URI + "/" + id)
40
+ response = Net::HTTP.get_response(uri)
41
+ raise IOError, "Network Error #{response.message}" if response.code == 200
42
+ j = JSON.parse(response.body)
43
+ end
44
+
45
+ # Update/Replace the enterprise document on the server
46
+ def SimplyMongoClient.update(enterprise)
47
+ request = Net::HTTP::Put.new(BASE_URI + enterprise['_id'])
48
+ request['CONTENT-TYPE'] = 'application/json'
49
+ request.set_form_data(enterprise)
50
+ response = Net::HTTP.new('0.0.0.0', 3000).start do |http |
51
+ response = http.request(request)
52
+ end
53
+ raise IOError, "Network Error #{response.message}" if response.code == 200
54
+ return response
55
+ end
56
+
57
+ # Delete the enterprise document with the given id
58
+ def SimplyMongoClient.destroy(id)
59
+ request = Net::HTTP::Delete.new(BASE_URI + "/" + id)
60
+ response = Net::HTTP.new('0.0.0.0', 3000).start do |http |
61
+ http.request(request)
62
+ end
63
+ raise IOError, "Network Error #{response.message}" if response.code == 200
64
+ return response
65
+ end
66
+
67
+ end # SimplyMongoClient
68
+
69
+
70
+ ## Contrived set of example statement to create, fetch, update and delete an enterprise document
71
+
72
+ # Get all documents and print the count
73
+ puts "**LIST**"
74
+ j = SimplyMongoClient.index
75
+ puts "We start with #{j.count} enterprise documents in the Mongo collection"
76
+ puts ""
77
+
78
+ # Create an enterprise document
79
+ puts "**CREATE**"
80
+ fjson = File.open(SimplyMongoClient::INPUT_FILE)
81
+ enterprise = ""
82
+ fjson.each { |line| enterprise = enterprise + line; }
83
+ res = SimplyMongoClient.create enterprise
84
+ e = JSON.parse res.body
85
+ puts "Created one enterprise document with id: #{e['id']}"
86
+ fjson.close
87
+ puts ""
88
+
89
+ # Fetch and display the recently created enterprise document
90
+ puts "**GET**"
91
+ puts "Display created enterprise document with id: #{e['id']}"
92
+ j = SimplyMongoClient.show e['id']
93
+ puts "Show document with id #{e['id']} : #{j}"
94
+ puts ""
95
+
96
+ # Update/Replay the enterprise document by changing the email address
97
+ puts "**UPDATE**"
98
+ new_mail = "fflintstone@slaterockandgravel.com"
99
+ puts "Update document by changing home email: fflinstone@bedrock.com to : #{new_mail}"
100
+ contacts = j['contacts']
101
+ contacts.each { |c|
102
+ if c['last_name'] == 'Flintstone'
103
+ then
104
+ c['email'].each { |e|
105
+ if e['description'] == "Work Email"
106
+ then
107
+ puts "CURRENT EMAIL #{e['email']}"
108
+ e['email'] = new_mail
109
+ puts "NEW EMAIL #{e['email']}"
110
+ end
111
+ }
112
+ end
113
+ }
114
+ r = SimplyMongoClient.update j
115
+ # Fetch and display the recently updateed enterprise document
116
+ puts "Display updated enterprise document with id: #{e['id']}"
117
+ uj = SimplyMongoClient.show e['id']
118
+ puts "Show document with id #{e['id']} : #{uj}"
119
+ puts ""
120
+
121
+ # Delete the newly created enterprise document
122
+ puts "**DELETE**"
123
+ puts "Destroy one enterprise document with id: #{e['id']}"
124
+ r = SimplyMongoClient.destroy e['id']
125
+ puts "Destroy returned with a response code of : #{r.code}"
126
+ puts "Show document with id #{e['id']} "
127
+ j = SimplyMongoClient.show e['id']
128
+ puts "Document id: #{e['id']} should be deleted (empty) => #{j}"
@@ -0,0 +1,45 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails'
4
+ gem 'mongo'
5
+ gem 'bson_ext'
6
+
7
+ # Bundle edge Rails instead:
8
+ # gem 'rails', :git => 'git://github.com/rails/rails.git'
9
+
10
+
11
+ # Gems used only for assets and not required
12
+ # in production environments by default.
13
+ group :assets do
14
+ gem 'sass-rails'
15
+ gem 'coffee-rails'
16
+
17
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
18
+ # gem 'therubyracer', :platform => :ruby
19
+
20
+ gem 'uglifier'
21
+ end
22
+
23
+ group :production do
24
+
25
+ end
26
+
27
+ #gem 'simply_mongo', :git => 'https://github.com/robdbirch/simply_mongo.git'
28
+ gem 'simply_mongo'
29
+
30
+ gem 'jquery-rails'
31
+
32
+ # To use ActiveModel has_secure_password
33
+ # gem 'bcrypt-ruby', '~> 3.0.0'
34
+
35
+ # To use Jbuilder templates for JSON
36
+ # gem 'jbuilder'
37
+
38
+ # Use unicorn as the app server
39
+ # gem 'unicorn'
40
+
41
+ # Deploy with Capistrano
42
+ # gem 'capistrano'
43
+
44
+ # To use debugger
45
+ # gem 'ruby-debug19', :require => 'ruby-debug'
@@ -0,0 +1,122 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ actionmailer (3.2.8)
5
+ actionpack (= 3.2.8)
6
+ mail (~> 2.4.4)
7
+ actionpack (3.2.8)
8
+ activemodel (= 3.2.8)
9
+ activesupport (= 3.2.8)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ journey (~> 1.0.4)
13
+ rack (~> 1.4.0)
14
+ rack-cache (~> 1.2)
15
+ rack-test (~> 0.6.1)
16
+ sprockets (~> 2.1.3)
17
+ activemodel (3.2.8)
18
+ activesupport (= 3.2.8)
19
+ builder (~> 3.0.0)
20
+ activerecord (3.2.8)
21
+ activemodel (= 3.2.8)
22
+ activesupport (= 3.2.8)
23
+ arel (~> 3.0.2)
24
+ tzinfo (~> 0.3.29)
25
+ activeresource (3.2.8)
26
+ activemodel (= 3.2.8)
27
+ activesupport (= 3.2.8)
28
+ activesupport (3.2.8)
29
+ i18n (~> 0.6)
30
+ multi_json (~> 1.0)
31
+ arel (3.0.2)
32
+ bson (1.7.0)
33
+ bson_ext (1.7.0)
34
+ bson (~> 1.7.0)
35
+ builder (3.0.4)
36
+ coffee-rails (3.2.2)
37
+ coffee-script (>= 2.2.0)
38
+ railties (~> 3.2.0)
39
+ coffee-script (2.2.0)
40
+ coffee-script-source
41
+ execjs
42
+ coffee-script-source (1.3.3)
43
+ erubis (2.7.0)
44
+ execjs (1.4.0)
45
+ multi_json (~> 1.0)
46
+ hike (1.2.1)
47
+ i18n (0.6.1)
48
+ journey (1.0.4)
49
+ jquery-rails (2.1.3)
50
+ railties (>= 3.1.0, < 5.0)
51
+ thor (~> 0.14)
52
+ json (1.7.5)
53
+ mail (2.4.4)
54
+ i18n (>= 0.4.0)
55
+ mime-types (~> 1.16)
56
+ treetop (~> 1.4.8)
57
+ mime-types (1.19)
58
+ mongo (1.7.0)
59
+ bson (~> 1.7.0)
60
+ multi_json (1.3.7)
61
+ polyglot (0.3.3)
62
+ rack (1.4.1)
63
+ rack-cache (1.2)
64
+ rack (>= 0.4)
65
+ rack-ssl (1.3.2)
66
+ rack
67
+ rack-test (0.6.2)
68
+ rack (>= 1.0)
69
+ rails (3.2.8)
70
+ actionmailer (= 3.2.8)
71
+ actionpack (= 3.2.8)
72
+ activerecord (= 3.2.8)
73
+ activeresource (= 3.2.8)
74
+ activesupport (= 3.2.8)
75
+ bundler (~> 1.0)
76
+ railties (= 3.2.8)
77
+ railties (3.2.8)
78
+ actionpack (= 3.2.8)
79
+ activesupport (= 3.2.8)
80
+ rack-ssl (~> 1.3.2)
81
+ rake (>= 0.8.7)
82
+ rdoc (~> 3.4)
83
+ thor (>= 0.14.6, < 2.0)
84
+ rake (0.9.2.2)
85
+ rdoc (3.12)
86
+ json (~> 1.4)
87
+ sass (3.2.1)
88
+ sass-rails (3.2.5)
89
+ railties (~> 3.2.0)
90
+ sass (>= 3.1.10)
91
+ tilt (~> 1.3)
92
+ simply_mongo (0.0.6)
93
+ bson
94
+ bson_ext
95
+ mongo
96
+ rails (~> 3.2.8)
97
+ sprockets (2.1.3)
98
+ hike (~> 1.2)
99
+ rack (~> 1.0)
100
+ tilt (~> 1.1, != 1.3.0)
101
+ thor (0.16.0)
102
+ tilt (1.3.3)
103
+ treetop (1.4.12)
104
+ polyglot
105
+ polyglot (>= 0.3.1)
106
+ tzinfo (0.3.35)
107
+ uglifier (1.3.0)
108
+ execjs (>= 0.3.0)
109
+ multi_json (~> 1.0, >= 1.0.2)
110
+
111
+ PLATFORMS
112
+ ruby
113
+
114
+ DEPENDENCIES
115
+ bson_ext
116
+ coffee-rails
117
+ jquery-rails
118
+ mongo
119
+ rails
120
+ sass-rails
121
+ simply_mongo
122
+ uglifier
@@ -259,3 +259,7 @@ vendor
259
259
  External libraries that the application depends on. Also includes the plugins
260
260
  subdirectory. If the app has frozen rails, those gems also go here, under
261
261
  vendor/rails/. This directory is in the load path.
262
+
263
+ Setup
264
+ $ rails new enterprise --skip-active-record --skip-test-unit
265
+ $ bundle install --without production
@@ -4,4 +4,4 @@
4
4
 
5
5
  require File.expand_path('../config/application', __FILE__)
6
6
 
7
- Dummy::Application.load_tasks
7
+ Enterprise::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -10,4 +10,4 @@
10
10
  *
11
11
  *= require_self
12
12
  *= require_tree .
13
- */
13
+ */
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the Enterprises controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,62 @@
1
+ require 'simply_mongo'
2
+
3
+ class EnterprisesController < ApplicationController
4
+
5
+ def new
6
+ render :text => "SHOW"
7
+ end
8
+
9
+ def create
10
+ e = params[:enterprise]
11
+ logger.debug(e)
12
+ en = e[:name]
13
+ ec = SimplyMongo.db['enterprises']
14
+ id = BSON::ObjectId.new
15
+ e[:_id] = id
16
+ ec.insert(e)
17
+ eid = ec.find_one({'_id' => id}, { :fields => [ '_id'] } )
18
+ j = { :id => eid['_id'].to_s}
19
+ render :text => j.to_json
20
+ end
21
+
22
+ def index
23
+ ec = SimplyMongo.db['enterprises']
24
+ c = ec.find()
25
+ e = [ ]
26
+ c.each { |ce| e.push(ce) }
27
+ render :text => e.to_json
28
+ end
29
+
30
+ def show
31
+ ec = SimplyMongo.db['enterprises']
32
+ id = params['id']
33
+ bid = BSON::ObjectId id
34
+ one = ec.find_one({ '_id' => bid})
35
+ if one.nil?
36
+ render :text => { }.to_json
37
+ else
38
+ oid = one['_id']
39
+ one['_id'] = oid.to_s
40
+ render :text => one.to_json
41
+ end
42
+ end
43
+
44
+ def update
45
+ p = params.clone
46
+ id = p.delete('id')
47
+ bid = BSON::ObjectId id
48
+ p['_id'] = bid
49
+ ec = SimplyMongo.db['enterprises']
50
+ ec.update({'_id' => bid}, p)
51
+ render :text => "{ 'code': 'success'}"
52
+ end
53
+
54
+ def destroy
55
+ ec = SimplyMongo.db['enterprises']
56
+ id = params['id']
57
+ bid = BSON::ObjectId id
58
+ ec.remove({ '_id' => bid})
59
+ render :text => { :removed =>"removed"}
60
+ end
61
+
62
+ end
@@ -0,0 +1,2 @@
1
+ module EnterprisesHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ <h1>Enterprises#create</h1>
2
+ <p>Find me in app/views/enterprises/create.html.erb</p>
@@ -0,0 +1,2 @@
1
+ <h1>Enterprises#new</h1>
2
+ <p>Find me in app/views/enterprises/new.html.erb</p>
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Dummy</title>
4
+ <title>Enterprise</title>
5
5
  <%= stylesheet_link_tag "application", :media => "all" %>
6
6
  <%= javascript_include_tag "application" %>
7
7
  <%= csrf_meta_tags %>
@@ -1,11 +1,21 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
- require 'rails/all'
4
-
5
- Bundler.require
6
- require "simply_mongo"
3
+ # Pick the frameworks you want:
4
+ # require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_mailer/railtie"
7
+ require "active_resource/railtie"
8
+ require "sprockets/railtie"
9
+ # require "rails/test_unit/railtie"
10
+
11
+ if defined?(Bundler)
12
+ # If you precompile assets before deploying to production, use this line
13
+ Bundler.require(*Rails.groups(:assets => %w(development test)))
14
+ # If you want your assets lazily compiled in production, use this line
15
+ # Bundler.require(:default, :assets, Rails.env)
16
+ end
7
17
 
8
- module Dummy
18
+ module Enterprise
9
19
  class Application < Rails::Application
10
20
  # Settings in config/environments/* take precedence over those specified here.
11
21
  # Application configuration should go into files in config/initializers
@@ -35,9 +45,6 @@ module Dummy
35
45
  # Configure sensitive parameters which will be filtered from the log file.
36
46
  config.filter_parameters += [:password]
37
47
 
38
- # Enable escaping HTML in JSON.
39
- config.active_support.escape_html_entities_in_json = true
40
-
41
48
  # Use SQL instead of Active Record's schema dumper when creating the database.
42
49
  # This is necessary if your schema can't be completely dumped by the schema dumper,
43
50
  # like if you have constraints or database-specific column types
@@ -47,7 +54,7 @@ module Dummy
47
54
  # This will create an empty whitelist of attributes available for mass-assignment for all models
48
55
  # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
49
56
  # parameters by using an attr_accessible or attr_protected declaration.
50
- config.active_record.whitelist_attributes = true
57
+ # config.active_record.whitelist_attributes = true
51
58
 
52
59
  # Enable the asset pipeline
53
60
  config.assets.enabled = true
@@ -56,4 +63,3 @@ module Dummy
56
63
  config.assets.version = '1.0'
57
64
  end
58
65
  end
59
-
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
+
6
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -2,4 +2,4 @@
2
2
  require File.expand_path('../application', __FILE__)
3
3
 
4
4
  # Initialize the rails application
5
- Dummy::Application.initialize!
5
+ Enterprise::Application.initialize!
@@ -1,4 +1,4 @@
1
- Dummy::Application.configure do
1
+ Enterprise::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
4
  # In the development environment your application's code is reloaded on
@@ -22,12 +22,6 @@ Dummy::Application.configure do
22
22
  # Only use best-standards-support built into browsers
23
23
  config.action_dispatch.best_standards_support = :builtin
24
24
 
25
- # Raise exception on mass assignment protection for Active Record models
26
- config.active_record.mass_assignment_sanitizer = :strict
27
-
28
- # Log the query plan for queries taking more than this (works
29
- # with SQLite, MySQL, and PostgreSQL)
30
- config.active_record.auto_explain_threshold_in_seconds = 0.5
31
25
 
32
26
  # Do not compress assets
33
27
  config.assets.compress = false
@@ -1,4 +1,4 @@
1
- Dummy::Application.configure do
1
+ Enterprise::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
4
  # Code is not reloaded between requests
@@ -20,7 +20,7 @@ Dummy::Application.configure do
20
20
  # Generate digests for assets URLs
21
21
  config.assets.digest = true
22
22
 
23
- # Defaults to nil and saved in location specified by config.assets.prefix
23
+ # Defaults to Rails.root.join("public/assets")
24
24
  # config.assets.manifest = YOUR_PATH
25
25
 
26
26
  # Specifies the header that your server uses for sending files
@@ -61,7 +61,4 @@ Dummy::Application.configure do
61
61
  # Send deprecation notices to registered listeners
62
62
  config.active_support.deprecation = :notify
63
63
 
64
- # Log the query plan for queries taking more than this (works
65
- # with SQLite, MySQL, and PostgreSQL)
66
- # config.active_record.auto_explain_threshold_in_seconds = 0.5
67
64
  end
@@ -1,4 +1,4 @@
1
- Dummy::Application.configure do
1
+ Enterprise::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
4
  # The test environment is used exclusively to run your application's
@@ -29,8 +29,6 @@ Dummy::Application.configure do
29
29
  # ActionMailer::Base.deliveries array.
30
30
  config.action_mailer.delivery_method = :test
31
31
 
32
- # Raise exception on mass assignment protection for Active Record models
33
- config.active_record.mass_assignment_sanitizer = :strict
34
32
 
35
33
  # Print deprecation notices to the stderr
36
34
  config.active_support.deprecation = :stderr
@@ -0,0 +1,47 @@
1
+ require 'simply_mongo'
2
+ module SimplyMongo
3
+
4
+ Rails.application.config.after_initialize do
5
+ mongo_config_file = File.join("#{Rails.root}", 'config', 'mongo.yml')
6
+ raise "#{mongo_config_file} is missing!" unless File.exists? mongo_config_file
7
+ mongo_config = YAML.load_file(mongo_config_file)
8
+
9
+ db_config = mongo_config.fetch(Rails.env)
10
+
11
+ db_name = db_config['database']
12
+ raise "Mongo database not set for environment #{Rails.env}" unless not db_name.nil?
13
+
14
+ host = db_config['host']
15
+ if host.nil? then
16
+ host = localhost
17
+ end
18
+
19
+ port = db_config['port']
20
+ if port.nil? then
21
+ port = 27017
22
+ end
23
+
24
+ options = db_config['options']
25
+ if options.nil?
26
+ options = {}
27
+ end
28
+
29
+ @@driver = SimplyMongo::Driver.new(db_name, host, port, options.symbolize_keys);
30
+ @@connection = @@driver.conn
31
+ @@db = @@driver.db
32
+ end
33
+
34
+ def SimplyMongo.db
35
+ @@db
36
+ end
37
+
38
+ def SimplyMongo.connction
39
+ @@connection
40
+ end
41
+
42
+ def SimplyMongo.driver
43
+ @@driver
44
+ end
45
+ end
46
+
47
+