we_bridge-html_builder 0.1.0 → 0.1.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: b359e4541ed719ea2c520f59daa759f12f46d6b2
4
- data.tar.gz: a85de7784329434fb4c840b3bc9783e57e059dc7
3
+ metadata.gz: c159c66bbe5af58050eacd2fa2d3febf9752bd2e
4
+ data.tar.gz: 29572d033f893511147468e0e9ac1bd631218a61
5
5
  SHA512:
6
- metadata.gz: 6ab20ec0eadfc92ef2bcd93b0fd5c83e4eed61a3680e25a0418a6fc76d3b56a8b951fcc3e353a2d1ae05ea1a7c19d714bf7e2775537e2974bb71ea12835545af
7
- data.tar.gz: dbed42788c8a7cda945c3b2cf1dbcb65bb3583ca6754795111eea888bfe864b8acaeeda031dcc1b49239483e49104ff43a7d42099a06911731cdbe62f3fb7c17
6
+ metadata.gz: e87c60be7dc2457a131e11531887c9dd5610b2830b23b794704ae0418d2e908c1633931953a083b31a67580880a57c46bf6c82d21daa19659f4dfb0cac3c2993
7
+ data.tar.gz: fc203f6f3132cfb97bfdfb608f2781d3268460d4667bb69a9a0b0e70b52a9fc029098581889239303f1f80c4c801ee54174a7adb5dcf02c975f790791e1ab12e
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  /vendor
10
+ /app
data/Gemfile CHANGED
@@ -4,4 +4,6 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'nokogiri'
7
- gem 'actionview'
7
+ gem 'actionview'
8
+ gem 'rails', '>= 4.0'
9
+ gem 'rspec'
@@ -1,35 +1,78 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- we_bridge-html_builder (0.1.0)
4
+ we_bridge-html_builder (0.1.4)
5
5
  nokogiri
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ actionmailer (4.2.3)
11
+ actionpack (= 4.2.3)
12
+ actionview (= 4.2.3)
13
+ activejob (= 4.2.3)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ actionpack (4.2.3)
17
+ actionview (= 4.2.3)
18
+ activesupport (= 4.2.3)
19
+ rack (~> 1.6)
20
+ rack-test (~> 0.6.2)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
10
23
  actionview (4.2.3)
11
24
  activesupport (= 4.2.3)
12
25
  builder (~> 3.1)
13
26
  erubis (~> 2.7.0)
14
27
  rails-dom-testing (~> 1.0, >= 1.0.5)
15
28
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ activejob (4.2.3)
30
+ activesupport (= 4.2.3)
31
+ globalid (>= 0.3.0)
32
+ activemodel (4.2.3)
33
+ activesupport (= 4.2.3)
34
+ builder (~> 3.1)
35
+ activerecord (4.2.3)
36
+ activemodel (= 4.2.3)
37
+ activesupport (= 4.2.3)
38
+ arel (~> 6.0)
16
39
  activesupport (4.2.3)
17
40
  i18n (~> 0.7)
18
41
  json (~> 1.7, >= 1.7.7)
19
42
  minitest (~> 5.1)
20
43
  thread_safe (~> 0.3, >= 0.3.4)
21
44
  tzinfo (~> 1.1)
45
+ arel (6.0.2)
22
46
  builder (3.2.2)
23
47
  diff-lcs (1.2.5)
24
48
  erubis (2.7.0)
49
+ globalid (0.3.5)
50
+ activesupport (>= 4.1.0)
25
51
  i18n (0.7.0)
26
52
  json (1.8.3)
27
53
  loofah (2.0.2)
28
54
  nokogiri (>= 1.5.9)
55
+ mail (2.6.3)
56
+ mime-types (>= 1.16, < 3)
57
+ mime-types (2.6.1)
29
58
  mini_portile (0.6.2)
30
59
  minitest (5.7.0)
31
60
  nokogiri (1.6.6.2)
32
61
  mini_portile (~> 0.6.0)
62
+ rack (1.6.4)
63
+ rack-test (0.6.3)
64
+ rack (>= 1.0)
65
+ rails (4.2.3)
66
+ actionmailer (= 4.2.3)
67
+ actionpack (= 4.2.3)
68
+ actionview (= 4.2.3)
69
+ activejob (= 4.2.3)
70
+ activemodel (= 4.2.3)
71
+ activerecord (= 4.2.3)
72
+ activesupport (= 4.2.3)
73
+ bundler (>= 1.3.0, < 2.0)
74
+ railties (= 4.2.3)
75
+ sprockets-rails
33
76
  rails-deprecated_sanitizer (1.0.3)
