josevalim-thor 0.10.1 → 0.10.2
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/lib/thor/actions/directory.rb +16 -10
- data/lib/thor/actions.rb +0 -8
- metadata +1 -1
@@ -5,11 +5,13 @@ class Thor
|
|
5
5
|
|
6
6
|
# Copies interactively the files from source directory to root directory.
|
7
7
|
# If any of the files finishes with .tt, it's considered to be a template
|
8
|
-
# and is placed in the destination without the extension .tt.
|
9
|
-
#
|
10
|
-
#
|
8
|
+
# and is placed in the destination without the extension .tt. If any
|
9
|
+
# empty directory is found, it's copied and all .empty_directory files are
|
10
|
+
# ignored. Remember that file paths can also be encoded, let's suppose a doc
|
11
|
+
# directory with the following files:
|
11
12
|
#
|
12
13
|
# doc/
|
14
|
+
# components/.empty_directory
|
13
15
|
# README
|
14
16
|
# rdoc.rb.tt
|
15
17
|
# %app_name%.rb
|
@@ -22,6 +24,7 @@ class Thor
|
|
22
24
|
# files (assuming that the app_name is "blog"):
|
23
25
|
#
|
24
26
|
# doc/
|
27
|
+
# components/
|
25
28
|
# README
|
26
29
|
# rdoc.rb
|
27
30
|
# blog.rb
|
@@ -43,15 +46,18 @@ class Thor
|
|
43
46
|
|
44
47
|
def invoke!
|
45
48
|
Dir[File.join(source, '**', '*')].each do |file_source|
|
46
|
-
next if File.directory?(file_source)
|
47
|
-
|
48
49
|
file_destination = File.join(relative_destination, file_source.gsub(source, ''))
|
49
|
-
file_source.gsub!(base.source_root, '.')
|
50
50
|
|
51
|
-
if file_source
|
52
|
-
base.
|
53
|
-
|
54
|
-
base.
|
51
|
+
if File.directory?(file_source)
|
52
|
+
base.empty_directory(file_destination, @log_status)
|
53
|
+
elsif file_source !~ /\.empty_directory$/
|
54
|
+
file_source.gsub!(base.source_root, '.')
|
55
|
+
|
56
|
+
if file_source =~ /\.tt$/
|
57
|
+
base.template(file_source, file_destination[0..-4], @log_status)
|
58
|
+
else
|
59
|
+
base.copy_file(file_source, file_destination, @log_status)
|
60
|
+
end
|
55
61
|
end
|
56
62
|
end
|
57
63
|
end
|
data/lib/thor/actions.rb
CHANGED
@@ -36,9 +36,6 @@ class Thor
|
|
36
36
|
# root<String>:: The root directory needed for some actions. It's also known
|
37
37
|
# as destination root.
|
38
38
|
#
|
39
|
-
# in_root<Boolean>:: When true, creates the root directory if it does not exist
|
40
|
-
# and move to it. False by default.
|
41
|
-
#
|
42
39
|
def initialize(args=[], options={}, config={})
|
43
40
|
self.behavior = case config[:behavior]
|
44
41
|
when :force
|
@@ -57,11 +54,6 @@ class Thor
|
|
57
54
|
end
|
58
55
|
|
59
56
|
self.root = config[:root]
|
60
|
-
if config[:in_root]
|
61
|
-
FileUtils.mkdir_p(root) unless File.exist?(root)
|
62
|
-
FileUtils.cd(root)
|
63
|
-
end
|
64
|
-
|
65
57
|
super
|
66
58
|
end
|
67
59
|
|