minimongo 0.0.3 → 0.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d23caa04c45a7a6ed4eff7c5b88740297560c5ff
4
- data.tar.gz: f7b33ab0c1ecaa15dc09fd465f22c7e192c9d132
3
+ metadata.gz: cdc210b03c6a4909f8beaad790a09d5c45142f11
4
+ data.tar.gz: 9aa996f4d3c7e81c04cb66b1265bf4c3474a8c20
5
5
  SHA512:
6
- metadata.gz: 2126224fbd0804e04298e5f45b65ab09004b6e71ec486e95dcf5eeccef2af6ef15093fea446de46bf5d199ce878f3c942bb4c70acaa529938fda7beef20c73c1
7
- data.tar.gz: d182d9d4a498d5c5951a1571b2f910dada8a78790587e9cc6dc8575ec53bb80d6047b88e9353f67e11b18a1be4cf9955ae41926b427da3522cee1eb8b10d43ea
6
+ metadata.gz: e7015d75709cb37cb50fff0e70f6d68ad70bef56fbfc8f06f604ec275d4623118b65653ccfa83aa55934deb5f47720f139e7329b7435de50b9bfea9d2aa8cdcb
7
+ data.tar.gz: af4271a4e4b5b750560ac71fc09bcb37f1ede0ba7eeda3f4b04f8076e3c259a0a135a574c9d737572c3a4ae62ed4bd484d681cf54af7dba5643ae846d74aac72
@@ -0,0 +1,2 @@
1
+ .bundle
2
+ Gemfile.lock
@@ -0,0 +1,3 @@
1
+ **Version 0.1.0** - *2017-01-05*
2
+
3
+ - Fixed gemspec issues
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rerun'
7
+ gem 'rb-fsevent'
8
+ gem 'terminal-notifier'
9
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Fugroup
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,70 @@
1
+ # Minimongo
2
+ The world's tiniest MongoDB Ruby library, only 6 lines of code. Nothing is faster than no code.
3
+
4
+ If you need models, have a look at [Modelize,](https://github.com/fugroup/modelize) it can be run on top of Minimongo.
5
+
6
+ We also have [Mongocore](https://github.com/fugroup/mongocore) if you're looking for a full ORM.
7
+
8
+ ### Installation
9
+ ```
10
+ gem install minimongo
11
+ ```
12
+ or add to Gemfile.
13
+
14
+ ### Usage
15
+ ```ruby
16
+ # All commands supported
17
+ # https://docs.mongodb.com/ruby-driver/master/quick-start
18
+
19
+ # Connect
20
+ Minimongo.db = Mongo::Client.new([ '127.0.0.1:27017' ], :database => "minimongo")
21
+
22
+ # Include methods in a class or module
23
+ include Minimongo::Query
24
+
25
+ # Include as helper in a Sinatra app
26
+ helpers Minimongo::Query
27
+
28
+ # Find needs first, count or to_a after
29
+ d = find(:domains).first
30
+ d = find(:domains).sort(:duration => -1).to_a
31
+ m = find(:messages, :_id => d._id).limit(1).first
32
+ c = find(:messages).count
33
+
34
+ # All
35
+ m = all(:messages)
36
+ m = all(:messages, :duration => {:$gt => 6})
37
+
38
+ # First
39
+ m = first(:models)
40
+ m = first(:models, :goal => 7)
41
+
42
+ # Last
43
+ m = last(:models)
44
+ m = last(:models, :duration => {:$ne => 6})
45
+
46
+ # Count
47
+ c = count(:messages)
48
+ c = count(:messages, :goal => 'hello')
49
+
50
+ # Insert
51
+ insert(:domains, :name => p[:name], :email => p[:email], :reply => p[:reply])
52
+
53
+ # Update
54
+ update(:domains, {:_id => p[:id]}, :name => p[:name], :email => p[:email])
55
+
56
+ # Delete
57
+ delete(:domains, :_id => p[:id])
58
+
59
+ # String to Object ID
60
+ oid('586333360aec08e87bd62180')
61
+
62
+ # New Object ID
63
+ oid
64
+ oid(:new)
65
+
66
+ ```
67
+
68
+ Created and maintained by [Fugroup Ltd.](https://www.fugroup.net) We are the creators of [CrowdfundHQ.](https://crowdfundhq.com)
69
+
70
+ `@authors: Vidar`
@@ -0,0 +1,12 @@
1
+ require 'bundler/setup'
2
+ Bundler.require(:default, :development)
3
+
4
+ MODE = ENV['RACK_ENV'] || 'development'
5
+
6
+ require './lib/minimongo.rb'
7
+
8
+ # Connect
9
+ Minimongo.db = Mongo::Client.new([ '127.0.0.1:27017' ], :database => "minimongo_#{MODE}")
10
+
11
+ include Futest::Helpers
12
+ include Minimongo::Query
@@ -1,3 +1,5 @@
1
+ require 'mongo'
2
+
1
3
  module Minimongo
2
4
 
3
5
  # # # # # #
@@ -0,0 +1,31 @@
1
+ module Minimongo
2
+ module Query
3
+
4
+ # # # # # # # # # # # # #
5
+ # This is the tiniest possible implementation of a mongodb library.
6
+ # Instead of doing $db[:models].find, you can now do find(:models),
7
+ # and there's some extra short cuts like first, last, all and count.
8
+ #
9
+ # Intended use is with tests, especially Fugroup/Futest, but can also
10
+ # be used for full fledged applications if you don't want an ORM.
11
+ #
12
+ # If you need models for Minimongo, check out https://github.com/fugroup/modelize
13
+ #
14
+ # If you need an ORM, check out https://github.com/fugroup/mongocore
15
+ #
16
+
17
+ # Creates a BSON::ObjectId from a string, or a new one
18
+ # Use with: oid(string), or oid, oid(:new), oid(nil) to create a new BSON::ObjectId
19
+ def oid(v = nil); BSON::ObjectId.from_string(v) rescue BSON::ObjectId.new; end
20
+
21
+ # Find, insert, update, delete
22
+ [:find, :insert, :update, :delete].each{|m| class_eval %Q{def #{m}(*g); Minimongo.db[g.shift].#{m != :find ? "#{m}_one" : m}(*g); end}}
23
+
24
+ # First, last, count, all
25
+ def first(*g); find(*g).limit(-1).first; end
26
+ def last(*g); find(*g).limit(-1).sort(:$natural => -1).first; end
27
+ def count(*g); find(*g).count; end
28
+ def all(*g); find(*g).to_a; end
29
+
30
+ end
31
+ end
@@ -0,0 +1,20 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'minimongo'
3
+ s.version = '0.1.0'
4
+ s.date = '2017-01-05'
5
+ s.summary = "Tiny MongoDB library"
6
+ s.description = "Helpers that sits right on top of mongodb with a nicer syntax. Only 6 lines of code."
7
+ s.authors = ["Fugroup Limited"]
8
+ s.email = 'mail@fugroup.net'
9
+
10
+ s.add_runtime_dependency 'mongo', '>= 2.2'
11
+ s.add_development_dependency 'futest', '>= 0'
12
+
13
+ s.homepage = 'https://github.com/fugroup/minimongo'
14
+ s.license = 'MIT'
15
+
16
+ s.require_paths = ['lib']
17
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fugroup Limited
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-29 00:00:00.000000000 Z
11
+ date: 2017-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongo
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.2'
27
- - !ruby/object:Gem::Dependency
28
- name: bson_ext
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: futest
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -59,7 +45,15 @@ executables: []
59
45
  extensions: []
60
46
  extra_rdoc_files: []
61
47
  files:
48
+ - ".gitignore"
49
+ - CHANGELOG.md
50
+ - Gemfile
51
+ - LICENSE
52
+ - README.md
53
+ - config/boot.rb
62
54
  - lib/minimongo.rb
55
+ - lib/minimongo/query.rb
56
+ - minimongo.gemspec
63
57
  homepage: https://github.com/fugroup/minimongo
64
58
  licenses:
65
59
  - MIT