glass-rails 0.1.5 → 1.0.0
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 +4 -4
- data/glass-rails.gemspec +2 -2
- data/lib/generators/glass/install/templates/google_account.rb +1 -1
- data/lib/generators/glass/install/templates/initializer.rb +13 -16
- data/lib/generators/glass/model/templates/model.rb +2 -2
- data/lib/glass.rb +7 -7
- data/lib/glass/client.rb +6 -1
- data/lib/glass/rails/version.rb +1 -1
- data/lib/glass/template.rb +3 -3
- data/lib/glass/timeline_item.rb +9 -37
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f0c58157a2668abbda0417296fcf8ac4f57a3a4
|
4
|
+
data.tar.gz: b7859dc9b8804a5c7c2f95a0fe27eb8cf236d852
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c51db88dae76a80f11a2ef3fcce707e8944f27ea615111872d939449ac09aa276175f21fc45514acc8bbc51ba13fc0aad28d42c961a67a74565e8917f7b4825
|
7
|
+
data.tar.gz: 92de4b4ca3572f44bc297ee6cb8a4f6063b2aa530d116b4a6b34af255b0cd490db6381bfeb3e656ec40dba835207f014897b859b02882ab8fe7633fb8c485cc5
|
data/glass-rails.gemspec
CHANGED
@@ -23,11 +23,11 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_dependency "railties", [">= 3.1"]
|
25
25
|
spec.add_dependency "google-api-client"
|
26
|
-
spec.add_development_dependency "bundler", "
|
26
|
+
spec.add_development_dependency "bundler", ">= 1.3"
|
27
27
|
spec.add_development_dependency "rake"
|
28
28
|
spec.add_development_dependency "pry"
|
29
29
|
spec.add_development_dependency "pry-rails"
|
30
30
|
spec.add_development_dependency "rspec", ">= 1.5.2"
|
31
|
-
spec.add_development_dependency "rspec-rails", '
|
31
|
+
spec.add_development_dependency "rspec-rails", '>= 2.11.0'
|
32
32
|
|
33
33
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
class GoogleAccount < ActiveRecord::Base
|
2
2
|
belongs_to :<%= user_model.underscore.singularize %>
|
3
|
-
attr_accessible :email, :expires_at, :name, :refresh_token, :token, :verification_secret
|
4
3
|
before_create :generate_verification_secret
|
5
4
|
after_create :subscribe_to_google_notifications
|
5
|
+
|
6
6
|
def token_expiry
|
7
7
|
Time.at(self.expires_at)
|
8
8
|
end
|
@@ -1,24 +1,21 @@
|
|
1
|
-
if
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
elsif Rails.env.test?
|
11
|
-
|
12
|
-
## setup whatever you want for default url options for your test env.
|
13
|
-
end
|
1
|
+
## if you've set this elsewhere you may want
|
2
|
+
## to comment this out.
|
3
|
+
##
|
4
|
+
## Glass requires this to be defined for callback url
|
5
|
+
## purposes.
|
6
|
+
|
7
|
+
Rails.application.routes.default_url_options[:host] = 'localhost:3000' if Rails.env.development?
|
8
|
+
|
9
|
+
## Your configuration details here:
|
14
10
|
|
15
11
|
Glass.setup do |config|
|
16
|
-
##
|
17
|
-
## config.
|
12
|
+
## modify this to change the name of your glass app
|
13
|
+
## config.application_name = "SomeGlassApp"
|
18
14
|
|
15
|
+
## modify this to change the application version of your glass app
|
16
|
+
## config.application_version = "0.0.1"
|
19
17
|
|
20
18
|
|
21
19
|
## manually override your glass views path here.
|
22
20
|
config.glass_template_path = "app/views/glass"
|
23
|
-
|
24
21
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Glass::<%= model_name.camelize %> < Glass::TimelineItem
|
2
2
|
|
3
3
|
|
4
|
-
|
4
|
+
defaults_template_with :simple
|
5
5
|
|
6
6
|
|
7
7
|
|
@@ -30,4 +30,4 @@ class Glass::<%= model_name.camelize %> < Glass::TimelineItem
|
|
30
30
|
## when the action is invoked
|
31
31
|
end
|
32
32
|
|
33
|
-
end
|
33
|
+
end
|
data/lib/glass.rb
CHANGED
@@ -4,14 +4,14 @@ require 'active_support/dependencies'
|
|
4
4
|
require 'glass/rails/version'
|
5
5
|
|
6
6
|
module Glass
|
7
|
+
|
8
|
+
mattr_accessor :application_name
|
9
|
+
application_name = (defined?(::Rails) && ::Rails.application) ? ::Rails.application.class.name.split('::').first : "SomeGlassApp"
|
10
|
+
@@application_name = application_name
|
7
11
|
|
8
|
-
mattr_accessor :
|
9
|
-
@@
|
10
|
-
|
11
|
-
mattr_accessor :brandname_styles
|
12
|
-
@@brandname_styles = {color: "#8BCDF8",
|
13
|
-
font_size: "30px"}
|
14
|
-
|
12
|
+
mattr_accessor :application_version
|
13
|
+
@@application_version = "0.0.1"
|
14
|
+
|
15
15
|
mattr_accessor :glass_template_path
|
16
16
|
@@glass_template_path = "app/views/glass"
|
17
17
|
|
data/lib/glass/client.rb
CHANGED
@@ -17,7 +17,7 @@ module Glass
|
|
17
17
|
|
18
18
|
def initialize(opts)
|
19
19
|
self.api_keys = opts[:api_keys] || ::Glass::ApiKeys.new
|
20
|
-
|
20
|
+
initialize_google_api_client
|
21
21
|
self.mirror_api = google_client.discovered_api("mirror", "v1")
|
22
22
|
self.google_account = opts[:google_account]
|
23
23
|
|
@@ -37,6 +37,11 @@ module Glass
|
|
37
37
|
setup_with_user_access_token
|
38
38
|
self
|
39
39
|
end
|
40
|
+
def initialize_google_api_client
|
41
|
+
application_name = ::Glass.application_name
|
42
|
+
application_version = ::Glass.application_version
|
43
|
+
self.google_client = ::Google::APIClient.new(application_name: application_name, application_version: application_version)
|
44
|
+
end
|
40
45
|
|
41
46
|
def get_timeline_item(id)
|
42
47
|
response_hash(self.google_client.execute(get_timeline_item_parameters(id)).response)
|
data/lib/glass/rails/version.rb
CHANGED
data/lib/glass/template.rb
CHANGED
@@ -19,9 +19,9 @@ module Glass
|
|
19
19
|
## "app/views/glass-templates/tweets/blue.html.erb"
|
20
20
|
|
21
21
|
## then your template name would be:
|
22
|
-
## "tweets/blue
|
22
|
+
## "tweets/blue"
|
23
23
|
def initialize(opts={})
|
24
|
-
self.template_name = opts.delete(:template_name) || "simple
|
24
|
+
self.template_name = opts.delete(:template_name) || "simple"
|
25
25
|
set_template_instance_variables(opts)
|
26
26
|
super(glass_template_path)
|
27
27
|
end
|
@@ -42,4 +42,4 @@ module Glass
|
|
42
42
|
::Glass.glass_template_path
|
43
43
|
end
|
44
44
|
end
|
45
|
-
end
|
45
|
+
end
|
data/lib/glass/timeline_item.rb
CHANGED
@@ -15,12 +15,6 @@ module Glass
|
|
15
15
|
|
16
16
|
belongs_to :google_account
|
17
17
|
|
18
|
-
attr_accessible :display_time, :glass_content, :glass_content_type,
|
19
|
-
:glass_created_at, :glass_etag, :glass_item_id,
|
20
|
-
:glass_kind, :glass_self_link, :glass_updated_at,
|
21
|
-
:is_deleted, :google_account_id
|
22
|
-
|
23
|
-
|
24
18
|
|
25
19
|
## i'd use cattr_accessor, but unfortunately
|
26
20
|
## ruby has some very crappy class variables, which
|
@@ -33,21 +27,12 @@ module Glass
|
|
33
27
|
|
34
28
|
attr_accessor :template_type, :to_json
|
35
29
|
|
36
|
-
|
37
|
-
|
38
30
|
## only a writer for these two
|
39
31
|
## because I want to hook an error
|
40
32
|
## message to each of these if they haven't
|
41
33
|
## had there values set yet.
|
42
34
|
attr_writer :client, :mirror_content, :template_name
|
43
35
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
36
|
### a couple custom attr_readers which raise a
|
52
37
|
### helpful error message if the value is nil;
|
53
38
|
### i.e. error flow handling.
|
@@ -59,15 +44,7 @@ module Glass
|
|
59
44
|
raise UnserializedTemplateError unless @client
|
60
45
|
@client
|
61
46
|
end
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
47
|
+
|
71
48
|
## this methods sets the default template for
|
72
49
|
## all instances of the class.
|
73
50
|
|
@@ -90,24 +67,19 @@ module Glass
|
|
90
67
|
## Usage:
|
91
68
|
## class Glass::Tweet < Glass::TimelineItem
|
92
69
|
|
93
|
-
## defaults_template_with
|
70
|
+
## defaults_template_with :table
|
94
71
|
## this defaults to the glass_template_path
|
95
72
|
## which you set in your glass initializer.
|
96
73
|
|
97
74
|
## end
|
98
75
|
def self.defaults_template_with(name_of_template)
|
99
76
|
if name_of_template.is_a? Symbol
|
100
|
-
self.default_template = name_of_template.to_s
|
77
|
+
self.default_template = name_of_template.to_s
|
78
|
+
else
|
79
|
+
raise InvalidArgumentError, 'Template name is not a symbol'
|
101
80
|
end
|
102
81
|
end
|
103
82
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
83
|
## this methods sets the default template for
|
112
84
|
## all instances of the class.
|
113
85
|
|
@@ -290,13 +262,13 @@ module Glass
|
|
290
262
|
|
291
263
|
## this is not intended to be a part of the public api
|
292
264
|
def template_name
|
293
|
-
@template_name = self.class.default_template
|
265
|
+
@template_name = self.class.default_template
|
294
266
|
end
|
295
267
|
|
296
268
|
## this is not intended to be a part of the public api
|
297
269
|
def setup_template(variables={})
|
298
|
-
|
299
|
-
Glass::Template.new(
|
270
|
+
variables[:template_name] ||= self.template_name
|
271
|
+
Glass::Template.new(variables).render_self
|
300
272
|
end
|
301
273
|
|
302
274
|
## this is not intended to be a part of the public api
|
@@ -309,4 +281,4 @@ module Glass
|
|
309
281
|
end
|
310
282
|
|
311
283
|
end
|
312
|
-
end
|
284
|
+
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: 0.
|
4
|
+
version: 1.0.0
|
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-
|
12
|
+
date: 2013-07-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -43,14 +43,14 @@ dependencies:
|
|
43
43
|
name: bundler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - '>='
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '1.3'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - '>='
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '1.3'
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -113,14 +113,14 @@ dependencies:
|
|
113
113
|
name: rspec-rails
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- -
|
116
|
+
- - '>='
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: 2.11.0
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - '>='
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: 2.11.0
|
126
126
|
description: ' A framework for creating google glass applications using ruby on rails. '
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
198
|
rubyforge_project:
|
199
|
-
rubygems_version: 2.0.
|
199
|
+
rubygems_version: 2.0.5
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: A framework for creating google glass applications using ruby on rails. This
|