scaffold_cn 0.1.5 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 443fc531d199a2a09930b7c24254b74ea4263774
4
- data.tar.gz: 8d8ad108cb358cb0909102784a5fd56715ccfbd2
3
+ metadata.gz: 20db374be069a7b0529846e3c980a99851cf9ed0
4
+ data.tar.gz: ddc0e6021a7b350a9d085e1118e926a4ba24615f
5
5
  SHA512:
6
- metadata.gz: 35ba3b4dc71e43b941324f2ade601e106b63958dbe30eab1f6c81e61cee6e8c76c19f9bb35554e7e9d1c09f695df901b2c1db32df8dafa7e12b1ce973eac96c8
7
- data.tar.gz: 009ddca39ed4894319b8e7c74e9090e0e73af3f95881501ff7afd21729e31dffe6f47c9fcd119fbbcf106aba9748b84c7197ec56d7913ae137a78b4b3183a2df
6
+ metadata.gz: 896bda0d63ef494ed1306d5120852b30492931ee1ec059b67f36d7c99eec491828759dd08ab43c15f6e0e7ebba6a73eb03b843d683aff65ffee71a977890e595
7
+ data.tar.gz: da3871c9e1e3b524f5475532dbb4c4aba6cd17e165d6a1ea2df74e405031c43475b8fb1b7772cc9b87fa2ffc102b81f1b49dd1654b1811c4fbbb4de70bff448a
@@ -1,15 +1,8 @@
1
1
  Description:
2
2
  Translate the scaffold templates to zh_CN.
3
3
 
4
- Example:
5
- rails g scaffold_cn
4
+ Usage:
5
+ rails g scaffold_cn [type]
6
6
 
7
- This will create:
8
- lib/templates/erb/scaffold/_form.html.erb
9
- lib/templates/erb/scaffold/edit.html.erb
10
- lib/templates/erb/scaffold/index.html.erb
11
- lib/templates/erb/scaffold/new.html.erb
12
- lib/templates/erb/scaffold/show.html.erb
13
-
14
- config/locales/model.yml
15
- config/locales/zh-CN.yml
7
+ The type is 'erb' or 'slim'.
8
+ For example, 'rails g scaffold_cn erb'
@@ -1,20 +1,28 @@
1
- #class CnGenerator < Rails::Generators::NamedBase
2
- class Scaffold_cnGenerator < Rails::Generators::Base
1
+ class ScaffoldCnGenerator < Rails::Generators::NamedBase
2
+ #class Scaffold_cnGenerator < Rails::Generators::Base
3
3
  source_root File.expand_path('../templates', __FILE__)
4
4
 
5
5
  def generate_scaffold_cn
