glass-rails 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 382a58c0097543d4c1afff112bf680c70cebd294
4
- data.tar.gz: d2a2efab6190ae3c9baf25b031f5cca9062e6f82
3
+ metadata.gz: a740d70335aad3f64c715122c72881360bc8bbfc
4
+ data.tar.gz: 0148e1df2284ed65cc3043d83670156465e1c85c
5
5
  SHA512:
6
- metadata.gz: ffbea85cb1056755b39a54a32a615eba6051aa1a68f64ad10fac3bcc56b569119f4d45352e301326d5da0d078abd714f7833cc6af9bce1017723164b34709724
7
- data.tar.gz: 7c63a4cef7533efde5d529009409988f149734f04ac5116c2b09a7fa05e6f478a1962e1e6c66f6b925f7cf9f3cc638f671a8a7a64e0d6009455d0dd7f1211f21
6
+ metadata.gz: 79e7d4da1ee906570c6ff3908f933c52e6bd976ed85636b9b2d202322ab4d5d954de719ffb129135510a0292cfbd9374d621c859fb2f8d8765b7ccb991983f0c
7
+ data.tar.gz: 1286d9ac8eb2acc8cb636d282a64fa46c9cf23d29c7dfb7389a6d286e15a984e7d2b67cac071d7762327be3ccedc2154fdd007b766ec50e7a1458caae74d47e7
@@ -19,6 +19,9 @@ class GoogleAccount < ActiveRecord::Base
19
19
  def subscribe_to_google_notifications
20
20
  subscription = Glass::Subscription.new google_account: self
21
21
  subscription.insert
22
+ end
23
+ def update_location(location)
24
+
22
25
  end
23
26
  def list
24
27
  Glass::Client.new(google_account: self).list
@@ -30,4 +33,4 @@ class GoogleAccount < ActiveRecord::Base
30
33
  def generate_verification_secret
31
34
  self.verification_secret = SecureRandom.urlsafe_base64
32
35
  end
33
- end
36
+ end
@@ -58,6 +58,16 @@ module Glass
58
58
  self
59
59
  end
60
60
 
61
+ def get_location(id='latest')
62
+ response_hash(self.google_client.execute(get_location_parameters(id)).response)
63
+ end
64
+
65
+ def get_location_parameters(id)
66
+ { api_method: self.mirror_api.locations.get,
67
+ parameters: { "id" => id}
68
+ }
69
+ end
70
+
61
71
  def json_content(options, api_method="insert")
62
72
  if c = options[:content]
63
73
  data = c.is_a?(String) ? {text: c} : c
@@ -213,4 +223,4 @@ module Glass
213
223
  self.api_keys = ::Glass._api_keys
214
224
  end
215
225
  end
216
- end
226
+ end
@@ -1,5 +1,5 @@
1
1
  module Glass
2
2
  module Rails
3
- VERSION="1.0.4"
3
+ VERSION="1.0.5"
4
4
  end
5
5
  end
@@ -27,9 +27,7 @@ module Glass
27
27
  ## Perform the corresponding notification actions
28
28
  def handle!
29
29
  if collection == "locations"
30
- # TODO: This is a location update - should the GoogleAccount handle these updates?
31
- # When your Glassware receives a location update, send a request to the glass.locations.get endpoint to retrieve the latest known location.
32
- # Something like: google_account.handle_location_update
30
+ handle_location
33
31
  else
34
32
  self.glass_item_id = params[:itemId]
35
33
  handle_reply(params)
@@ -38,6 +36,11 @@ module Glass
38
36
  end
39
37
 
40
38
  private
39
+ def handle_location
40
+ google_client = ::Glass::Client.new(google_account: self.google_account)
41
+ google_account.update_location(google_client.get_location)
42
+ end
43
+
41
44
  def handle_reply(params)
42
45
  return unless has_user_action? :reply
43
46
  google_client = ::Glass::Client.new(google_account: self.google_account)
@@ -80,4 +83,4 @@ module Glass
80
83
  end
81
84
  end
82
85
  end
83
- end
86
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glass-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kunal Modi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-28 00:00:00.000000000 Z
12
+ date: 2013-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties