Class: Plasmoid::Package
- Inherits:
-
Object
- Object
- Plasmoid::Package
- Defined in:
- lib/plasmoid/package.rb
Instance Method Summary collapse
-
#initialize(filename) ⇒ Package
constructor
A new instance of Package.
- #install ⇒ Object
- #run ⇒ Object
- #uninstall ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(filename) ⇒ Package
Returns a new instance of Package.
6 7 8 9 |
# File 'lib/plasmoid/package.rb', line 6 def initialize(filename) @filename = filename @pkg_name = File.basename(@filename, ".zip") end |
Instance Method Details
#install ⇒ Object
36 37 38 |
# File 'lib/plasmoid/package.rb', line 36 def install system("plasmapkg -i '#{@filename}'") end |
#run ⇒ Object
32 33 34 |
# File 'lib/plasmoid/package.rb', line 32 def run system("plasmoidviewer '#{@pkg_name}'") end |
#uninstall ⇒ Object
40 41 42 |
# File 'lib/plasmoid/package.rb', line 40 def uninstall system("plasmapkg -r '#{@pkg_name}'") end |
#write ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/plasmoid/package.rb', line 11 def write File.unlink(@filename) if File.exist?(@filename) Zip::ZipFile.open(@filename, Zip::ZipFile::CREATE) do |zf| Find.find(".") do |path| path.sub!(/^\.\//, "") if path.empty? || path =~ /^\.+$/ || path =~ /\.(zip|haml)$/ || path == "Rakefile" next end if File.directory?(path) zf.dir.mkdir(path) else zf.file.open(path, "w") do |file| file.write(File.read(path)) end end end end end |