scaffold_pico 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -47
- data/lib/scaffold/cli.rb +16 -4
- data/lib/scaffold/erb_context.rb +11 -0
- data/lib/scaffold/generators/base_generator.rb +74 -0
- data/lib/scaffold/generators/controller_generator.rb +27 -0
- data/lib/scaffold/generators/fabricator_generator.rb +26 -0
- data/lib/scaffold/generators/locales_generator.rb +42 -0
- data/lib/scaffold/generators/models_generator.rb +53 -0
- data/lib/scaffold/generators/routes_generator.rb +48 -0
- data/lib/scaffold/generators/views_generator.rb +57 -0
- data/lib/scaffold/main.rb +15 -6
- data/lib/scaffold/models/resource.rb +66 -0
- data/lib/scaffold/rails.rb +54 -0
- data/lib/scaffold/services/controller.rb +112 -0
- data/lib/scaffold/services/nested_in_resources.rb +42 -0
- data/lib/scaffold/services/path.rb +72 -0
- data/lib/scaffold/services/resource.rb +73 -0
- data/lib/scaffold/services/route.rb +20 -0
- data/lib/scaffold/services/view.rb +14 -0
- data/lib/scaffold_pico.rb +6 -7
- data/lib/templates/pico/controller.rb.erb +34 -26
- data/lib/templates/pico/fabricators/fabrication.rb.erb +4 -4
- data/lib/templates/pico/locales/bg.scaffold_pico.yml.erb +35 -0
- data/lib/templates/pico/locales/en.scaffold_pico.yml.erb +35 -0
- data/lib/templates/pico/model.rb.erb +2 -2
- data/lib/templates/pico/search.rb.erb +12 -12
- data/lib/templates/pico/views/materialize/slim/_form.html.slim.erb +1 -4
- data/lib/templates/pico/views/materialize/slim/edit.html.slim.erb +9 -7
- data/lib/templates/pico/views/materialize/slim/index.html.slim.erb +15 -15
- data/lib/templates/pico/views/materialize/slim/new.html.slim.erb +7 -5
- data/lib/templates/pico/views/materialize/slim/show.html.slim.erb +10 -10
- data/lib/templates/pico/views/zurb/slim/_form.html.slim.erb +2 -5
- data/lib/templates/pico/views/zurb/slim/edit.html.slim.erb +8 -6
- data/lib/templates/pico/views/zurb/slim/index.html.slim.erb +14 -14
- data/lib/templates/pico/views/zurb/slim/new.html.slim.erb +6 -4
- data/lib/templates/pico/views/zurb/slim/show.html.slim.erb +7 -7
- metadata +22 -10
- data/lib/scaffold/base_generator.rb +0 -60
- data/lib/scaffold/controller_generator.rb +0 -24
- data/lib/scaffold/fabricator_generator.rb +0 -25
- data/lib/scaffold/models_generator.rb +0 -51
- data/lib/scaffold/params.rb +0 -174
- data/lib/scaffold/routes_generator.rb +0 -29
- data/lib/scaffold/views_generator.rb +0 -52
@@ -1,29 +0,0 @@
|
|
1
|
-
module Scaffold
|
2
|
-
class RoutesGenerator < Scaffold::BaseGenerator
|
3
|
-
|
4
|
-
def generate
|
5
|
-
puts "Insert something like this in routes.rb"
|
6
|
-
namespaces_count = @params.namespaces_array.count
|
7
|
-
route_string = "#{spaces(namespaces_count+2)}resources :#{@params.route_resource_name}"
|
8
|
-
|
9
|
-
@params.namespaces_array.reverse.each_with_index do |namespace, index|
|
10
|
-
route_string = namespace_block(namespace, namespaces_count - index, route_string)
|
11
|
-
end
|
12
|
-
puts route_string
|
13
|
-
end
|
14
|
-
|
15
|
-
def spaces(count)
|
16
|
-
" "*2*(count)
|
17
|
-
end
|
18
|
-
|
19
|
-
def namespace_block namespace, index, route_string
|
20
|
-
ident = spaces(index+1)
|
21
|
-
|
22
|
-
begin_namespace_line = "#{ident}namespace :#{namespace} do"
|
23
|
-
namespace = "#{ident*2}#{namespace}"
|
24
|
-
end_namespace_line = "#{ident}end"
|
25
|
-
"#{begin_namespace_line}\n#{route_string}\n#{end_namespace_line}"
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module Scaffold
|
2
|
-
class ViewsGenerator < Scaffold::BaseGenerator
|
3
|
-
def generate
|
4
|
-
views_path = create_views_path
|
5
|
-
templating_engine = choose_templating_engine
|
6
|
-
|
7
|
-
# print "Creating view:"
|
8
|
-
%w(index new edit show _form).each do |view_name|
|
9
|
-
# print view_name, ' '
|
10
|
-
create views_path, view_name, templating_engine, css_framework
|
11
|
-
end
|
12
|
-
# print "\n"
|
13
|
-
end
|
14
|
-
|
15
|
-
def create views_path, view_name, templating_engine, css_framework
|
16
|
-
source_file_name = "#{view_name}.html.#{templating_engine.extension}.erb"
|
17
|
-
target_file_name = "#{view_name}.html.#{templating_engine.extension}"
|
18
|
-
source_file_path = find_root(templates, 'views',
|
19
|
-
css_framework,
|
20
|
-
templating_engine.source_folder_name,
|
21
|
-
source_file_name)
|
22
|
-
content = File.read(source_file_path)
|
23
|
-
|
24
|
-
# http://www.stuartellis.eu/articles/erb/
|
25
|
-
content = ::ERB.new(content, nil, '-').result(@params.instance_eval{ binding })#.gsub(/\s+\n$/, "")
|
26
|
-
|
27
|
-
target_file_path = File.join(create_views_path, target_file_name)
|
28
|
-
write_with_confirmation(target_file_path, content)
|
29
|
-
end
|
30
|
-
|
31
|
-
def create_views_path
|
32
|
-
views_path = File.join(Dir.pwd, 'app', 'views', @params.namespaces_array, @params.views_folder_name)
|
33
|
-
FileUtils.mkpath(views_path)
|
34
|
-
views_path
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
def choose_templating_engine
|
39
|
-
case @params.template
|
40
|
-
when 'slim'
|
41
|
-
::Scaffold::TemplateEngines::Slim.new
|
42
|
-
else
|
43
|
-
raise "I don't have defined templates for #{@params.template}. However you can use [slim,]"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def css_framework
|
48
|
-
@params.css_framework
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|