generator_extensions 0.1.7 → 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.
- data/README.rdoc +20 -0
- data/VERSION +1 -1
- data/generator_extensions.gemspec +2 -2
- data/lib/generator_extensions.rb +18 -0
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -47,6 +47,26 @@ do this:
|
|
47
47
|
|
48
48
|
m.mirror
|
49
49
|
|
50
|
+
There's also a convenience function for adding a whole chunk of code
|
51
|
+
to routes.rb. Let's say you set it up like this in your initialize()
|
52
|
+
method:
|
53
|
+
|
54
|
+
@route_text = <<END_OF_ROUTES
|
55
|
+
map.root :controller => 'contig'
|
56
|
+
|
57
|
+
[:find, :graph, :list, :add, :remove].each do |route|
|
58
|
+
map.named_route route.to_s, '/%s' % route.to_s, :controller => 'contig', :action => route.to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
map.showclique '/clique', :controller => 'contig', :action => 'showclique'
|
62
|
+
map.clearcart '/clearcart', :controller => 'contig', :action => 'clearcart'
|
63
|
+
map.findclique '/clique/find', :controller => 'contig', :action => 'findclique'
|
64
|
+
END_OF_ROUTES
|
65
|
+
|
66
|
+
Well, then just call this in your manifest:
|
67
|
+
|
68
|
+
m.add_to_routes @route_text
|
69
|
+
|
50
70
|
One problem with mirroring a directory tree is that at the moment
|
51
71
|
there is no way to distinguish between existing directories (say, the
|
52
72
|
ones rails sets up) and any new ones you've implicitly created by
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{generator_extensions}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marcel Levy"]
|
12
|
-
s.date = %q{2009-12-
|
12
|
+
s.date = %q{2009-12-18}
|
13
13
|
s.description = %q{Functions that make it easier to write a Rails generator.}
|
14
14
|
s.email = %q{heymarcel@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/generator_extensions.rb
CHANGED
@@ -31,10 +31,28 @@ module Rails
|
|
31
31
|
|
32
32
|
class Base
|
33
33
|
include RailsGeneratorExtensions
|
34
|
+
|
35
|
+
def add_to_routes(text)
|
36
|
+
first_line = text.split("\n")[0]
|
37
|
+
logger.routes "#{first_line} ..."
|
38
|
+
unless options[:pretend]
|
39
|
+
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
40
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
41
|
+
"#{match}\n#{text}\n"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
34
46
|
end
|
35
47
|
|
36
48
|
class Destroy < RewindBase
|
37
49
|
include RailsGeneratorExtensions
|
50
|
+
|
51
|
+
def add_to_routes(text)
|
52
|
+
first_line = text.split("\n")[0]
|
53
|
+
logger.routes "#{first_line} ..."
|
54
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(text)})/mi, ''
|
55
|
+
end
|
38
56
|
end
|
39
57
|
|
40
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: generator_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcel Levy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-18 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|