bungle 0.0.1
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.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/bungle.gemspec +25 -0
- data/lib/bungle.rb +3 -0
- data/lib/bungle/action_view.rb +26 -0
- data/lib/bungle/version.rb +3 -0
- data/lib/generators/bungle/bungle_generator.rb +2 -0
- data/lib/generators/bungle/generators/current_generator.rb +47 -0
- data/lib/generators/bungle/generators/legacy_generator.rb +13 -0
- data/lib/generators/bungle/templates/app/views/inherited_resources/_collection_table.html.haml +18 -0
- data/lib/generators/bungle/templates/app/views/inherited_resources/_edit_navigation.html.haml +2 -0
- data/lib/generators/bungle/templates/app/views/inherited_resources/_form.html.haml +7 -0
- data/lib/generators/bungle/templates/app/views/inherited_resources/_index_navigation.html.haml +1 -0
- data/lib/generators/bungle/templates/app/views/inherited_resources/_new_navigation.html.haml +1 -0
- data/lib/generators/bungle/templates/app/views/inherited_resources/_resource_detail.html.haml +6 -0
- data/lib/generators/bungle/templates/app/views/inherited_resources/_show_navigation.html.haml +2 -0
- data/lib/generators/bungle/templates/app/views/inherited_resources/edit.html.haml +4 -0
- data/lib/generators/bungle/templates/app/views/inherited_resources/index.html.haml +4 -0
- data/lib/generators/bungle/templates/app/views/inherited_resources/new.html.haml +4 -0
- data/lib/generators/bungle/templates/app/views/inherited_resources/show.html.haml +3 -0
- metadata +128 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bungle.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "bungle/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "bungle"
|
7
|
+
s.version = Bungle::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = "Neil Middleton"
|
10
|
+
s.email = "neil.middleton@gmail.com"
|
11
|
+
s.homepage = "http://www.neilmiddleton.com"
|
12
|
+
s.summary = "Generates views for use with inherited resources"
|
13
|
+
s.description = "Generates views for use with inherited resources, saving on time when creating new models"
|
14
|
+
|
15
|
+
s.rubyforge_project = "bungle"
|
16
|
+
|
17
|
+
s.add_dependency 'inherited_resources'
|
18
|
+
s.add_dependency 'haml'
|
19
|
+
s.add_dependency 'formtastic'
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
end
|
data/lib/bungle.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Bungle
|
2
|
+
module ActionView
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
def self.process_view_paths(value)
|
6
|
+
PathSet.new(Array.wrap(value))
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class PathSet < ::ActionView::PathSet
|
12
|
+
def find(path, prefix = nil, partial = false, details = {}, key = nil)
|
13
|
+
super
|
14
|
+
rescue ::ActionView::MissingTemplate
|
15
|
+
super(path, "inherited_resources", partial, details, key)
|
16
|
+
end
|
17
|
+
|
18
|
+
def find_template(original_template_path, format = nil, html_fallback = true)
|
19
|
+
super
|
20
|
+
rescue ::ActionView::MissingTemplate
|
21
|
+
original_template_path.sub!(/^[\w]+/, "inherited_resources")
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class BungleGenerator < Rails::Generators::Base
|
2
|
+
desc "Generates bungle templates for inherited_resources."
|
3
|
+
|
4
|
+
def self.source_root
|
5
|
+
@_views_source_root ||= File.expand_path("../../templates/app/views", __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
def copy_views
|
9
|
+
generate_formtastic
|
10
|
+
directory "inherited_resources", "app/views/inherited_resources"
|
11
|
+
tell_them_about_them_gems
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def generate_formtastic
|
17
|
+
%x[rails generate formtastic:install]
|
18
|
+
end
|
19
|
+
|
20
|
+
def verify_haml_existence
|
21
|
+
begin
|
22
|
+
require 'haml'
|
23
|
+
rescue LoadError
|
24
|
+
say "HAML is not installed, or it is not specified in your Gemfile."
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def verify_haml_version
|
30
|
+
unless Haml.version[:major] == 2 and Haml.version[:minor] >= 3 or Haml.version[:major] >= 3
|
31
|
+
say "To generate HAML templates, you need to install HAML 2.3 or above."
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def tell_them_about_them_gems
|
37
|
+
puts "======================================================"
|
38
|
+
puts " Remember to add the following to your Gemfile "
|
39
|
+
puts ""
|
40
|
+
puts " gem 'haml' "
|
41
|
+
puts " gem 'formtastic' "
|
42
|
+
puts ""
|
43
|
+
puts " and then bundle install "
|
44
|
+
puts "======================================================"
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class BungleGenerator < Rails::Generator::Base
|
2
|
+
def manifest
|
3
|
+
directory = "app/views/inherited_resources"
|
4
|
+
record do |m|
|
5
|
+
m.directory directory
|
6
|
+
m.file "#{directory}/_form.html.haml", "#{directory}/_form.html.haml"
|
7
|
+
m.file "#{directory}/edit.html.haml", "#{directory}/edit.html.haml"
|
8
|
+
m.file "#{directory}/index.html.haml", "#{directory}/index.html.haml"
|
9
|
+
m.file "#{directory}/new.html.haml", "#{directory}/new.html.haml"
|
10
|
+
m.file "#{directory}/show.html.haml", "#{directory}/show.html.haml"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/generators/bungle/templates/app/views/inherited_resources/_collection_table.html.haml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
%table{:class => "#{collection.first.class.to_s.downcase.pluralize} collection"}
|
2
|
+
%thead
|
3
|
+
%tr
|
4
|
+
- collection.first.attributes.each_pair do |field, value|
|
5
|
+
- next if ['id', 'created_at', 'updated_at'].include?(field)
|
6
|
+
%th= field.titleize
|
7
|
+
%th Show
|
8
|
+
%th Edit
|
9
|
+
%th Destroy
|
10
|
+
%tbody
|
11
|
+
- collection.each do |r|
|
12
|
+
%tr
|
13
|
+
- r.attributes.each_pair do |field, value|
|
14
|
+
- next if ['id', 'created_at', 'updated_at'].include?(field)
|
15
|
+
%td= value
|
16
|
+
%td= link_to "Show", resource_url(r)
|
17
|
+
%td= link_to "Edit", edit_resource_url(r)
|
18
|
+
%td= link_to "Destroy", resource_url(r), :confirm => 'Are you sure?', :method => :delete
|
data/lib/generators/bungle/templates/app/views/inherited_resources/_index_navigation.html.haml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
%p= link_to "New", new_resource_url
|
@@ -0,0 +1 @@
|
|
1
|
+
%p= link_to "Back", collection_url
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bungle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Neil Middleton
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-02-01 00:00:00 +00:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: inherited_resources
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: haml
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: formtastic
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :runtime
|
62
|
+
version_requirements: *id003
|
63
|
+
description: Generates views for use with inherited resources, saving on time when creating new models
|
64
|
+
email: neil.middleton@gmail.com
|
65
|
+
executables: []
|
66
|
+
|
67
|
+
extensions: []
|
68
|
+
|
69
|
+
extra_rdoc_files: []
|
70
|
+
|
71
|
+
files:
|
72
|
+
- .gitignore
|
73
|
+
- Gemfile
|
74
|
+
- Rakefile
|
75
|
+
- bungle.gemspec
|
76
|
+
- lib/bungle.rb
|
77
|
+
- lib/bungle/action_view.rb
|
78
|
+
- lib/bungle/version.rb
|
79
|
+
- lib/generators/bungle/bungle_generator.rb
|
80
|
+
- lib/generators/bungle/generators/current_generator.rb
|
81
|
+
- lib/generators/bungle/generators/legacy_generator.rb
|
82
|
+
- lib/generators/bungle/templates/app/views/inherited_resources/_collection_table.html.haml
|
83
|
+
- lib/generators/bungle/templates/app/views/inherited_resources/_edit_navigation.html.haml
|
84
|
+
- lib/generators/bungle/templates/app/views/inherited_resources/_form.html.haml
|
85
|
+
- lib/generators/bungle/templates/app/views/inherited_resources/_index_navigation.html.haml
|
86
|
+
- lib/generators/bungle/templates/app/views/inherited_resources/_new_navigation.html.haml
|
87
|
+
- lib/generators/bungle/templates/app/views/inherited_resources/_resource_detail.html.haml
|
88
|
+
- lib/generators/bungle/templates/app/views/inherited_resources/_show_navigation.html.haml
|
89
|
+
- lib/generators/bungle/templates/app/views/inherited_resources/edit.html.haml
|
90
|
+
- lib/generators/bungle/templates/app/views/inherited_resources/index.html.haml
|
91
|
+
- lib/generators/bungle/templates/app/views/inherited_resources/new.html.haml
|
92
|
+
- lib/generators/bungle/templates/app/views/inherited_resources/show.html.haml
|
93
|
+
has_rdoc: true
|
94
|
+
homepage: http://www.neilmiddleton.com
|
95
|
+
licenses: []
|
96
|
+
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
hash: 3
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
version: "0"
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
hash: 3
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
version: "0"
|
120
|
+
requirements: []
|
121
|
+
|
122
|
+
rubyforge_project: bungle
|
123
|
+
rubygems_version: 1.4.2
|
124
|
+
signing_key:
|
125
|
+
specification_version: 3
|
126
|
+
summary: Generates views for use with inherited resources
|
127
|
+
test_files: []
|
128
|
+
|