Sha256: 51e65bfc1ed4b54c66c6580264b3c1188a219aeead20f98a674c71fbcd469a0c

Contents?: true

Size: 1.08 KB

Versions: 42

Compression:

Stored size: 1.08 KB

Contents

module HttpUtilities
  module Generators
    module FileHelper

      private

      def copy_dir(source, destination)
        root_dir=File.join(self.class.source_root, source)
        Dir[File.join(root_dir, "**/*")].each do |file|
          relative = file.gsub(/^#{root_dir}\//, '')
          copy_file file, File.join(Rails.root, destination, relative) if File.file?(file)
        end
      end
      
      def append_to_file(source, destination, prepend_with = "\n")
        source_file = File.join(self.class.source_root, source)
        destination_file = File.join(Rails.root, destination)
        
        if (File.exists?(source_file) && File.exists?(destination_file))
          source_data = []
          File.open(source_file, 'r') {|f| source_data = f.readlines("\n") }
          open(destination_file, 'a') { |dest_file|
            dest_file << prepend_with if (prepend_with)
            source_data.each { |line| dest_file.puts line }
          }
        end
      end

      def file_exists? path
        File.exists?(File.join(destination_root, path))
      end
      
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
http_utilities-1.4.3 lib/generators/helpers/file_helper.rb
http_utilities-1.4.2 lib/generators/helpers/file_helper.rb
http_utilities-1.4.1 lib/generators/helpers/file_helper.rb
http_utilities-1.4.0 lib/generators/helpers/file_helper.rb
http_utilities-1.3.9 lib/generators/helpers/file_helper.rb
http_utilities-1.3.8 lib/generators/helpers/file_helper.rb
http_utilities-1.3.7 lib/generators/helpers/file_helper.rb
http_utilities-1.3.6 lib/generators/helpers/file_helper.rb
http_utilities-1.3.5 lib/generators/helpers/file_helper.rb
http_utilities-1.3.4 lib/generators/helpers/file_helper.rb
http_utilities-1.3.3 lib/generators/helpers/file_helper.rb
http_utilities-1.3.2 lib/generators/helpers/file_helper.rb
http_utilities-1.3.1 lib/generators/helpers/file_helper.rb
http_utilities-1.3.0 lib/generators/helpers/file_helper.rb
http_utilities-1.2.7 lib/generators/helpers/file_helper.rb
http_utilities-1.2.6.5 lib/generators/helpers/file_helper.rb
http_utilities-1.2.6.4 lib/generators/helpers/file_helper.rb
http_utilities-1.2.6.3 lib/generators/helpers/file_helper.rb
http_utilities-1.2.6.2 lib/generators/helpers/file_helper.rb
http_utilities-1.2.6.1 lib/generators/helpers/file_helper.rb