acfs 0.27.0.1.b248 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZTgwOTRmNjQ2MGNjY2M4MjBmYTBlMmVmOGIyYTAwNWRhMTlkNzFmOQ==
5
- data.tar.gz: !binary |-
6
- YjBkZTQ0ZWMzY2Q3OWQ4N2U1MjczZTdkYjhkMmI3NGMwMmExNWQ3ZA==
2
+ SHA1:
3
+ metadata.gz: 98eda5967f361039a7f8a9385833ca64624b67df
4
+ data.tar.gz: 88d36bab133493be788ee548d2f070218faa2a7f
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZWQ1NTgwOTE0MTMxY2RkN2ExMjEzN2M0MmUzZjkwODQ4MWMwODY0NzkyMDBm
10
- NmNiZTNhZDRkOGJiM2Q1OGFjZGJlMWQxMGFkODA2MTg5NTg4YTQwNThhNTEx
11
- Yjc5YTNlMzBlOWFlZDFjNzU3NDQxZDU2OWRlYTg3MTI5ZmExMzg=
12
- data.tar.gz: !binary |-
13
- NDIwM2ZkYWZkNTZiZjJkNjVjZmY4NTZjN2VkYTI3NTY1YzhlYWZmYmY0YzI3
14
- NjYwYzliNTgwMDM4NGIxZjhmMmJlMDQzYzJjNmIwZmVlN2I4ZWFmMWRkN2My
15
- MzY2Y2IwMGQwM2Q4NDc5YmQ0OTYzYjg1Y2VjOWJjMmQwYTcyZjI=
6
+ metadata.gz: 0a4537bc92ae5a023e1c0923494d0be2e7b242b0d5f75574f5b4f1174328a70e251d868ad97aae944e8b877205fad6c6e6c292fba83c44b8ddffb00033971681
7
+ data.tar.gz: 0864494675874aeb2e2dd522d306be8ef01c1d67ce3735f372953c6cfc5f1f6093a074ab6100792ae5c08d8bf5e7bbba3720e3e3d948f04f05b7e9cbb0079707
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.28.0
4
+
5
+ * Add find_by (Nicolas Fricke)
6
+
3
7
  ## 0.27.0
4
8
 
