scaffold_pico 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +15 -2
- data/lib/scaffold/cli.rb +8 -3
- data/lib/scaffold/fabricator_generator.rb +24 -0
- data/lib/scaffold/main.rb +3 -1
- data/lib/scaffold/models_generator.rb +1 -1
- data/lib/scaffold/params.rb +10 -2
- data/lib/scaffold_pico.rb +1 -0
- data/lib/templates/pico/fabricators/fabrication.rb.erb +15 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e40cb927580081fb976d84220cc33e0e636345df
|
4
|
+
data.tar.gz: 5fca21fc95f40f2df1ae2add3af2807cb6ffce97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 661bfda0de1d8e558e008a05f4c23da19a5e5478342a71af3c52eb596ffaf3c6fbe7d4424b0e7bc324ed44e628f1390382e987122fa4d9c1f7582f69c532e836
|
7
|
+
data.tar.gz: 1df187a0f3e592fd2d01c6416eea13fa2441c1634a26ef67000620b1dc11a33bc647ef0b4f26b0ce663ab9d9cd9905a4cf27c77e3fc0c93cb3a5a8cb43c36f60
|
data/README.rdoc
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
= scaffold_pico
|
2
2
|
|
3
|
-
|
3
|
+
|
4
|
+
ruby -I lib bin/scaffold_pico.rb \
|
5
|
+
--css_framework=materialize --template=slim \
|
6
|
+
-m User -n Admin
|
7
|
+
--fields name:string
|
8
|
+
--fabrication \
|
4
9
|
|
5
10
|
|
6
11
|
Used in production:
|
@@ -51,10 +56,18 @@ further details.
|
|
51
56
|
scaffold_pico.rb -m Admin::CompanyOwnerships -b AuthenticatedController -n admin \
|
52
57
|
--includes :user, :company \ <---
|
53
58
|
--css_framework=materialize \
|
54
|
-
--fields user_id: company_id: admin:boolean approved:boolean \
|
59
|
+
--fields user_id: company_id: admin:boolean approved:boolean \ <---belongsto, file fields
|
55
60
|
--index-fields user_id admin approved \
|
56
61
|
--search-fields admin approved <-- missing searchfields
|
57
62
|
|
63
|
+
scaffold_pico.rb -m Auctions::AuctionItem -b Manage::BaseController -n manage \
|
64
|
+
--includes :user :page :auction \
|
65
|
+
--css_framework=zurb --services_folder=actions\
|
66
|
+
--fields id: auction:belongs_to user:belongs_to page:belongs_to state: message:text money_wanted_by_user: money_approved_for_user: tickets_count: ended_at: claimed_at: document_1:file document_2:file document_3:file document_4:file document_5:file created_at: \
|
67
|
+
--index-fields auction user page state money_wanted_by_user \
|
68
|
+
--search-fields auction_id user_id
|
69
|
+
|
70
|
+
|
58
71
|
Started POST "/super_admin/company_ownerships" for 127.0.0.1 at 2016-05-18 21:36:21 +0300
|
59
72
|
Processing by SuperAdmin::CompanyOwnershipsController#create as HTML
|
60
73
|
Parameters: {"utf8"=>"✓", "authenticity_token"=>"OBASAkBg11kfNd0omZ6Jd4AApmCIU1Q2f9uCq/665cwf/qJva74jkS620ELii96stkPcYfLfzes0yu0i/+nKAQ==", "company_ownership"=>{"user_id"=>"1", "company_id"=>"1", "admin"=>"0", "approved"=>"0"}, "commit"=>"Създай Членство"}
|
data/lib/scaffold/cli.rb
CHANGED
@@ -6,7 +6,7 @@ module Scaffold
|
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
Choice.options do
|
9
|
-
header 'Synopsys: scaffold_pico.rb
|
9
|
+
header 'Synopsys: scaffold_pico.rb -m User -n Admin --includes :roles :company --joins :roles :company --fields name:string --fabrication'
|
10
10
|
separator ''
|
11
11
|
header 'Specific options:'
|
12
12
|
|
@@ -16,6 +16,11 @@ module Scaffold
|
|
16
16
|
desc 'print some debug info'
|
17
17
|
end
|
18
18
|
|
19
|
+
option :fabrication do
|
20
|
+
long '--fabrication'
|
21
|
+
desc 'Generate fabrication fabricator https://github.com/paulelliott/fabrication'
|
22
|
+
end
|
23
|
+
|
19
24
|
option :namespace do
|
20
25
|
short '-n'
|
21
26
|
long '--namespace=namespace1/namespace2'
|
@@ -30,7 +35,7 @@ module Scaffold
|
|
30
35
|
desc 'Optional base controller. Example: -b Admin::BaseController'
|
31
36
|
end
|
32
37
|
|
33
|
-
option :model do
|
38
|
+
option :model, :required => true do
|
34
39
|
short '-m'
|
35
40
|
long '--model=model'
|
36
41
|
desc 'The model. It could be with modules. Example: ModuleA::ModuleB::SomeClassName'
|
@@ -52,7 +57,7 @@ module Scaffold
|
|
52
57
|
option :fields do
|
53
58
|
long '-f'
|
54
59
|
long '--fields *FIELDS'
|
55
|
-
desc 'title:string body:text published:boolean amount:decimal tracking_id:integer:uniq '
|
60
|
+
desc 'title:string body:text published:boolean amount:decimal attachment:file tracking_id:integer:uniq '
|
56
61
|
end
|
57
62
|
|
58
63
|
option :index_fields do
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Scaffold
|
2
|
+
class FabricatorGenerator < Scaffold::BaseGenerator
|
3
|
+
def generate
|
4
|
+
fabricators_path = create_fabricators_path
|
5
|
+
source_file_name = "fabrication.rb.erb"
|
6
|
+
target_file_name = "#{@params.resource_name}_fabricator.rb"
|
7
|
+
source_file_path = File.join(root, templates, 'fabricators', source_file_name)
|
8
|
+
content = File.read(source_file_path)
|
9
|
+
|
10
|
+
# http://www.stuartellis.eu/articles/erb/
|
11
|
+
content = ::ERB.new(content, nil, '-').result(@params.instance_eval{ binding })#.gsub(/\s+\n$/, "")
|
12
|
+
|
13
|
+
target_file_path = File.join(fabricators_path, target_file_name)
|
14
|
+
IO.write(target_file_path, content)
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_fabricators_path
|
18
|
+
fabricators_path = File.join(Dir.pwd, 'spec', 'fabricators')
|
19
|
+
FileUtils.mkpath(fabricators_path)
|
20
|
+
fabricators_path
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lib/scaffold/main.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
module Scaffold
|
2
2
|
class Main
|
3
3
|
def initialize choice
|
4
|
-
@
|
4
|
+
@choice = choice
|
5
|
+
@params = Params.new(@choice)
|
5
6
|
end
|
6
7
|
|
7
8
|
def run
|
9
|
+
Scaffold::FabricatorGenerator.new(@params).generate if @choice[:fabrication]
|
8
10
|
Scaffold::ControllerGenerator.new(@params).generate
|
9
11
|
Scaffold::ModelsGenerator.new(@params).generate
|
10
12
|
Scaffold::ViewsGenerator.new(@params).generate
|
@@ -2,7 +2,7 @@ module Scaffold
|
|
2
2
|
class ModelsGenerator < Scaffold::BaseGenerator
|
3
3
|
def generate
|
4
4
|
searches_path = create_searches_path
|
5
|
-
puts "Don't forget to add '
|
5
|
+
puts "Don't forget to add '#{@params.services_folder}' in your autoload_paths (application.rb)"
|
6
6
|
create_search_object searches_path
|
7
7
|
end
|
8
8
|
|
data/lib/scaffold/params.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
module Scaffold
|
2
2
|
class Params
|
3
|
-
attr_reader :resource_name,
|
3
|
+
attr_reader :resource_name, # user for use in @user or filenames
|
4
|
+
:resource_class_name, # CompanyOwnership
|
5
|
+
:namespaces_array,
|
6
|
+
:controller_file_name,
|
7
|
+
:template,
|
8
|
+
:css_framework,
|
9
|
+
:views_folder_name,
|
10
|
+
:route_resource_name,
|
11
|
+
:services_folder
|
4
12
|
|
5
13
|
def expand_default_types hash
|
6
14
|
hash.each_pair do |key, value|
|
@@ -29,7 +37,7 @@ module Scaffold
|
|
29
37
|
end
|
30
38
|
|
31
39
|
# routes
|
32
|
-
@route_resource_name = @model_name.tableize #
|
40
|
+
@route_resource_name = @model_name.tableize # resourse :users
|
33
41
|
@namespace = choice[:namespace] # for the controllers
|
34
42
|
@base_controller = choice[:base_controller] || 'ApplicationController'
|
35
43
|
@namespaces_array = parse_namespaces_array(@namespace) # [:admin, ...?... ]
|
data/lib/scaffold_pico.rb
CHANGED
@@ -8,6 +8,7 @@ require 'scaffold/controller_generator'
|
|
8
8
|
require 'scaffold/models_generator'
|
9
9
|
require 'scaffold/views_generator'
|
10
10
|
require 'scaffold/routes_generator'
|
11
|
+
require 'scaffold/fabricator_generator'
|
11
12
|
require 'scaffold/template_engines/slim'
|
12
13
|
require 'erb'
|
13
14
|
require 'fileutils'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% if @modules.empty? %>
|
2
|
+
Fabricator(:company) do
|
3
|
+
<% else %>
|
4
|
+
Fabricator(:company, class_name: '<%= @modulized_resource_class_name -%>') do
|
5
|
+
<% end -%>
|
6
|
+
<% @fields.each_pair do |field_name, kind| -%>
|
7
|
+
<% if kind == 'belongs_to' -%>
|
8
|
+
<%= field_name %>
|
9
|
+
<% elsif kind == 'text' -%>
|
10
|
+
<%= field_name -%> { Faker::Lorem.sentence }
|
11
|
+
<% elsif kind == 'string' -%>
|
12
|
+
<%= field_name -%> { Faker::Lorem.word }
|
13
|
+
<% end -%>
|
14
|
+
<% end -%>
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scaffold_pico
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gudata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- lib/scaffold/base_generator.rb
|
96
96
|
- lib/scaffold/cli.rb
|
97
97
|
- lib/scaffold/controller_generator.rb
|
98
|
+
- lib/scaffold/fabricator_generator.rb
|
98
99
|
- lib/scaffold/main.rb
|
99
100
|
- lib/scaffold/models_generator.rb
|
100
101
|
- lib/scaffold/params.rb
|
@@ -103,6 +104,7 @@ files:
|
|
103
104
|
- lib/scaffold/views_generator.rb
|
104
105
|
- lib/scaffold_pico.rb
|
105
106
|
- lib/templates/pico/controller.rb.erb
|
107
|
+
- lib/templates/pico/fabricators/fabrication.rb.erb
|
106
108
|
- lib/templates/pico/search.rb.erb
|
107
109
|
- lib/templates/pico/views/materialize/slim/_form.html.slim.erb
|
108
110
|
- lib/templates/pico/views/materialize/slim/edit.html.slim.erb
|