sensor 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWI2YWIwYWFiMTE5Njg3OGYyYTY0YmVkN2YxNTA1MWFmMTQzZmQxMA==
4
+ ZmQzMzIzYjljOTBiZDExNmM4M2JmN2JiYjUwODUwMDUwZGFlOGMyNQ==
5
5
  data.tar.gz: !binary |-
6
- ZjMyODZlY2ViYTMxMzAxZGUyZGJmMDJjMDNjY2FjNjRlYjI4Y2U4MA==
6
+ OTIwNzBmNjRiNjU5OGJiZjQwNmFiNzIxZTJmNDRmZDJjY2Y2MzI0ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGQxYWZlYzFjZDAwYjNhODg2NDQ0OWZhMTViNDlkMTAwNTEzMDRkYjU4ZWI2
10
- ZmEyNWJlZWVlY2I3YTlmNjQ1Zjk5YjRhYTM5MzQ1NzI4MWJlOTIxYTUwNjFk
11
- MzViZDVkZTQxYjlmOWUzY2NlZTFmN2ExNTQxNmM4ZTYwOGM2MzA=
9
+ ODY3NjU2ODNjYmIwOTNjNjRkOTNhMTliYzc2MzA2MmI1NTc0OTZlMmY1OTIz
10
+ NGZmNTM4MDY2ZjRmOGI2N2E1ZDcxNGY2ZWRjMTMyZmM4NmJmY2U0MGVmZDFi
11
+ MWVhYjUxNWMzOGNkYTE3NDE1YTE3MWZmMTgwMzAyYjI3NzI0NzI=
12
12
  data.tar.gz: !binary |-
13
- YmNhMmM5NzlhOTFmNDE4ZTY1ZWE2N2RhZjgxMThiYmFjZThmYTAwMzVhMjM1
14
- MTE5MjE5YzlmM2E0MDE0OTk5M2Q4NmQzYjZkYjkyNDJmOWQ0NjFhZDQ3Zjdk
15
- OWM1ZjI2ZWRlOTk1MDQzZmE1YWRlNjkwZGMwMWIyMjYyMzlkYTU=
13
+ OGVhYzc4NWYwZjZkOTIxOWE1Mzg5YTFlZjc4ZGRjOGNjY2EwMjQzZWUyYWNk
14
+ MmQxOTVkMzhjNjYyZDczNzdlMTE2MjBhNmIwYmQzODBkNWRkZjkwYjdlOWRh
15
+ ZDYwNWUyMDM5YzFlMjMxMjlhMTVhMWUyNmZkNGYzYWI4ZDIwYjc=
data/.env.example CHANGED
@@ -1,6 +1,7 @@
1
- export GOOGLE_ANALYTICS_USER=""
2
- export GOOGLE_ANALYTICS_PASSWORD=""
1
+ export GOOGLE_CLIENT_ID=""
2
+ export GOOGLE_CLIENT_SECRET=""
3
3
  export GOOGLE_ANALYTICS_WEB_PROPERTY_ID=""
4
+ export GOOGLE_REFRESH_TOKEN=""
4
5
 
5
6
  export TWITTER_CONSUMER_KEY=""
6
7
  export TWITTER_CONSUMER_SECRET=""
@@ -15,4 +16,9 @@ export FACEBOOK_PAGE=""
15
16
  export FACEBOOK_SHORT_LIVED_TOKEN=""
16
17
  export FACEBOOK_TOKEN=""
17
18
 
19
+ export BITLY_USER=""
20
+ export BITLY_API_KEY=""
21
+
18
22
  export FLOWDOCK_TOKEN=""
23
+
24
+ export COOKIE_SECRET=""
data/Rakefile CHANGED
@@ -7,4 +7,7 @@ RSpec::Core::RakeTask.new(:spec)
7
7
 
8
8
  task :default => :spec
9
9
 
10
+ require 'dotenv'
11
+ Dotenv.load
12
+
10
13
  Sensor::RakeTask.new(:sensor)
data/config.ru ADDED
@@ -0,0 +1,46 @@
1
+ require 'sinatra'
2
+
3
+ require 'omniauth-facebook'
4
+ require 'dotenv'
5
+ require 'omniauth/google_oauth2'
6
+ Dotenv.load
7
+
8
+ require 'koala'
9
+
10
+ class App < Sinatra::Base
11
+ set :protection, :except => :frame_options
12
+
13
+ get '/auth/:provider/callback' do
14
+ content_type 'application/json'
15
+ provider = request.env['omniauth.auth']['provider']
16
+ if provider == 'facebook'
17
+ session[:fb_access_token] = request.env['omniauth.auth']['credentials']['token']
18
+ graph = Koala::Facebook::API.new(session[:fb_access_token])
19
+ graph.get_page_access_token(ENV['FACEBOOK_PAGE'])
20
+ else
21
+ request.env['omniauth.auth']['credentials']['refresh_token']
22
+ end
23
+ end
24
+ end
25
+
26
+ use Rack::Session::Cookie, :key => 'rack.session',
27
+ :domain => 'localhost',
28
+ :path => '/',
29
+ :expire_after => 2592000, # In seconds
30
+ :secret => ENV['COOKIE_SECRET']
31
+
32
+ use OmniAuth::Builder do
33
+ provider :facebook,
34
+ ENV['FACEBOOK_API_KEY'],
35
+ ENV['FACEBOOK_SECRET_KEY'],
36
+ scope: "manage_pages,read_insights",
37
+ provider_ignores_state: true
38
+ provider :google_oauth2,
39
+ ENV["GOOGLE_CLIENT_ID"],
40
+ ENV["GOOGLE_CLIENT_SECRET"],
41
+ scope: 'https://www.googleapis.com/auth/analytics.readonly,email',
42
+ provider_ignores_state: true,
43
+ prompt: 'consent'
44
+ end
45
+
46
+ run App.new
@@ -1,4 +1,5 @@
1
1
  require 'garb'
2
+ require 'oauth2'
2
3
 
3
4
  module Sensor
4
5
  module Actuator
@@ -15,6 +16,15 @@ module Sensor
15
16
 
16
17
  def initialize(time_range)
17
18
  @time_range = time_range
19
+ client = OAuth2::Client.new(ENV['GOOGLE_CLIENT_ID'],
20
+ ENV['GOOGLE_CLIENT_SECRET'],
21
+ {
22
+ site: 'https://accounts.google.com',
23
+ authorize_url: "/o/oauth2/auth",
24
+ token_url: "/o/oauth2/token"
25
+ })
26
+ token = OAuth2::AccessToken.from_hash(client, refresh_token: ENV['GOOGLE_REFRESH_TOKEN']).refresh!
27
+ Garb::Session.access_token = token
18
28
  end
19
29
 
20
30
  def acquire
@@ -41,28 +51,12 @@ module Sensor
41
51
  end
42
52
 
43
53
  protected
44
- def client
45
- if !@client
46
- session = Garb::Session.login(analytics_user, analytics_password, secure: true)
47
- end
48
-
49
- end
50
-
51
- def analytics_user
52
- ENV['GOOGLE_ANALYTICS_USER']
53
- end
54
-
55
- def analytics_password
56
- ENV['GOOGLE_ANALYTICS_PASSWORD']
57
- end
58
-
59
54
  def analytics_profile_id
60
55
  ENV['GOOGLE_ANALYTICS_WEB_PROPERTY_ID']
61
56
  end
62
57
 
63
58
  def profile
64
59
  if !@profile
65
- client
66
60
  @profile = Garb::Management::Profile.all.detect do |p|
67
61
  p.web_property_id == analytics_profile_id
68
62
  end
@@ -1,3 +1,3 @@
1
1
  module Sensor
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/sensor.rb CHANGED
@@ -15,8 +15,12 @@ module Sensor
15
15
  def require(path)
16
16
  begin
17
17
  super("sensor/actuator/#{path}")
18
- rescue LoadError
19
- super("sensor/output_distribution/#{path}")
18
+ rescue LoadError => e
19
+ if e.message =~ /#{Regexp.escape(path)}/
20
+ super("sensor/output_distribution/#{path}")
21
+ else
22
+ raise e
23
+ end
20
24
  end
21
25
  end
22
26
  end
data/sensor.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "koala"
25
25
  spec.add_dependency "flowdock"
26
26
  spec.add_dependency "rake"
27
+ spec.add_dependency "oauth2"
27
28
 
28
29
  spec.add_development_dependency "bundler", "~> 1.3"
29
30
 
@@ -33,4 +34,9 @@ Gem::Specification.new do |spec|
33
34
  spec.add_development_dependency "pry"
34
35
  spec.add_development_dependency "timecop"
35
36
  spec.add_development_dependency "dotenv"
37
+
38
+ spec.add_development_dependency "sinatra"
39
+ spec.add_development_dependency "shotgun"
40
+ spec.add_development_dependency "omniauth-facebook"
41
+ spec.add_development_dependency "omniauth-google-oauth2"
36
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Pickett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-04 00:00:00.000000000 Z
11
+ date: 2014-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chronic
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ! '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: oauth2
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: bundler
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +206,62 @@ dependencies:
192
206
  - - ! '>='
193
207
  - !ruby/object:Gem::Version
194
208
  version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: sinatra
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ! '>='
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ! '>='
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: shotgun
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ! '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ! '>='
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: omniauth-facebook
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ! '>='
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ! '>='
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
251
+ - !ruby/object:Gem::Dependency
252
+ name: omniauth-google-oauth2
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ! '>='
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ! '>='
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
195
265
  description: Sensor provides a set of marketing metrics
196
266
  email:
197
267
  - dan.pickett@launchware.com
@@ -209,6 +279,7 @@ files:
209
279
  - README.md
210
280
  - Rakefile
211
281
  - certs/cacert.pem
282
+ - config.ru
212
283
  - lib/sensor.rb
213
284
  - lib/sensor/actuator/analytics_retrieval.rb
214
285
  - lib/sensor/actuator/facebook_retrieval.rb
@@ -248,7 +319,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
319
  version: '0'
249
320
  requirements: []
250
321
  rubyforge_project:
251
- rubygems_version: 2.1.11
322
+ rubygems_version: 2.2.2
252
323
  signing_key:
253
324
  specification_version: 4
254
325
  summary: Marketing Metrics Acquisition Tool