fetty-generators 2.0.1 → 2.0.3
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/lib/generators/fetty/authentication/authentication_generator.rb +1 -1
- data/lib/generators/fetty/messages/messages_generator.rb +1 -1
- data/lib/generators/fetty/scaffold/scaffold_generator.rb +2 -2
- data/lib/generators/fetty/setup/setup_generator.rb +29 -35
- data/lib/generators/fetty/views/USAGE +1 -1
- data/lib/generators/fetty/views/views_generator.rb +19 -39
- data/lib/generators/fetty.rb +4 -7
- data/lib/generators/scaffold.rb +2 -0
- metadata +2 -2
@@ -16,7 +16,7 @@ module Fetty
|
|
16
16
|
else
|
17
17
|
unless using_fetty_authentication?
|
18
18
|
@orm = using_mongoid? ? 'mongoid' : 'active_record'
|
19
|
-
|
19
|
+
gem "bcrypt-ruby", :require => "bcrypt"
|
20
20
|
generate_users
|
21
21
|
generate_sessions
|
22
22
|
generate_reset_passwords
|
@@ -25,7 +25,7 @@ module Fetty
|
|
25
25
|
print_usage unless scaffold_name.underscore =~ /^[a-z][a-z0-9_\/]+$/ && !attributes.empty?
|
26
26
|
print_usage unless attributes.drop_while { |arg| arg.include?(':') }.count == 0
|
27
27
|
|
28
|
-
if check_required_gems? "jquery-rails", "simple_form", "kaminari"
|
28
|
+
if check_required_gems? "jquery-rails", "simple_form", "kaminari"
|
29
29
|
@orm = using_mongoid? ? 'mongoid' : 'active_record'
|
30
30
|
|
31
31
|
setting_model_attributes
|
@@ -49,7 +49,7 @@ module Fetty
|
|
49
49
|
generate_specs if using_rspec?
|
50
50
|
end
|
51
51
|
else
|
52
|
-
raise "Missing gems: jquery-rails
|
52
|
+
raise "Missing gems: jquery-rails simple_form kaminari"
|
53
53
|
end
|
54
54
|
rescue Exception => e
|
55
55
|
print_notes(e.message,"error",:red)
|
@@ -23,13 +23,15 @@ module Fetty
|
|
23
23
|
@selected_gems = options.only.empty? ? options.reject { |k,v| k == "only" || k == "mongoid" || v == false }.keys : options.only
|
24
24
|
@selected_gems.each do |gems|
|
25
25
|
asking "Would you like to setup #{gems} gem?" do
|
26
|
-
send("setup_#{gems}")
|
26
|
+
send("setup_#{gems.gsub('-','_')}")
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
if options.only.empty?
|
30
|
+
remove_file 'public/index.html' if file_exists?('public/index.html')
|
31
|
+
remove_file 'public/images/rails.png' if file_exists?('public/images/rails.png')
|
32
|
+
print_notes("Refreshing Bundle")
|
33
|
+
refresh_bundle
|
34
|
+
end
|
33
35
|
rescue Exception => e
|
34
36
|
print_notes(e.message,"error",:red)
|
35
37
|
end
|
@@ -37,10 +39,8 @@ module Fetty
|
|
37
39
|
private
|
38
40
|
|
39
41
|
def setup_mongoid
|
40
|
-
|
41
|
-
|
42
|
-
gem "mongoid"
|
43
|
-
end
|
42
|
+
gem "bson_ext"
|
43
|
+
gem "mongoid"
|
44
44
|
generate("mongoid:config")
|
45
45
|
set_application_config { " config.mongoid.preload_models = true\n" }
|
46
46
|
rescue Exception => e
|
@@ -48,7 +48,7 @@ private
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def setup_cancan
|
51
|
-
|
51
|
+
gem "cancan"
|
52
52
|
copy_file 'ability.rb', 'app/models/ability.rb'
|
53
53
|
inject_into_class 'app/controllers/application_controller.rb', ApplicationController do
|
54
54
|
" rescue_from CanCan::AccessDenied do |exception| flash[:alert] = exception.message; redirect_to root_url end;\n"
|
@@ -58,24 +58,22 @@ private
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def setup_jquery_rails
|
61
|
-
|
61
|
+
gem "jquery-rails"
|
62
62
|
generate("jquery:install")
|
63
63
|
rescue Exception => e
|
64
64
|
raise e
|
65
65
|
end
|
66
66
|
|
67
67
|
def setup_simple_form
|
68
|
-
|
68
|
+
gem "simple_form"
|
69
69
|
generate("simple_form:install")
|
70
70
|
rescue Exception => e
|
71
71
|
raise e
|
72
72
|
end
|
73
73
|
|
74
74
|
def setup_carrierwave
|
75
|
-
|
76
|
-
|
77
|
-
gem "carrierwave"
|
78
|
-
end
|
75
|
+
gem "mini_magick"
|
76
|
+
gem "carrierwave"
|
79
77
|
copy_file 'image_uploader.rb', 'app/uploaders/image_uploader.rb'
|
80
78
|
copy_file 'file_uploader.rb', 'app/uploaders/file_uploader.rb'
|
81
79
|
print_notes("carrierwave will use mini_magick by default!")
|
@@ -84,7 +82,7 @@ private
|
|
84
82
|
end
|
85
83
|
|
86
84
|
def setup_kaminari
|
87
|
-
|
85
|
+
gem "kaminari"
|
88
86
|
rescue Exception => e
|
89
87
|
raise e
|
90
88
|
end
|
@@ -94,11 +92,11 @@ private
|
|
94
92
|
destroy("public/javascripts/ckeditor")
|
95
93
|
ver = ask("==> What version of CKEditor javascript files do you need? [default 3.5.4]")
|
96
94
|
if ver == "3.5.4" || ver.blank?
|
97
|
-
|
95
|
+
gem "ckeditor", "3.5.4"
|
98
96
|
template "ckeditor.rb", "config/initializers/ckeditor.rb"
|
99
97
|
extract("setup/templates/ckeditor.tar.gz","public/javascripts","ckeditor")
|
100
98
|
else
|
101
|
-
|
99
|
+
gem "ckeditor", ver
|
102
100
|
generate("ckeditor:base --version=#{ver}")
|
103
101
|
end
|
104
102
|
rescue Exception => e
|
@@ -109,18 +107,16 @@ private
|
|
109
107
|
# remove the existing install (if any)
|
110
108
|
destroy("Guardfile")
|
111
109
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
gem 'growl', :group => [:development, :test]
|
123
|
-
end
|
110
|
+
gem 'rspec-rails', :group => [:development, :test]
|
111
|
+
gem 'capybara', :group => [:development, :test]
|
112
|
+
gem 'factory_girl_rails', :group => [:development, :test]
|
113
|
+
gem 'faker', :group => [:development, :test]
|
114
|
+
gem 'database_cleaner', :group => [:development, :test]
|
115
|
+
gem 'escape_utils', :group => [:development, :test]
|
116
|
+
gem 'guard-rspec', :group => [:development, :test]
|
117
|
+
if RUBY_PLATFORM =~ /darwin/i
|
118
|
+
gem 'rb-fsevent', :group => [:development, :test], :require => false
|
119
|
+
gem 'growl', :group => [:development, :test]
|
124
120
|
end
|
125
121
|
|
126
122
|
copy_file 'escape_utils.rb', 'config/initializers/escape_utils.rb'
|
@@ -132,10 +128,8 @@ private
|
|
132
128
|
|
133
129
|
asking "Would you like to install Cucumber?" do
|
134
130
|
destroy("features")
|
135
|
-
|
136
|
-
|
137
|
-
gem "guard-cucumber", :group => [:development, :test]
|
138
|
-
end
|
131
|
+
gem "cucumber-rails", :group => [:development, :test]
|
132
|
+
gem "guard-cucumber", :group => [:development, :test]
|
139
133
|
generate("cucumber:install", "--rspec", "--capybara")
|
140
134
|
template 'env.rb', 'features/support/env.rb', :force => true
|
141
135
|
`guard init cucumber`
|
@@ -2,4 +2,4 @@ Description:
|
|
2
2
|
The fetty:views generator creates a basic layout, stylesheet and
|
3
3
|
helper which will give some structure to starting your Rails app.
|
4
4
|
|
5
|
-
Also able to convert your template views from ERB to HAML
|
5
|
+
Also able to convert your template views from ERB to HAML.
|
@@ -4,16 +4,14 @@ module Fetty
|
|
4
4
|
module Generators
|
5
5
|
class ViewsGenerator < Base
|
6
6
|
|
7
|
-
argument :arg, :type => :string, :required => true, :banner => 'layout |
|
7
|
+
argument :arg, :type => :string, :required => true, :banner => 'layout | erb_to_haml'
|
8
8
|
|
9
9
|
def generate_views
|
10
10
|
case arg
|
11
11
|
when "layout"
|
12
|
-
generate_layout
|
13
|
-
when "
|
12
|
+
generate_layout
|
13
|
+
when "erb_to_haml"
|
14
14
|
erb_to_haml
|
15
|
-
when "haml:to:erb"
|
16
|
-
haml_to_erb
|
17
15
|
end
|
18
16
|
rescue Exception => e
|
19
17
|
print_notes(e.message,"error",:red)
|
@@ -37,50 +35,32 @@ private
|
|
37
35
|
def erb_to_haml
|
38
36
|
asking "Are you sure want to convert all your views from ERB to HAML ?" do
|
39
37
|
# => Cycles through the views folder and searches for erb files
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
def haml_to_erb
|
54
|
-
asking "Are you sure want to convert all your views from HAML to ERB ? [yes]" do
|
55
|
-
# => Cycles through the views folder and searches for haml files
|
38
|
+
prepare_convert_gems
|
39
|
+
::Bundler.with_clean_env do
|
40
|
+
Dir.glob("app/views/**/*.erb").each do |file|
|
41
|
+
out_file = file.gsub(/erb$/, "haml")
|
42
|
+
unless file_exists? out_file
|
43
|
+
puts "Convert ERB: #{file} => HAML: #{out_file}"
|
44
|
+
`html2haml #{file} | cat > #{out_file}`
|
45
|
+
File.delete(file) if $? == 0
|
46
|
+
else
|
47
|
+
puts "WARNING: '#{out_file}' already exists!"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
56
51
|
end
|
57
52
|
rescue Exception => e
|
58
53
|
raise e
|
59
54
|
end
|
60
55
|
|
61
56
|
def prepare_convert_gems
|
62
|
-
|
63
|
-
|
64
|
-
|
57
|
+
gem "haml-rails"
|
58
|
+
install_local_gem "hpricot" unless check_local_gem? "hpricot"
|
59
|
+
install_local_gem "ruby_parser" unless check_local_gem? "ruby_parser"
|
65
60
|
rescue Exception => e
|
66
61
|
raise e
|
67
62
|
end
|
68
63
|
|
69
|
-
def convert_views(in_type,out_type)
|
70
|
-
# Dir["app/views/**/*.#{in_type}"].each do |file_name|
|
71
|
-
# puts "Convert #{first_type.capitalize}: #{file_name}"
|
72
|
-
# out_file_name = file_name.gsub(/#{first_type}$/, second_type)
|
73
|
-
# unless file_exists? out_file_name
|
74
|
-
# erb_string = File.open(file_name).read
|
75
|
-
# haml_string = Haml::HTML.new(erb_string, :erb => true).render
|
76
|
-
# f = File.new(haml_file_name, "w")
|
77
|
-
# f.write(haml_string)
|
78
|
-
# File.delete(file_name)
|
79
|
-
# end
|
80
|
-
# end
|
81
|
-
rescue Exception => e
|
82
|
-
raise e
|
83
|
-
end
|
84
64
|
|
85
65
|
end
|
86
66
|
end
|
data/lib/generators/fetty.rb
CHANGED
@@ -16,13 +16,6 @@ module Fetty
|
|
16
16
|
|
17
17
|
protected
|
18
18
|
|
19
|
-
def add_gem(&block)
|
20
|
-
yield
|
21
|
-
refresh_bundle
|
22
|
-
rescue Exception => e
|
23
|
-
raise e
|
24
|
-
end
|
25
|
-
|
26
19
|
def root_path(path)
|
27
20
|
File.expand_path(File.join(File.dirname(__FILE__), 'fetty', path))
|
28
21
|
end
|
@@ -193,3 +186,7 @@ protected
|
|
193
186
|
end
|
194
187
|
end
|
195
188
|
|
189
|
+
# => set callback on when calling +gem+
|
190
|
+
set_trace_func proc { |event, file, line, id, binding, classname|
|
191
|
+
::Bundler.with_clean_env { `bundle` } if classname == Rails::Generators::Actions && id == :gem && event == 'return'
|
192
|
+
}
|
data/lib/generators/scaffold.rb
CHANGED
@@ -18,8 +18,10 @@ module Fetty
|
|
18
18
|
if arg.include?(':file') || arg.include?(':image') || arg.include?(':editor')
|
19
19
|
self.special_types[arg.split(':').first] = arg.split(':').last.to_sym
|
20
20
|
if arg.include?(':editor')
|
21
|
+
raise "Missing gems: ckeditor" unless check_required_gems? "ckeditor"
|
21
22
|
self.model_attributes << Rails::Generators::GeneratedAttribute.new(arg.split(':').first, "text")
|
22
23
|
else
|
24
|
+
raise "Missing gems: carrierwave" unless check_required_gems? "carrierwave"
|
23
25
|
self.model_attributes << Rails::Generators::GeneratedAttribute.new(arg.split(':').first, "string")
|
24
26
|
end
|
25
27
|
else
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fetty-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
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: 2011-08-
|
12
|
+
date: 2011-08-19 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: This generators provide you to easily setup your Rails 3 application,
|
15
15
|
create authentication, messages, admin style scaffolding and many more
|