dailycred 0.1.45 → 0.1.46
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/Gemfile +1 -1
- data/README.md +2 -0
- data/Rakefile +33 -24
- data/lib/dailycred/acts_as_dailycred.rb +2 -1
- data/lib/dailycred/helper.rb +1 -1
- data/lib/dailycred/user.rb +63 -63
- data/lib/dailycred/version.rb +1 -1
- data/lib/omniauth/strategies/dailycred.rb +1 -1
- data/spec/helper_spec.rb +1 -1
- data/test/generator_test.rb +14 -13
- data/test/test_helper.rb +1 -1
- metadata +3 -2
data/.travis.yml
ADDED
data/Gemfile
CHANGED
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
-
|
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
|
data/lib/dailycred/helper.rb
CHANGED
data/lib/dailycred/user.rb
CHANGED
@@ -1,63 +1,63 @@
|
|
1
|
-
module Dailycred
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
data/lib/dailycred/version.rb
CHANGED
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
|
-
|
12
|
+
require 'omniauth/strategies/dailycred_spec'
|
13
13
|
|
14
14
|
RSpec.configure do |config|
|
15
15
|
config.include Rack::Test::Methods
|
data/test/generator_test.rb
CHANGED
@@ -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
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
59
|
-
|
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
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
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
|
-
|
81
|
-
|
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
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.
|
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-
|
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
|