34
77
  activesupport (>= 4.2.0.alpha)
35
78
  rails-dom-testing (1.0.6)
@@ -38,6 +81,11 @@ GEM
38
81
  rails-deprecated_sanitizer (>= 1.0.1)
39
82
  rails-html-sanitizer (1.0.2)
40
83
  loofah (~> 2.0)
84
+ railties (4.2.3)
85
+ actionpack (= 4.2.3)
86
+ activesupport (= 4.2.3)
87
+ rake (>= 0.8.7)
88
+ thor (>= 0.18.1, < 2.0)
41
89
  rake (10.4.2)
42
90
  rspec (3.3.0)
43
91
  rspec-core (~> 3.3.0)
@@ -52,6 +100,13 @@ GEM
52
100
  diff-lcs (>= 1.2.0, < 2.0)
53
101
  rspec-support (~> 3.3.0)
54
102
  rspec-support (3.3.0)
103
+ sprockets (3.2.0)
104
+ rack (~> 1.0)
105
+ sprockets-rails (2.3.2)
106
+ actionpack (>= 3.0)
107
+ activesupport (>= 3.0)
108
+ sprockets (>= 2.8, < 4.0)
109
+ thor (0.19.1)
55
110
  thread_safe (0.3.5)
56
111
  tzinfo (1.2.2)
57
112
  thread_safe (~> 0.1)
@@ -63,6 +118,7 @@ DEPENDENCIES
63
118
  actionview
64
119
  bundler (~> 1.10)
65
120
  nokogiri
121
+ rails (>= 4.0)
66
122
  rake (~> 10.0)
67
123
  rspec
68
124
  we_bridge-html_builder!
