scaffold_pico 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01ed0d0a8a59adbc57c39dbc8a8bf930e8e7171b
4
- data.tar.gz: 2f0dd10cb828c05079a94a47060b3bde5958fade
3
+ metadata.gz: e19a7250e48783d7ecea85cdcaee1d7d909c4ef4
4
+ data.tar.gz: 33f1da79febd07343c6949c3ea7945818caef1fe
5
5
  SHA512:
6
- metadata.gz: 616d2848206de87163b6ed3fca98d23bcfa0424958a337ea2f6bd5901c392ce27d621958cee9d7f64f139c2f98517d568bee1994b393ba379b334997afc87898
7
- data.tar.gz: b6c379c22b317c8a5f06e0e68b1af018b4caf9bd80b86306c834e8e3db346f240fd3d412892dbe45bfd5c67d141c4936a7b4d40f80cb0f14a32977548839920e
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
- ruby -I ~/scaffold_pico/lib ~/scaffold_pico/bin/scaffold_pico.rb -m Admin::Assistant -n administation/pencho --fields first_name:string last_name:string
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
- ruby -I ~/scaffold_pico/lib ~/scaffold_pico/bin/scaffold_pico.rb -m Company -n super_admin --fields name:string website:string active:string subscription:string contact_person:string
16
+ scaffold_pico.rb -m Admin::Assistant -n administation/pencho --fields first_name:string last_name:string
11
17
 
12
-
13
- ruby -I ~/scaffold_pico/lib ~/scaffold_pico/bin/scaffold_pico.rb -d --css_framework=materialize \
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', 'services', 'search', @params.namespaces_array)
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
@@ -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.each do |field_name| %>
14
- <%= @resource_name %> = <%= @resource_name %>.where(<%= field_name %>: <%= field_name %>) if self.<%= field_name %>.present?
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: <%= @resource_class_name %>.model_name.human(count: 2))
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: <%= @resource_class_name %>.model_name.human(count: 1).mb_chars.downcase)
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 = <%= @resource_class_name -%>.human_attribute_name(:<%= field_name -%>)
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: <%= @resource_class_name %>.model_name.human(count: 2).mb_chars.downcase)
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: <%= @resource_class_name %>.model_name.human.mb_chars.downcase), <%= @new_resource_path %>, class: 'button small secondary'
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 = <%= @resource_class_name -%>.human_attribute_name(:<%= field_name -%>)
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.3
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-05-12 00:00:00.000000000 Z
11
+ date: 2016-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport