cloudant_backup 0.0.2 → 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.
data/.travis.yml CHANGED
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.9.2"
4
3
  - "1.9.3"
5
4
  script:
6
5
  - bundle exec rspec spec
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Jannis Hermanns
1
+ Copyright (c) 2013 moviepilot.com
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![Build Status](https://travis-ci.org/jayniz/cloudant-backup.png)](https://travis-ci.org/jayniz/cloudant-backup)
1
2
  # CloudantBackup
2
3
 
3
4
  Easily backup a cloudant db using replication. This gem wraps
@@ -68,7 +69,7 @@ Don't use cloudant at all, just copy one couchdb over to another:
68
69
  ```ruby
69
70
  cb = CloudantBackup.new
70
71
  [...]
71
- cb.host = 'my-couchdb-instance.com'
72
+ cb.host = 'http://my-couchdb-instance.com:5984'
72
73
 
73
74
  cb.backup
74
75
  ```
@@ -67,7 +67,11 @@ class CloudantBackup
67
67
  end
68
68
 
69
69
  def db_url(name)
70
- "#{protocol}://#{user}:#{password}@#{host}/#{name}"
70
+ if user
71
+ "#{protocol}://#{user}:#{password}@#{host}/#{name}"
72
+ else
73
+ "#{protocol}://#{host}/#{name}"
74
+ end
71
75
  end
72
76
 
73
77
  def protocol
@@ -1,3 +1,3 @@
1
1
  class CloudantBackup
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -64,26 +64,60 @@ describe CloudantBackup do
64
64
  end
65
65
 
66
66
  context "not using cloudant at all" do
67
- it "creates the backup db" do
68
- cb.host = 'my-couchdb.com'
69
- cb.target = 'custom-name'
70
- url = "http://backup-user:password@my-couchdb.com/custom-name"
71
- RestClient.should_receive(:put).with(url, options)
72
- cb.create_target_db
67
+
68
+ describe "with authentication" do
69
+ it "creates the backup db" do
70
+ cb.host = 'my-couchdb.com'
71
+ cb.target = 'custom-name'
72
+ url = "http://backup-user:password@my-couchdb.com/custom-name"
73
+ RestClient.should_receive(:put).with(url, options)
74
+ cb.create_target_db
75
+ end
76
+
77
+ it "triggers the replication" do
78
+ cb.target = 'custom-name'
79
+ cb.host = 'my-couchdb.com'
80
+ url = "http://backup-user:password@my-couchdb.com/_replicate"
81
+ source_db = "http://backup-user:password@my-couchdb.com/production-db"
82
+ target_db = "http://backup-user:password@my-couchdb.com/custom-name"
83
+ data = {
84
+ source: source_db,
85
+ target: target_db
86
+ }.to_json
87
+ RestClient.should_receive(:post).with(url, data, options)
88
+ cb.replicate
89
+ end
73
90
  end
74
91
 
75
- it "triggers the replication" do
76
- cb.target = 'custom-name'
77
- cb.host = 'my-couchdb.com'
78
- url = "http://backup-user:password@my-couchdb.com/_replicate"
79
- source_db = "http://backup-user:password@my-couchdb.com/production-db"
80
- target_db = "http://backup-user:password@my-couchdb.com/custom-name"
81
- data = {
82
- source: source_db,
83
- target: target_db
84
- }.to_json
85
- RestClient.should_receive(:post).with(url, data, options)
86
- cb.replicate
92
+ describe "without authentication" do
93
+ let(:cb) do
94
+ cb = CloudantBackup.new
95
+ cb.source = 'production-db'
96
+ cb.cloudant_host = 'main-user'
97
+ cb
98
+ end
99
+
100
+ it "creates the backup db" do
101
+ cb.host = 'my-couchdb.com'
102
+ cb.target = 'custom-name'
103
+ url = "http://my-couchdb.com/custom-name"
104
+ RestClient.should_receive(:put).with(url, options)
105
+ cb.create_target_db
106
+ end
107
+
108
+ it "triggers the replication" do
109
+ cb.target = 'custom-name'
110
+ cb.host = 'my-couchdb.com'
111
+ url = "http://my-couchdb.com/_replicate"
112
+ source_db = "http://my-couchdb.com/production-db"
113
+ target_db = "http://my-couchdb.com/custom-name"
114
+ data = {
115
+ source: source_db,
116
+ target: target_db
117
+ }.to_json
118
+ RestClient.should_receive(:post).with(url, data, options)
119
+ cb.replicate
120
+ end
87
121
  end
88
122
  end
89
123
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cloudant_backup
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jannis Hermanns
@@ -141,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
141
  - !ruby/object:Gem::Version
142
142
  segments:
143
143
  - 0
144
- hash: 3180739372986018778
144
+ hash: -3012344103416834145
145
145
  version: '0'
146
146
  none: false
147
147
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  - !ruby/object:Gem::Version
151
151
  segments:
152
152
  - 0
153
- hash: 3180739372986018778
153
+ hash: -3012344103416834145
154
154
  version: '0'
155
155
  none: false
156
156
  requirements: []