glass-rails 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/glass/install/templates/google_account.rb +6 -1
- data/lib/glass/.DS_Store +0 -0
- data/lib/glass/client.rb +13 -13
- data/lib/glass/rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d4e68dd44d9acc1a4db1e881de0e215f0c6b724
|
4
|
+
data.tar.gz: 64a8e0d00431a9c3c2ae9e379b73082943ff06a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b779ef5e95f0576baaba0c11c27222d93aad62a76f70722686031fdbcc0407b27ce473ec4c5e645e1db660b4fee0be22628254f5f901adce1b00c7c35ca8a865
|
7
|
+
data.tar.gz: ebb85eb846ac8b6ce922358a7da1593af599184e9ea5920682393e3f277784a6f736f3dc922dad0ee768ee0457b001e4669e5139037773bbfb4c89c8448dce9a
|
@@ -20,7 +20,12 @@ class GoogleAccount < ActiveRecord::Base
|
|
20
20
|
subscription = Glass::Subscription.new google_account: self
|
21
21
|
subscription.insert
|
22
22
|
end
|
23
|
-
|
23
|
+
def list
|
24
|
+
Glass::Client.new(google_account: self).list
|
25
|
+
end
|
26
|
+
def cached_list
|
27
|
+
Glass::Client.new(google_account: self).cached_list
|
28
|
+
end
|
24
29
|
private
|
25
30
|
def generate_verification_secret
|
26
31
|
self.verification_secret = SecureRandom.urlsafe_base64
|
data/lib/glass/.DS_Store
CHANGED
Binary file
|
data/lib/glass/client.rb
CHANGED
@@ -4,7 +4,7 @@ require "google/api_client"
|
|
4
4
|
|
5
5
|
module Glass
|
6
6
|
class Client
|
7
|
-
attr_accessor :access_token, :google_client, :mirror_api,
|
7
|
+
attr_accessor :access_token, :google_client, :mirror_api,
|
8
8
|
:google_account, :refresh_token, :content,
|
9
9
|
:mirror_content_type, :timeline_item, :has_expired_token,
|
10
10
|
:api_keys, :timeline_list
|
@@ -21,7 +21,7 @@ module Glass
|
|
21
21
|
self.mirror_api = google_client.discovered_api("mirror", "v1")
|
22
22
|
self.google_account = opts[:google_account]
|
23
23
|
|
24
|
-
### this isn't functional yet but this is an idea for
|
24
|
+
### this isn't functional yet but this is an idea for
|
25
25
|
### an api for those who wish to opt out of passing in a
|
26
26
|
### google account, by passing in a hash of options
|
27
27
|
###
|
@@ -29,7 +29,7 @@ module Glass
|
|
29
29
|
### the tricky aspect of this is how to handle the update
|
30
30
|
### of the token information if the token is expired.
|
31
31
|
|
32
|
-
self.access_token = opts[:access_token] || google_account.try(:token)
|
32
|
+
self.access_token = opts[:access_token] || google_account.try(:token)
|
33
33
|
self.refresh_token = opts[:refresh_token] || google_account.try(:refresh_token)
|
34
34
|
self.has_expired_token = opts[:has_expired_token] || google_account.has_expired_token?
|
35
35
|
|
@@ -69,12 +69,12 @@ module Glass
|
|
69
69
|
mirror_api.timeline.send(api_method).request_schema.new({text: text})
|
70
70
|
end
|
71
71
|
|
72
|
-
## optional parameter is merged into the content hash
|
72
|
+
## optional parameter is merged into the content hash
|
73
73
|
## before sending. good for specifying more application
|
74
|
-
## specific stuff like speakableText parameters.
|
74
|
+
## specific stuff like speakableText parameters.
|
75
75
|
def rest_action(options, action="insert")
|
76
76
|
body_object = json_content(options, action)
|
77
|
-
inserting_content = { api_method: mirror_api.timeline.send(action),
|
77
|
+
inserting_content = { api_method: mirror_api.timeline.send(action),
|
78
78
|
body_object: body_object}
|
79
79
|
end
|
80
80
|
def get(id)
|
@@ -95,7 +95,7 @@ module Glass
|
|
95
95
|
|
96
96
|
def update(timeline_item, options={})
|
97
97
|
glass_item_id = options.delete(:glass_item_id)
|
98
|
-
update_content = { api_method: mirror_api.timeline.update,
|
98
|
+
update_content = { api_method: mirror_api.timeline.update,
|
99
99
|
body_object: timeline_item,
|
100
100
|
parameters: {id: glass_item_id}}
|
101
101
|
google_client.execute update_content
|
@@ -104,7 +104,7 @@ module Glass
|
|
104
104
|
|
105
105
|
|
106
106
|
## deprecated: please use cached_list instead
|
107
|
-
def timeline_list
|
107
|
+
def timeline_list(opts={as_hash: true})
|
108
108
|
puts "DEPRECATION WARNING: timeline_list is now deprecated, please use cached_list instead"
|
109
109
|
cached_list
|
110
110
|
end
|
@@ -117,7 +117,7 @@ module Glass
|
|
117
117
|
|
118
118
|
|
119
119
|
|
120
|
-
### this method is pretty much extracted directly from
|
120
|
+
### this method is pretty much extracted directly from
|
121
121
|
### the mirror API code samples in ruby
|
122
122
|
###
|
123
123
|
### https://developers.google.com/glass/v1/reference/timeline/list
|
@@ -164,13 +164,13 @@ module Glass
|
|
164
164
|
private
|
165
165
|
|
166
166
|
def setup_with_our_access_tokens
|
167
|
-
["client_id", "client_secret"].each do |meth|
|
168
|
-
google_client.authorization.send("#{meth}=", self.api_keys.send(meth))
|
167
|
+
["client_id", "client_secret"].each do |meth|
|
168
|
+
google_client.authorization.send("#{meth}=", self.api_keys.send(meth))
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
172
|
def setup_with_user_access_token
|
173
|
-
google_client.authorization.update_token!(access_token: access_token,
|
173
|
+
google_client.authorization.update_token!(access_token: access_token,
|
174
174
|
refresh_token: refresh_token)
|
175
175
|
update_token_if_necessary
|
176
176
|
end
|
@@ -197,7 +197,7 @@ module Glass
|
|
197
197
|
acc[new_key]= (new_key == "displayTime") ? format_date(value) : value
|
198
198
|
acc
|
199
199
|
end.with_indifferent_access
|
200
|
-
end
|
200
|
+
end
|
201
201
|
def to_google_time(time)
|
202
202
|
Time.now.to_i + time
|
203
203
|
end
|
data/lib/glass/rails/version.rb
CHANGED