bmizerany-sinatra-mongo 0.0.3

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.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -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.
@@ -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.
@@ -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.2"
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,44 @@
1
+ require 'sinatra/base'
2
+ require 'mongo'
3
+
4
+ module Sinatra
5
+ module MongoHelper
6
+ def mongo
7
+ options.mongo
8
+ end
9
+ end
10
+
11
+ module MongoExtension
12
+ def mongo=(url)
13
+ @mongo = nil
14
+ set :mongo_url, url
15
+ mongo
16
+ end
17
+
18
+ def mongo
19
+ synchronize do
20
+ @mongo ||= (
21
+ url = URI(mongo_url)
22
+ connection = Mongo::Connection.new(url.host, url.port)
23
+ mongo = connection.db(url.path[1..-1], mongo_settings)
24
+ if url.user && url.password
25
+ mongo.authenticate(url.user, url.password)
26
+ end
27
+ mongo
28
+ )
29
+ end
30
+ end
31
+
32
+ protected
33
+
34
+ def self.registered(app)
35
+ app.set :mongo_url, ENV['MONGO_URL'] || 'mongo://127.0.0.1:27017/default'
36
+ app.set :mongo_settings, Hash.new
37
+ app.helpers MongoHelper
38
+ end
39
+
40
+ end
41
+
42
+ register MongoExtension
43
+
44
+ end
@@ -0,0 +1,109 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{sinatra-mongo}
8
+ s.version = "0.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Joshua Nichols"]
12
+ s.date = %q{2009-12-10}
13
+ s.description = %q{= sinatra-mongo
14
+
15
+ Extends Sinatra with an extension method for dealing with monogodb using the ruby driver.
16
+
17
+
18
+ Install it with gem:
19
+
20
+ $ gem install sinatra-mongo
21
+
22
+ Now we can use it an example application.
23
+
24
+ require 'sinatra'
25
+ require 'sinatra/mongo'
26
+
27
+ # Specify the database to use. Defaults to mongo://localhost:27017/default,
28
+ # so you will almost definitely want to change this.
29
+ #
30
+ # Alternatively, you can specify the MONGO_URL as an environment variable
31
+ set :mongo, 'mongo://localhost:27017/sinatra-mongo-example'
32
+
33
+ # At this point, you can access the Mongo::Database object using the 'mongo' helper:
34
+
35
+ puts mongo["testCollection"].insert {"name" => "MongoDB", "type" => "database", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
36
+
37
+ get '/' do
38
+ mongo["testCollection"].find_one
39
+ end
40
+
41
+ If you need to use authentication, you can specify this in the mongo uri:
42
+
43
+ set :mongo, 'mongo://myuser:mypass@localhost:27017/sinatra-mongo-example'
44
+
45
+ == Mongo Reference
46
+
47
+ * http://www.mongodb.org/display/DOCS/Ruby+Tutorial
48
+
49
+ == Note on Patches/Pull Requests
50
+
51
+ * Fork the project.
52
+ * Make your feature addition or bug fix.
53
+ * Add tests for it. This is important so I don't break it in a
54
+ future version unintentionally.
55
+ * Commit, do not mess with rakefile, version, or history.
56
+ (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)
57
+ * Send me a pull request. Bonus points for topic branches.
58
+
59
+ == Copyright
60
+
61
+ Copyright (c) 2009 Joshua Nichols. See LICENSE for details.
62
+ }
63
+ s.email = %q{josh@technicalpickles.com}
64
+ s.extra_rdoc_files = [
65
+ "LICENSE",
66
+ "README.rdoc"
67
+ ]
68
+ s.files = [
69
+ ".document",
70
+ ".gitignore",
71
+ "LICENSE",
72
+ "README.rdoc",
73
+ "Rakefile",
74
+ "lib/sinatra/mongo.rb",
75
+ "sinatra-mongo.gemspec",
76
+ "spec/sinatra-mongo_spec.rb",
77
+ "spec/spec.opts",
78
+ "spec/spec_helper.rb"
79
+ ]
80
+ s.homepage = %q{http://github.com/technicalpickles/sinatra-mongo}
81
+ s.rdoc_options = ["--charset=UTF-8"]
82
+ s.require_paths = ["lib"]
83
+ s.rubygems_version = %q{1.3.5}
84
+ s.summary = %q{A light extension to sinatra for using mongo}
85
+ s.test_files = [
86
+ "spec/sinatra-mongo_spec.rb",
87
+ "spec/spec_helper.rb"
88
+ ]
89
+
90
+ if s.respond_to? :specification_version then
91
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
92
+ s.specification_version = 3
93
+
94
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
95
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
96
+ s.add_runtime_dependency(%q<mongo>, [">= 0"])
97
+ s.add_runtime_dependency(%q<sinatra>, [">= 0.9.4"])
98
+ else
99
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
100
+ s.add_dependency(%q<mongo>, [">= 0"])
101
+ s.add_dependency(%q<sinatra>, [">= 0.9.4"])
102
+ end
103
+ else
104
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
105
+ s.add_dependency(%q<mongo>, [">= 0"])
106
+ s.add_dependency(%q<sinatra>, [">= 0.9.4"])
107
+ end
108
+ end
109
+
@@ -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
@@ -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,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bmizerany-sinatra-mongo
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 3
9
+ version: 0.0.3
10
+ platform: ruby
11
+ authors:
12
+ - Joshua Nichols
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2009-12-10 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
31
+ version: 1.2.9
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: mongo
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: sinatra
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ - 9
56
+ - 4
57
+ version: 0.9.4
58
+ type: :runtime
59
+ version_requirements: *id003
60
+ description: |
61
+ = sinatra-mongo
62
+
63
+ Extends Sinatra with an extension method for dealing with monogodb using the ruby driver.
64
+
65
+
66
+ Install it with gem:
67
+
68
+ $ gem install sinatra-mongo
69
+
70
+ Now we can use it an example application.
71
+
72
+ require 'sinatra'
73
+ require 'sinatra/mongo'
74
+
75
+ # Specify the database to use. Defaults to mongo://localhost:27017/default,
76
+ # so you will almost definitely want to change this.
77
+ #
78
+ # Alternatively, you can specify the MONGO_URL as an environment variable
79
+ set :mongo, 'mongo://localhost:27017/sinatra-mongo-example'
80
+
81
+ # At this point, you can access the Mongo::Database object using the 'mongo' helper:
82
+
83
+ puts mongo["testCollection"].insert {"name" => "MongoDB", "type" => "database", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
84
+
85
+ get '/' do
86
+ mongo["testCollection"].find_one
87
+ end
88
+
89
+ If you need to use authentication, you can specify this in the mongo uri:
90
+
91
+ set :mongo, 'mongo://myuser:mypass@localhost:27017/sinatra-mongo-example'
92
+
93
+ == Mongo Reference
94
+
95
+ * http://www.mongodb.org/display/DOCS/Ruby+Tutorial
96
+
97
+ == Note on Patches/Pull Requests
98
+
99
+ * Fork the project.
100
+ * Make your feature addition or bug fix.
101
+ * Add tests for it. This is important so I don't break it in a
102
+ future version unintentionally.
103
+ * Commit, do not mess with rakefile, version, or history.
104
+ (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)
105
+ * Send me a pull request. Bonus points for topic branches.
106
+
107
+ == Copyright
108
+
109
+ Copyright (c) 2009 Joshua Nichols. See LICENSE for details.
110
+
111
+ email: josh@technicalpickles.com
112
+ executables: []
113
+
114
+ extensions: []
115
+
116
+ extra_rdoc_files:
117
+ - LICENSE
118
+ - README.rdoc
119
+ files:
120
+ - .document
121
+ - .gitignore
122
+ - LICENSE
123
+ - README.rdoc
124
+ - Rakefile
125
+ - lib/sinatra/mongo.rb
126
+ - sinatra-mongo.gemspec
127
+ - spec/sinatra-mongo_spec.rb
128
+ - spec/spec.opts
129
+ - spec/spec_helper.rb
130
+ has_rdoc: true
131
+ homepage: http://github.com/technicalpickles/sinatra-mongo
132
+ licenses: []
133
+
134
+ post_install_message:
135
+ rdoc_options:
136
+ - --charset=UTF-8
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ segments:
144
+ - 0
145
+ version: "0"
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ segments:
151
+ - 0
152
+ version: "0"
153
+ requirements: []
154
+
155
+ rubyforge_project:
156
+ rubygems_version: 1.3.6
157
+ signing_key:
158
+ specification_version: 3
159
+ summary: A light extension to sinatra for using mongo
160
+ test_files:
161
+ - spec/sinatra-mongo_spec.rb
162
+ - spec/spec_helper.rb