old_sql 0.29.0 → 0.30.0
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.
@@ -6,9 +6,8 @@ module OldSql
|
|
6
6
|
desc "Old SQL Install"
|
7
7
|
|
8
8
|
def check_for_devise
|
9
|
-
puts "
|
10
|
-
|
11
|
-
"
|
9
|
+
puts "Old SQL works with devise. Checking for a current installation of devise!
|
10
|
+
"
|
12
11
|
|
13
12
|
if defined?(Devise)
|
14
13
|
check_for_devise_models
|
@@ -28,7 +27,7 @@ Old SQL works with devise. Checking for a current installation of devise!
|
|
28
27
|
|
29
28
|
def check_for_devise_models
|
30
29
|
# File.exists?
|
31
|
-
devise_path = FileUtils.pwd
|
30
|
+
devise_path = "#{FileUtils.pwd}/config/initializers/devise.rb"
|
32
31
|
|
33
32
|
if File.exists?(devise_path)
|
34
33
|
parse_route_files
|
@@ -37,33 +36,32 @@ Old SQL works with devise. Checking for a current installation of devise!
|
|
37
36
|
|
38
37
|
invoke 'devise:install'
|
39
38
|
|
40
|
-
if !
|
39
|
+
if !devise_table_exists?
|
41
40
|
puts 'User Model Does Not Exist'
|
42
41
|
set_devise
|
43
|
-
elsif !
|
42
|
+
elsif !model_has_devise?
|
44
43
|
puts 'User Model Does Not Have Devise Support'
|
45
44
|
invoke 'old_sql:install_devise_migrations'
|
46
|
-
|
45
|
+
create_model_class unless model_exists?
|
47
46
|
end
|
48
47
|
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
52
|
-
|
53
|
-
def user_model_exists?
|
51
|
+
def devise_table_exists?
|
54
52
|
app_path = Rails.public_path.split("/")
|
55
53
|
app_path.delete_at(-1)
|
56
54
|
app_path = app_path.join("/")
|
57
|
-
schema_path = app_path
|
55
|
+
schema_path = "#{app_path}/db/schema.rb"
|
58
56
|
|
59
|
-
if File.exists?(schema_path) && open(schema_path).grep(/
|
57
|
+
if File.exists?(schema_path) && open(schema_path).grep(/#{:model_name}/).count>0
|
60
58
|
return true
|
61
59
|
else
|
62
60
|
return false
|
63
61
|
end
|
64
62
|
end
|
65
63
|
|
66
|
-
def
|
64
|
+
def model_has_devise?
|
67
65
|
app_path = Rails.public_path.split("/")
|
68
66
|
app_path.delete_at(-1)
|
69
67
|
app_path = app_path.join("/")
|
@@ -75,13 +73,34 @@ Old SQL works with devise. Checking for a current installation of devise!
|
|
75
73
|
return false
|
76
74
|
end
|
77
75
|
end
|
78
|
-
|
79
|
-
def
|
80
|
-
# check if migrations exist
|
76
|
+
|
77
|
+
def model_exists?
|
81
78
|
app_path = Rails.public_path.split("/")
|
82
79
|
app_path.delete_at(-1)
|
83
80
|
app_path = app_path.join("/")
|
84
|
-
|
81
|
+
|
82
|
+
File.exists?("#{app_path}/app/models/#{:model_name}.rb")
|
83
|
+
end
|
84
|
+
|
85
|
+
def create_model_class
|
86
|
+
model_path = "#{app_path}/app/models/#{:model_name}.rb"
|
87
|
+
|
88
|
+
gem_path = __FILE__
|
89
|
+
gem_path = gem_path.split("/")
|
90
|
+
gem_path = gem_path[0..-5]
|
91
|
+
gem_path = gem_path.join("/")
|
92
|
+
devise_template_path = "#{gem_path}/lib/generators/old_sql/templates/devise/devise_model.rb.template"
|
93
|
+
|
94
|
+
copy_file devise_template_path, model_path
|
95
|
+
|
96
|
+
gsub_file model_path, /DeviseModel/, :green do |match|
|
97
|
+
match << :model_name.capitalize
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def parse_route_files
|
102
|
+
# check if migrations exist
|
103
|
+
routes_path = "#{app_path}/config/routes.rb"
|
85
104
|
|
86
105
|
content = ""
|
87
106
|
|
@@ -106,28 +125,19 @@ Old SQL works with devise. Checking for a current installation of devise!
|
|
106
125
|
|
107
126
|
def copy_locales_files
|
108
127
|
print "Now copying locales files! "
|
109
|
-
gem_path = __FILE__
|
110
|
-
gem_path = gem_path.split("/")
|
111
|
-
|
112
|
-
gem_path = gem_path[0..-5]
|
113
|
-
gem_path = gem_path.join("/")
|
114
128
|
###
|
115
|
-
locales_path = gem_path
|
129
|
+
locales_path = "#{gem_path}/config/locales/*.yml"
|
116
130
|
|
117
|
-
|
118
|
-
app_path.delete_at(-1)
|
119
|
-
app_path = app_path.join("/")
|
131
|
+
locales_app_path = "#{app_path}/config/locales"
|
120
132
|
|
121
|
-
|
122
|
-
|
123
|
-
unless File.directory?(app_path)
|
124
|
-
FileUtils.mkdir app_path
|
133
|
+
unless File.directory?(locales_app_path)
|
134
|
+
FileUtils.mkdir locales_app_path
|
125
135
|
end
|
126
136
|
|
127
137
|
Dir.glob(locales_path).each do |file|
|
128
138
|
file_path = file.split("/")
|
129
139
|
file_path = file_path[-1]
|
130
|
-
FileUtils.copy_file(file,
|
140
|
+
FileUtils.copy_file(file, "#{locales_app_path}/#{file_path}")
|
131
141
|
print "."
|
132
142
|
end
|
133
143
|
print "\n"
|
@@ -135,28 +145,30 @@ Old SQL works with devise. Checking for a current installation of devise!
|
|
135
145
|
end
|
136
146
|
|
137
147
|
def create_old_sql_dirs
|
138
|
-
|
139
|
-
app_path
|
140
|
-
|
141
|
-
|
142
|
-
empty_directory(app_path + "/config/old_sql/")
|
143
|
-
empty_directory(app_path + "/config/old_sql/report_sql")
|
144
|
-
empty_directory(app_path + "/lib/old_sql/report_processor")
|
148
|
+
empty_directory "#{app_path}/config/old_sql/"
|
149
|
+
empty_directory "#{app_path}/config/old_sql/report_sql"
|
150
|
+
empty_directory "#{app_path}/lib/old_sql/report_processor"
|
145
151
|
end
|
146
152
|
|
147
153
|
def copy_old_sql_files
|
154
|
+
copy_file "#{gem_path}/config/old_sql/reports.yml.example", "#{app_path}/config/old_sql/reports.yml"
|
155
|
+
copy_file "#{gem_path}/config/old_sql/report_sql/user.erb.example", "#{app_path}/config/old_sql/report_sql/user.erb"
|
156
|
+
copy_file "#{gem_path}/lib/old_sql/report_processor/user_processor.rb.example", "#{app_path}/lib/old_sql/report_processor/user_processor.rb"
|
157
|
+
end
|
158
|
+
|
159
|
+
def app_path
|
148
160
|
app_path = Rails.public_path.split("/")
|
149
161
|
app_path.delete_at(-1)
|
150
162
|
app_path = app_path.join("/")
|
151
|
-
|
163
|
+
app_path
|
164
|
+
end
|
165
|
+
|
166
|
+
def
|
152
167
|
gem_path = __FILE__
|
153
168
|
gem_path = gem_path.split("/")
|
154
169
|
gem_path = gem_path[0..-5]
|
155
170
|
gem_path = gem_path.join("/")
|
156
|
-
|
157
|
-
copy_file gem_path + "/config/old_sql/reports.yml.example", app_path + "/config/old_sql/reports.yml"
|
158
|
-
copy_file gem_path + "/config/old_sql/report_sql/user.erb.example", app_path + "/config/old_sql/report_sql/user.erb"
|
159
|
-
copy_file gem_path + "/lib/old_sql/report_processor/user_processor.rb.example", app_path + "/lib/old_sql/report_processor/user_processor.rb"
|
171
|
+
gem_path
|
160
172
|
end
|
161
173
|
end
|
162
174
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class DeviseModel < ActiveRecord::Base
|
2
|
+
# Include default devise modules. Others available are:
|
3
|
+
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
|
4
|
+
devise :database_authenticatable, :registerable,
|
5
|
+
:recoverable, :rememberable, :trackable, :validatable
|
6
|
+
|
7
|
+
# Setup accessible (or protected) attributes for your model
|
8
|
+
attr_accessible :email, :password, :password_confirmation, :remember_me
|
9
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: old_sql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.30.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Eddie Gonzales
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/generators/old_sql/old_sql_generator.rb
|
88
88
|
- lib/generators/old_sql/templates/add_old_sql_admin_to_users_migration.rb
|
89
89
|
- lib/generators/old_sql/templates/devise/add_devise_to_users_migration.rb
|
90
|
+
- lib/generators/old_sql/templates/devise/devise_model.rb.template
|
90
91
|
- lib/old_sql.rb
|
91
92
|
- lib/old_sql/engine.rb
|
92
93
|
- lib/old_sql/report_processor/base.rb
|
@@ -191,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
191
192
|
requirements:
|
192
193
|
- - ">="
|
193
194
|
- !ruby/object:Gem::Version
|
194
|
-
hash: -
|
195
|
+
hash: -850664368174475429
|
195
196
|
segments:
|
196
197
|
- 0
|
197
198
|
version: "0"
|