Skip to content

Commit 6b4dec7

Browse files
committed
Move .tt extension to a constant
1 parent 472f5fa commit 6b4dec7

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

lib/thor/actions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def source_paths
131131
# Receives a file or directory and search for it in the source paths.
132132
#
133133
def find_in_source_paths(file)
134-
files = [file, "#{file}.tt"]
134+
files = [file, file + TEMPLATE_EXTNAME]
135135
relative_root = relative_to_original_destination_root(destination_root, false)
136136

137137
source_paths.each do |source|

lib/thor/actions/directory.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def execute!
8888
dirname = File.dirname(file_destination).gsub(/\/\.$/, '')
8989
next if dirname == given_destination
9090
base.empty_directory(dirname, config)
91-
when /\.tt$/
91+
when /#{TEMPLATE_EXTNAME}$/
9292
destination = base.template(file_source, file_destination[0..-4], config, &@block)
9393
else
9494
destination = base.copy_file(file_source, file_destination, config, &@block)

lib/thor/actions/file_manipulation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def get(source, *args, &block)
108108
#
109109
def template(source, *args, &block)
110110
config = args.last.is_a?(Hash) ? args.pop : {}
111-
destination = args.first || source.sub(/\.tt$/, '')
111+
destination = args.first || source.sub(/#{TEMPLATE_EXTNAME}$/, '')
112112

113113
source = File.expand_path(find_in_source_paths(source.to_s))
114114
context = instance_eval('binding')

lib/thor/base.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Thor
1919
THOR_RESERVED_WORDS = %w(invoke shell options behavior root destination_root relative_root
2020
action add_file create_file in_root inside run run_ruby_script)
2121

22+
TEMPLATE_EXTNAME = '.tt'
23+
2224
module Base
2325
attr_accessor :options, :parent_options, :args
2426

0 commit comments

Comments
 (0)