controller_scaffolding 1.0.4 → 1.1.0
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.md +11 -2
- data/lib/controller_scaffolding/version.rb +1 -1
- data/lib/generators/controller/controller_scaffolding_generator.rb +5 -3
- data/lib/generators/haml/controller/controller_scaffolding_generator.rb +24 -17
- data/test/dummy/app/models/dinosaur.rb +2 -0
- data/test/dummy/config/locales/en.yml +18 -24
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20140806202909_create_dinosaurs.rb +11 -0
- data/test/dummy/db/schema.rb +9 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/OLDtest.log +78896 -0
- data/test/dummy/log/development.log +41 -0
- data/test/dummy/log/test.log +9286 -36126
- data/test/dummy/spec/requests/people_spec.rb +7 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/lib/generators/controller_scaffolding_generator_test.rb +19 -2
- data/test/lib/generators/destroy_cs_test.rb +41 -0
- data/test/lib/generators/dummy_test_files/app/models/dinosaur.rb +8 -0
- data/test/lib/generators/dummy_test_files/config/locales/en.yml +0 -20
- data/test/lib/generators/ext_controller_scaffolding_generator_test.rb +4 -4
- data/test/lib/generators/mult_model_cs_test.rb +101 -0
- data/test/lib/tmp/app/models/dinosaur.rb +8 -0
- data/test/lib/tmp/config/locales/en.yml +14 -25
- data/test/test_helper.rb +56 -0
- metadata +30 -4
- data/test/controller_scaffolding_test.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d15324bcb4113f23fcdb1d8511c62391ea5acde
|
4
|
+
data.tar.gz: 5fb7433753516ace78210991a5a6d1b931a88716
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 729298a36cf88deb7f9c18e336985612d5178615de50537af795e2b140e62fdb0c37f042b5ce0454980a38c54c84bb1f255e8120139db4f20518a8281c32b7b7
|
7
|
+
data.tar.gz: 083dec941527e785d4a70233bf350d9eccdc071317988281d7ef81027eb04ef8f4eaf32c5270058d2f9d4073116bda90195cade8ae7fd081514825640b0f83d2
|
data/README.md
CHANGED
@@ -7,6 +7,9 @@ The generator acts somewhat like scaffolding, but you must specify an *existing*
|
|
7
7
|
|
8
8
|
\* https://github.com/jomalley2112/sql_search_n_sort
|
9
9
|
|
10
|
+
#### Current Issues ####
|
11
|
+
* made 2 intermittently failing specs in people_spec pending
|
12
|
+
|
10
13
|
#### Index page ####
|
11
14
|

