dailycred 0.1.45 → 0.1.46

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/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/Gemfile CHANGED
@@ -11,7 +11,7 @@ gem 'spork'
11
11
  gem 'guard'
12
12
  gem 'guard-test'
13
13
  gem 'guard-rspec'
14
- gem 'mocha'
14
+ gem "mocha", '0.12.1', :require => false
15
15
  gem 'fl-rocco'
16
16
  gem 'redcarpet', '~> 1.17'
17
17
  gem 'markdown'
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Dailycred
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/dailycred/dailycred.png?branch=master)](https://travis-ci.org/dailycred/dailycred)
4
+
3
5
  ## Introduction
4
6
 
5
7
  The Dailycred ruby gem is everything you need to get off the ground running with robust authentication. It includes an [omniauth](https://github.com/intridea/omniauth) provider and a generator to create necessary models and controllers. The generated authentication structure is inspired by [nifty-generators](https://github.com/ryanb/nifty-generators). To get started using Dailycred with Ruby on Rails, the first thing you need to do is add the dailycred gem to your gemfile:
data/Rakefile CHANGED
@@ -2,33 +2,42 @@
2
2
  require "bundler/gem_tasks"
3
3
  require 'rspec/core/rake_task'
4
4
 
5
- desc 'Default: run specs.'
6
- task :default => :spec
7
-
8
5
  desc "Run specs"
9
6
  RSpec::Core::RakeTask.new do |t|
10
7
  # t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
11
8
  # Put spec opts in a file named .rspec in root
12
9
  end
13
10
 
14
- # desc 'docs'
15
- # begin
16
- # require 'rocco'
17
- # require 'rocco/tasks'
18
- # require 'fileutils'
19
- # require 'maruku'
20
- # Rocco::make 'docs/'
21
- # FileUtils.cp_r "docs/lib/", "/Users/hank/rails/dailycred/public/docs/ruby/", :verbose => true
22
- # md = ""
23
- # File.open("README.md", "r") do |infile|
24
- # while (line = infile.gets)
25
- # md += line
26
- # end
27
- # end
28
- # doc = Maruku.new(md)
29
- # File.open("/Users/hank/rails/dailycred/app/views/tags/ruby.html", 'w') {|f| f.write doc.to_html}
30
- # rescue LoadError
31
- # warn "#$! -- rocco tasks not loaded."
32
- # task :rocco
33
- # end
34
- # end
11
+ desc "run travis"
12
+ task :travis do
13
+ ["rake spec","ruby test/test_helper.rb"].each do |cmd|
14
+ puts "Starting to run #{cmd}..."
15
+ system("export DISPLAY=:99.0 && bundle exec #{cmd}")
16
+ raise "#{cmd} failed!" unless $?.exitstatus == 0
17
+ end
18
+ end
19
+
20
+ task :default => :travis
21
+
22
+ desc 'docs'
23
+ task :docs do
24
+ begin
25
+ require 'rocco'
26
+ require 'rocco/tasks'
27
+ require 'fileutils'
28
+ require 'maruku'
29
+ Rocco::make 'docs/'
30
+ FileUtils.cp_r "docs/lib/", "/Users/hank/rails/dailycred/public/docs/ruby/", :verbose => true
31
+ md = ""
32
+ File.open("README.md", "r") do |infile|
33
+ while (line = infile.gets)
34
+ md += line
35
+ end
36
+ end
37
+ doc = Maruku.new(md)
38
+ File.open("/Users/hank/rails/dailycred/app/views/tags/ruby.html", 'w') {|f| f.write doc.to_html}
39
+ rescue LoadError
40
+ warn "#$! -- rocco tasks not loaded."
41
+ task :rocco
42
+ end
43
+ end
@@ -15,7 +15,8 @@ module ActsAsDailycred
15
15
  end
16
16
  module SingletonMethods
17
17
  def find_or_create_with_omniauth(model)
18
- @user = User.find_by_provider_and_uid(model[:provider], model[:uid]) || User.new
18
+ ap model
19
+ @user = User.find_by_provider_and_uid(model['provider'], model['uid']) || User.new
19
20
  @user.update_from_dailycred model[:info]
20
21
  @user
21
22
  end
@@ -42,7 +42,7 @@ module Dailycred
42
42
  if user.nil?
43
43
  user = current_user
44
44
  end
45
- connect_path(access_token: user.token, identity_provider: provider)
45
+ connect_path(:access_token => user.token, :identity_provider => provider)
46
46
  end
47
47
 
48
48
  def redirect_to_auth opts={}
@@ -1,63 +1,63 @@
1
- module Dailycred
2
- class User
3
- include ActiveModel::Validations
4
- include ActiveModel::Serialization
5
-
6
- validates_presence_of :email, :pass
7
-
8
- attr_accessor :client, :email, :pass, :authorized
9
-
10
- def initialize client, user = {}
11
- self.client = client
12
- self.authorized = false
13
- user.each do |k,v|
14
- self[k] = v if self.respond_to(k)
15
- end
16
- end
17
-
18
- def login
19
- if !self.valid?
20
- #it didn't work already, return false
21
- return false
22
- end
23
-
24
- response = JSON.parse client.login(self.to_hash)
25
- err_parser response
26
-
27
- return false if !self.valid?
28
- true
29
- end
30
-
31
- def to_hash
32
- {
33
- :email => self.email,
34
- :pass => self.pass
35
- }
36
- end
37
-
38
- private
39
-
40
- #response is a hash, which is
41
- #a json-parsed http response body
42
- def err_parser response
43
- if !response["worked"]
44
- self.authorized = false
45
- response["errors"].each do |err|
46
- attrib = err["attribute"]
47
- message = err["message"]
48
- if attrib == "form"
49
- self.errors.add_to_base message
50
- else
51
- if attrib == "user"
52
- self.errors.add :email, message
53
- elsif self.respond_to attrib
54
- self.errors.add attrib, message
55
- end
56
- end
57
- end
58
- end
59
- end
60
-
61
- end
62
-
63
- end
1
+ # module Dailycred
2
+ # class User
3
+ # include ActiveModel::Validations
4
+ # include ActiveModel::Serialization
5
+
6
+ # validates_presence_of :email, :pass
7
+
8
+ # attr_accessor :client, :email, :pass, :authorized
9
+
10
+ # def initialize client, user = {}
11
+ # self.client = client
12
+ # self.authorized = false
13
+ # user.each do |k,v|
14
+ # self[k] = v if self.respond_to(k)
15
+ # end
16
+ # end
17
+
18
+ # def login
19
+ # if !self.valid?
20
+ # #it didn't work already, return false
21
+ # return false
22
+ # end
23
+
24
+ # response = JSON.parse client.login(self.to_hash)
25
+ # err_parser response
26
+
27
+ # return false if !self.valid?
28
+ # true
29
+ # end
30
+
31
+ # def to_hash
32
+ # {
33
+ # :email => self.email,
34
+ # :pass => self.pass
35
+ # }
36
+ # end
37
+
38
+ # private
39
+
40
+ # #response is a hash, which is
41
+ # #a json-parsed http response body
42
+ # def err_parser response
43
+ # if !response["worked"]
44
+ # self.authorized = false
45
+ # response["errors"].each do |err|
46
+ # attrib = err["attribute"]
47
+ # message = err["message"]
48
+ # if attrib == "form"
49
+ # self.errors.add_to_base message
50
+ # else
51
+ # if attrib == "user"
52
+ # self.errors.add :email, message
53
+ # elsif self.respond_to attrib
54
+ # self.errors.add attrib, message
55
+ # end
56
+ # end
57
+ # end
58
+ # end
59
+ # end
60
+
61
+ # end
62
+
63
+ # end
@@ -1,3 +1,3 @@
1
1
  module Dailycred
2
- VERSION = "0.1.45"
2
+ VERSION = "0.1.46"
3
3
  end
@@ -21,7 +21,7 @@ module OmniAuth
21
21
 
22
22
  option :authorize_options, OmniAuth::Strategies::Dailycred::AUTH_PARAMS
23
23
 
24
- uid { user['id'] }
24
+ uid { user['uid'] }
25
25
 
26
26
  info do
27
27
  user
data/spec/helper_spec.rb CHANGED
@@ -9,7 +9,7 @@ require 'dailycred'
9
9
 
10
10
  Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
11
11
 
12
- # require 'omniauth/strategies/dailycred_spec'
12
+ require 'omniauth/strategies/dailycred_spec'
13
13
 
14
14
  RSpec.configure do |config|
15
15
  config.include Rack::Test::Methods
@@ -1,4 +1,5 @@
1
1
  require 'rails/generators'
2
+ require 'test/unit'
2
3
  # require 'mocha'
3
4
  require_relative "../lib/generators/dailycred_generator.rb"
4
5
  class GeneratorTest < Rails::Generators::TestCase
@@ -44,41 +45,41 @@ class GeneratorTest < Rails::Generators::TestCase
44
45
  assert_credentials "aaa", "bbb"
45
46
  end
46
47
 
47
- test "generator works with login" do
48
- generator_class.any_instance.stubs(:get_input).returns(["localtest@dailycred.com","password"])
49
- test_generator
50
- assert_credentials "e92e20bf-e0a4-49b4-8a82-ff1b65d80017", "9adf81a8-ce97-4bcb-9c1f-c09f5fc7b6b8-0d1a4553-496d-450e-80fd-9e8d0552a920"
51
- end
48
+ # test "generator works with login" do
49
+ # generator_class.any_instance.stubs(:get_input).returns(["localtest@dailycred.com","password"])
50
+ # test_generator
51
+ # assert_credentials "e92e20bf-e0a4-49b4-8a82-ff1b65d80017", "9adf81a8-ce97-4bcb-9c1f-c09f5fc7b6b8-0d1a4553-496d-450e-80fd-9e8d0552a920"
52
+ # end
52
53
 
53
54
  private
54
55
 
55
56
  def test_generator args=[]
56
57
  run_generator args
57
58
  assert_file "config/initializers/omniauth.rb" do |config|
58
- assert_true config.include? 'Rails.configuration.DAILYCRED_CLIENT_ID ='
59
- assert_true config.include? 'Rails.configuration.DAILYCRED_SECRET_KEY ='
59
+ assert config.include? 'Rails.configuration.DAILYCRED_CLIENT_ID ='
60
+ assert config.include? 'Rails.configuration.DAILYCRED_SECRET_KEY ='
60
61
  end
61
62
 
62
63
  assert_file "config/routes.rb", /(#{Regexp.escape("mount Dailycred::Engine => '/auth', :as => 'dailycred_engine'")})/
63
64
 
64
65
  assert_file "app/models/user.rb" do |model|
65
- assert_true model.include? "acts_as_dailycred"
66
+ assert model.include? "acts_as_dailycred"
66
67
  end
67
68
 
68
69
  assert_file "app/controllers/application_controller.rb" do |controller|
69
70
  end
70
71
 
71
72
  assert_migration "db/migrate/create_users.rb" do |migration|
72
- assert_true migration.include? ":twitter"
73
- assert_true migration.include? ":github"
74
- assert_true migration.include? ":google"
73
+ assert migration.include? ":twitter"
74
+ assert migration.include? ":github"
75
+ assert migration.include? ":google"
75
76
  end
76
77
  end
77
78
 
78
79
  def assert_credentials client_id, client_secret
79
80
  assert_file "config/initializers/omniauth.rb" do |config|
80
- assert_true config.include? "Rails.configuration.DAILYCRED_CLIENT_ID = \"#{client_id}\""
81
- assert_true config.include? "Rails.configuration.DAILYCRED_SECRET_KEY = \"#{client_secret}\""
81
+ assert config.include? "Rails.configuration.DAILYCRED_CLIENT_ID = \"#{client_id}\""
82
+ assert config.include? "Rails.configuration.DAILYCRED_SECRET_KEY = \"#{client_secret}\""
82
83
  end
83
84
  end
84
85
 
data/test/test_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'test/unit'
2
-
2
+ # require 'mocha/setup'
3
3
 
4
4
 
5
5
  require_relative './generator_test.rb'
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.45
4
+ version: 0.1.46
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-12-03 00:00:00.000000000 Z
12
+ date: 2012-12-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth
@@ -51,6 +51,7 @@ extensions: []
51
51
  extra_rdoc_files: []
52
52
  files:
53
53
  - .gitignore
54
+ - .travis.yml
54
55
  - Gemfile
55
56
  - Guardfile
56
57
  - LICENSE