socialite 0.0.1.beta4 → 0.1.0.pre

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.
Files changed (87) hide show
  1. data/README.md +33 -34
  2. data/Rakefile +8 -21
  3. data/app/controllers/socialite/application_controller.rb +4 -0
  4. data/app/controllers/socialite/identities_controller.rb +2 -14
  5. data/app/controllers/socialite/session_controller.rb +20 -0
  6. data/app/controllers/socialite/users_controller.rb +0 -1
  7. data/app/views/layouts/socialite/application.html.haml +11 -0
  8. data/app/views/socialite/identities/new.html.haml +27 -0
  9. data/app/views/socialite/session/new.html.haml +31 -14
  10. data/app/views/socialite/user/edit.html.haml +1 -1
  11. data/config/routes.rb +7 -7
  12. data/lib/generators/socialite/install_generator.rb +7 -9
  13. data/lib/generators/socialite/migrations_generator.rb +34 -0
  14. data/lib/generators/socialite/templates/identity.rb.erb +25 -0
  15. data/lib/generators/socialite/templates/socialite.rb +20 -7
  16. data/lib/generators/socialite/templates/users.rb.erb +12 -0
  17. data/lib/socialite.rb +25 -27
  18. data/lib/socialite/controllers/helpers.rb +107 -111
  19. data/lib/socialite/engine.rb +19 -32
  20. data/lib/socialite/helpers/authentication.rb +1 -1
  21. data/lib/socialite/models/identity_concern.rb +91 -0
  22. data/lib/socialite/models/user_concern.rb +54 -0
  23. data/lib/socialite/version.rb +1 -1
  24. data/spec/dummy/README.rdoc +261 -0
  25. data/spec/dummy/app/assets/javascripts/application.js +9 -3
  26. data/spec/dummy/app/assets/stylesheets/application.css +11 -5
  27. data/{app/assets/images/socialite → spec/dummy/app/mailers}/.gitkeep +0 -0
  28. data/{app/assets/javascripts/socialite → spec/dummy/app/models}/.gitkeep +0 -0
  29. data/spec/dummy/app/models/identity.rb +4 -0
  30. data/spec/dummy/app/models/user.rb +4 -0
  31. data/spec/dummy/app/views/layouts/application.html.erb +1 -5
  32. data/spec/dummy/config/application.rb +19 -2
  33. data/spec/dummy/config/boot.rb +1 -11
  34. data/spec/dummy/config/database.yml +18 -2
  35. data/spec/dummy/config/environments/development.rb +8 -1
  36. data/spec/dummy/config/environments/production.rb +9 -2
  37. data/spec/dummy/config/environments/test.rb +4 -9
  38. data/spec/dummy/config/initializers/inflections.rb +5 -0
  39. data/spec/dummy/config/initializers/secret_token.rb +1 -1
  40. data/spec/dummy/config/initializers/session_store.rb +1 -1
  41. data/spec/dummy/config/initializers/socialite.rb +26 -4
  42. data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
  43. data/spec/dummy/config/routes.rb +2 -10
  44. data/{db/migrate/20110914215410_create_users.rb → spec/dummy/db/migrate/20130206224516_create_socialite_users.rb} +2 -4
  45. data/spec/dummy/db/migrate/20130206224517_create_socialite_identities.rb +25 -0
  46. data/spec/dummy/db/schema.rb +12 -20
  47. data/{lib/tasks → spec/dummy/lib/assets}/.gitkeep +0 -0
  48. data/spec/dummy/log/.gitkeep +0 -0
  49. data/spec/dummy/public/500.html +0 -1
  50. data/spec/factories/facebook.rb +5 -5
  51. data/spec/factories/identity.rb +3 -3
  52. data/spec/factories/user.rb +10 -12
  53. data/spec/generators/socialite/install_generator_spec.rb +43 -0
  54. data/spec/generators/socialite/migrations_generator_spec.rb +27 -0
  55. data/spec/models/facebook_spec.rb +24 -21
  56. data/spec/models/identity_spec.rb +2 -2
  57. data/spec/models/user_spec.rb +7 -7
  58. data/spec/socialite_spec.rb +53 -0
  59. data/spec/spec_helper.rb +23 -10
  60. data/spec/support/identity_shared_example.rb +24 -20
  61. metadata +202 -144
  62. data/.autotest +0 -7
  63. data/.gitignore +0 -9
  64. data/.rspec +0 -2
  65. data/.travis.yml +0 -10
  66. data/.yardopts +0 -8
  67. data/Gemfile +0 -8
  68. data/Gemfile.lock +0 -208
  69. data/app/models/socialite/facebook_identity.rb +0 -5
  70. data/app/models/socialite/identity.rb +0 -5
  71. data/app/models/socialite/user.rb +0 -10
  72. data/config/initializers/simple_form.rb +0 -90
  73. data/config/locales/simple_form.en.yml +0 -23
  74. data/db/migrate/20110925224222_create_identities.rb +0 -26
  75. data/db/migrate/20110926005551_create_facebook_identities.rb +0 -12
  76. data/lib/socialite/api_wrappers/facebook.rb +0 -67
  77. data/lib/socialite/api_wrappers/twitter.rb +0 -19
  78. data/lib/socialite/models/identity.rb +0 -99
  79. data/lib/socialite/models/user.rb +0 -50
  80. data/lib/socialite/service_config.rb +0 -14
  81. data/lib/tasks/cucumber.rake +0 -65
  82. data/script/cucumber +0 -10
  83. data/script/rails +0 -6
  84. data/socialite.gemspec +0 -39
  85. data/spec/dummy/app/controllers/home_controller.rb +0 -11
  86. data/spec/dummy/app/views/home/index.html.haml +0 -12
  87. data/spec/dummy/app/views/home/show.html.haml +0 -6
