Class: Bundler::Thor::Actions::Directory
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
EmptyDirectory
|
|
Instance Chain:
self,
EmptyDirectory
|
|
Inherits: |
Bundler::Thor::Actions::EmptyDirectory
|
Defined in: | lib/bundler/vendor/thor/lib/thor/actions/directory.rb |
Class Method Summary
EmptyDirectory
- Inherited
.new | Initializes given the source and destination. |
Instance Attribute Summary
- #source readonly
EmptyDirectory
- Inherited
#base, #config, #destination, | |
#exists? | Checks if the destination file already exists. |
#given_destination, #relative_destination, | |
#destination= | Sets the absolute destination value from a relative destination value. |
#pretend? | Shortcut for pretend. |
Instance Method Summary
- #invoke!
- #revoke!
- #execute! protected
- #file_level_lookup(previous_lookup) protected
- #files(lookup) protected
EmptyDirectory
- Inherited
#invoke!, #revoke!, | |
#convert_encoded_instructions | Filenames in the encoded form are converted. |
#invoke_with_conflict_check | Receives a hash of options and just execute the block if some conditions are met. |
#on_conflict_behavior | What to do when the destination file already exists. |
#on_file_clash_behavior, | |
#say_status | Shortcut to say_status shell method. |
Constructor Details
.new(base, source, destination = nil, config = {}, &block) ⇒ Directory
# File 'lib/bundler/vendor/thor/lib/thor/actions/directory.rb', line 58
def initialize(base, source, destination = nil, config = {}, &block) @source = File. (Dir[Util.escape_globs(base.find_in_source_paths(source.to_s))].first) @block = block super(base, destination, {:recursive => true}.merge(config)) end
Instance Attribute Details
#source (readonly)
[ GitHub ]# File 'lib/bundler/vendor/thor/lib/thor/actions/directory.rb', line 56
attr_reader :source
Instance Method Details
#execute! (protected)
[ GitHub ]# File 'lib/bundler/vendor/thor/lib/thor/actions/directory.rb', line 75
def execute! lookup = Util.escape_globs(source) lookup = config[:recursive] ? File.join(lookup, "**") : lookup lookup = file_level_lookup(lookup) files(lookup).sort.each do |file_source| next if File.directory?(file_source) next if config[:exclude_pattern] && file_source.match(config[:exclude_pattern]) file_destination = File.join(given_destination, file_source.gsub(source, ".")) file_destination.gsub!("/./", "/") case file_source when /\.empty_directory$/ dirname = File.dirname(file_destination).gsub(%r{/\.$}, "") next if dirname == given_destination base.empty_directory(dirname, config) when /#{TEMPLATE_EXTNAME}$/ base.template(file_source, file_destination[0..-4], config, &@block) else base.copy_file(file_source, file_destination, config, &@block) end end end
#file_level_lookup(previous_lookup) (protected)
[ GitHub ]# File 'lib/bundler/vendor/thor/lib/thor/actions/directory.rb', line 99
def file_level_lookup(previous_lookup) File.join(previous_lookup, "*") end
#files(lookup) (protected)
[ GitHub ]# File 'lib/bundler/vendor/thor/lib/thor/actions/directory.rb', line 103
def files(lookup) Dir.glob(lookup, File::FNM_DOTMATCH) end
#invoke!
[ GitHub ]# File 'lib/bundler/vendor/thor/lib/thor/actions/directory.rb', line 64
def invoke! base.empty_directory given_destination, config execute! end
#revoke!
[ GitHub ]# File 'lib/bundler/vendor/thor/lib/thor/actions/directory.rb', line 69
def revoke! execute! end