generator_extensions 0.1.4 → 0.1.6
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/VERSION +1 -1
- data/generator_extensions.gemspec +2 -2
- data/lib/generator_extensions.rb +59 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{generator_extensions}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.6"
|
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-15}
|
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
@@ -3,6 +3,8 @@ require 'find'
|
|
3
3
|
module Rails
|
4
4
|
module Generator
|
5
5
|
module Commands
|
6
|
+
|
7
|
+
|
6
8
|
class Create < Base
|
7
9
|
|
8
10
|
def mirror(origin='mirror')
|
@@ -27,6 +29,63 @@ module Rails
|
|
27
29
|
end
|
28
30
|
|
29
31
|
end
|
32
|
+
|
33
|
+
|
34
|
+
# Lists a generator's action manifest
|
35
|
+
class List < Base
|
36
|
+
|
37
|
+
def mirror(origin='mirror')
|
38
|
+
directory_copy(origin, '')
|
39
|
+
end
|
40
|
+
|
41
|
+
def directory_copy(relative_source, relative_destination=nil)
|
42
|
+
source = source_path(relative_source)
|
43
|
+
relative_destination ||= relative_source
|
44
|
+
path_to_delete = "#{source_root}/"
|
45
|
+
|
46
|
+
Find.find(source) do |f|
|
47
|
+
source = f.sub(path_to_delete, '')
|
48
|
+
target = File.join(relative_destination, source.sub(relative_source, ''))
|
49
|
+
case
|
50
|
+
when File.file?(f)
|
51
|
+
file source, target
|
52
|
+
when File.directory?(f)
|
53
|
+
directory target
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Undo the actions performed by a generator. Rewind the action
|
60
|
+
# manifest and attempt to completely erase the results of each action.
|
61
|
+
# Note that we're punting here when it comes to directories.
|
62
|
+
class Destroy < RewindBase
|
63
|
+
def mirror(origin='mirror')
|
64
|
+
directory_copy(origin, '')
|
65
|
+
end
|
66
|
+
|
67
|
+
def directory_copy(relative_source, relative_destination=nil)
|
68
|
+
source = source_path(relative_source)
|
69
|
+
relative_destination ||= relative_source
|
70
|
+
path_to_delete = "#{source_root}/"
|
71
|
+
|
72
|
+
Find.find(source) do |f|
|
73
|
+
source = f.sub(path_to_delete, '')
|
74
|
+
target = File.join(relative_destination, source.sub(relative_source, ''))
|
75
|
+
case
|
76
|
+
when File.file?(f)
|
77
|
+
file source, target
|
78
|
+
when File.directory?(f)
|
79
|
+
# Do nothing here, because the point is to use this to
|
80
|
+
# mirror directories. We don't want to risk deleting
|
81
|
+
# directories Rails needs.
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
end
|
88
|
+
|
30
89
|
end
|
31
90
|
end
|
32
91
|
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.1.
|
4
|
+
version: 0.1.6
|
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-15 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|