scaffold_pico 0.2.3 → 0.2.4
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.
- checksums.yaml +4 -4
- data/README.rdoc +33 -6
- data/lib/scaffold/cli.rb +7 -0
- data/lib/scaffold/models_generator.rb +1 -1
- data/lib/scaffold/params.rb +4 -4
- data/lib/templates/pico/search.rb.erb +7 -3
- data/lib/templates/pico/views/materialize/slim/index.html.slim.erb +3 -3
- data/lib/templates/pico/views/zurb/slim/index.html.slim.erb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e19a7250e48783d7ecea85cdcaee1d7d909c4ef4
|
4
|
+
data.tar.gz: 33f1da79febd07343c6949c3ea7945818caef1fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6f67fe57933324dc8bb505dc68c645421087714348bf407d45fe7906c930ab2be07092124ef12bbda1d4830c9cd5db1a9e0391d4251696211ed468d66501da1
|
7
|
+
data.tar.gz: e168b3d924e1fe54ba0312983781371ddf37a0a819e9404497f17da879c6ad39b8ed022216aa88a219009fee88f3c555e03c1068ae1edc4b1d13cb64c6a48dd0
|
data/README.rdoc
CHANGED
@@ -2,20 +2,26 @@
|
|
2
2
|
|
3
3
|
ruby -I lib bin/scaffold_pico.rb --css_framework=zurb --template=slim -m user -n Admin -i :roles :company -j :roles :company --fields name:string
|
4
4
|
|
5
|
-
scaffold_pico.rb -m Admin::User -n admin/gosho -i :roles :company -j :roles :company --fields name:string
|
6
5
|
|
7
|
-
|
6
|
+
Used in production:
|
7
|
+
scaffold_pico.rb -m Company -n super_admin --fields name:string website:string active:string subscription:string contact_person:string
|
8
8
|
|
9
|
+
scaffold_pico.rb -m CompanyOwnerships -b AuthenticatedController -n admin \
|
10
|
+
--includes :user :company \
|
11
|
+
--css_framework=materialize \
|
12
|
+
--fields user_id: company_id: admin:boolean approved:boolean \
|
13
|
+
--index-fields user_id admin approved \
|
14
|
+
--search-fields admin approved
|
9
15
|
|
10
|
-
|
16
|
+
scaffold_pico.rb -m Admin::Assistant -n administation/pencho --fields first_name:string last_name:string
|
11
17
|
|
12
|
-
|
13
|
-
|
18
|
+
Example with options:
|
19
|
+
scaffold_pico.rb -d --css_framework=materialize \
|
14
20
|
-m Vector -n manage -b AdminController \
|
15
21
|
--fields name: featured:boolean aspect_ratio: portrait:boolean landscape:boolean imported:boolean trending:boolean width:integer height:integer transperant:boolean bw:boolean license:belongs_to group_id:integer tool:belongs_to user_id: category_id: category_display_order:integer group_display_order:integer svg:file ai:file png:file emf:file wmf:file \
|
16
22
|
--index-fields id name imported featured \
|
17
23
|
--search-fields name aspect_ratio landscape portrait imported featured trending width height transperant bw license_id group_id tool_id user_id category_id
|
18
|
-
|
24
|
+
--services_folder=services
|
19
25
|
|
20
26
|
== I18n
|
21
27
|
|
@@ -37,3 +43,24 @@ en.yml:
|
|
37
43
|
Copyright (c) 2016 gudata. See LICENSE.txt for
|
38
44
|
further details.
|
39
45
|
|
46
|
+
|
47
|
+
|
48
|
+
2fix
|
49
|
+
|
50
|
+
|
51
|
+
scaffold_pico.rb -m Admin::CompanyOwnerships -b AuthenticatedController -n admin \
|
52
|
+
--includes :user, :company \ <---
|
53
|
+
--css_framework=materialize \
|
54
|
+
--fields user_id: company_id: admin:boolean approved:boolean \
|
55
|
+
--index-fields user_id admin approved \
|
56
|
+
--search-fields admin approved <-- missing searchfields
|
57
|
+
|
58
|
+
Started POST "/super_admin/company_ownerships" for 127.0.0.1 at 2016-05-18 21:36:21 +0300
|
59
|
+
Processing by SuperAdmin::CompanyOwnershipsController#create as HTML
|
60
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"OBASAkBg11kfNd0omZ6Jd4AApmCIU1Q2f9uCq/665cwf/qJva74jkS620ELii96stkPcYfLfzes0yu0i/+nKAQ==", "company_ownership"=>{"user_id"=>"1", "company_id"=>"1", "admin"=>"0", "approved"=>"0"}, "commit"=>"Създай Членство"}
|
61
|
+
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 4], ["LIMIT", 1]]
|
62
|
+
Unpermitted parameters: user_id, company_id <---
|
63
|
+
|
64
|
+
|
65
|
+
services/action folder param
|
66
|
+
auction = auction.where(name: name) if self.name.present?
|
data/lib/scaffold/cli.rb
CHANGED
@@ -85,6 +85,13 @@ module Scaffold
|
|
85
85
|
desc 'zurb'
|
86
86
|
end
|
87
87
|
|
88
|
+
option :services_folder do
|
89
|
+
long '--services_folder=services'
|
90
|
+
validate /\A(\w+(?:\/\w+)*)\z/
|
91
|
+
desc 'Where to put the search model. Example: --services=actions'
|
92
|
+
end
|
93
|
+
|
94
|
+
|
88
95
|
separator ''
|
89
96
|
separator 'Common options: '
|
90
97
|
|
@@ -20,7 +20,7 @@ module Scaffold
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def create_searches_path
|
23
|
-
searches_path = File.join(Dir.pwd, 'app',
|
23
|
+
searches_path = File.join(Dir.pwd, 'app', @params.services_folder, 'search', @params.namespaces_array)
|
24
24
|
FileUtils.mkpath(searches_path)
|
25
25
|
searches_path
|
26
26
|
end
|
data/lib/scaffold/params.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Scaffold
|
2
2
|
class Params
|
3
|
-
attr_reader :resource_name, :namespaces_array, :controller_file_name, :template, :css_framework, :views_folder_name, :route_resource_name
|
3
|
+
attr_reader :resource_name, :namespaces_array, :controller_file_name, :template, :css_framework, :views_folder_name, :route_resource_name, :services_folder
|
4
4
|
|
5
5
|
def expand_default_types hash
|
6
6
|
hash.each_pair do |key, value|
|
@@ -35,12 +35,11 @@ module Scaffold
|
|
35
35
|
@namespaces_array = parse_namespaces_array(@namespace) # [:admin, ...?... ]
|
36
36
|
|
37
37
|
# controller
|
38
|
-
@controller_namespaces = @namespace.camelize
|
39
|
-
|
40
38
|
if @namespaces_array.blank?
|
41
39
|
@controller_class_name = "#{@model_name.pluralize}Controller"
|
42
40
|
@search_modulized_resource_class_name = "Search::#{@resource_class_name}Search"
|
43
41
|
else
|
42
|
+
@controller_namespaces = @namespace.camelize
|
44
43
|
@controller_class_name = "#{@controller_namespaces}::#{@model_name.pluralize}Controller"
|
45
44
|
@search_modulized_resource_class_name = "Search::#{@controller_namespaces}::#{@resource_class_name.pluralize}Search"
|
46
45
|
end
|
@@ -63,6 +62,7 @@ module Scaffold
|
|
63
62
|
|
64
63
|
@collection_path = @path_segments.dup << @collection_name.to_sym
|
65
64
|
|
65
|
+
@services_folder = choice[:services_folder]
|
66
66
|
debug_info if choice[:debug]
|
67
67
|
end
|
68
68
|
|
@@ -90,7 +90,7 @@ module Scaffold
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def parse_namespaces_array namespace
|
93
|
-
namespace.split('/').collect{|name| name.underscore}
|
93
|
+
(namespace || "").split('/').collect{|name| name.underscore}
|
94
94
|
end
|
95
95
|
|
96
96
|
def hasherize_fields fields_array
|
@@ -10,11 +10,15 @@ class <%= @search_modulized_resource_class_name %>
|
|
10
10
|
|
11
11
|
def results
|
12
12
|
<%= @resource_name %> = <%= @modulized_resource_class_name %>
|
13
|
-
<% @search_fields.
|
14
|
-
|
13
|
+
<% @fields.select {|k,v| @search_fields.include?(k) }.each_pair do |field_name, field_type| %>
|
14
|
+
<%- if field_type == "string" %>
|
15
|
+
<%= @resource_name %> = <%= @resource_name %>.where("<%= field_name %> LIKE ?", "%#{<%= field_name %>}%") if self.<%= field_name %>.present?
|
16
|
+
<%- else %>
|
17
|
+
<%= @resource_name %> = <%= @resource_name %>.where(<%= field_name %>: <%= field_name %>) if self.<%= field_name %>.present?
|
18
|
+
<%- end %>
|
15
19
|
<% end %>
|
16
20
|
|
17
21
|
<%= @resource_name %>
|
18
22
|
end
|
19
23
|
|
20
|
-
end
|
24
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
h1 = t('scaffold.index.title', model: <%= @
|
1
|
+
h1 = t('scaffold.index.title', model: <%= @modulized_resource_class_name %>.model_name.human(count: 2))
|
2
2
|
|
3
3
|
= link_to <%= @new_resource_path %>, class: 'btn waves-effect waves-light' do
|
4
4
|
i.material-icons.right add
|
5
|
-
= t('scaffold.actions.new', model: <%= @
|
5
|
+
= t('scaffold.actions.new', model: <%= @modulized_resource_class_name %>.model_name.human(count: 1).mb_chars.downcase)
|
6
6
|
|
7
7
|
.row
|
8
8
|
.col.s12.m9
|
@@ -12,7 +12,7 @@ h1 = t('scaffold.index.title', model: <%= @resource_class_name %>.model_name.hum
|
|
12
12
|
thead
|
13
13
|
tr
|
14
14
|
<% @fields.select {|k,v| @index_fields.include?(k) }.keys.each do |field_name| %>
|
15
|
-
th = <%= @
|
15
|
+
th = <%= @modulized_resource_class_name -%>.human_attribute_name(:<%= field_name -%>)
|
16
16
|
<% end %>
|
17
17
|
th colspan=3 = t('scaffold.index.actions')
|
18
18
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
h1 = t('scaffold.index.title', model: <%= @
|
1
|
+
h1 = t('scaffold.index.title', model: <%= @modulized_resource_class_name %>.model_name.human(count: 2).mb_chars.downcase)
|
2
2
|
|
3
|
-
= link_to t('scaffold.actions.new', model: <%= @
|
3
|
+
= link_to t('scaffold.actions.new', model: <%= @modulized_resource_class_name %>.model_name.human.mb_chars.downcase), <%= @new_resource_path %>, class: 'button small secondary'
|
4
4
|
|
5
5
|
.row
|
6
6
|
.small-12.medium-10.columns
|
@@ -8,7 +8,7 @@ h1 = t('scaffold.index.title', model: <%= @resource_class_name %>.model_name.hum
|
|
8
8
|
thead
|
9
9
|
tr
|
10
10
|
<% @fields.select {|k,v| @index_fields.include?(k) }.keys.each do |field_name| %>
|
11
|
-
th = <%= @
|
11
|
+
th = <%= @modulized_resource_class_name -%>.human_attribute_name(:<%= field_name -%>)
|
12
12
|
<% end %>
|
13
13
|
th colspan=3 = t('scaffold.index.actions')
|
14
14
|
|
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.4
|
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-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|