6
- templates = [
7
- 'lib/templates/erb/scaffold/_form.html.erb',
8
- 'lib/templates/erb/scaffold/edit.html.erb',
9
- 'lib/templates/erb/scaffold/index.html.erb',
10
- 'lib/templates/erb/scaffold/new.html.erb',
11
- 'lib/templates/erb/scaffold/show.html.erb',
6
+ type = plural_name.singularize
7
+ puts "generate #{type} template files ..."
8
+ types = ['erb', 'slim']
9
+ if types.include? type
10
+ templates = [
11
+ "lib/templates/#{type}/scaffold/_form.html.#{type}",
12
+ "lib/templates/#{type}/scaffold/edit.html.#{type}",
13
+ "lib/templates/#{type}/scaffold/index.html.#{type}",
14
+ "lib/templates/#{type}/scaffold/new.html.#{type}",
15
+ "lib/templates/#{type}/scaffold/show.html.#{type}",
12
16
  'config/locales/defaults.zh_CN.yml',
13
17
  'config/locales/models.zh_CN.yml',
14
18
  'config/locales/views.zh_CN.yml',
15
19
  'config/locales/devise.zh_CN.yml']
16
- templates.each do |path|
17
- copy_file path, path
20
+ templates.each do |path|
21
+ copy_file path, path
22
+ end
23
+ else
24
+ puts "The type '#{type}' not support yet."
25
+ puts "You can choose one from [ #{types.join(',')} ]"
18
26
  end
19
27
  end
20
28
  end
@@ -0,0 +1,14 @@
1
+ = form_for @<%= singular_table_name %> do |f|
2
+ - if @<%= singular_table_name %>.errors.any?
3
+ #error_explanation
4
+ h2 = "#{pluralize(@<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
5
+ ul
6
+ - @<%= singular_table_name %>.errors.full_messages.each do |message|
7
+ li = message
8
+
9
+ <% attributes.each do |attribute| -%>
10
+ .field
11
+ = f.label :<%= attribute.name %>
12
+ = f.<%= attribute.field_type %> :<%= attribute.name %>
13
+ <% end -%>
14
+ .actions = f.submit t(:submit)
@@ -0,0 +1,8 @@
1
+ h1 = t(:edit) + <%= human_name %>.model_name.human
2
+
3
+ == render 'form'
4
+
5
+ = link_to t(:show), @<%= singular_table_name %>
6
+ '|
7
+ = link_to t(:back), <%= index_helper %>_path
8
+
@@ -0,0 +1,23 @@
1
+ h1 = <%= human_name %>.model_name.human + t(:index)
2
+
3
+ table
4
+ tr
5
+ <% attributes.each do |attribute| -%>
6
+ th = <%= human_name %>.human_attribute_name("<%= attribute.name %>")
7
+ <% end -%>
8
+ th
9
+ th
10
+ th
11
+
12
+ - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
13
+ tr
14
+ <% attributes.each do |attribute| -%>
15
+ td = <%= singular_table_name %>.<%= attribute.name %>
16
+ <% end -%>
17
+ td = link_to t(:show), <%= singular_table_name %>
18
+ td = link_to t(:edit), edit_<%= singular_table_name %>_path(<%= singular_table_name %>)
19
+ td = link_to t(:delete), <%= singular_table_name %>, :confirm => t(:confirm_delete), :method => :delete
20
+
21
+ br
22
+
23
+ = link_to (t(:new) + <%= human_name %>.model_name.human), new_<%= singular_table_name %>_path
@@ -0,0 +1,5 @@
1
+ h1 = t(:new) + <%= human_name %>.model_name.human
2
+
3
+ == render 'form'
4
+
5
+ = link_to t(:back), <%= index_helper %>_path
@@ -0,0 +1,11 @@
1
+ p#notice = notice
2
+
3
+ <% attributes.each do |attribute| -%>
4
+ p
5
+ strong = <%= human_name %>.human_attribute_name("<%= attribute.name %>") + ':'
6
+ = @<%= singular_table_name %>.<%= attribute.name %>
7
+ <% end -%>
8
+
9
+ = link_to t(:edit), edit_<%= singular_table_name %>_path(@<%= singular_table_name %>)
10
+ '|
11
+ = link_to t(:back), <%= index_helper %>_path
@@ -1,3 +1,3 @@
1
1
  module ScaffoldCn
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scaffold_cn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - homeway
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-03 00:00:00.000000000 Z
11
+ date: 2013-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -41,6 +41,11 @@ files:
41
41
  - lib/generators/scaffold_cn/templates/lib/templates/erb/scaffold/index.html.erb
42
42
  - lib/generators/scaffold_cn/templates/lib/templates/erb/scaffold/new.html.erb
43
43
  - lib/generators/scaffold_cn/templates/lib/templates/erb/scaffold/show.html.erb
44
+ - lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/_form.html.slim
45
+ - lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/edit.html.slim
46
+ - lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/index.html.slim
47
+ - lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/new.html.slim
48
+ - lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/show.html.slim
44
49
  - lib/generators/scaffold_cn/USAGE
45
50
  - lib/scaffold_cn/version.rb
46
51
  - lib/scaffold_cn.rb