Class: PackageConsumer
- Inherits:
-
Object
- Object
- PackageConsumer
- Defined in:
- lib/seabass/package_consumer.rb
Instance Attribute Summary collapse
-
#application_name ⇒ Object
Returns the value of attribute application_name.
-
#consumer_dir ⇒ Object
Returns the value of attribute consumer_dir.
-
#package_dir ⇒ Object
Returns the value of attribute package_dir.
Instance Method Summary collapse
Instance Attribute Details
#application_name ⇒ Object
Returns the value of attribute application_name.
4 5 6 |
# File 'lib/seabass/package_consumer.rb', line 4 def application_name @application_name end |
#consumer_dir ⇒ Object
Returns the value of attribute consumer_dir.
4 5 6 |
# File 'lib/seabass/package_consumer.rb', line 4 def consumer_dir @consumer_dir end |
#package_dir ⇒ Object
Returns the value of attribute package_dir.
4 5 6 |
# File 'lib/seabass/package_consumer.rb', line 4 def package_dir @package_dir end |
Instance Method Details
#execute ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/seabass/package_consumer.rb', line 6 def execute() raise "The directory containing the packages has not been specified" if @package_dir.nil? raise "The directory packages should be copied to has not been specified" if @consumer_dir.nil? raise "The name of the application has not been specified" if @application_name.nil? files = Dir[@package_dir + "**/#{@application_name}/**/**"] puts "Found #{files.length} files" Dir[@package_dir + "**/#{@application_name}/**/**"].each do |resource| raise "Could not find the app name in the resource type" if resource.match(/.*\/#{@application_name}\/(.*)/).nil? destination = File.(File.join(@consumer_dir, $1)) next if File.directory?(resource) dir = File.(File.dirname(destination)) FileUtils.mkdir_p(dir) if false == File.exists?(dir) puts "Copying #{resource} to #{destination}" File.copy(resource, destination) end end |