dailycred 0.1.22 → 0.1.23

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.
data/README.md CHANGED
@@ -1,67 +1,8 @@
1
1
  # Dailycred
2
2
 
3
- ## Installation
3
+ ## Rails gem for instant authentication using Dailycred with Ruby on Rails
4
4
 
5
- Add this line to your application's Gemfile:
6
-
7
- And then execute:
8
-
9
- $ bundle
10
-
11
- Or install it yourself as:
12
-
13
- $ gem install omniauth-dailycred
14
-
15
- ## Usage
16
-
17
- bash
18
-
19
- rails g dailycred YOUR_CLIENT_ID YOUR_SECRET_KEY
20
- rake db:migrate
21
-
22
- This will generate everything you need to get going with authentication, including a user model, session controller, omniauth initializer, javascript tracking code, and many helper variables. You will You can locate your API keys at [dailycred](https://www.dailycred.com/admin/settings/keys)
23
-
24
- ##### Authentication
25
-
26
- Use the `:authenticate` helper to require a user to be signed in:
27
-
28
- before_filter :authenticate
29
-
30
- The current user object can be located with `current_user`:
31
-
32
- # in posts_controller
33
-
34
- @posts = currrent_user.posts.all
35
-
36
- ##### Using only with Omniauth
37
-
38
- If you already have omniauth set up and only want to use Dailycred as another OAuth provider, just add this line to your omniauth initializer file
39
-
40
- provider :dailycred, 'CLIENT_ID', 'SECRET_KEY'
41
-
42
- ##### Events
43
-
44
- To fire an event to be logged in Dailycred:
45
-
46
- #in your controller
47
-
48
- before_filter :dailycred
49
-
50
- def create
51
- ...
52
-
53
- # after successfully saving the model:
54
- @dailycred.event(current_user.uid, 'Created Post', @post.name)
55
-
56
- end
57
-
58
- ## SSL Error
59
-
60
- You may get an error such as the following:
61
-
62
- Faraday::Error::ConnectionFailed (SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed):
63
-
64
- If that is the case, consider following fixes explained [here](https://github.com/technoweenie/faraday/wiki/Setting-up-SSL-certificates) or [here](http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error).
5
+ ### Check out the documenation at [dailycred.com]("https://www.dailycred.com/docs/ruby")
65
6
 
66
7
  ## Contributing
67
8
 
@@ -70,7 +11,3 @@ If that is the case, consider following fixes explained [here](https://github.co
70
11
  3. Commit your changes (`git commit -am 'Added some feature'`)
71
12
  4. Push to the branch (`git push origin my-new-feature`)
72
13
  5. Create new Pull Request
73
-
74
- omniauth-dailycred
75
-
76
- OmniAuth adapter for dailycred using their OAuth2 Strategy
data/Rakefile CHANGED
@@ -10,3 +10,13 @@ RSpec::Core::RakeTask.new do |t|
10
10
  t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
11
11
  # Put spec opts in a file named .rspec in root
12
12
  end
13
+
14
+ begin
15
+ require 'rocco/tasks'
16
+ require 'fileutils'
17
+ Rocco::make 'docs/'
18
+ FileUtils.cp_r "docs/lib/", "/Users/hank/rails/dailycred/public/docs/ruby/"
19
+ rescue LoadError
20
+ warn "#$! -- rocco tasks not loaded."
21
+ task :rocco
22
+ end
data/dailycred.gemspec CHANGED
@@ -14,5 +14,5 @@ Gem::Specification.new do |gem|
14
14
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
15
  gem.name = "dailycred"
16
16
  gem.require_paths = ["lib"]
17
- gem.version = "0.1.22"
17
+ gem.version = "0.1.23"
18
18
  end
data/lib/dailycred.rb CHANGED
@@ -14,9 +14,10 @@ class Dailycred
14
14
  }
15
15
 
16
16
  # Initializes a dailycred object
17
- # @param [String] client_id the client's daiycred client id
18
- # @param [String] secret_key the clients secret key
19
- # @param [Hash] opts a hash of options
17
+ #
18
+ # - @param [String] client\_id the client's daiycred client id
19
+ # - @param [String] secret\_key the clients secret key
20
+ # - @param [Hash] opts a hash of options
20
21
  def initialize(client_id, secret_key="", opts={})
21
22
  @client_id = client_id
22
23
  @secret_key = secret_key
@@ -26,9 +27,10 @@ class Dailycred
26
27
  end
27
28
 
28
29
  # Generates a Dailycred event
29
- # @param [String] user_id the user's dailycred user id
30
- # @param [String] key the name of the event type
31
- # @param [String] val the value of the event (optional)
30
+ #
31
+ # - @param [String] user_id the user's dailycred user id
32
+ # - @param [String] key the name of the event type
33
+ # - @param [String] val the value of the event (optional)
32
34
  def event(user_id, key, val="")
33
35
  opts = {
34
36
  :key => key,
@@ -39,8 +41,9 @@ class Dailycred
39
41
  end
40
42
 
41
43
  # Tag a user in dailycred
42
- # @param [String] user_id the user's dailycred user id
43
- # @param [String] tag the desired tag to add
44
+ #
45
+ # - @param [String] user_id the user's dailycred user id
46
+ # - @param [String] tag the desired tag to add
44
47
  def tag(user_id, tag)
45
48
  opts = {
46
49
  :user_id => user_id,
@@ -53,13 +53,13 @@ class Dailycred
53
53
  document.body.appendChild(dc);
54
54
  }).call(this);
55
55
  </script>
56
- <script src="#{@opts[:url]}/public/js/dailycred.coffee"></script>
56
+ <!--<script src="#{@opts[:url]}/public/js/dailycred.coffee"></script>
57
57
  <script>
58
58
  DC.init({
59
59
  "showModal" : #{@opts[:modal]},
60
60
  "triggers" : #{@opts[:triggers].to_s}
61
61
  });
62
- </script>
62
+ </script>-->
63
63
  <!-- end dailycred -->
64
64
  EOT
65
65
  end
@@ -4,17 +4,22 @@ require 'net/https'
4
4
  require 'json'
5
5
  require 'pp'
6
6
 
7
+ # #The Dailycred Omniauth Strategy
7
8
  module OmniAuth
8
9
  module Strategies
9
10
  class Dailycred < OmniAuth::Strategies::OAuth2
10
11
 
12
+ # default options
11
13
  option :client_options, {
12
14
  :site => "https://www.dailycred.com",
13
15
  :authorize_url => '/oauth/authorize',
14
16
  :token_url => '/oauth/access_token'
15
17
  }
16
18
 
19
+ # parameters to expect and return from dailycred responses
17
20
  ATTRIBUTES = ["email", "username", "created", "verified", "admin", "referred_by", "tags", "referred"]
21
+
22
+ # allows parameters to be passed through
18
23
  AUTH_PARAMS = ["action"]
19
24
 
20
25
  option :authorize_options, OmniAuth::Strategies::Dailycred::AUTH_PARAMS
@@ -34,6 +39,7 @@ module OmniAuth
34
39
  end
35
40
  end
36
41
 
42
+ # this step allows auth_params to be added to the url
37
43
  def request_phase
38
44
  OmniAuth::Strategies::Dailycred::AUTH_PARAMS.each do |param|
39
45
  val = session['omniauth.params'][param]
@@ -47,11 +53,10 @@ module OmniAuth
47
53
 
48
54
  private
49
55
 
56
+ # This is the phase where the gem calls me.json, which returns information about the user
50
57
  def user
51
58
  return @duser if !@duser.nil?
52
- connection = Faraday::Connection.new options.client_options[:site], :ssl => {
53
- :ca_file => "/opt/local/share/curl/curl-ca-bundle.crt"
54
- }
59
+ connection = Faraday::Connection.new options.client_options[:site], options.client_options[:ssl]
55
60
  response = connection.get("/graph/me.json?access_token=#{access_token.token}")
56
61
  json = JSON.parse(response.body)
57
62
  pp json
@@ -11,7 +11,7 @@ describe Dailycred do
11
11
  secret = "6925d89e-d04d-469e-8fc9-3782af57bc29-c2340f1e-25a0-40af-b638-7429947a6cd7"
12
12
  @user_id = "0c19c355-2a71-4c8e-805e-f7a6087ea84c"
13
13
 
14
- #dev settings
14
+ # dev settings
15
15
  # site = "http://localhost:9000"
16
16
  # client_id = "4337ed55-aaca-4e38-8824-6c016c59dd5b"
17
17
  # secret = "34f2ecc3-f955-4292-9747-39b876d91d8b-a4f7ad8e-f8a4-4573-b23d-686f6e28a820"
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.22
4
+ version: 0.1.23
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-10 00:00:00.000000000 Z
12
+ date: 2012-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth