minimum-omniauth-scaffold 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdaf73cb4c1edcd2047dd434c02679512eda2513
4
- data.tar.gz: 0cb571e798b03c4c90ad8d0045c6960a29e69eee
3
+ metadata.gz: 01d9f75658c40d0a9b44a607b3413f817012a86e
4
+ data.tar.gz: aea95f89fa362e318c3a493fc7701d985d88a965
5
5
  SHA512:
6
- metadata.gz: 8dcb903956226d1dde8cf2af054874ed87c04213da51fdc029b11749d2760caa2f6be23433e5c0a466b97f9bf992f20d40cc22f945468762cc75cfd4d7455e83
7
- data.tar.gz: 6300f337a14f665f37e48a36904f186104d769c247ea40cd9077ab4763dcaa16cc4023f7a20a4364de7e1f727387dcbc678344102e627f275752218929814ffb
6
+ metadata.gz: 2ef6d2ffcb602d75cccb9a9686851a4b827d0e60d126bebfaf10b17571299e230466d502853a91f47a538488cda308d171f6a89342bdb7463da451c61e8bca27
7
+ data.tar.gz: 58931d8661f393c6dfb75a3b2780b791d9f9563a08448913b9dc2eaf14c8d539f8b35510dbf5623610714af9c9f8b7ce928d5c6be09fe7558e9a792f2a524722
@@ -15,7 +15,7 @@ module Minimum
15
15
  def generate_scaffold
16
16
  app_name = Rails.application.class.name.split('::').first
17
17
 
18
- ## rails_config
18
+ # rails_config
19
19
  copy_file "#{@@template_path}/rails_config/config.rb", "config/initializers/config.rb"
20
20
  copy_file "#{@@template_path}/rails_config/settings.yml", "config/settings.yml"
21
21
  copy_file "#{@@template_path}/rails_config/settings.local.yml", "config/settings.local.yml"
@@ -23,10 +23,10 @@ module Minimum
23
23
  copy_file "#{@@template_path}/rails_config/production.yml", "config/settings/production.yml"
24
24
  copy_file "#{@@template_path}/rails_config/test.yml", "config/settings/test.yml"
25
25
 
26
- ## omniauth
26
+ # omniauth
27
27
  copy_file "#{@@template_path}/initializers/omniauth.rb", "config/initializers/omniauth.rb"
28
28
 
29
- ## routes.rb
29
+ # routes.rb
30
30
  content = "\n # For OmniAuth\n"
31
31
  content += " get \"/auth/:provider/callback\" => \"sessions#callback\"\n"
32
32
  content += " get \"/auth/failure\" => \"sessions#failure\"\n"
@@ -35,59 +35,44 @@ module Minimum
35
35
  insert_into_file "config/routes.rb", content.force_encoding('ASCII-8BIT'), after: "Rails.application.routes.draw do\n"
36
36
  insert_into_file "config/routes.rb", " root to: 'top#index'\n", after: "Rails.application.routes.draw do\n"
37
37
 
38
- # ## application.rb
39
- # content = " config.time_zone = 'Tokyo'\n"
40
- # insert_into_file( "config/application.rb", content.force_encoding('ASCII-8BIT'), after: "# config.time_zone = 'Central Time (US & Canada)'\n" )
41
- # insert_into_file( "config/application.rb", " config.i18n.default_locale = :ja\nI18n.enforce_available_locales = true\n", after: "# config.i18n.default_locale = :de\n" )
42
- # content = " # For Tapp\n"
43
- # content += " Tapp.config.default_printer = :awesome_print\n"
44
- # content += "\n"
45
- # insert_into_file( "config/application.rb", content.force_encoding('ASCII-8BIT'), after: "class Application < Rails::Application\n" )
46
-
47
- # ## production.rb
48
- # insert_into_file( "config/environments/production.rb", " config.force_ssl = true\n", after: "# config.force_ssl = true\n" ) # 強制SSL設定
49
-
50
- # ## development.rb
51
- # gsub_file "config/environments/development.rb", /(config.assets.debug = true)+/, "# config.assets.debug = true" # コメントアウト追加
52
- # insert_into_file( "config/environments/development.rb", " config.assets.debug = false\n", after: "config.assets.debug = true\n" ) # false設定追加
53
-
54
- ## ja.yml
38
+ # ja.yml
55
39
  copy_file "#{@@template_path}/locales/ja.yml", "config/locales/ja.yml"
56
40
  copy_file "#{@@template_path}/locales/translation_ja.yml", "config/locales/translation_ja.yml"
57
41
 
58
- ## migration
42
+ # migration
59
43
  copy_file "#{@@template_path}/migrate/create_users.rb", "db/migrate/20000101000000_create_users.rb"
60
44
  copy_file "#{@@template_path}/migrate/create_authentications.rb", "db/migrate/20000102000000_create_authentications.rb"
61
45
 
62
- ## models
46
+ # models
63
47
  copy_file "#{@@template_path}/models/user.rb", "app/models/user.rb"
64
48
  copy_file "#{@@template_path}/models/authentication.rb", "app/models/authentication.rb"
65
49
 
66
- ## controllers
50
+ # controllers
67
51
  content = File.read("#{@@template_path}/controllers/application_controller.rb", encoding: Encoding::UTF_8)
68
52
  insert_into_file "app/controllers/application_controller.rb", content.force_encoding('ASCII-8BIT'), after: "protect_from_forgery with: :exception\n"
69
53
  copy_file "#{@@template_path}/controllers/sessions_controller.rb", "app/controllers/sessions_controller.rb"
70
54
  copy_file "#{@@template_path}/controllers/top_controller.rb", "app/controllers/top_controller.rb"
71
55
 
72
- ## views
56
+ # views
73
57
  # content = File.read( "#{@@template_path}/views/application.html.erb", encoding: Encoding::UTF_8 )
74
58
  # gsub_file "app/views/layouts/application.html.erb", /(<%= yield %>)+/, content.force_encoding('ASCII-8BIT')
75
59
  # gsub_file "app/views/layouts/application.html.erb", Regexp.new("<title>#{app_name}</title>"), "<title><%= Settings.app_name %></title>"
76
60
 
77
- # copy_file 'app/views/layouts/application.html.erb', 'app/views/layouts/_____application.html.erb'
61
+ copy_file 'app/views/layouts/application.html.erb', 'app/views/layouts/application_BACKUP.html.erb'
78
62
  remove_file 'app/views/layouts/application.html.erb'
79
63
  copy_file "#{@@template_path}/views/application.html.haml", 'app/views/layouts/application.html.haml'
80
64
  copy_file "#{@@template_path}/views/_user_icon.html.haml", "app/views/layouts/_user_icon.html.haml"
81
65
  copy_file "#{@@template_path}/views/index.html.haml", "app/views/top/index.html.haml"
82
66
 
83
- ## assets
67
+ # assets
84
68
  copy_file "#{@@template_path}/stylesheets/scaffolds.css.scss", "app/assets/stylesheets/scaffolds.css.scss"
85
69
 
86
- ## README
70
+ # README
71
+ copy_file 'README.rdoc', 'README_BACKUP.rdoc'
87
72
  remove_file 'README.rdoc'
88
73
  copy_file "#{@@template_path}/README.md", "README.md"
89
74
 
90
- ## .gitignore
75
+ # .gitignore
91
76
  content = "\n# Add\n"
92
77
  content += ".DS_Store\n"
93
78
  content += "vendor/bundle\n"
@@ -6,10 +6,8 @@
6
6
  # ログイン認証
7
7
  def authenticate
8
8
  unless signed_in?
9
- # リクエストURL保管
10
9
  session[:request_url] = request.url
11
10
 
12
- # ルートヘリダイレクト
13
11
  redirect_to :root and return
14
12
  end
15
13
  end
@@ -1,5 +1,5 @@
1
1
  class Authentication < ActiveRecord::Base
2
- belongs_to :user
2
+ belongs_to :user, optional: true
3
3
 
4
4
  # バリデーション
5
5
  validates :provider, presence: true
@@ -26,40 +26,36 @@ class Authentication < ActiveRecord::Base
26
26
  self.gender = gender if gender.present?
27
27
  self.location = location if location.present?
28
28
  self.save!
29
- rescue => e
30
- puts "[ ---------- e ---------- ]" ; e.tapp ;
31
- return nil
32
29
  end
33
30
 
34
- private
35
-
36
- # auth情報登録/ユーザ作成
37
- def self.create_with_omniauth(auth)
31
+ class << self
38
32
  # auth情報登録
39
- authentication = Authentication.new
40
- authentication.provider = auth["provider"]
41
- authentication.uid = auth["uid"]
42
-
43
- if auth["info"].present?
44
- authentication.name = auth["info"]["name"]
45
- authentication.nickname = auth["info"]["nickname"]
46
- authentication.image = auth["info"]["image"]
47
- authentication.email = auth["info"]["email"]
48
- authentication.location = auth["info"]["location"]
49
- end
50
-
51
- if auth["credentials"].present?
52
- authentication.token = auth['credentials']['token']
53
- authentication.secret = auth['credentials']['secret']
33
+ def create_with_omniauth(auth)
34
+ authentication = Authentication.new
35
+ authentication.provider = auth["provider"]
36
+ authentication.uid = auth["uid"]
37
+
38
+ if auth["info"].present?
39
+ authentication.name = auth["info"]["name"]
40
+ authentication.nickname = auth["info"]["nickname"]
41
+ authentication.image = auth["info"]["image"]
42
+ authentication.email = auth["info"]["email"]
43
+ authentication.location = auth["info"]["location"]
44
+ end
45
+
46
+ if auth["credentials"].present?
47
+ authentication.token = auth['credentials']['token']
48
+ authentication.secret = auth['credentials']['secret']
49
+ end
50
+
51
+ if auth["extra"].present? and auth["extra"]["raw_info"].present?
52
+ authentication.gender = auth["extra"]["raw_info"]["gender"]
53
+ authentication.location = auth["extra"]["raw_info"]["location"] if authentication.location.blank?
54
+ end
55
+
56
+ authentication.save!
57
+
58
+ return authentication
54
59
  end
55
-
56
- if auth["extra"].present? and auth["extra"]["raw_info"].present?
57
- authentication.gender = auth["extra"]["raw_info"]["gender"]
58
- authentication.location = auth["extra"]["raw_info"]["location"] if authentication.location.blank?
59
- end
60
-
61
- authentication.save!
62
-
63
- return authentication
64
60
  end
65
61
  end
@@ -1,26 +1,22 @@
1
1
  class User < ActiveRecord::Base
2
2
  has_many :authentications
3
3
 
4
- private
5
-
6
- # ユーザ作成
7
- def self.create_with_auth(authentication, request)
4
+ class << self
8
5
  # ユーザ作成
9
- user = User.new
10
- user.name = (authentication.nickname.presence || authentication.name)
11
- user.image = authentication.image if authentication.image.present?
12
- user.email = authentication.email if authentication.email.present?
13
- user.last_login_provider = authentication.provider if authentication.provider.present?
14
- user.last_login_at = Time.now
15
- user.user_agent = request.env['HTTP_USER_AGENT'] rescue 'error'
16
-
17
- # データ保存
18
- user.save!
6
+ def create_with_auth(authentication, request)
7
+ user = User.new
8
+ user.name = (authentication.nickname.presence || authentication.name)
9
+ user.image = authentication.image if authentication.image.present?
10
+ user.email = authentication.email if authentication.email.present?
11
+ user.last_login_provider = authentication.provider if authentication.provider.present?
12
+ user.last_login_at = Time.now
13
+ user.user_agent = request.env['HTTP_USER_AGENT'] rescue 'error'
14
+ user.save!
19
15
 
20
- # auth紐付け
21
- authentication.user_id = user.id
22
- authentication.save!
16
+ authentication.user_id = user.id
17
+ authentication.save!
23
18
 
24
- return user
19
+ return user
20
+ end
25
21
  end
26
22
  end
@@ -9,8 +9,5 @@ app_name: "YOUR_APP_NAME"
9
9
  # プログラマTwitterID
10
10
  programmer_twitter_id: "PROGRAMMER_TWITTER_ID"
11
11
 
12
- # デザイナーTwitterID
13
- designer_twitter_id: "DESIGNER_TWITTER_ID"
14
-
15
12
  # 曜日
16
13
  weekday: ["日", "月", "火", "水", "木", "金", "土"]
@@ -2,10 +2,10 @@
2
2
  %html
3
3
  %head
4
4
  %title= Settings.app_name
5
- = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
6
- = javascript_include_tag 'application', 'data-turbolinks-track' => true
5
+ = stylesheet_link_tag 'application', media: 'all'
6
+ = javascript_include_tag 'application'
7
7
  = csrf_meta_tags
8
- %body{ 'data-no-turbolink' => true }
8
+ %body
9
9
  = link_to Settings.app_name, :root
10
10
 
11
11
  - if signed_in?
@@ -28,13 +28,8 @@
28
28
 
29
29
  %center
30
30
  Developed by
31
- = succeed "," do
32
- %a{ href: "https://twitter.com/#{Settings.programmer_twitter_id}/", target: '_blank' }
33
- = "@#{Settings.programmer_twitter_id}"
34
- Designed by
35
- = succeed "," do
36
- %a{ href: "https://twitter.com/#{Settings.designer_twitter_id}/", target: '_blank' }
37
- = "@#{Settings.designer_twitter_id}"
38
- Licence by
39
- %a{ href: 'https://creativecommons.org/licenses/by-nc-sa/2.1/jp/', target: '_blank' }
40
- CC BY-NC-SA 2.1
31
+ = link_to "@#{Settings.programmer_twitter_id}", "https://twitter.com/#{Settings.programmer_twitter_id}/", target: '_blank'
32
+
33
+ -# Licence by
34
+ -# %a{ href: 'https://creativecommons.org/licenses/by-nc-sa/2.1/jp/', target: '_blank' }
35
+ -# CC BY-NC-SA 2.1
@@ -1,7 +1,7 @@
1
1
  module Minimum
2
2
  module Omniauth
3
3
  module Scaffold
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimum-omniauth-scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - shu0115
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-17 00:00:00.000000000 Z
11
+ date: 2016-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
- rubygems_version: 2.4.5
184
+ rubygems_version: 2.5.1
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: Minimum OmniAuth Scaffold