couch-db 0.11.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbb34f2e691ddb9f10d9a2750263da533e30d3c0
4
- data.tar.gz: 236e61f8a352207e84e6ba8d2941d6d3f9a225bd
3
+ metadata.gz: 137f5c10ef1eb17cf123528fa4cab7d18bf861c2
4
+ data.tar.gz: 019fdc4d6cc75e7941a4d50f7ed9df04449f2d1e
5
5
  SHA512:
6
- metadata.gz: 6137b21830233b0c118b036b0e8c1dbe5116582898de5bf9816b8b330ed26cc55b5f82d5ed1902afe1437528a317e1c25410c30022c8d1a9860f5ce1e71bfa9a
7
- data.tar.gz: 2cefc48dc8690981ca9c5b67b3009fdb6cd9008a617c961d32b2698c07c09a27685494fa94fdfd98668aee83460b839c5e89a827e1014b71a2cef856d8772946
6
+ metadata.gz: c0ac698d46202d63bb71c9ecb8888b5bdd215a83e8be5247f71f41c907cc51168c8da992149cde60476bdaff9810d8bdf4fab4c06f58742ce544f16d2d0a2fe7
7
+ data.tar.gz: ad71cb56c244106bafb5bf35f8a9038834e4a71875a642b476d0e449ccebef218faca7520bc9c16b334fc3a18f8937aba05d49d332e6bad11c8ffb91899c248e
data/.gitignore CHANGED
@@ -1,13 +1,13 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- .idea/
11
-
12
- lol.rb
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea/
11
+
12
+ lol.rb
13
13
  rake_secret
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --format documentation
2
- --color
1
+ --format documentation
2
+ --color
@@ -1,7 +1,7 @@
1
- language: ruby
2
- rvm:
3
- - 2.1.6
4
- - 2.2.2
5
- - 2.0.0
6
- - 1.9.3
7
- before_install: gem install bundler -v 1.10
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.6
4
+ - 2.2.2
5
+ - 2.0.0
6
+ - 1.9.3
7
+ before_install: gem install bundler -v 1.10
@@ -1,13 +1,13 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
-
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
-
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
-
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
-
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
-
13
- This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in couch-request.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in couch-request.gemspec
4
+ gemspec
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 Maarten Trompper
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
13
- all 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
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Maarten Trompper
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,116 +1,122 @@
1
- # Ruby CouchDB
2
- [![Build Status](https://travis-ci.org/digitalheir/ruby-couch-db.svg)](https://travis-ci.org/digitalheir/ruby-couch-db)
3
- [![Code Climate](https://codeclimate.com/repos/557eed7de30ba02ffe010520/badges/11baa9055d509aedf45d/gpa.svg)](https://codeclimate.com/repos/557eed7de30ba02ffe010520/feed)
4
- [![Test Coverage](https://codeclimate.com/repos/557eed7de30ba02ffe010520/badges/11baa9055d509aedf45d/coverage.svg)](https://codeclimate.com/repos/557eed7de30ba02ffe010520/coverage)
5
-
6
- Ruby gem to connect to a CouchDB database in Ruby, focusing on bulk requests. Make sure to watch Tim Anglade's excellent talk **[CouchDB & Ruby: You're Doing It Wrong](https://www.youtube.com/watch?v=zEMfvCqVL4E)**.
7
-
8
- <center>
9
- <a href="http://www.youtube.com/watch?feature=player_embedded&v=zEMfvCqVL4E
10
- " target="_blank"><img src="https://img.youtube.com/vi/zEMfvCqVL4E/0.jpg"
11
- alt="CouchDB & Ruby: You're Doing It Wrong by Tim Anglade" width="240" height="180" border="10" /></a>
12
- </center>
13
-
14
- ## Installation
15
-
16
- Add this line to your application's Gemfile:
17
-
18
- ```ruby
19
- gem 'couch-db'
20
- ```
21
-
22
- And then execute:
23
-
24
- $ bundle
25
-
26
- Or install it yourself as:
27
-
28
- $ gem install couch-db
29
-
30
- ## Usage
31
-
32
- ```ruby
33
-
34
- require 'couch'
35
-
36
- # Subclass Couch::Server for application-specific logic
37
- class MyCouch < Couch::Server
38
- DB_NAME = 'my-db'
39
-
40
- def initialize
41
- super(
42
- 'https://user.couchprovider.com/', # The library automatically detects whether to use SSL
43
- {
44
- name: 'user',
45
- password: 'supersecretpassword' # May be nil for public databases
46
- }
47
- )
48
- @queue = []
49
- end
50
-
51
- def add_to_queue(doc, max_array_length: 3)
52
- @queue << doc
53
- flushed = post_bulk_if_big_enough(DB_NAME, @queue, max_array_length: max_array_length)
54
- puts "Added #{doc[:_id]} to queue. Flushed: #{flushed}"
55
- end
56
-
57
- def flush_queue
58
- length = @queue.length
59
- post_bulk_throttled(DB_NAME, @queue) do |res|
60
- puts "Flushed bulk, response code #{res.code}"
61
- end
62
- length
63
- end
64
- end
65
-
66
- #####################
67
- # Script starts here
68
- #####################
69
-
70
- # Initialize couch interface
71
- couch = MyCouch.new
72
- couch.put("/#{MyCouch::DB_NAME}",'') # Create database
73
-
74
- # Add some documents to our database, triggering a bulk post after every 3 docs
75
- (1..11).each do |i|
76
- couch.add_to_queue({_id: "document-#{i}"})
77
- end
78
-
79
- # Get single document.
80
- puts couch.get_doc(
81
- 'document-7',
82
- {stale: 'ok'} # Pass URL parameters in a hash
83
- )
84
-
85
- # Flush remaining docs
86
- l = couch.flush_queue
87
- puts "Flushed remaining #{l} docs in queue"
88
-
89
- # Access docs
90
- couch.all_docs(MyCouch::DB_NAME, 4) do |slice|
91
- puts "> Next #{slice.length} docs:"
92
- slice.each do |doc|
93
- puts doc
94
- end
95
- end
96
-
97
- # Delete database
98
- couch.delete("/#{MyCouch::DB_NAME}")
99
-
100
- ```
101
-
102
- ## Development
103
-
104
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
105
-
106
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
107
-
108
- ## Contributing
109
-
110
- Bug reports and pull requests are welcome on GitHub at https://github.com/digitalheir/ruby-couch-db. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
111
-
112
-
113
- ## License
114
-
115
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
116
-
1
+ # Ruby CouchDB
2
+ [![Build Status](https://travis-ci.org/digitalheir/ruby-couch-db.svg)](https://travis-ci.org/digitalheir/ruby-couch-db)
3
+ [![Code Climate](https://codeclimate.com/repos/557eed7de30ba02ffe010520/badges/11baa9055d509aedf45d/gpa.svg)](https://codeclimate.com/repos/557eed7de30ba02ffe010520/feed)
4
+ [![Test Coverage](https://codeclimate.com/repos/557eed7de30ba02ffe010520/badges/11baa9055d509aedf45d/coverage.svg)](https://codeclimate.com/repos/557eed7de30ba02ffe010520/coverage)
5
+
6
+ Ruby gem to connect to a CouchDB database in Ruby, focusing on bulk requests. Make sure to watch Tim Anglade's excellent talk **[CouchDB & Ruby: You're Doing It Wrong](https://www.youtube.com/watch?v=zEMfvCqVL4E)**.
7
+
8
+ <center>
9
+ <a href="http://www.youtube.com/watch?feature=player_embedded&v=zEMfvCqVL4E
10
+ " target="_blank"><img src="https://img.youtube.com/vi/zEMfvCqVL4E/0.jpg"
11
+ alt="CouchDB & Ruby: You're Doing It Wrong by Tim Anglade" width="240" height="180" border="10" /></a>
12
+ </center>
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'couch-db'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install couch-db
29
+
30
+ ## Usage
31
+
32
+ ```ruby
33
+
34
+ require 'couch'
35
+
36
+ # Subclass Couch::Server for application-specific logic
37
+ class MyCouch < Couch::Server
38
+ DB_NAME = 'my-db'
39
+
40
+ def initialize
41
+ super(
42
+ 'https://user.couchprovider.com/', # The library automatically detects whether to use SSL
43
+ {
44
+ name: 'user',
45
+ password: 'supersecretpassword' # May be nil for public databases
46
+
47
+ max_array_length: 50, # Number of documents queued before an automatic write to the database occurs. Defaults to 250.
48
+ flush_size_mb: 15, # Size of documents queued before an automatic write to the database occurs. Defaults to 10.
49
+ open_timeout: 5*60, # HTTP timeout for opening connections, defaults to 5*30
50
+ read_timeout: 5*60, # HTTP timeout for opening connections, defaults to 5*30
51
+ }
52
+ )
53
+ @queue = []
54
+ end
55
+
56
+ def add_to_queue(doc)
57
+ @queue << doc
58
+ flushed = post_bulk_if_big_enough(DB_NAME, @queue)
59
+ puts "Added #{doc[:_id]} to queue. Flushed: #{flushed}"
60
+ end
61
+
62
+ def flush_queue
63
+ length = @queue.length
64
+ post_bulk_throttled(DB_NAME, @queue) do |res|
65
+ puts "Flushed bulk, response code #{res.code}"
66
+ end
67
+ length
68
+ end
69
+ end
70
+
71
+ #####################
72
+ # Script starts here
73
+ #####################
74
+
75
+ # Initialize couch interface
76
+ couch = MyCouch.new
77
+ couch.put("/#{MyCouch::DB_NAME}", '') # Create database
78
+
79
+ # Add some documents to our database, triggering a bulk post after every 3 docs
80
+ couch.options[:max_array_length] = 3
81
+ (1..11).each do |i|
82
+ couch.add_to_queue({_id: "document-#{i}"})
83
+ end
84
+
85
+ # Get single document.
86
+ puts couch.get_doc(
87
+ MyCouch::DB_NAME,
88
+ 'document-7',
89
+ {stale: 'ok'} # Pass URL parameters in a hash
90
+ )
91
+
92
+ # Flush remaining docs
93
+ l = couch.flush_queue
94
+ puts "Flushed remaining #{l} docs in queue"
95
+
96
+ # Access docs
97
+ couch.all_docs(MyCouch::DB_NAME, 4) do |slice|
98
+ puts "> Next #{slice.length} docs:"
99
+ slice.each do |doc|
100
+ puts doc
101
+ end
102
+ end
103
+
104
+ # Delete database
105
+ couch.delete("/#{MyCouch::DB_NAME}")
106
+ ```
107
+
108
+ ## Development
109
+
110
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
111
+
112
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
113
+
114
+ ## Contributing
115
+
116
+ Bug reports and pull requests are welcome on GitHub at https://github.com/digitalheir/ruby-couch-db. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
117
+
118
+
119
+ ## License
120
+
121
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
122
+
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'couch'
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require 'irb'
14
- IRB.start
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'couch'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
data/bin/setup CHANGED
@@ -1,7 +1,7 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -1,39 +1,39 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'couch/db/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'couch-db'
8
- spec.version = Couch::DB::VERSION
9
- spec.authors = ['Maarten Trompper']
10
- spec.email = ['maartentrompper@gmail.com']
11
-
12
- spec.required_ruby_version = '>= 1.9'
13
-
14
- spec.summary = %q{Interface with a CouchDB database. Focuses on bulk requests.}
15
- # spec.description = %q{Write a longer description or delete this line.}
16
- spec.homepage = 'https://github.com/digitalheir/couch-request'
17
- spec.license = 'MIT'
18
-
19
- # # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
20
- # # delete this section to allow pushing this gem to any host.
21
- # if spec.respond_to?(:metadata)
22
- # spec.metadata['allowed_push_host'] = "http://mygemserver.com"
23
- # else
24
- # raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
25
- # end
26
-
27
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
- spec.bindir = 'exe'
29
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
- spec.require_paths = ['lib']
31
-
32
- spec.add_development_dependency 'bundler', '~> 1'
33
- spec.add_development_dependency 'rake', '~> 10.0'
34
- spec.add_development_dependency 'rspec', '~> 2.4'
35
- spec.add_development_dependency 'codeclimate-test-reporter'
36
-
37
-
38
- spec.add_runtime_dependency 'json', '~> 1'
39
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'couch/db/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'couch-db'
8
+ spec.version = Couch::DB::VERSION
9
+ spec.authors = ['Maarten Trompper']
10
+ spec.email = ['maartentrompper@gmail.com']
11
+
12
+ spec.required_ruby_version = '>= 1.9'
13
+
14
+ spec.summary = %q{Interface with a CouchDB database. Focuses on bulk requests.}
15
+ # spec.description = %q{Write a longer description or delete this line.}
16
+ spec.homepage = 'https://github.com/digitalheir/couch-request'
17
+ spec.license = 'MIT'
18
+
19
+ # # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
20
+ # # delete this section to allow pushing this gem to any host.
21
+ # if spec.respond_to?(:metadata)
22
+ # spec.metadata['allowed_push_host'] = "http://mygemserver.com"
23
+ # else
24
+ # raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
25
+ # end
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+
32
+ spec.add_development_dependency 'bundler', '~> 1'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'rspec', '~> 2.4'
35
+ spec.add_development_dependency 'codeclimate-test-reporter'
36
+
37
+
38
+ spec.add_runtime_dependency 'json', '~> 1'
39
+ end