@@ -0,0 +1,15 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/erb/controller/controller_generator'
3
+
4
+ module Builder
5
+ module Generators
6
+ class ControllerGenerator < Erb::Generators::ControllerGenerator
7
+ source_root File.expand_path(File.join('..', 'templates'), __FILE__)
8
+
9
+ protected
10
+ def handler
11
+ :builder
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ markup do |m|
2
+ m.h1 class_name + "##{@action}"
3
+ m.p "Find me in #{@path}"
4
+ end
@@ -0,0 +1,29 @@
1
+ require 'rails'
2
+ require 'rails/generators/erb/scaffold/scaffold_generator'
3
+
4
+ module Builder
5
+ module Generators
6
+ class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
7
+ source_root File.expand_path(File.join('..', 'templates'), __FILE__)
8
+
9
+ def copy_view_files
10
+ available_views.each do |view|
11
+ filename = filename_with_extensions view
12
+ template "#{view}.html.builder", File.join('app', 'views', controller_file_path, filename)
13
+ end
14
+ end
15
+
16
+ def self.available_views
17
+ ['index', 'show', 'new', 'edit', '_form']
18
+ end
19
+
20
+ def available_views
21
+ self.class.available_views
22
+ end
23
+
24
+ def handler
25
+ :builder
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ form_for @<%= singular_table_name %> do |f|
2
+ markup{|m|
3
+ if @<%= singular_table_name %>.errors.any?
4
+ #error_explanation
5
+ m.h2 "#{pluralize(@<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
6
+ m.ul do
7
+ @<%= singular_table_name %>.errors.full_messages.each do |message|
8
+ m.li message
9
+ end
10
+ end
11
+ end
12
+ <% attributes.each do |attribute| -%>
13
+ m.div class: 'field' do
14
+ m << f.label(:<%= attribute.name %>)
15
+ m << f.<%= attribute.field_type %>(:<%= attribute.name %>)
16
+ end
17
+ <% end -%>
18
+ m << f.submit
19
+ }.html_safe
20
+ end
@@ -0,0 +1,7 @@
1
+ markup do |m|
2
+ m.h1 "Editing <%= singular_table_name %>"
3
+ m << render('form')
4
+ m << link_to('Show', @<%= singular_table_name %>)
5
+ m << link_to('Back', <%= index_helper %>_path)
6
+ end
7
+
@@ -0,0 +1,31 @@
1
+ markup do |m|
2
+ m.h1 'Listing <%= plural_table_name %>'
3
+ m.table do
4
+ m.thead do
5
+ m.tr do
6
+ <% attributes.each do |attribute| -%>
7
+ m.th '<%= attribute.human_name %>'
8
+ <% end -%>
9
+ m.th
10
+ m.th
11
+ m.th
12
+ end
13
+ end
14
+ m.tbody do
15
+ @<%= plural_table_name %>.each do |<%= singular_table_name %>|
16
+ m.tr do
17
+ <% attributes.each do |attribute| -%>
18
+ m.td '<%= singular_table_name %>.<%= attribute.name %>'
19
+ <% end -%>
20
+ m.td << link_to('Show', '<%= singular_table_name %>')
21
+ m.td << link_to('Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>))
22
+ m.td << link_to('Destroy', <%= singular_table_name %>, data: { confirm: 'Are you sure?' }, method: :delete)
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ m.br
29
+ m << link_to('New <%= human_name %>', new_<%= singular_table_name %>_path)
30
+
31
+ end
@@ -0,0 +1,5 @@
1
+ markup do |m|
2
+ m.h1 'New <%= singular_table_name %>'
3
+ m << render('form')
4
+ m << link_to('Back', <%= index_helper %>_path)
5
+ end
@@ -0,0 +1,12 @@
1
+ markup do |m|
2
+ m.p id: 'notice'
3
+ m.dl do
4
+ <% attributes.each do |attribute| -%>
5
+ m.dt '<%= attribute.human_name %>:'
6
+ m.dd @<%= singular_table_name %>.<%= attribute.name %>
7
+ <% end -%>
8
+ end
9
+
10
+ m << link_to('Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>))
11
+ m << link_to('Back', <%= index_helper %>_path)
12
+ end
@@ -14,14 +14,15 @@ module WeBridge
14
14
  yield doc
15
15
  end
16
16
  end
17
- r = root.to_html
18
- r = r.html_safe if r.respond_to? :html_safe
19
- r
17
+ root.to_html
20
18
  end
21
19
 
22
20
  def self.register_template_handler(extension = nil)
23
21
  handler = WeBridge::HtmlBuilder::Handler
24
22
  ActionView::Template.register_template_handler(extension || handler.default_extension, handler) if defined? ActionView::Template
23
+ ActionView::Helpers.__send__(:include,self) if defined? ActionView::Helpers
25
24
  end
26
25
  end
27
26
  end
27
+
28
+ require "we_bridge/html_builder/railtie" if defined? Rails
@@ -0,0 +1,7 @@
1
+ module WeBridge
2
+ module HtmlBuilder
3
+ class Railtie < ::Rails::Railtie
4
+ config.app_generators.template_engine :builder
5
+ end
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  module WeBridge
2
2
  module HtmlBuilder
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
@@ -31,5 +31,6 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "rake", "~> 10.0"
32
32
  spec.add_development_dependency "rspec"
33
33
  spec.add_development_dependency "actionview"
34
+ spec.add_development_dependency "rails", ">= 4.0"
34
35
  spec.add_dependency "nokogiri"
35
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: we_bridge-html_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinjiro Itagaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-30 00:00:00.000000000 Z
11
+ date: 2015-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '4.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: nokogiri
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -99,8 +113,17 @@ files:
99
113
  - Rakefile
100
114
  - bin/console
101
115
  - bin/setup
116
+ - lib/generators/builder/controller/controller_generator.rb
117
+ - lib/generators/builder/controller/templates/view.html.builder
118
+ - lib/generators/builder/scaffold/scaffold_generator.rb
119
+ - lib/generators/builder/scaffold/templates/_form.html.builder
120
+ - lib/generators/builder/scaffold/templates/edit.html.builder
121
+ - lib/generators/builder/scaffold/templates/index.html.builder
122
+ - lib/generators/builder/scaffold/templates/new.html.builder
123
+ - lib/generators/builder/scaffold/templates/show.html.builder
102
124
  - lib/we_bridge/html_builder.rb
103
125
  - lib/we_bridge/html_builder/handler.rb
126
+ - lib/we_bridge/html_builder/railtie.rb
104
127
  - lib/we_bridge/html_builder/version.rb
105
128
  - we_bridge-html_builder.gemspec
106
129
  homepage: https://github.com/baseball-bridge/we_bridge-html_builder