Class: FeaturePackager
- Inherits:
-
Object
- Object
- FeaturePackager
- Defined in:
- lib/seabass/feature_packager.rb
Instance Attribute Summary collapse
-
#package_dir ⇒ Object
Returns the value of attribute package_dir.
-
#source_dir ⇒ Object
Returns the value of attribute source_dir.
-
#valid_file_types ⇒ Object
Returns the value of attribute valid_file_types.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize ⇒ FeaturePackager
constructor
A new instance of FeaturePackager.
Constructor Details
#initialize ⇒ FeaturePackager
Returns a new instance of FeaturePackager.
8 9 10 |
# File 'lib/seabass/feature_packager.rb', line 8 def initialize() @valid_file_types = ['aspx', 'ascx', 'js', 'css', 'png', 'gif', 'jpeg', 'dll'] end |
Instance Attribute Details
#package_dir ⇒ Object
Returns the value of attribute package_dir.
6 7 8 |
# File 'lib/seabass/feature_packager.rb', line 6 def package_dir @package_dir end |
#source_dir ⇒ Object
Returns the value of attribute source_dir.
6 7 8 |
# File 'lib/seabass/feature_packager.rb', line 6 def source_dir @source_dir end |
#valid_file_types ⇒ Object
Returns the value of attribute valid_file_types.
6 7 8 |
# File 'lib/seabass/feature_packager.rb', line 6 def valid_file_types @valid_file_types end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/seabass/feature_packager.rb', line 12 def execute() raise "Please specify the directory where the features to package exist" if @source_dir.nil? raise "Please specify the directory packages should be placed into" if @package_dir.nil? Dir[@source_dir + '/**/.feature'].each do |feature| next if File.basename(File.dirname(feature)).downcase == File.basename(@source_dir).downcase feature_config = YAML.load(File.read(feature)) raise "The feature config does not contain the destination name" if !feature_config.has_key?('destination_name') destination = File.(File.join(@package_dir, feature_config['destination_name'])) FileUtils.mkdir_p(destination) feature_root = File.(File.dirname(feature) + '/../') Dir[feature_root + '/**/**'].each do |file| next if File.directory?(file) next if is_not_valid_file_type(file) file_destination = File.join(destination, file.gsub(/#{feature_root}/, '')) FileUtils.mkdir_p(File.dirname(file_destination)) if(!File.exists?(File.dirname(file_destination))) File.copy(file, file_destination) end end end |