|
12
15
|
---
|
@@ -22,7 +25,7 @@ and then run `bundle install`
|
|
22
25
|
#### Usage ####
|
23
26
|
```bash
|
24
27
|
$ rails g|d controller_scaffolding users index new create edit update destroy --template-engine=haml
|
25
|
-
[--skip-ext-index-nav] [--skip-ext-form-submit] [--skip-assets] [--skip-test-framework] [--skip-helper] [--quiet] [--force] [
|
28
|
+
[--skip-ext-index-nav] [--skip-ext-form-submit] [--skip-assets] [--skip-test-framework] [--skip-helper] [--quiet] [--force] [--skip-search-sort]
|
26
29
|
```
|
27
30
|
|
28
31
|
*Note: You must restart Rails after running this generator*
|
@@ -42,7 +45,7 @@ $ rails g|d controller_scaffolding users index new create edit update destroy --
|
|
42
45
|
| --skip-helper | Do not create helper file | yes |
|
43
46
|
| --quiet | Suppress info messages | yes |
|
44
47
|
| --force | Overwrite files without prompting | yes |
|
45
|
-
| --skip-search-sort | Do not include search or sort
|
48
|
+
| --skip-search-sort | Do not include search or sort functionality | yes |
|
46
49
|
|
47
50
|
### Description of generator actions ###
|
48
51
|
|
@@ -87,6 +90,10 @@ $ rails g|d controller_scaffolding users index new create edit update destroy --
|
|
87
90
|
#### Search and Sort ####
|
88
91
|
* see README.md at https://github.com/jomalley2112/sql_search_n_sort
|
89
92
|
|
93
|
+
### Testing ###
|
94
|
+
* Generator tests: run `rake test` from the root directory.
|
95
|
+
* Integration test specs: run `rspec spec` from 'test/dummy'
|
96
|
+
|
90
97
|
### Gem dependencies ###
|
91
98
|
#### Dependencies ####
|
92
99
|
- 'rails', '~> 4.1'
|
@@ -105,6 +112,8 @@ $ rails g|d controller_scaffolding users index new create edit update destroy --
|
|
105
112
|
- "database_cleaner"
|
106
113
|
|
107
114
|
#### TODO ####
|
115
|
+
- See if we can support case where existing model has been removed after generator has been run and then the user decides to uninstall (revoke) controller_scaffolding.
|
108
116
|
- Do something with template engine hook so Haml doesn't need to be specified in the generator call
|
109
117
|
- Add search results message like "9 Results match 'you search string'"
|
118
|
+
- Nail down versions for dependencies
|
110
119
|
|
@@ -1,7 +1,9 @@
|
|
1
1
|
#CONTROLLER GENERATOR
|
2
|
+
#To Teardown manually:
|
3
|
+
# rails d controller_scaffolding people index new create edit update destroy custom_action --template-engine=haml
|
2
4
|
|
3
5
|
require 'rails/generators/generated_attribute'
|
4
|
-
|
6
|
+
|
5
7
|
|
6
8
|
module Rails
|
7
9
|
module Generators
|
@@ -49,12 +51,12 @@ module Rails
|
|
49
51
|
@actions = actions.nil? || actions.empty? ? %w(index new create edit update destroy) : actions
|
50
52
|
end
|
51
53
|
|
52
|
-
def check_for_model
|
54
|
+
def check_for_model #TODO: only do if behavior = :invoke maybe?
|
53
55
|
begin
|
54
56
|
table_name.classify.constantize #throws runtime if model doesn't exist
|
55
57
|
rescue
|
56
58
|
raise Thor::Error,
|
57
|
-
"Cannot run controller scaffold for model (#{table_name}) that doesn't yet exist."
|
59
|
+
"Cannot run controller scaffold for model (#{table_name.constantize}) that doesn't yet exist."
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
@@ -1,5 +1,8 @@
|
|
1
1
|
#TEMPLATE GENERATOR & FILE COPIER
|
2
2
|
|
3
|
+
#To Teardown manually:
|
4
|
+
# rails d controller_scaffolding people index new create edit update destroy custom_action --template-engine=haml
|
5
|
+
|
3
6
|
require 'rails/generators/erb/controller/controller_generator'
|
4
7
|
require 'rails/generators/erb/scaffold/scaffold_generator'
|
5
8
|
|
@@ -148,23 +151,27 @@ module Haml
|
|
148
151
|
end
|
149
152
|
|
150
153
|
def add_pagination_to_locale_file
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
154
|
+
#TODO: Could put some kind of logic in here when revoking that removes some lines
|
155
|
+
# from the locale file, but it shouldn't hurt anything if we don't
|
156
|
+
lang = I18n.locale.to_s
|
157
|
+
locale_config = YAML.load_file("#{destination_root}/config/locales/#{lang}.yml")
|
158
|
+
locale_config[I18n.locale.to_s] = {} unless locale_config[lang]
|
159
|
+
lc_wp = locale_config[I18n.locale.to_s]['will_paginate'] ||=
|
160
|
+
locale_config[I18n.locale.to_s]['will_paginate'] = {}
|
161
|
+
wp_models = lc_wp['models'] || lc_wp['models'] = {}
|
162
|
+
curr_model = wp_models[table_name] ||
|
163
|
+
wp_models[table_name] = { "zero"=>table_name.humanize,
|
164
|
+
"one"=>file_name.singularize.humanize,
|
165
|
+
"other"=>table_name.humanize }
|
166
|
+
wp_pei = lc_wp['page_entries_info'] || lc_wp['page_entries_info'] = {}
|
167
|
+
pei_mph = wp_pei['multi_page_html'] || wp_pei['multi_page_html'] =
|
168
|
+
"Displaying <b>%{from} - %{to}</b> of <b>%{count}</b> %{model}"
|
169
|
+
|
170
|
+
pei_sph = wp_pei['single_page_html'] || wp_pei['single_page_html'] = {}
|
171
|
+
pei_sph['zero'] || pei_sph['zero'] = "No %{model} found"
|
172
|
+
pei_sph['one'] || pei_sph['one'] = "Displaying <b>1</b> %{model}"
|
173
|
+
pei_sph['other'] || pei_sph['other'] = "Displaying <b>all %{count}</b> %{model}"
|
174
|
+
File.open("#{destination_root}/config/locales/#{lang}.yml", "w") { |f| YAML.dump(locale_config, f) }
|
168
175
|
end
|
169
176
|
|
170
177
|
def file_action(path)
|
@@ -1,25 +1,19 @@
|
|
1
|
-
|
2
|
-
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
-
# than English, add the necessary files in this directory.
|
4
|
-
#
|
5
|
-
# To use the locales, use `I18n.t`:
|
6
|
-
#
|
7
|
-
# I18n.t 'hello'
|
8
|
-
#
|
9
|
-
# In views, this is aliased to just `t`:
|
10
|
-
#
|
11
|
-
# <%= t('hello') %>
|
12
|
-
#
|
13
|
-
# To use a different locale, set it with `I18n.locale`:
|
14
|
-
#
|
15
|
-
# I18n.locale = :es
|
16
|
-
#
|
17
|
-
# This would use the information in config/locales/es.yml.
|
18
|
-
#
|
19
|
-
# To learn more, please read the Rails Internationalization guide
|
20
|
-
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
-
|
1
|
+
---
|
22
2
|
en:
|
23
|
-
|
24
|
-
|
25
|
-
|
3
|
+
will_paginate:
|
4
|
+
models:
|
5
|
+
people:
|
6
|
+
zero: People
|
7
|
+
one: Person
|
8
|
+
other: People
|
9
|
+
credit_card_infos:
|
10
|
+
zero: Credit card infos
|
11
|
+
one: Credit card info
|
12
|
+
other: Credit card infos
|
13
|
+
page_entries_info:
|
14
|
+
multi_page_html: Displaying <b>%{from} - %{to}</b> of <b>%{count}</b>
|
15
|
+
%{model}
|
16
|
+
single_page_html:
|
17
|
+
zero: No %{model} found
|
18
|
+
one: Displaying <b>1</b> %{model}
|
19
|
+
other: Displaying <b>all %{count}</b> %{model}
|
Binary file
|
data/test/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20140806202909) do
|
15
15
|
|
16
16
|
create_table "credit_card_infos", force: true do |t|
|
17
17
|
t.string "cardholder"
|
@@ -21,6 +21,14 @@ ActiveRecord::Schema.define(version: 20140731014857) do
|
|
21
21
|
t.datetime "updated_at"
|
22
22
|
end
|
23
23
|
|
24
|
+
create_table "dinosaurs", force: true do |t|
|
25
|
+
t.string "name"
|
26
|
+
t.string "age"
|
27
|
+
t.boolean "good_dino"
|
28
|
+
t.datetime "created_at"
|
29
|
+
t.datetime "updated_at"
|
30
|
+
end
|
31
|
+
|
24
32
|
create_table "people", force: true do |t|
|
25
33
|
t.string "first_name"
|
26
34
|
t.string "last_name"
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|