database_cleaner-remote_api 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -10,6 +10,8 @@ Tested against ruby-head, ruby 2.0.0, ruby 1.9.3, jruby-19mode, jruby-head, and
10
10
  (https://codeclimate.com/github/jtescher/database_cleaner-remote_api)
11
11
  [![Dependency Status](https://gemnasium.com/jtescher/database_cleaner-remote_api.png)]
12
12
  (https://gemnasium.com/jtescher/database_cleaner-remote_api)
13
+ [![Coverage Status](https://coveralls.io/repos/jtescher/database_cleaner-remote_api/badge.png)]
14
+ (https://coveralls.io/r/jtescher/database_cleaner-remote_api)
13
15
 
14
16
 
15
17
  ##Installation
@@ -17,7 +19,7 @@ Tested against ruby-head, ruby 2.0.0, ruby 1.9.3, jruby-19mode, jruby-head, and
17
19
  Add this line to your application's Gemfile:
18
20
 
19
21
  ```ruby
20
- gem 'database_cleaner-remote_api', '~> 0.0.1'
22
+ gem 'database_cleaner-remote_api', '~> 0.1.0'
21
23
  ```
22
24
 
23
25
  And then execute:
@@ -68,6 +70,32 @@ Then the users have been removed:
68
70
  User.count #=> 0
69
71
  ```
70
72
 
73
+ ## Usage (As Client)
74
+
75
+ DatabaseCleaner::RemoteApi can also be used between rails servers by the client rails app.
76
+ First install the gem (You don't have to mount the engine in routes.rb)
77
+
78
+ Then configure the server URL (if different than localhost:3000/database_cleaner) in
79
+ `spec/support/database_cleaner-remote_api.rb`
80
+
81
+ ```ruby
82
+ require 'database_cleaner/remote_api'
83
+ DatabaseCleaner::RemoteApi.configure do |config|
84
+ config.server_url = 'http://localhost:3001' # Default: http://localhost:3000
85
+ config.server_mount_path = '/db_cleaner' # Default: /database_cleaner
86
+ end
87
+ ```
88
+
89
+ Then you can wipe the remote server's database after each test has been run:
90
+
91
+ ```ruby
92
+ RSpec.configure do |config|
93
+ config.after(:each) do
94
+ DatabaseCleaner::RemoteApi.clean
95
+ end
96
+ end
97
+ ```
98
+
71
99
 
72
100
  ## Contributing
73
101
 
@@ -1,2 +1,26 @@
1
1
  require 'database_cleaner'
2
2
  require 'database_cleaner/remote_api/engine'
3
+ require 'database_cleaner/remote_api/configuration'
4
+ require 'database_cleaner/remote_api/request'
5
+
6
+ module DatabaseCleaner
7
+ module RemoteApi
8
+
9
+ def self.configure
10
+ yield configuration if block_given?
11
+ end
12
+
13
+ def self.configuration
14
+ @configuration ||= DatabaseCleaner::RemoteApi::Configuration.new
15
+ end
16
+
17
+ def self.reset_configuration
18
+ @configuration = nil
19
+ end
20
+
21
+ def self.clean
22
+ DatabaseCleaner::RemoteApi::Request.new.clean
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ module DatabaseCleaner
2
+ module RemoteApi
3
+ class Configuration
4
+ attr_reader :server_url, :server_mount_path
5
+
6
+ def initialize
7
+ @server_url = 'http://localhost:3000'
8
+ @server_mount_path = '/database_cleaner'
9
+ end
10
+
11
+ def server_url=(server_url)
12
+ @server_url = server_url.gsub(/\/$/, '')
13
+ end
14
+
15
+ def server_mount_path=(server_mount_path)
16
+ @server_mount_path = "/#{server_mount_path}".squeeze('/').gsub(/\/+\Z/, '')
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ module DatabaseCleaner
5
+ module RemoteApi
6
+ class Request
7
+
8
+ def clean
9
+ JSON.parse(Net::HTTP.get_response(clean_uri).body)
10
+ end
11
+
12
+ private
13
+
14
+ def clean_uri
15
+ URI("#{configuration.server_url}#{configuration.server_mount_path}/clean")
16
+ end
17
+
18
+ def configuration
19
+ DatabaseCleaner::RemoteApi.configuration
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -1,5 +1,5 @@
1
1
  module DatabaseCleaner
2
2
  module RemoteApi
3
- VERSION = "0.0.2"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_cleaner-remote_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  V3NaK2F3dzJpU05DNVhGaEEvOHhzSzBCbHRZUkY5blAKSEE0MVV0RHhySmtI
37
37
  TDNOMXo4Z1BNWFNyRlQ0MUZSMndnazgrbDE0UCs3ZzFVVFBpZDJFSXdmdDJ4
38
38
  T2JGZUE9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
39
- date: 2013-06-14 00:00:00.000000000 Z
39
+ date: 2013-06-17 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rails
@@ -150,6 +150,22 @@ dependencies:
150
150
  - - ~>
151
151
  - !ruby/object:Gem::Version
152
152
  version: 0.7.1
153
+ - !ruby/object:Gem::Dependency
154
+ name: coveralls
155
+ requirement: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ~>
159
+ - !ruby/object:Gem::Version
160
+ version: 0.6.7
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ~>
167
+ - !ruby/object:Gem::Version
168
+ version: 0.6.7
153
169
  - !ruby/object:Gem::Dependency
154
170
  name: appraisal
155
171
  requirement: !ruby/object:Gem::Requirement
@@ -181,10 +197,11 @@ files:
181
197
  - app/helpers/database_cleaner/remote_api/application_helper.rb
182
198
  - app/views/layouts/database_cleaner/remote_api/application.html.erb
183
199
  - config/routes.rb
200
+ - lib/database_cleaner/remote_api/configuration.rb
184
201
  - lib/database_cleaner/remote_api/engine.rb
202
+ - lib/database_cleaner/remote_api/request.rb
185
203
  - lib/database_cleaner/remote_api/version.rb
186
204
  - lib/database_cleaner/remote_api.rb
187
- - lib/tasks/database_cleaner-remote_api_tasks.rake
188
205
  - MIT-LICENSE
189
206
  - Rakefile
190
207
  - README.md
@@ -202,7 +219,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
219
  version: '0'
203
220
  segments:
204
221
  - 0
205
- hash: -2752588305541383512
222
+ hash: -2404727274741873945
206
223
  required_rubygems_version: !ruby/object:Gem::Requirement
207
224
  none: false
208
225
  requirements:
@@ -211,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
228
  version: '0'
212
229
  segments:
213
230
  - 0
214
- hash: -2752588305541383512
231
+ hash: -2404727274741873945
215
232
  requirements: []
216
233
  rubyforge_project:
217
234
  rubygems_version: 1.8.25
metadata.gz.sig CHANGED
Binary file
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :database_cleaner/remote_api do
3
- # # Task goes here
4
- # end