ar_http_wrapper 0.0.1
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/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +34 -0
- data/app/interfaces/active_record_api_wrapper.rb +2 -0
- data/app/interfaces/active_record_http_wrapper.rb +67 -0
- data/config/routes.rb +2 -0
- data/lib/ar_http_wrapper.rb +5 -0
- data/lib/ar_http_wrapper/engine.rb +11 -0
- data/lib/ar_http_wrapper/version.rb +3 -0
- data/lib/tasks/ar_http_wrapper_tasks.rake +4 -0
- metadata +201 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
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.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'ArHttpWrapper'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
25
|
+
load 'rails/tasks/engine.rake'
|
26
|
+
|
27
|
+
|
28
|
+
Bundler::GemHelper.install_tasks
|
29
|
+
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec)
|
32
|
+
|
33
|
+
task :cucumber => 'app:cucumber'
|
34
|
+
task :default => [:spec, :cucumber]
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class ActiveRecordHttpWrapper
|
2
|
+
include HTTParty
|
3
|
+
|
4
|
+
attr_accessor :id
|
5
|
+
|
6
|
+
def initialize(args={})
|
7
|
+
@id = args[:id]
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.create(args={})
|
11
|
+
options = { :body => args[:params] }
|
12
|
+
post(path("/"), options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def update_attributes(args={})
|
16
|
+
options = { :body => args[:params] }
|
17
|
+
put(path("/"), options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.find_by_id(_id)
|
21
|
+
get(new(:id => _id).send(:path))
|
22
|
+
end
|
23
|
+
|
24
|
+
def destroy
|
25
|
+
delete(send(:path))
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.where(conditions)
|
29
|
+
options = {:body => {:conditions => conditions}}
|
30
|
+
get(path("/"), options)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.find_each(batch_size=1000,&block)
|
34
|
+
n_batches = (count / batch_size).to_i + 1
|
35
|
+
n_batches.times do |i|
|
36
|
+
options = {:body => {:offset => i * batch_size, :limit => batch_size}}
|
37
|
+
records = get(path("/"), options)
|
38
|
+
yield records if block_given?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.count(params={})
|
43
|
+
options = {:body => {:count => true}.merge(params)}
|
44
|
+
get(path("/"),options)
|
45
|
+
end
|
46
|
+
private
|
47
|
+
|
48
|
+
def self.path(_path=nil)
|
49
|
+
"/#{to_url}#{_path}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def path(_path=nil)
|
53
|
+
"#{self.class.send(:path)}/#{id}#{_path}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.to_url
|
57
|
+
to_s.underscore
|
58
|
+
end
|
59
|
+
|
60
|
+
def put(*args)
|
61
|
+
self.class.put(*args)
|
62
|
+
end
|
63
|
+
|
64
|
+
def delete(*args)
|
65
|
+
self.class.delete(*args)
|
66
|
+
end
|
67
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
module ArHttpWrapper
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace ArHttpWrapper
|
4
|
+
|
5
|
+
initializer "wz_music_data_input.initialize" do |app|
|
6
|
+
app.config.autoload_paths += Dir[Rails.root.join('app', 'interfaces')]
|
7
|
+
app.config.autoload_paths += Dir[Rails.root.join('app', 'interfaces', '**')]
|
8
|
+
app.config.autoload_paths += Dir[Rails.root.join('app', 'interfaces', '**', '**')]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ar_http_wrapper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nicolas Arbogast
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.9
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.9
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: httparty
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: mysql2
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec-rails
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2.0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: shoulda-matchers
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: factory_girl_rails
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '4.0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '4.0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: cucumber-rails
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: database_cleaner
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: activerecord-nulldb-adapter
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
description: Small wrapper (using httparty, etc.) to provide an interface that mimicks
|
159
|
+
AR main methods using a REST API
|
160
|
+
email:
|
161
|
+
- nicolas.arbogast@gmail.com
|
162
|
+
executables: []
|
163
|
+
extensions: []
|
164
|
+
extra_rdoc_files: []
|
165
|
+
files:
|
166
|
+
- app/interfaces/active_record_api_wrapper.rb
|
167
|
+
- app/interfaces/active_record_http_wrapper.rb
|
168
|
+
- config/routes.rb
|
169
|
+
- lib/ar_http_wrapper/engine.rb
|
170
|
+
- lib/ar_http_wrapper/version.rb
|
171
|
+
- lib/ar_http_wrapper.rb
|
172
|
+
- lib/tasks/ar_http_wrapper_tasks.rake
|
173
|
+
- MIT-LICENSE
|
174
|
+
- Rakefile
|
175
|
+
- README.rdoc
|
176
|
+
homepage: https://github.com/NicoArbogast/ar_http_wrapper.git
|
177
|
+
licenses: []
|
178
|
+
post_install_message:
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
181
|
+
- lib
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
none: false
|
184
|
+
requirements:
|
185
|
+
- - ! '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
none: false
|
190
|
+
requirements:
|
191
|
+
- - ! '>='
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0'
|
194
|
+
requirements: []
|
195
|
+
rubyforge_project:
|
196
|
+
rubygems_version: 1.8.24
|
197
|
+
signing_key:
|
198
|
+
specification_version: 3
|
199
|
+
summary: Small wrapper (using httparty, etc.) to provide an interface that mimicks
|
200
|
+
AR main methods using a REST API
|
201
|
+
test_files: []
|