data/.autotest DELETED
@@ -1,7 +0,0 @@
1
- begin
2
- require 'rubygems'
3
- require 'autotest/growl'
4
- require 'autotest/fsevent'
5
- rescue LoadError
6
-
7
- end
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- .DS_Store
2
- .bundle/
3
- log/*.log
4
- pkg/
5
- spec/dummy/db/*.sqlite3
6
- spec/dummy/log/*.log
7
- spec/dummy/tmp/
8
- .yardoc
9
- doc
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --colour
2
- --format nested
@@ -1,10 +0,0 @@
1
- before_script:
2
- - "psql -c 'create database socialite_test;' -U postgres >/dev/null"
3
- - "mysql -e 'create database socialite_test;' >/dev/null"
4
- rvm:
5
- - 1.9.2
6
- - 1.9.3
7
- env:
8
- - DB=sqlite
9
- - DB=mysql
10
- - DB=postgres
data/.yardopts DELETED
@@ -1,8 +0,0 @@
1
- 'lib/**/*.rb'
2
- 'app/**/*.rb'
3
- 'config/**/*.rb'
4
- 'db/**/*.rb'
5
- - README.md
6
- - LICENSE
7
- --protected
8
- --no-private
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gemspec
4
-
5
- group :travis_ci do
6
- gem 'pg', '~> 0.11'
7
- gem 'mysql2'
8
- end
@@ -1,208 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- socialite (0.0.1.beta4)
5
- grackle (~> 0.1.10)
6
- haml (~> 3.1.2)
7
- koala (~> 1.2.0beta4)
8
- oa-core (~> 0.3.0.rc3)
9
- oa-oauth (~> 0.3.0.rc3)
10
- rails (~> 3.1.0)
11
- sass-rails (~> 3.1.0)
12
- simple_form (~> 1.5.2)
13
-
14
- GEM
15
- remote: http://rubygems.org/
16
- specs:
17
- actionmailer (3.1.0)
18
- actionpack (= 3.1.0)
19
- mail (~> 2.3.0)
20
- actionpack (3.1.0)
21
- activemodel (= 3.1.0)
22
- activesupport (= 3.1.0)
23
- builder (~> 3.0.0)
24
- erubis (~> 2.7.0)
25
- i18n (~> 0.6)
26
- rack (~> 1.3.2)
27
- rack-cache (~> 1.0.3)
28
- rack-mount (~> 0.8.2)
29
- rack-test (~> 0.6.1)
30
- sprockets (~> 2.0.0)
31
- activemodel (3.1.0)
32
- activesupport (= 3.1.0)
33
- bcrypt-ruby (~> 3.0.0)
34
- builder (~> 3.0.0)
35
- i18n (~> 0.6)
36
- activerecord (3.1.0)
37
- activemodel (= 3.1.0)
38
- activesupport (= 3.1.0)
39
- arel (~> 2.2.1)
40
- tzinfo (~> 0.3.29)
41
- activeresource (3.1.0)
42
- activemodel (= 3.1.0)
43
- activesupport (= 3.1.0)
44
- activesupport (3.1.0)
45
- multi_json (~> 1.0)
46
- addressable (2.2.6)
47
- arel (2.2.1)
48
- bcrypt-ruby (3.0.1)
49
- builder (3.0.0)
50
- capybara (1.1.1)
51
- mime-types (>= 1.16)
52
- nokogiri (>= 1.3.3)
53
- rack (>= 1.0.0)
54
- rack-test (>= 0.5.4)
55
- selenium-webdriver (~> 2.0)
56
- xpath (~> 0.1.4)
57
- childprocess (0.2.2)
58
- ffi (~> 1.0.6)
59
- cucumber (1.1.0)
60
- builder (>= 2.1.2)
61
- diff-lcs (>= 1.1.2)
62
- gherkin (~> 2.5.0)
63
- json (>= 1.4.6)
64
- term-ansicolor (>= 1.0.6)
65
- cucumber-rails (1.0.6)
66
- capybara (>= 1.1.1)
67
- cucumber (>= 1.0.6)
68
- nokogiri (>= 1.5.0)
69
- database_cleaner (0.6.7)
70
- diff-lcs (1.1.3)
71
- erubis (2.7.0)
72
- factory_girl (2.1.2)
73
- activesupport
74
- faraday (0.7.4)
75
- addressable (~> 2.2.6)
76
- multipart-post (~> 1.1.0)
77
- rack (>= 1.1.0, < 2)
78
- ffi (1.0.9)
79
- gherkin (2.5.1)
80
- json (>= 1.4.6)
81
- grackle (0.1.10)
82
- json
83
- mime-types
84
- oauth
85
- haml (3.1.3)
86
- hike (1.2.1)
87
- i18n (0.6.0)
88
- json (1.6.1)
89
- json_pure (1.6.1)
90
- koala (1.2.0beta4)
91
- faraday (~> 0.7.0)
92
- multi_json (~> 1.0)
93
- launchy (2.0.5)
94
- addressable (~> 2.2.6)
95
- mail (2.3.0)
96
- i18n (>= 0.4.0)
97
- mime-types (~> 1.16)
98
- treetop (~> 1.4.8)
99
- mime-types (1.16)
100
- multi_json (1.0.3)
101
- multi_xml (0.4.1)
102
- multipart-post (1.1.3)
103
- mysql2 (0.3.7)
104
- nokogiri (1.5.0)
105
- oa-core (0.3.0)
106
- oa-oauth (0.3.0)
107
- faraday (~> 0.7.3)
108
- multi_json (~> 1.0.0)
109
- multi_xml (~> 0.4.0)
110
- oa-core (= 0.3.0)
111
- oauth (~> 0.4.0)
112
- oauth2 (~> 0.5.0)
113
- oauth (0.4.5)
114
- oauth2 (0.5.1)
115
- faraday (~> 0.7.4)
116
- multi_json (~> 1.0.3)
117
- pg (0.11.0)
118
- polyglot (0.3.2)
119
- rack (1.3.3)
120
- rack-cache (1.0.3)
121
- rack (>= 0.4)
122
- rack-mount (0.8.3)
123
- rack (>= 1.0.0)
124
- rack-ssl (1.3.2)
125
- rack
126
- rack-test (0.6.1)
127
- rack (>= 1.0)
128
- rails (3.1.0)
129
- actionmailer (= 3.1.0)
130
- actionpack (= 3.1.0)
131
- activerecord (= 3.1.0)
132
- activeresource (= 3.1.0)
133
- activesupport (= 3.1.0)
134
- bundler (~> 1.0)
135
- railties (= 3.1.0)
136
- railties (3.1.0)
137
- actionpack (= 3.1.0)
138
- activesupport (= 3.1.0)
139
- rack-ssl (~> 1.3.2)
140
- rake (>= 0.8.7)
141
- rdoc (~> 3.4)
142
- thor (~> 0.14.6)
143
- rake (0.9.2)
144
- rdiscount (1.6.8)
145
- rdoc (3.9.4)
146
- rspec (2.6.0)
147
- rspec-core (~> 2.6.0)
148
- rspec-expectations (~> 2.6.0)
149
- rspec-mocks (~> 2.6.0)
150
- rspec-core (2.6.4)
151
- rspec-expectations (2.6.0)
152
- diff-lcs (~> 1.1.2)
153
- rspec-mocks (2.6.0)
154
- rspec-rails (2.6.1)
155
- actionpack (~> 3.0)
156
- activesupport (~> 3.0)
157
- railties (~> 3.0)
158
- rspec (~> 2.6.0)
159
- rubyzip (0.9.4)
160
- sass (3.1.7)
161
- sass-rails (3.1.2)
162
- actionpack (~> 3.1.0)
163
- railties (~> 3.1.0)
164
- sass (>= 3.1.4)
165
- sprockets (~> 2.0.0)
166
- tilt (~> 1.3.2)
167
- selenium-webdriver (2.7.0)
168
- childprocess (>= 0.2.1)
169
- ffi (>= 1.0.7)
170
- json_pure
171
- rubyzip
172
- shoulda-matchers (1.0.0.beta3)
173
- simple_form (1.5.2)
174
- actionpack (~> 3.0)
175
- activemodel (~> 3.0)
176
- sprockets (2.0.0)
177
- hike (~> 1.2)
178
- rack (~> 1.0)
179
- tilt (~> 1.1, != 1.3.0)
180
- sqlite3 (1.3.4)
181
- term-ansicolor (1.0.6)
182
- thor (0.14.6)
183
- tilt (1.3.3)
184
- treetop (1.4.10)
185
- polyglot
186
- polyglot (>= 0.3.1)
187
- tzinfo (0.3.30)
188
- xpath (0.1.4)
189
- nokogiri (~> 1.3)
190
- yard (0.7.2)
191
-
192
- PLATFORMS
193
- ruby
194
-
195
- DEPENDENCIES
196
- cucumber-rails (~> 1.0.6)
197
- database_cleaner (>= 0.6.7)
198
- factory_girl (~> 2.1.0)
199
- launchy (~> 2.0.5)
200
- mysql2
201
- pg (~> 0.11)
202
- rdiscount
203
- rspec-rails (~> 2.6.1)
204
- selenium-webdriver (>= 2.4.0)
205
- shoulda-matchers
206
- socialite!
207
- sqlite3
208
- yard
@@ -1,5 +0,0 @@
1
- module Socialite
2
- class FacebookIdentity < ActiveRecord::Base
3
- include Models::FacebookIdentity
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- module Socialite
2
- class Identity < ActiveRecord::Base
3
- include Models::Identity
4
- end
5
- end
@@ -1,10 +0,0 @@
1
- module Socialite
2
- class User < ActiveRecord::Base
3
- include Models::User
4
-
5
- has_one :facebook_identity,
6
- :class_name => 'Identity', :foreign_key => 'user_id', :conditions => { :provider => 'facebook' }
7
- has_one :twitter_identity,
8
- :class_name => 'Identity', :foreign_key => 'user_id', :conditions => { :provider => 'twitter' }
9
- end
10
- end
@@ -1,90 +0,0 @@
1
- require 'simple_form'
2
-
3
- # Use this setup block to configure all options available in SimpleForm.
4
- SimpleForm.setup do |config|
5
- # Wrappers are used by the form builder to generate a complete input.
6
- # You can remove any component from the wrapper, change the order or even
7
- # add your own to the stack. The options given to the wrappers method
8
- # are used to wrap the whole input (if any exists).
9
- # config.wrappers :class => :input, :error_class => :field_with_errors do |b|
10
- # b.use :placeholder
11
- # b.use :label_input
12
- # b.use :hint, :tag => :span, :class => :hint
13
- # b.use :error, :tag => :span, :class => :error
14
- # end
15
-
16
- # Method used to tidy up errors.
17
- # config.error_method = :first
18
-
19
- # Default tag used for error notification helper.
20
- # config.error_notification_tag = :p
21
-
22
- # CSS class to add for error notification helper.
23
- # config.error_notification_class = :error_notification
24
-
25
- # ID to add for error notification helper.
26
- # config.error_notification_id = nil
27
-
28
- # Series of attempts to detect a default label method for collection.
29
- # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
30
-
31
- # Series of attempts to detect a default value method for collection.
32
- # config.collection_value_methods = [ :id, :to_s ]
33
-
34
- # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
35
- # config.collection_wrapper_tag = nil
36
-
37
- # You can wrap each item in a collection of radio/check boxes with a tag, defaulting to span.
38
- # config.item_wrapper_tag = :span
39
-
40
- # How the label text should be generated altogether with the required text.
41
- # config.label_text = lambda { |label, required| "#{required} #{label}" }
42
-
43
- # You can define the class to use on all labels. Default is nil.
44
- # config.label_class = nil
45
-
46
- # You can define the class to use on all forms. Default is simple_form.
47
- # config.form_class = :simple_form
48
-
49
- # Whether attributes are required by default (or not). Default is true.
50
- # config.required_by_default = true
51
-
52
- # Tell browsers whether to use default HTML5 validations (novalidate option).
53
- # Default is enabled.
54
- # config.browser_validations = true
55
-
56
- # Determines whether HTML5 types (:email, :url, :search, :tel) and attributes
57
- # (e.g. required) are used or not. True by default.
58
- # Having this on in non-HTML5 compliant sites can cause odd behavior in
59
- # HTML5-aware browsers such as Chrome.
60
- config.html5 = true
61
-
62
- # Collection of methods to detect if a file type was given.
63
- # config.file_methods = [ :mounted_as, :file?, :public_filename ]
64
-
65
- # Custom mappings for input types. This should be a hash containing a regexp
66
- # to match as key, and the input type that will be used when the field name
67
- # matches the regexp as value.
68
- # config.input_mappings = { /count/ => :integer }
69
-
70
- # Default priority for time_zone inputs.
71
- # config.time_zone_priority = nil
72
-
73
- # Default priority for country inputs.
74
- # config.country_priority = nil
75
-
76
- # Default size for text inputs.
77
- # config.default_input_size = 50
78
-
79
- # When false, do not use translations for labels, hints or placeholders.
80
- # config.translate = true
81
-
82
- # Automatically discover new inputs in Rails' autoload path.
83
- # config.inputs_discovery = true
84
-
85
- # Cache simple form inputs discovery
86
- # config.cache_discovery = !Rails.env.development?
87
-
88
- # Default class for buttons
89
- # config.button_class = 'button'
90
- end
@@ -1,23 +0,0 @@
1
- en:
2
- simple_form:
3
- "yes": 'Yes'
4
- "no": 'No'
5
- required:
6
- text: 'required'
7
- mark: '*'
8
- # You can uncomment the line below if you need to overwrite the whole required html.
9
- # When using html, text and mark won't be used.
10
- # html: '<abbr title="required">*</abbr>'
11
- error_notification:
12
- default_message: "Some errors were found, please take a look:"
13
- # Labels and hints examples
14
- # labels:
15
- # password: 'Password'
16
- # user:
17
- # new:
18
- # email: 'E-mail para efetuar o sign in.'
19
- # edit:
20
- # email: 'E-mail.'
21
- # hints:
22
- # username: 'User name to sign in.'
23
- # password: 'No special characters, please.'
@@ -1,26 +0,0 @@
1
- class CreateIdentities < ActiveRecord::Migration
2
- def up
3
- create_table :socialite_identities do |t|
4
- t.belongs_to :user
5
- t.references :api, :polymorphic => true
6
-
7
- t.string :unique_id, :null => false
8
- t.string :provider, :null => false
9
- t.text :auth_hash
10
- t.timestamps
11
- end
12
-
13
- add_index :socialite_identities, :user_id
14
- add_index :socialite_identities, [:api_id, :api_type]
15
- add_index :socialite_identities, [:user_id, :provider], :unique => true
16
- add_index :socialite_identities, [:provider, :unique_id], :unique => true
17
- end
18
-
19
- def down
20
- remove_index :socialite_identites, :user_id
21
- remove_index :socialite_identites, [:api_id, :api_type]
22
- remove_index :socialite_identites, [:user_id, :provider_id]
23
- remove_index :socialite_identites, [:provider, :unique_id]
24
- drop_table :socialite_identities
25
- end
26
- end
@@ -1,12 +0,0 @@
1
- class CreateFacebookIdentities < ActiveRecord::Migration
2
- def up
3
- create_table :socialite_facebook_identities do |t|
4
- # Additional Fields that you want to cache
5
- t.timestamps
6
- end
7
- end
8
-
9
- def down
10
- drop_table :socialite_facebook_identities
11
- end
12
- end
@@ -1,67 +0,0 @@
1
- module Socialite
2
- module ApiWrappers
3
- module Facebook
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- require 'koala'
8
- end
9
-
10
- module ClassMethods
11
- def lookup(unique_id, options={})
12
- options.reverse_merge!({:access_token => nil})
13
- api_connection(options[:access_token]).get_object(unique_id)
14
- end
15
-
16
- def api_connection(access_token=nil)
17
- Koala::Facebook::API.new(access_token)
18
- end
19
- end
20
-
21
- module InstanceMethods
22
- def account_url
23
- "http://facebook.com/#{login}"
24
- end
25
-
26
- def access_token
27
- raise unless super
28
- end
29
-
30
- def api
31
- api_connection
32
- end
33
-
34
- def checkins
35
- api.get_connections(unique_id, 'checkins')
36
- end
37
-
38
- def friends
39
- api.get_connections(unique_id, 'friends')
40
- end
41
-
42
- def login
43
- raise unless super
44
- end
45
-
46
- def picture
47
- api.get_picture(unique_id)
48
- end
49
-
50
- def info
51
- api.get_object(unique_id)
52
- end
53
-
54
- def unique_id
55
- raise unless super
56
- end
57
-
58
- protected
59
-
60
- def api_connection
61
- @api_connection ||= self.class.api_connection(access_token)
62
- end
63
- end
64
- end
65
- end
66
- end
67
-