airrecord 0.2.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa2416d29667f3621c84a16cf761cf065a98be8e
4
- data.tar.gz: bbc197ae2c88828c9b90580e45d4cb011729ee21
3
+ metadata.gz: 0c7750e40929942d774da0aba5ad0672c550b3fc
4
+ data.tar.gz: 4a1f864a9970f156ed310d7f6635da316c73c7c3
5
5
  SHA512:
6
- metadata.gz: 94ba94acd00c8262b7d77b75641721cfe4f61d2c9f8bd93b567154e128eb03ade3c3ddfda2d0e9db4b09b5bfd1d3c151901e6144f57f5238b73ce702843b75ea
7
- data.tar.gz: 83392e39f08594d19976e2803c11c0e7ef4e34aec2a731bb569a845808d6311a67d9787393e884e44e67d2776aaf1934cc04270ec65a4043218938e012ec5ad1
6
+ metadata.gz: 359c165ea9163454dff7067029a08bccaa2a57d07c36a710a734dcc3321bf17162772c11debc6ab5800a443b1c47c1e1c701a321b0ed69f9e3d033bee16b7889
7
+ data.tar.gz: 2e1d2950f4f2c36fdb2dced7d5384f8652138e8b27f164efef1d7d9967fe0864ca7b7f839a0c3eaba306d169f23a500617ab92180f626d38527086a6912c2b97
@@ -0,0 +1,3 @@
1
+ # 0.2.1
2
+
3
+ * Added comparison operator (#9)
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: "{Country} == "China")
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
- teas = Airrecord.table("key1", "app1", "Teas")
291
+ Tea = Airrecord.table("api_key", "app_key", "Teas")
258
292
 
259
- teas.records.each do |record|
293
+ Tea.all.each do |record|
260
294
  puts "#{record.id}: #{record[:name]}"
261
295
  end
262
296
 
263
- p teas.find(teas.records.first.id)
297
+ Tea.find("rec3838")
264
298
  ```
265
299
 
266
300
  ### Snake-cased helper methods
@@ -197,6 +197,11 @@ module Airrecord
197
197
  }]
198
198
  end
199
199
 
200
+ def ==(other)
201
+ self.class == other.class &&
202
+ serializable_fields == other.serializable_fields
203
+ end
204
+
200
205
  protected
201
206
 
202
207
  def association(key)
@@ -1,3 +1,3 @@
1
1
  module Airrecord
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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-03-04 00:00:00.000000000 Z
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