5
9
  * Reset method to clear stubs, request queues, internal state
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'https://github.com/jgraichen/acfs'
14
14
  spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.files = Dir['**/*'].grep(%r{^((bin|lib|test|spec|features)/|.*\.gemspec|.*LICENSE.*|.*README.*|.*CHANGELOG.*)})
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = %w(lib)
@@ -0,0 +1,307 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.8.6.1
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index</a> &raquo;
35
+ <span class="title">File: README</span>
36
+
37
+
38
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
39
+ </div>
40
+
41
+ <div id="search">
42
+
43
+ <a class="full_list_link" id="class_list_link"
44
+ href="class_list.html">
45
+ Class List
46
+ </a>
47
+
48
+ <a class="full_list_link" id="method_list_link"
49
+ href="method_list.html">
50
+ Method List
51
+ </a>
52
+
53
+ <a class="full_list_link" id="file_list_link"
54
+ href="file_list.html">
55
+ File List
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <iframe id="search_frame"></iframe>
63
+
64
+ <div id="content"><div id='filecontents'><h1>Acfs - <em>API client for services</em></h1>
65
+
66
+ <p><a href="http://badge.fury.io/rb/acfs"><img src="https://badge.fury.io/rb/acfs.png" alt="Gem Version"></a>
67
+ <a href="https://travis-ci.org/jgraichen/acfs"><img src="https://travis-ci.org/jgraichen/acfs.png?branch=master" alt="Build Status"></a>
68
+ <a href="https://coveralls.io/r/jgraichen/acfs"><img src="https://coveralls.io/repos/jgraichen/acfs/badge.png?branch=master" alt="Coverage Status"></a>
69
+ <a href="https://codeclimate.com/github/jgraichen/acfs"><img src="https://codeclimate.com/github/jgraichen/acfs.png" alt="Code Climate"></a>
70
+ <a href="https://gemnasium.com/jgraichen/acfs"><img src="https://gemnasium.com/jgraichen/acfs.png" alt="Dependency Status"></a>
71
+ <a href="http://rubydoc.info/github/jgraichen/acfs/master/frames"><img src="https://raw.github.com/jgraichen/acfs/master/rubydoc.png" alt="RubyDoc Documentation"></a></p>
72
+
73
+ <p>Acfs is a library to develop API client libraries for single services within a larger service oriented application.</p>
74
+
75
+ <p>Acfs covers model and service abstraction, convenient query and filter methods, full middleware stack for pre-processing requests and responses on a per service level and automatic request queuing and parallel processing. See Usage for more.</p>
76
+
77
+ <h2>Installation</h2>
78
+
79
+ <p>Add this line to your application&#39;s Gemfile:</p>
80
+
81
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>acfs</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>~&gt; 0.16.0</span><span class='tstring_end'>&#39;</span></span>
82
+ </code></pre>
83
+
84
+ <p><strong>Note:</strong> Acfs is under development. I&#39;ll try to avoid changes to the public API but internal APIs may change quite often.</p>
85
+
86
+ <p>And then execute:</p>
87
+
88
+ <pre class="code ruby"><code class="ruby">&gt; bundle
89
+ </code></pre>
90
+
91
+ <p>Or install it yourself as:</p>
92
+
93
+ <pre class="code ruby"><code class="ruby">&gt; gem install acfs
94
+ </code></pre>
95
+
96
+ <h2>Usage</h2>
97
+
98
+ <p>First you need to define your service(s):</p>
99
+
100
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>UserService</span> <span class='op'>&lt;</span> <span class='const'>Acfs</span><span class='op'>::</span><span class='const'>Service</span>
101
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_base_url'>base_url</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://users.myapp.org</span><span class='tstring_end'>&#39;</span></span>
102
+
103
+ <span class='comment'># You can configure middlewares you want to use for the service here.
104
+ </span> <span class='comment'># Each service has it own middleware stack.
105
+ </span> <span class='comment'>#
106
+ </span> <span class='id identifier rubyid_use'>use</span> <span class='const'>Acfs</span><span class='op'>::</span><span class='const'>Middleware</span><span class='op'>::</span><span class='const'>JsonDecoder</span>
107
+ <span class='id identifier rubyid_use'>use</span> <span class='const'>Acfs</span><span class='op'>::</span><span class='const'>Middleware</span><span class='op'>::</span><span class='const'>MessagePackDecoder</span>
108
+ <span class='kw'>end</span>
109
+ </code></pre>
110
+
111
+ <p>This specifies where the <code>UserService</code> is located. You can now create some models representing resources served by the <code>UserService</code>.</p>
112
+
113
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>User</span>
114
+ <span class='id identifier rubyid_include'>include</span> <span class='const'>Acfs</span><span class='op'>::</span><span class='const'>Model</span>
115
+ <span class='id identifier rubyid_service'>service</span> <span class='const'>UserService</span> <span class='comment'># Associate `User` model with `UserService`.
116
+ </span>
117
+ <span class='comment'># Define model attributes and types
118
+ </span> <span class='comment'># Types are needed to parse and generate request and response payload.
119
+ </span>
120
+ <span class='id identifier rubyid_attribute'>attribute</span> <span class='symbol'>:id</span><span class='comma'>,</span> <span class='symbol'>:uuid</span> <span class='comment'># Types can be classes or symbols.
121
+ </span> <span class='comment'># Symbols will be used to load a class from `Acfs::Model::Attributes` namespace.
122
+ </span> <span class='comment'># Eg. `:uuid` will load class `Acfs::Model::Attributes::Uuid`.
123
+ </span>
124
+ <span class='id identifier rubyid_attribute'>attribute</span> <span class='symbol'>:name</span><span class='comma'>,</span> <span class='symbol'>:string</span><span class='comma'>,</span> <span class='label'>default:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Anonymous</span><span class='tstring_end'>&#39;</span></span>
125
+ <span class='id identifier rubyid_attribute'>attribute</span> <span class='symbol'>:age</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Acfs</span><span class='op'>::</span><span class='const'>Model</span><span class='op'>::</span><span class='const'>Attributes</span><span class='op'>::</span><span class='const'>Integer</span> <span class='comment'># Or use :integer
126
+ </span>
127
+ <span class='kw'>end</span>
128
+ </code></pre>
129
+
130
+ <p>The service and model classes can be shipped as a gem or git submodule to be included by the frontend application(s).</p>
131
+
132
+ <p>You can use the model there:</p>
133
+
134
+ <pre class="code ruby"><code class="ruby"><span class='ivar'>@user</span> <span class='op'>=</span> <span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='int'>14</span>
135
+
136
+ <span class='ivar'>@user</span><span class='period'>.</span><span class='id identifier rubyid_loaded?'>loaded?</span> <span class='comment'>#=&gt; false
137
+ </span>
138
+ <span class='const'>Acfs</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span> <span class='comment'># This will run all queued request as parallel as possible.
139
+ </span> <span class='comment'># For @user the following URL will be requested:
140
+ </span> <span class='comment'># `http://users.myapp.org/users/14`
141
+ </span>
142
+ <span class='ivar'>@model</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='comment'># =&gt; &quot;...&quot;
143
+ </span>
144
+ <span class='ivar'>@users</span> <span class='op'>=</span> <span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span>
145
+ <span class='ivar'>@users</span><span class='period'>.</span><span class='id identifier rubyid_loaded?'>loaded?</span> <span class='comment'>#=&gt; false
146
+ </span>
147
+ <span class='const'>Acfs</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span> <span class='comment'># Will request `http://users.myapp.org/users`
148
+ </span>
149
+ <span class='ivar'>@users</span> <span class='comment'>#=&gt; [&lt;User&gt;, ...]
150
+ </span></code></pre>
151
+
152
+ <p>If you need multiple resources or dependent resources first define a &quot;plan&quot; how they can be loaded:</p>
153
+
154
+ <pre class="code ruby"><code class="ruby"><span class='ivar'>@user</span> <span class='op'>=</span> <span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='int'>5</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_user'>user</span><span class='op'>|</span>
155
+ <span class='comment'># Block will be executed right after user with id 5 is loaded
156
+ </span>
157
+ <span class='comment'># You can load additional resources also from other services
158
+ </span> <span class='comment'># Eg. fetch comments from `CommentSerivce`. The line below will
159
+ </span> <span class='comment'># load comments from `http://comments.myapp.org/comments?user=5`
160
+ </span> <span class='ivar'>@comments</span> <span class='op'>=</span> <span class='const'>Comment</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span> <span class='label'>user:</span> <span class='id identifier rubyid_user'>user</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span>
161
+
162
+ <span class='comment'># You can load multiple resources in parallel if you have multiple
163
+ </span> <span class='comment'># ids.
164
+ </span> <span class='ivar'>@friends</span> <span class='op'>=</span> <span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='int'>1</span><span class='comma'>,</span> <span class='int'>4</span><span class='comma'>,</span> <span class='int'>10</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_friends'>friends</span><span class='op'>|</span>
165
+ <span class='comment'># This block will be executed when all friends are loaded.
166
+ </span> <span class='comment'># [ ... ]
167
+ </span> <span class='kw'>end</span>
168
+ <span class='kw'>end</span>
169
+
170
+ <span class='const'>Acfs</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span> <span class='comment'># This call will fire all request as parallel as possible.
171
+ </span> <span class='comment'># The sequence above would look similar to:
172
+ </span> <span class='comment'>#
173
+ </span> <span class='comment'># Start Fin
174
+ </span> <span class='comment'># |===================| `Acfs.run`
175
+ </span> <span class='comment'># |====| /users/5
176
+ </span> <span class='comment'># | |==============| /comments?user=5
177
+ </span> <span class='comment'># | |======| /users/1
178
+ </span> <span class='comment'># | |=======| /users/4
179
+ </span> <span class='comment'># | |======| /users/10
180
+ </span>
181
+ <span class='comment'># Now we can access all resources:
182
+ </span>
183
+ <span class='ivar'>@user</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='comment'># =&gt; &quot;John
184
+ </span><span class='ivar'>@comments</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='comment'># =&gt; 25
185
+ </span><span class='ivar'>@friends</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='comment'># =&gt; &quot;Miraculix&quot;
186
+ </span></code></pre>
187
+
188
+ <p>Acfs has basic update support using <code>PUT</code> requests:</p>
189
+
190
+ <pre class="code ruby"><code class="ruby"><span class='ivar'>@user</span> <span class='op'>=</span> <span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='int'>5</span>
191
+ <span class='ivar'>@user</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Bob</span><span class='tstring_end'>&quot;</span></span>
192
+
193
+ <span class='ivar'>@user</span><span class='period'>.</span><span class='id identifier rubyid_changed?'>changed?</span> <span class='comment'># =&gt; true
194
+ </span><span class='ivar'>@user</span><span class='period'>.</span><span class='id identifier rubyid_persisted?'>persisted?</span> <span class='comment'># =&gt; false
195
+ </span>
196
+ <span class='ivar'>@user</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span> <span class='comment'># Or .save!
197
+ </span> <span class='comment'># Will PUT new resource to service synchronously.
198
+ </span>
199
+ <span class='ivar'>@user</span><span class='period'>.</span><span class='id identifier rubyid_changed?'>changed?</span> <span class='comment'># =&gt; false
200
+ </span><span class='ivar'>@user</span><span class='period'>.</span><span class='id identifier rubyid_persisted?'>persisted?</span> <span class='comment'># =&gt; true
201
+ </span></code></pre>
202
+
203
+ <h2>Stubbing</h2>
204
+
205
+ <p>You can stub resources in applications using an Acfs service client:</p>
206
+
207
+ <pre class="code ruby"><code class="ruby"><span class='comment'># Enable stubs in spec helper
208
+ </span><span class='const'>Acfs</span><span class='op'>::</span><span class='const'>Stub</span><span class='period'>.</span><span class='id identifier rubyid_enable'>enable</span>
209
+
210
+ <span class='id identifier rubyid_before'>before</span> <span class='kw'>do</span>
211
+ <span class='const'>Acfs</span><span class='op'>::</span><span class='const'>Stub</span><span class='period'>.</span><span class='id identifier rubyid_resource'>resource</span> <span class='const'>MyUser</span><span class='comma'>,</span> <span class='symbol'>:read</span><span class='comma'>,</span> <span class='label'>with:</span> <span class='lbrace'>{</span> <span class='label'>id:</span> <span class='int'>1</span> <span class='rbrace'>}</span><span class='comma'>,</span> <span class='label'>return:</span> <span class='lbrace'>{</span> <span class='label'>id:</span> <span class='int'>1</span><span class='comma'>,</span> <span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>John Smith</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>age:</span> <span class='int'>32</span> <span class='rbrace'>}</span>
212
+ <span class='const'>Acfs</span><span class='op'>::</span><span class='const'>Stub</span><span class='period'>.</span><span class='id identifier rubyid_resource'>resource</span> <span class='const'>MyUser</span><span class='comma'>,</span> <span class='symbol'>:read</span><span class='comma'>,</span> <span class='label'>with:</span> <span class='lbrace'>{</span> <span class='label'>id:</span> <span class='int'>2</span> <span class='rbrace'>}</span><span class='comma'>,</span> <span class='label'>raise:</span> <span class='symbol'>:not_found</span>
213
+ <span class='const'>Acfs</span><span class='op'>::</span><span class='const'>Stub</span><span class='period'>.</span><span class='id identifier rubyid_resource'>resource</span> <span class='const'>Session</span><span class='comma'>,</span> <span class='symbol'>:create</span><span class='comma'>,</span> <span class='label'>with:</span> <span class='lbrace'>{</span> <span class='label'>ident:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>john@exmaple.org</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>password:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>s3cr3t</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span><span class='comma'>,</span> <span class='label'>return:</span> <span class='lbrace'>{</span> <span class='label'>id:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>longhash</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>user:</span> <span class='int'>1</span> <span class='rbrace'>}</span>
214
+ <span class='kw'>end</span>
215
+
216
+ <span class='id identifier rubyid_it'>it</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>should find user number one</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>do</span>
217
+ <span class='id identifier rubyid_user'>user</span> <span class='op'>=</span> <span class='const'>MyUser</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='int'>1</span>
218
+ <span class='const'>Acfs</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span>
219
+
220
+ <span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='id identifier rubyid_user'>user</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_be'>be</span> <span class='op'>==</span> <span class='int'>1</span>
221
+ <span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='id identifier rubyid_user'>user</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_be'>be</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>John Smith</span><span class='tstring_end'>&#39;</span></span>
222
+ <span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='id identifier rubyid_user'>user</span><span class='period'>.</span><span class='id identifier rubyid_age'>age</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_be'>be</span> <span class='op'>==</span> <span class='int'>32</span>
223
+ <span class='kw'>end</span>
224
+
225
+ <span class='id identifier rubyid_it'>it</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>should not find user number two</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>do</span>
226
+ <span class='const'>MyUser</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='int'>3</span>
227
+
228
+ <span class='id identifier rubyid_expect'>expect</span> <span class='lbrace'>{</span> <span class='const'>Acfs</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_raise_error'>raise_error</span><span class='lparen'>(</span><span class='const'>Acfs</span><span class='op'>::</span><span class='const'>ResourceNotFound</span><span class='rparen'>)</span>
229
+ <span class='kw'>end</span>
230
+
231
+ <span class='id identifier rubyid_it'>it</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>should allow stub resource creation</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>do</span>
232
+ <span class='id identifier rubyid_session'>session</span> <span class='op'>=</span> <span class='const'>Session</span><span class='period'>.</span><span class='id identifier rubyid_create!'>create!</span> <span class='label'>ident:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>john@exmaple.org</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>password:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>s3cr3t</span><span class='tstring_end'>&#39;</span></span>
233
+
234
+ <span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='id identifier rubyid_session'>session</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_be'>be</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>longhash</span><span class='tstring_end'>&#39;</span></span>
235
+ <span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='id identifier rubyid_session'>session</span><span class='period'>.</span><span class='id identifier rubyid_user'>user</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_be'>be</span> <span class='op'>==</span> <span class='int'>1</span>
236
+ <span class='kw'>end</span>
237
+ </code></pre>
238
+
239
+ <p>By default Acfs raises an error when a non stubbed resource should be requested. You can switch of the behavior:</p>
240
+
241
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_before'>before</span> <span class='kw'>do</span>
242
+ <span class='const'>Acfs</span><span class='op'>::</span><span class='const'>Stub</span><span class='period'>.</span><span class='id identifier rubyid_allow_requests'>allow_requests</span> <span class='op'>=</span> <span class='kw'>true</span>
243
+ <span class='kw'>end</span>
244
+
245
+ <span class='id identifier rubyid_it'>it</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>should find user number one</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>do</span>
246
+ <span class='id identifier rubyid_user'>user</span> <span class='op'>=</span> <span class='const'>MyUser</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='int'>1</span>
247
+ <span class='const'>Acfs</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span> <span class='comment'># Would have raised Acfs::RealRequestNotAllowedError
248
+ </span> <span class='comment'># Will run real request to user service instead.
249
+ </span><span class='kw'>end</span>
250
+ </code></pre>
251
+
252
+ <h2>Roadmap</h2>
253
+
254
+ <ul>
255
+ <li>Update
256
+
257
+ <ul>
258
+ <li>Better new? detection eg. storing ETag from request resources.</li>
259
+ <li>Use PATCH for with only changed attributes and <code>If-Unmodifed-Since</code>
260
+ and <code>If-Match</code> header fields if resource was surly loaded from service
261
+ and not created with an id (e.g <code>User.new id: 5, name: &quot;john&quot;</code>).</li>
262
+ <li>Conflict detection (ETag / If-Unmodified-Since)</li>
263
+ </ul></li>
264
+ <li>High level features
265
+
266
+ <ul>
267
+ <li>Support for custom mime types on client and server side. (<code>application/vnd.myservice.user.v2+msgpack</code>)</li>
268
+ <li>Server side components
269
+
270
+ <ul>
271
+ <li>Reusing model definitions for generating responses?</li>
272
+ <li>Rails responders providing REST operations with integrated ETag,
273
+ Modified Headers, conflict detection, ...</li>
274
+ </ul></li>
275
+ <li>Pagination? Filtering? (If service API provides such features.)</li>
276
+ <li>Messaging Queue support for services and models</li>
277
+ </ul></li>
278
+ <li>Documentation</li>
279
+ </ul>
280
+
281
+ <h2>Contributing</h2>
282
+
283
+ <ol>
284
+ <li>Fork it</li>
285
+ <li>Create your feature branch (<code>git checkout -b my-new-feature</code>)</li>
286
+ <li>Add specs for your feature</li>
287
+ <li>Implement your feature</li>
288
+ <li>Commit your changes (<code>git commit -am &#39;Add some feature&#39;</code>)</li>
289
+ <li>Push to the branch (<code>git push origin my-new-feature</code>)</li>
290
+ <li>Create new Pull Request</li>
291
+ </ol>
292
+
293
+ <h2>License</h2>
294
+
295
+ <p>MIT License</p>
296
+
297
+ <p>Copyright (c) 2013 Jan Graichen. MIT license, see LICENSE for more details.</p>
298
+ </div></div>
299
+
300
+ <div id="footer">
301
+ Generated on Thu May 23 21:23:35 2013 by
302
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
303
+ 0.8.6.1 (ruby-2.0.0).
304
+ </div>
305
+
306
+ </body>
307
+ </html>
@@ -1,7 +1,7 @@
1
1
  module Acfs
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 27
4
+ MINOR = 28
5
5
  PATCH = 0
6
6
  STAGE = nil
7
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.0.1.b248
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
@@ -14,98 +14,98 @@ dependencies:
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: actionpack
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: multi_json
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: typhoeus
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.6.5
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.6.5
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rack
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.3'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.3'
111
111
  description: API Client For Services
@@ -115,20 +115,11 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
- - .gitignore
119
- - .rspec
120
- - .travis.yml
121
118
  - CHANGELOG.md
122
- - Gemfile
123
- - Guardfile
124
119
  - LICENSE
125
120
  - README.md
126
- - Rakefile
127
121
  - acfs.gemspec
128
- - gemfiles/Gemfile.rails-3-0
129
- - gemfiles/Gemfile.rails-3-1
130
- - gemfiles/Gemfile.rails-3-2
131
- - gemfiles/Gemfile.rails-4-0
122
+ - doc/file.README.html
132
123
  - lib/acfs.rb
133
124
  - lib/acfs/adapter/base.rb
134
125
  - lib/acfs/adapter/typhoeus.rb
@@ -177,7 +168,6 @@ files:
177
168
  - lib/acfs/stub.rb
178
169
  - lib/acfs/version.rb
179
170
  - lib/acfs/yard.rb
180
- - rubydoc.png
181
171
  - spec/acfs/configuration_spec.rb
182
172
  - spec/acfs/middleware/json_decoder_spec.rb
183
173
  - spec/acfs/middleware/msgpack_decoder_spec.rb
@@ -215,14 +205,14 @@ require_paths:
215
205
  - lib
216
206
  required_ruby_version: !ruby/object:Gem::Requirement
217
207
  requirements:
218
- - - ! '>='
208
+ - - ">="
219
209
  - !ruby/object:Gem::Version
220
210
  version: '0'
221
211
  required_rubygems_version: !ruby/object:Gem::Requirement
222
212
  requirements:
223
- - - ! '>'
213
+ - - ">="
224
214
  - !ruby/object:Gem::Version
225
- version: 1.3.1
215
+ version: '0'
226
216
  requirements: []
227
217
  rubyforge_project:
228
218
  rubygems_version: 2.2.1
@@ -257,3 +247,4 @@ test_files:
257
247
  - spec/spec_helper.rb
258
248
  - spec/support/response.rb
259
249
  - spec/support/service.rb
250
+ has_rdoc:
data/.gitignore DELETED
@@ -1,23 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .rbx
4
- .bundle
5
- .config
6
- .yardoc
7
- doc
8
- Gemfile*.lock
9
- InstalledFiles
10
- _yardoc
11
- coverage
12
- doc/
13
- lib/bundler/man
14
- pkg
15
- rdoc
16
- spec/reports
17
- test/tmp
18
- test/version_tmp
19
- tmp
20
- .idea
21
- *.iml
22
- .rvmrc
23
- .ruby-version
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --backtrace
@@ -1,29 +0,0 @@
1
- language: ruby
2
- bundler_args: --without development
3
- rvm:
4
- - 2.1.0
5
- - 2.0.0
6
- - 1.9.3
7
- - jruby
8
- - rbx
9
- gemfile:
10
- - gemfiles/Gemfile.rails-4-0
11
- - gemfiles/Gemfile.rails-3-2
12
- - gemfiles/Gemfile.rails-3-1
13
- services:
14
- - rabbitmq
15
- deploy:
16
- provider: rubygems
17
- api_key:
18
- secure: gNudZK0JaRRweudmkpdkJjUMydItTSW5cXjpYdYCfahqd/cD0xPjxotr2TCHrJibfVauoT/PytbQWcP3jnOYytp6oS0up5Y+uKpGmbqVYx/rZvShWALszcBs71lUh/IZpDXNHc+yo/01HCn10/uQUFRtrjWgMwHtHxXb09xE4wQ=
19
- gem: acfs
20
- on:
21
- branch: master
22
- repo: jgraichen/acfs
23
- rvm: 2.0.0
24
- matrix:
25
- allow_failures:
26
- - rvm: 2.1.0
27
- before_install:
28
- - gem install minitest -v '4.7.5'
29
- - gem install json -v '1.8.1'
data/Gemfile DELETED
@@ -1,33 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Development gems
4
- #
5
- gem 'webmock', '~> 1.7'
6
- gem 'rake'
7
- gem 'rspec', '>= 3.0.0.beta1'
8
- gem 'rspec-its'
9
- gem 'rspec-collection_matchers'
10
- gem 'coveralls'
11
- gem 'json', '~> 1.8.1'
12
-
13
- # Doc
14
- group :development do
15
- gem 'yard', '~> 0.8.6'
16
- gem 'listen'
17
- gem 'guard-yard'
18
- gem 'guard-rspec'
19
- gem 'redcarpet', platform: :ruby
20
- end
21
-
22
- # Platform specific development dependencies
23
- #
24
- platform :rbx do
25
- gem 'rubysl', '~> 2.0'
26
- gem 'rubinius-coverage'
27
- end
28
- gem 'msgpack', '< 0.5.8', platform: :ruby
29
- gem 'msgpack-jruby', require: 'msgpack', platform: :jruby
30
-
31
- # Specify your gem's dependencies in acfs.gemspec
32
- gemroot = File.dirname File.absolute_path __FILE__
33
- gemspec path: gemroot
data/Guardfile DELETED
@@ -1,14 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- guard 'rspec' do
5
- watch(%r{^spec/.+_spec\.rb$})
6
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
-
8
- watch('spec/spec_helper.rb') { 'spec' }
9
- watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
10
- end
11
-
12
- guard 'yard' do
13
- watch(%r{lib/.+\.rb})
14
- end
data/Rakefile DELETED
@@ -1,16 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
- task :default => :spec
6
-
7
- begin
8
- require 'yard'
9
- require 'yard/rake/yardoc_task'
10
-
11
- YARD::Rake::YardocTask.new do |t|
12
- t.files = %w(lib/**/*.rb)
13
- t.options = %w(--output-dir doc/)
14
- end
15
- rescue LoadError
16
- end
@@ -1,8 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Load root Gemfile
4
- self.instance_eval Bundler.read_file 'Gemfile'
5
-
6
- gem 'activesupport', '~> 3.0.0'
7
- gem 'activemodel', '~> 3.0.0'
8
- gem 'actionpack', '~> 3.0.0'
@@ -1,8 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Load root Gemfile
4
- self.instance_eval Bundler.read_file 'Gemfile'
5
-
6
- gem 'activesupport', '~> 3.1.0'
7
- gem 'activemodel', '~> 3.1.0'
8
- gem 'actionpack', '~> 3.1.0'
@@ -1,8 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Load root Gemfile
4
- self.instance_eval Bundler.read_file 'Gemfile'
5
-
6
- gem 'activesupport', '~> 3.2.0'
7
- gem 'activemodel', '~> 3.2.0'
8
- gem 'actionpack', '~> 3.2.0'
@@ -1,8 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Load root Gemfile
4
- self.instance_eval Bundler.read_file 'Gemfile'
5
-
6
- gem 'activesupport', '~> 4.0.0.rc1'
7
- gem 'activemodel', '~> 4.0.0.rc1'
8
- gem 'actionpack', '~> 4.0.0.rc1'
Binary file