controller_scaffolding 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -2
  3. data/lib/controller_scaffolding/version.rb +1 -1
  4. data/lib/generators/controller/controller_scaffolding_generator.rb +5 -3
  5. data/lib/generators/haml/controller/controller_scaffolding_generator.rb +24 -17
  6. data/test/dummy/app/models/dinosaur.rb +2 -0
  7. data/test/dummy/config/locales/en.yml +18 -24
  8. data/test/dummy/db/development.sqlite3 +0 -0
  9. data/test/dummy/db/migrate/20140806202909_create_dinosaurs.rb +11 -0
  10. data/test/dummy/db/schema.rb +9 -1
  11. data/test/dummy/db/test.sqlite3 +0 -0
  12. data/test/dummy/log/OLDtest.log +78896 -0
  13. data/test/dummy/log/development.log +41 -0
  14. data/test/dummy/log/test.log +9286 -36126
  15. data/test/dummy/spec/requests/people_spec.rb +7 -0
  16. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  17. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  18. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  19. data/test/lib/generators/controller_scaffolding_generator_test.rb +19 -2
  20. data/test/lib/generators/destroy_cs_test.rb +41 -0
  21. data/test/lib/generators/dummy_test_files/app/models/dinosaur.rb +8 -0
  22. data/test/lib/generators/dummy_test_files/config/locales/en.yml +0 -20
  23. data/test/lib/generators/ext_controller_scaffolding_generator_test.rb +4 -4
  24. data/test/lib/generators/mult_model_cs_test.rb +101 -0
  25. data/test/lib/tmp/app/models/dinosaur.rb +8 -0
  26. data/test/lib/tmp/config/locales/en.yml +14 -25
  27. data/test/test_helper.rb +56 -0
  28. metadata +30 -4
  29. data/test/controller_scaffolding_test.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ce0c5472647af7643c8d093ba2022f779c34f3b
4
- data.tar.gz: 444dbed8858978aad01a3b20d2d958b74abf7cf0
3
+ metadata.gz: 4d15324bcb4113f23fcdb1d8511c62391ea5acde
4
+ data.tar.gz: 5fb7433753516ace78210991a5a6d1b931a88716
5
5
  SHA512:
6
- metadata.gz: f37f7db035f31330dd471d69e68f8a60e52d714d60ebed1586f2f548fa6a38ae3874e1163d4762dabd3d0d070baea3c0c8eeaf13ed89d398f56c8cb242ef2b89
7
- data.tar.gz: a29711151a8c3d127aa70294a14529e017f6bc1c5a1f850bb2b44278a21cb36a7a732fc9804699c32558dc7f872f9acb152411a4482eccc3073ac3e5048b8126
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
  ![Index](/readme_assets/index_ss.png?raw=true "Index")
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] [---skip-search-sort]
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 fucntionality | yes |
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,3 +1,3 @@
1
1
  module ControllerScaffolding
2
- VERSION = "1.0.4"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -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
- #require 'pry-rails'
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
- inject_into_file "config/locales/en.yml",
152
- after: "\nen:\n" do
153
- %Q{\n
154
- will_paginate:
155
- models:
156
- people:
157
- zero: People
158
- one: Person
159
- other: People
160
- page_entries_info:
161
- multi_page_html: "Displaying <b>%{from}&nbsp;-&nbsp;%{to}</b> of <b>%{count}</b> %{model}"
162
- single_page_html:
163
- zero: "No %{model} found"
164
- one: "Displaying <b>1</b> %{model}"
165
- other: "Displaying <b>all&nbsp;%{count}</b> %{model}"
166
- }
167
- end
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}&nbsp;-&nbsp;%{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&nbsp;%{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)
@@ -0,0 +1,2 @@
1
+ class Dinosaur < ActiveRecord::Base
2
+ end
@@ -1,25 +1,19 @@
1
- # Files in the config/locales directory are used for internationalization
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}&nbsp;-&nbsp;%{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&nbsp;%{count}</b> %{model}
Binary file
@@ -0,0 +1,11 @@
1
+ class CreateDinosaurs < ActiveRecord::Migration
2
+ def change
3
+ create_table :dinosaurs do |t|
4
+ t.string :name
5
+ t.string :age
6
+ t.boolean :good_dino
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -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: 20140731014857) do
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"
Binary file