radriar 0.1.0.alpha.2 → 0.1.0.alpha.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57ea1f5b5028c2d60f066bccee36a662244afee1
4
- data.tar.gz: bdaacb50e3f2dff27b6dee7fc8193cc1286ea984
3
+ metadata.gz: a54c46a793a980be7c145a4db67eea542d175390
4
+ data.tar.gz: 84bf3d6ff4da0701e9a337b2d78897a9b1e5d43f
5
5
  SHA512:
6
- metadata.gz: 81064a99af29b82f73cdba951a496ff56457bd1e21066c8dd56bffaffc323b06d4f57ffb65def6242c1077d11b837831d4be438b11edc2c3eae2fa5c9ef1e0ec
7
- data.tar.gz: 14c0d00e8d89a439a00f8bce1e78bdf3301d39e932c1120086a9cbd2aa52462cd0330101b6245c3d6b4a84f8e889484e79101842304ccef4d690dd37216eeab5
6
+ metadata.gz: 390ecbeb6f81f2b9593dc47c7b5a2a07363eb31333103a9bcaff63854ac74a839466677f1caa097b8961e0f5476318ee5ec306859427cc2b5d2a1f349811f593
7
+ data.tar.gz: d74dc28860d958fe14736e4a10bb09e387dd87be6c70b05d3fe47ccbe44ca5349f9ff9ddd8f4cc9771d16dba281663e70c64ff81b7f3ed17ead5960159b8ad0b
data/README.md CHANGED
@@ -8,25 +8,143 @@ Add this line to your application's Gemfile:
8
8
 
9
9
  gem 'radriar'
10
10
 
11
- And then execute:
11
+ ## Conventions and included components
12
12
 
13
- $ bundle
13
+ * API based on [Grape](https://github.com/intridea/grape)
14
+ * Model representation with [representable](https://github.com/apotonick/representable)
15
+ * Use of the `represent` and `represent_each` helpers inside the API, or a Grape formatter
16
+ _(coming soon)_.
17
+ * Hypermedia features are based on [HAL](http://stateless.co/hal_specification.html) and
18
+ require [Roar](https://github.com/apotonick/roar).
14
19
 
15
- Or install it yourself as:
20
+ ## Key Features
16
21
 
17
- $ gem install radriar
22
+ __TODO__: Redact
23
+
24
+ * Key translation (Snake case to underscore and viceversa).
25
+ * Optional field includes (Pass `fields` parameter in URL).
26
+ * Conventional error responses.
27
+ * Optional inclusion/exclusion of hypermedia (HAL).
18
28
 
19
29
  ## Usage
20
30
 
21
- TODO: Write usage instructions here
31
+ Include the gem in your Gemfile:
32
+
33
+ ```ruby
34
+ gem 'radriar'
35
+ ```
36
+
37
+ Then radriarize your API ;), aka invoke the `#radriarize` method with the specified
38
+ options from your API definition.
39
+
40
+ ``` ruby
41
+ class UserAPI < Grape::API
42
+ radriarize representer_namespace: 'MyApp::Representers',
43
+ hypermedia: true,
44
+ translate_keys: true
45
+ ```
46
+
47
+ ### Dynamic APIs
48
+
49
+ Assuming you're using the right conventions (to be redacted) this will magically
50
+ turn your API from this:
51
+
52
+ ```javascript
53
+ {
54
+ "id": "blackxored",
55
+ "first_name": "Adrian",
56
+ "last_name": "Perez",
57
+ "avatar_url": "...",
58
+ "hireable": false,
59
+ "registered_at": "...",
60
+ "social_urls": {
61
+ "github": "https://github.com/blackxored",
62
+ "twitter": "https://twitter.com/blackxored"
63
+ },
64
+ "comments": [ /* ... */],
65
+ }
66
+ ```
67
+
68
+ To this:
69
+
70
+ ```javascript
71
+ {
72
+ "_links": {
73
+ "self": {
74
+ "href": "/users/blackxored"
75
+ },
76
+ "html": {
77
+ "href": "/#/u/blackxored"
78
+ },
79
+ "timeline": {
80
+ "href": "/users/blackxored/timeline"
81
+ },
82
+ },
83
+ "_embedded": {
84
+ "total": 2,
85
+ "comments": [ /* ... */ ]
86
+ },
87
+ "id": "blackxored",
88
+ "firstName": "Adrian",
89
+ "lastName": "Perez",
90
+ "avatarUrl": "...",
91
+ "hireable": false,
92
+ "registeredAt": "2013-06-18T06:37:39.248Z",
93
+ "socialUrls": {
94
+ "github": "https://github.com/blackxored",
95
+ "twitter": "https://twitter.com/blackxored"
96
+ },
97
+ }
98
+ ```
99
+
100
+ ### Partial Responses
22
101
 
23
- ## Features
102
+ You can request partial responses (ideal for mobile apps). Just hit any endpoint with an optional `fields` attribute.
103
+
104
+ (__TODO__: Check that key translation works at the partial response level)
105
+
106
+ From the response above:
107
+
108
+ ```shell
109
+ curl $URL?fields=id,firstName,avatarUrl
110
+ ```
111
+
112
+ Will return the following JSON document:
113
+
114
+ ```javascript
115
+ {
116
+ "id": "blackxored"
117
+ "firstName": "Adrian",
118
+ "avatarUrl": "..."
119
+ }
120
+ ```
121
+
122
+ ### Error Conventions
24
123
 
25
124
  __TODO__: Redact
26
- * Key translation (Snake case to underscore and viceversa).
27
- * Optional field includes (Pass `fields` parameter in URL).
28
- * Conventional error responses.
29
- * Optional inclusion/exclusion of hypermedia (HAL).
125
+
126
+ ### Pagination
127
+
128
+ __TODO__: Test and implement
129
+
130
+ All your collection get automated pagination by default. In the case of hypermedia APIs it also includes pagination links.
131
+
132
+ ```javascript
133
+ {
134
+ "_links": {
135
+ "self": "/collection?page=3",
136
+ "first": "/collection",
137
+ "next": "/collection?page=4"
138
+ "prev": "/collection?page=2",
139
+ "last": "/collection?page=10"
140
+ },
141
+ "_embedded": {
142
+ "collection": [ /*...*/]
143
+ },
144
+ "total": 250,
145
+ "per": 25
146
+ }
147
+ ```
30
148
 
31
149
  ## Contributing
32
150
 
data/TODO.md CHANGED
@@ -4,3 +4,4 @@
4
4
  * Paginate collections automatically
5
5
  * Exposed actions as links
6
6
  * Figure out whether to do key translation in links or not.
7
+ * Check if key translation works at the partial response level.
@@ -1,3 +1,3 @@
1
1
  module Radriar
2
- VERSION = "0.1.0.alpha.2"
2
+ VERSION = "0.1.0.alpha.3"
3
3
  end
@@ -22,8 +22,9 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_dependency "activesupport", ">= 3.2"
24
24
  spec.add_dependency "representable", ">= 1.8.0"
25
- spec.add_dependency "roar"
26
- spec.add_dependency "grape"
25
+ spec.add_dependency "roar", ">= 0.12.7"
26
+ spec.add_dependency "grape", ">= 0.6.1"
27
+
27
28
  spec.add_development_dependency "bundler", "~> 1.6"
28
29
  spec.add_development_dependency "rake"
29
30
  spec.add_development_dependency "pry"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radriar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.alpha.2
4
+ version: 0.1.0.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Perez
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.12.7
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
- version: '0'
54
+ version: 0.12.7
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: grape
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.6.1
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
- version: '0'
68
+ version: 0.6.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement