dailycred 0.1.28 → 0.1.29

Sign up to get free protection for your applications and to get access to all the features.
data/dailycred.gemspec CHANGED
@@ -8,12 +8,12 @@ Gem::Specification.new do |gem|
8
8
  gem.homepage = "https://www.dailycred.com"
9
9
  gem.add_dependency("omniauth")
10
10
  gem.add_dependency("omniauth-oauth2")
11
- gem.add_dependency("securerandom")
11
+
12
12
 
13
13
  gem.files = `git ls-files`.split("\n")
14
14
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
15
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
16
  gem.name = "dailycred"
17
17
  gem.require_paths = ["lib"]
18
- gem.version = "0.1.28"
18
+ gem.version = "0.1.29"
19
19
  end
@@ -1,4 +1,5 @@
1
1
  class DailycredGenerator < Rails::Generators::Base
2
+ require 'faraday'
2
3
  source_root File.expand_path('../templates', __FILE__)
3
4
 
4
5
  argument :client_id, :type => :string, :default => 'YOUR_CLIENT_ID', :banner => 'dailycred_client_id'
@@ -73,7 +74,8 @@ class DailycredGenerator < Rails::Generators::Base
73
74
  *****
74
75
  *****
75
76
  EOS
76
- print dailycred_ascii
77
+ puts dailycred_ascii
78
+
77
79
  # copy initializer
78
80
  template "omniauth.rb", "config/initializers/omniauth.rb"
79
81
  # session_controller
@@ -91,4 +93,59 @@ class DailycredGenerator < Rails::Generators::Base
91
93
  # config/routes
92
94
  inject_into_file "config/routes.rb", APP_ROUTES_LINES, :after => "#{APP_NAME}::Application.routes.draw do\n"
93
95
  end
96
+
97
+ private
98
+
99
+ def get_info first=true
100
+ if first
101
+ puts "Please insert your dailycred credentials. You must sign up for a free account at "+
102
+ "http://www.dailycred.com. This is to automatically configure your api keys. If you wish to skip, enter 'n' as your email."
103
+ else
104
+ puts "Invalid email and password. Try again or type 'n' to skip."
105
+ end
106
+ puts ''
107
+ print "Enter email:"
108
+ email = gets.chomp
109
+ if email != "n"
110
+ stty_settings = %x[stty -g]
111
+ print 'Password: '
112
+ begin
113
+ %x[stty -echo]
114
+ password = gets
115
+ ensure
116
+ %x[stty #{stty_settings}]
117
+ end
118
+ ssl_opts = {}
119
+ if File.exists?('/etc/ssl/certs')
120
+ ssl_opts = { :ca_path => '/etc/ssl/certs'}
121
+ end
122
+ if File.exists?('/opt/local/share/curl/curl-ca-bundle.crt')
123
+ ssl_opts = { :ca_file => '/opt/local/share/curl/curl-ca-bundle.crt' }
124
+ end
125
+ connection = Faraday::Connection.new "http://localhost:9000/", :ssl => ssl_opts
126
+ params = {
127
+ :login => email
128
+ :pass => password
129
+ :client_id => "dailycred"
130
+ }
131
+ response = connection.post("/user/api/signin.json", params)
132
+ p response_body
133
+ json = JSON.parse(response.body)
134
+ if !json["worked"]
135
+ # wrong password
136
+ get_info false
137
+ end
138
+ access_token = json["access_token"]
139
+ p access_token
140
+ response = connection.post("graph/clientinfo.json", :access_token => access_token)
141
+ json = JSON.parse(response.body)
142
+ if !json["worked"]
143
+ # weird error
144
+ end
145
+ client_id = json["clientId"]
146
+ client_secret = json["clientSecret"]
147
+ file_gsub "config/initializers/omniauth.rb", "YOUR_CLIENT_ID", client_id
148
+ file_gsub "config/initializers/omniauth.rb", "YOUR_SECRET_KEY", client_secret
149
+ end
150
+
94
151
  end
@@ -0,0 +1,17 @@
1
+ stty_settings = %x[stty -g]
2
+ print 'Password: '
3
+
4
+ begin
5
+ %x[stty -echo]
6
+ password = gets
7
+ ensure
8
+ %x[stty #{stty_settings}]
9
+ end
10
+
11
+ puts
12
+
13
+ print 'regular info: '
14
+ regular_info = gets
15
+
16
+ puts "password: #{password}"
17
+ puts "regular: #{regular_info}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dailycred
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.28
4
+ version: 0.1.29
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-19 00:00:00.000000000 Z
12
+ date: 2012-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth
@@ -43,22 +43,6 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: securerandom
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
46
  description: descript
63
47
  email:
64
48
  - hstove@gmail.com
@@ -93,6 +77,7 @@ files:
93
77
  - lib/generators/templates/omniauth.rb
94
78
  - lib/generators/templates/sessions_controller.rb
95
79
  - lib/generators/templates/user.rb
80
+ - lib/generators/test.rb
96
81
  - lib/middleware/middleware.rb
97
82
  - lib/omniauth-dailycred/version.rb
98
83
  - lib/omniauth/strategies/dailycred.rb