Class: Extensionator::Creator
- Inherits:
-
Object
- Object
- Extensionator::Creator
- Defined in:
- lib/extensionator/creator.rb
Instance Method Summary collapse
- #copy(destination) ⇒ Object
- #crx(destination) ⇒ Object
-
#initialize(dir, options) ⇒ Creator
constructor
A new instance of Creator.
- #validate ⇒ Object
- #zip(destination) ⇒ Object
Constructor Details
#initialize(dir, options) ⇒ Creator
Returns a new instance of Creator.
10 11 12 13 14 |
# File 'lib/extensionator/creator.rb', line 10 def initialize(dir, ) @dir = dir @opts = @opts[:exclude] ||= /\.crx$/ end |
Instance Method Details
#copy(destination) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/extensionator/creator.rb', line 28 def copy(destination) FileUtils.mkdir_p(destination) process_directory.each do |p| path_in_dir, file = p write_path = File.join(destination, path_in_dir) if File.directory?(file) FileUtils.mkdir_p(write_path) else FileUtils.cp(file, write_path) end end end |
#crx(destination) ⇒ Object
22 23 24 25 26 |
# File 'lib/extensionator/creator.rb', line 22 def crx(destination) with_zip do |zip_str| CRX.create(destination, zip_str, private_key) end end |
#validate ⇒ Object
44 45 46 |
# File 'lib/extensionator/creator.rb', line 44 def validate manifest.validate(dir_files) end |
#zip(destination) ⇒ Object
16 17 18 19 20 |
# File 'lib/extensionator/creator.rb', line 16 def zip(destination) with_zip do |zip_str| File.open(destination, "wb"){|f| f.write zip_str} end end |