airrecord 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +40 -6
- data/lib/airrecord/table.rb +5 -0
- data/lib/airrecord/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c7750e40929942d774da0aba5ad0672c550b3fc
|
4
|
+
data.tar.gz: 4a1f864a9970f156ed310d7f6635da316c73c7c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 359c165ea9163454dff7067029a08bccaa2a57d07c36a710a734dcc3321bf17162772c11debc6ab5800a443b1c47c1e1c701a321b0ed69f9e3d033bee16b7889
|
7
|
+
data.tar.gz: 2e1d2950f4f2c36fdb2dced7d5384f8652138e8b27f164efef1d7d9967fe0864ca7b7f839a0c3eaba306d169f23a500617ab92180f626d38527086a6912c2b97
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -22,9 +22,21 @@ class Tea < Airrecord::Table
|
|
22
22
|
|
23
23
|
has_many :brews, class: 'Brew', column: "Brews"
|
24
24
|
|
25
|
+
def self.chinese
|
26
|
+
all(filter: '{Country} == "China"')
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.cheapest_and_best
|
30
|
+
all(sort: { "Rating" => "desc", "Price" => "asc" })
|
31
|
+
end
|
32
|
+
|
25
33
|
def location
|
26
34
|
[self[:village], self[:country], self[:region]].compact.join(", ")
|
27
35
|
end
|
36
|
+
|
37
|
+
def green?
|
38
|
+
self[:type] == "Green"
|
39
|
+
end
|
28
40
|
end
|
29
41
|
|
30
42
|
class Brew < Airrecord::Table
|
@@ -32,6 +44,14 @@ class Brew < Airrecord::Table
|
|
32
44
|
self.table_name = "Brews"
|
33
45
|
|
34
46
|
belongs_to :tea, class: 'Tea', column: 'Tea'
|
47
|
+
|
48
|
+
def self.hot
|
49
|
+
all(filter: "{Temperature} > 90")
|
50
|
+
end
|
51
|
+
|
52
|
+
def done_brewing?
|
53
|
+
self[:created_at] + self[:duration] > Time.now
|
54
|
+
end
|
35
55
|
end
|
36
56
|
|
37
57
|
teas = Tea.all
|
@@ -41,6 +61,18 @@ tea.location # instance methods
|
|
41
61
|
tea[:brews] # associated brews
|
42
62
|
```
|
43
63
|
|
64
|
+
A short-hand API for definitions and more ad-hoc querying is also available:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
Tea = Airrecord.table("api_key", "app_key", "Teas")
|
68
|
+
|
69
|
+
Tea.all.each do |record|
|
70
|
+
puts "#{record.id}: #{record[:name]}"
|
71
|
+
end
|
72
|
+
|
73
|
+
Tea.find("rec3838")
|
74
|
+
```
|
75
|
+
|
44
76
|
## Documentation
|
45
77
|
|
46
78
|
### Authentication
|
@@ -98,7 +130,7 @@ To use `filterbyFormula` to filter returned records:
|
|
98
130
|
|
99
131
|
```ruby
|
100
132
|
# Retrieve all teas from China
|
101
|
-
Tea.all(filter:
|
133
|
+
Tea.all(filter: '{Country} == "China"')
|
102
134
|
|
103
135
|
# Retrieve all teas created in the past week
|
104
136
|
Tea.all(filter: "DATETIME_DIFF(CREATED_TIME(), TODAY(), 'days') < 7")
|
@@ -178,8 +210,8 @@ tea = Tea.find("someid")
|
|
178
210
|
tea[:name] = "Feng Gang Organic"
|
179
211
|
|
180
212
|
# Since the Village column is not set, we do not have access to a snake-cased
|
181
|
-
variant since the mapping is not determined. For all we know, the correct column
|
182
|
-
name could be "VilLlaGe". Therefore, we must use the proper column name.
|
213
|
+
# variant since the mapping is not determined. For all we know, the correct column
|
214
|
+
# name could be "VilLlaGe". Therefore, we must use the proper column name.
|
183
215
|
tea["Village"] = "Feng Gang"
|
184
216
|
|
185
217
|
tea.save # persist to Airtable
|
@@ -252,15 +284,17 @@ Brew.create("Tea" => tea, "Temperature" => "80", "Time" => "4m", "Rating" => "5"
|
|
252
284
|
|
253
285
|
Airrtable provides a simple, ad-hoc API that will instantiate an anonymous
|
254
286
|
`Airrecord::Table` for you on the fly with the configured key, app, and table.
|
287
|
+
This is useful if you require no custom definitions, or you're just playing
|
288
|
+
around.
|
255
289
|
|
256
290
|
```ruby
|
257
|
-
|
291
|
+
Tea = Airrecord.table("api_key", "app_key", "Teas")
|
258
292
|
|
259
|
-
|
293
|
+
Tea.all.each do |record|
|
260
294
|
puts "#{record.id}: #{record[:name]}"
|
261
295
|
end
|
262
296
|
|
263
|
-
|
297
|
+
Tea.find("rec3838")
|
264
298
|
```
|
265
299
|
|
266
300
|
### Snake-cased helper methods
|
data/lib/airrecord/table.rb
CHANGED
data/lib/airrecord/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airrecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Eskildsen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -103,6 +103,7 @@ extra_rdoc_files: []
|
|
103
103
|
files:
|
104
104
|
- ".gitignore"
|
105
105
|
- ".travis.yml"
|
106
|
+
- CHANGELOG.md
|
106
107
|
- Gemfile
|
107
108
|
- LICENSE
|
108
109
|
- README.md
|