sinatra-mongo 0.0.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/.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,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Joshua Nichols
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,49 @@
1
+ = sinatra-mongo
2
+
3
+ Extends Sinatra with an extension method for dealing with monogodb using the ruby driver.
4
+
5
+
6
+ Install it with gem:
7
+
8
+ $ gem install sinatra-mongo
9
+
10
+ Now we can use it an example application.
11
+
12
+ require 'sinatra'
13
+ require 'sinatra/mongo'
14
+
15
+ # Specify the database to use. Defaults to mongo://localhost:27017/default,
16
+ # so you will almost definitely want to change this.
17
+ #
18
+ # Alternatively, you can specify the MONGO_URL as an environment variable
19
+ set :mongo, 'mongo://localhost:27017/sinatra-mongo-example'
20
+
21
+ # At this point, you can access the Mongo::Database object using the 'mongo' helper:
22
+
23
+ puts mongo["testCollection"].insert {"name" => "MongoDB", "type" => "database", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
24
+
25
+ get '/' do
26
+ mongo["testCollection"].find_one
27
+ end
28
+
29
+ If you need to use authentication, you can specify this in the mongo uri:
30
+
31
+ set :mongo, 'mongo://myuser:mypass@localhost:27017/sinatra-mongo-example'
32
+
33
+ == Mongo Reference
34
+
35
+ * http://www.mongodb.org/display/DOCS/Ruby+Tutorial
36
+
37
+ == Note on Patches/Pull Requests
38
+
39
+ * Fork the project.
40
+ * Make your feature addition or bug fix.
41
+ * Add tests for it. This is important so I don't break it in a
42
+ future version unintentionally.
43
+ * Commit, do not mess with rakefile, version, or history.
44
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
45
+ * Send me a pull request. Bonus points for topic branches.
46
+
47
+ == Copyright
48
+
49
+ Copyright (c) 2009 Joshua Nichols. 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 = "sinatra-mongo"
8
+ gem.summary = %Q{A light extension to sinatra for using mongo}
9
+ gem.description = File.read('README.rdoc')
10
+ gem.email = "josh@technicalpickles.com"
11
+ gem.homepage = "http://github.com/technicalpickles/sinatra-mongo"
12
+ gem.authors = ["Joshua Nichols"]
13
+ gem.version = "0.0.1"
14
+ gem.add_development_dependency "rspec", ">= 1.2.9"
15
+ gem.add_dependency "mongo"
16
+ gem.add_dependency 'sinatra', '>= 0.9.4'
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ require 'spec/rake/spectask'
25
+ Spec::Rake::SpecTask.new(:spec) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.spec_files = FileList['spec/**/*_spec.rb']
28
+ end
29
+
30
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
31
+ spec.libs << 'lib' << 'spec'
32
+ spec.pattern = 'spec/**/*_spec.rb'
33
+ spec.rcov = true
34
+ end
35
+
36
+ task :spec => :check_dependencies
37
+
38
+ task :default => :spec
39
+
40
+ require 'rake/rdoctask'
41
+ Rake::RDocTask.new do |rdoc|
42
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
43
+
44
+ rdoc.rdoc_dir = 'rdoc'
45
+ rdoc.title = "sinatra-mongo #{version}"
46
+ rdoc.rdoc_files.include('README*')
47
+ rdoc.rdoc_files.include('lib/**/*.rb')
48
+ end
@@ -0,0 +1,40 @@
1
+ require 'sinatra'
2
+
3
+ module Sinatra
4
+ module MongoHelper
5
+ def mongo
6
+ options.mongo
7
+ end
8
+ end
9
+
10
+ module MongoExtension
11
+ def mongo=(url)
12
+ @mongo = nil
13
+ set :mongo_url, url
14
+ mongo
15
+ end
16
+
17
+ def mongo
18
+ url = URI(mongo_url)
19
+ connection = Mongo::Connection.new(url.host, url.port)
20
+ @mongo ||= begin
21
+ mongo = connection.db(url.path[1..-1])
22
+ if url.user && url.password
23
+ mongo.authenticate(url.user, url.password)
24
+ end
25
+ mongo
26
+ end
27
+ end
28
+
29
+ protected
30
+
31
+ def self.registered(app)
32
+ app.set :mongo_url, ENV['MONGO_URL'] || 'mongo://127.0.0.1:27017/default'
33
+ app.helpers MongoHelper
34
+ end
35
+
36
+ end
37
+
38
+ register MongoExtension
39
+
40
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "SinatraMongo" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'sinatra-mongo'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-mongo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Joshua Nichols
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-09 00:00:00 -05: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: 1.2.9
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: mongo
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: sinatra
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.9.4
44
+ version:
45
+ description: |
46
+ = sinatra-mongo
47
+
48
+ Extends Sinatra with an extension method for dealing with monogodb using the ruby driver.
49
+
50
+
51
+ Install it with gem:
52
+
53
+ $ gem install sinatra-mongo
54
+
55
+ Now we can use it an example application.
56
+
57
+ require 'sinatra'
58
+ require 'sinatra/mongo'
59
+
60
+ # Specify the database to use. Defaults to mongo://localhost:27017/default,
61
+ # so you will almost definitely want to change this.
62
+ #
63
+ # Alternatively, you can specify the MONGO_URL as an environment variable
64
+ set :mongo, 'mongo://localhost:27017/sinatra-mongo-example'
65
+
66
+ # At this point, you can access the Mongo::Database object using the 'mongo' helper:
67
+
68
+ puts mongo["testCollection"].insert {"name" => "MongoDB", "type" => "database", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
69
+
70
+ get '/' do
71
+ mongo["testCollection"].find_one
72
+ end
73
+
74
+ If you need to use authentication, you can specify this in the mongo uri:
75
+
76
+ set :mongo, 'mongo://myuser:mypass@localhost:27017/sinatra-mongo-example'
77
+
78
+ == Mongo Reference
79
+
80
+ * http://www.mongodb.org/display/DOCS/Ruby+Tutorial
81
+
82
+ == Note on Patches/Pull Requests
83
+
84
+ * Fork the project.
85
+ * Make your feature addition or bug fix.
86
+ * Add tests for it. This is important so I don't break it in a
87
+ future version unintentionally.
88
+ * Commit, do not mess with rakefile, version, or history.
89
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
90
+ * Send me a pull request. Bonus points for topic branches.
91
+
92
+ == Copyright
93
+
94
+ Copyright (c) 2009 Joshua Nichols. See LICENSE for details.
95
+
96
+ email: josh@technicalpickles.com
97
+ executables: []
98
+
99
+ extensions: []
100
+
101
+ extra_rdoc_files:
102
+ - LICENSE
103
+ - README.rdoc
104
+ files:
105
+ - .document
106
+ - .gitignore
107
+ - LICENSE
108
+ - README.rdoc
109
+ - Rakefile
110
+ - lib/sinatra/mongo.rb
111
+ - spec/sinatra-mongo_spec.rb
112
+ - spec/spec.opts
113
+ - spec/spec_helper.rb
114
+ has_rdoc: true
115
+ homepage: http://github.com/technicalpickles/sinatra-mongo
116
+ licenses: []
117
+
118
+ post_install_message:
119
+ rdoc_options:
120
+ - --charset=UTF-8
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: "0"
128
+ version:
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: "0"
134
+ version:
135
+ requirements: []
136
+
137
+ rubyforge_project:
138
+ rubygems_version: 1.3.5
139
+ signing_key:
140
+ specification_version: 3
141
+ summary: A light extension to sinatra for using mongo
142
+ test_files:
143
+ - spec/sinatra-mongo_spec.rb
144
+ - spec/spec_helper.rb