packmule 0.4.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa88bafe7bbf29fd26cd48e2b4e6ab6cdf73c072
4
- data.tar.gz: c0e7f34e4fa41411b1fc8ae2454a623193fb411c
3
+ metadata.gz: 81e1d991a86d90119bfd798b3a29268c1eb7de79
4
+ data.tar.gz: ea62707723e6c582dec71692d119fbb55cc6c80f
5
5
  SHA512:
6
- metadata.gz: 93fffcc4aaa1064f48541e5792e7c884ef85699debe2c22b9954b6e02ae1865fef9a7826262b0067db227d38ccb580d4fb72713673fdcdabc391a0d431f0ddfe
7
- data.tar.gz: 5650c7c1f149ba66dc149f534f878a733d4959ca8b7ec04b6d771775b660a48894a6d035f2b5d6c7d3d9773c4deeeaefabb9db1748f023f241abb6c7503839dc
6
+ metadata.gz: 597733286d6eab9d3f542befa137b3eed9f1383ac22afdee4e4768d6ca419b4b9b76ef22052528181ac29a371ea8947dc913c05b2a3f6b6f54c39fd21e92c6fb
7
+ data.tar.gz: c095e0bf099c6840fab02a944720663a92eb4737df992061ace525cc3077ba0532aefb7d15dad6dc2ff682175dea869d9689df4cf47d5ab46eca954391f15e61
@@ -0,0 +1,46 @@
1
+ #
2
+ # Packmule
3
+ # Copyright (c) 2012-2015 Nirix
4
+ # https://github.com/nirix
5
+ #
6
+ # Packmule is released under
7
+ # the GNU GPL v3 only license.
8
+ #
9
+
10
+ module Packmule
11
+ module Archiver
12
+ ##
13
+ # Tar
14
+ class Tar
15
+ ##
16
+ # Creates the tar file, like a BOSS!
17
+ def self.create(options)
18
+ options = {:gzip => false, :bzip => false}.merge(options)
19
+ filename = "#{options[:filename]}.tar" + (options[:gzip] ? '.gz' : (options[:bzip] ? '.bz2' : ''))
20
+
21
+ # Make sure it doesn't exist..
22
+ if ::FileTest.exists? "./#{filename}"
23
+ puts "#{filename} already exists, skipping"
24
+ return false
25
+ end
26
+
27
+ if options[:gzip] == true
28
+ # Tar and gzip like a boss
29
+ `tar czf #{filename} -C #{options[:dir]} ./`
30
+ elsif options[:bzip] == true
31
+ # Bzippit
32
+ `tar cfj #{filename} -C #{options[:dir]} ./`
33
+ else
34
+ # Totally boss taring code, yo
35
+ `tar cf #{filename} -C #{options[:dir]} ./`
36
+ end
37
+
38
+ if ::FileTest.exists? "./#{filename}"
39
+ puts " - #{filename} created"
40
+ end
41
+
42
+ return true
43
+ end # self.create
44
+ end # Tar
45
+ end
46
+ end
@@ -0,0 +1,40 @@
1
+ #
2
+ # Packmule
3
+ # Copyright (c) 2012-2015 Nirix
4
+ # https://github.com/nirix
5
+ #
6
+ # Packmule is released under
7
+ # the GNU GPL v3 only license.
8
+ #
9
+
10
+ module Packmule
11
+ module Archiver
12
+ ##
13
+ # Zipper
14
+ class Zip
15
+ ##
16
+ # Zips the stuff
17
+ def self.create(options)
18
+ # Make sure the archive doesn't exist..
19
+ if ::FileTest.exists? "./#{options[:filename]}.zip"
20
+ puts "#{options[:filename]}.zip already exists, skipping"
21
+ return false
22
+ end
23
+
24
+ # Get the needed Zip stuff
25
+ gem 'rubyzip'
26
+ require 'zip'
27
+
28
+ # Create the archive
29
+ ::Zip::File.open("./#{options[:filename]}.zip", 'w') do |z|
30
+ Dir["#{options[:dir]}/**/**"].each do |file|
31
+ z.add(file.sub("#{options[:dir]}/", ''), file) if not options[:ignore].include?(file.sub("#{options[:dir]}/", ''))
32
+ end # Dir
33
+ end # Zip block
34
+
35
+ puts " - #{options[:filename]}.zip created"
36
+ return true
37
+ end # self.create
38
+ end # Zip
39
+ end
40
+ end
@@ -1,7 +1,6 @@
1
1
  #
2
2
  # Packmule
3
- # Copyright (c) 2012 Nirix
4
- # All Rights Reserved
3
+ # Copyright (c) 2012-2015 Nirix
5
4
  # https://github.com/nirix
6
5
  #
7
6
  # Packmule is released under
@@ -34,67 +33,5 @@ module Packmule
34
33
 
35
34
  puts "Done creating archives"
36
35
  end
37
-
38
- ##
39
- # Zipper
40
- class Zip
41
- ##
42
- # Zips the stuff
43
- def self.create(options)
44
- # Make sure the archive doesn't exist..
45
- if ::FileTest.exists? "./#{options[:filename]}.zip"
46
- puts "#{options[:filename]}.zip already exists, skipping"
47
- return false
48
- end
49
-
50
- # Get the needed Zip stuff
51
- gem 'rubyzip'
52
- require 'zip'
53
-
54
- # Create the archive
55
- ::Zip::File.open("./#{options[:filename]}.zip", 'w') do |z|
56
- Dir["#{options[:dir]}/**/**"].each do |file|
57
- z.add(file.sub("#{options[:dir]}/", ''), file) if not options[:ignore].include?(file.sub("#{options[:dir]}/", ''))
58
- end # Dir
59
- end # Zip block
60
-
61
- puts " - #{options[:filename]}.zip created"
62
- return true
63
- end # self.create
64
- end # Zip class
65
-
66
- ##
67
- # Tar
68
- class Tar
69
- ##
70
- # Creates the tar file, like a BOSS!
71
- def self.create(options)
72
- options = {:gzip => false, :bzip => false}.merge(options)
73
- filename = "#{options[:filename]}.tar" + (options[:gzip] ? '.gz' : (options[:bzip] ? '.bz2' : ''))
74
-
75
- # Make sure it doesn't exist..
76
- if ::FileTest.exists? "./#{filename}"
77
- puts "#{filename} already exists, skipping"
78
- return false
79
- end
80
-
81
- if options[:gzip] == true
82
- # Tar and gzip like a boss
83
- `tar czf #{filename} -C #{options[:dir]} ./`
84
- elsif options[:bzip] == true
85
- # Bzippit
86
- `tar cfj #{filename} -C #{options[:dir]} ./`
87
- else
88
- # Totally boss taring code, yo
89
- `tar cf #{filename} -C #{options[:dir]} ./`
90
- end
91
-
92
- if ::FileTest.exists? "./#{filename}"
93
- puts " - #{filename} created"
94
- end
95
-
96
- return true
97
- end # self.create
98
- end # Tar
99
36
  end # Archiver
100
37
  end
@@ -1,7 +1,6 @@
1
1
  #
2
2
  # Packmule
3
- # Copyright (c) 2012 Nirix
4
- # All Rights Reserved
3
+ # Copyright (c) 2012-2015 Nirix
5
4
  # https://github.com/nirix
6
5
  #
7
6
  # Packmule is released under
@@ -9,5 +8,5 @@
9
8
  #
10
9
 
11
10
  module Packmule
12
- VERSION = "0.4.2"
11
+ VERSION = "0.6.0"
13
12
  end
data/lib/packmule.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  #
2
2
  # Packmule
3
- # Copyright (c) 2012 Nirix
4
- # All Rights Reserved
3
+ # Copyright (c) 2012-2015 Nirix
5
4
  # https://github.com/nirix
6
5
  #
7
6
  # Packmule is released under
@@ -10,6 +9,8 @@
10
9
 
11
10
  require "packmule/version"
12
11
  require "packmule/archiver"
12
+ require "packmule/archiver/zip"
13
+ require "packmule/archiver/tar"
13
14
 
14
15
  module Packmule
15
16
  ##
@@ -24,12 +25,7 @@ module Packmule
24
25
 
25
26
  # Read the Packfile and exit if it doesn't exist
26
27
  puts "Reading the Packfile..."
27
- begin
28
- config = YAML::load_file('./Packfile')
29
- rescue
30
- puts "No Packfile found, stopping"
31
- exit;
32
- end
28
+ config = self.read_packfile
33
29
 
34
30
  # Options
35
31
  opt = {
@@ -45,15 +41,12 @@ module Packmule
45
41
 
46
42
  # Any commands?
47
43
  if opt[:commands]
48
- opt[:commands].each do |c|
49
- # Change to tempdir and run
50
- `cd #{tempdir}; #{c}`
51
- end
44
+ self.run_commands tempdir, opt[:commands]
52
45
  end
53
46
 
54
47
  # Remove ignored files and directories
55
- opt[:ignore].each do |badness|
56
- ::FileUtils.rm_rf Dir["#{tempdir}/#{badness}"], :secure => true
48
+ if opt[:ignore]
49
+ self.remove_files tempdir, opt[:ignore]
57
50
  end
58
51
 
59
52
  # Archive the directory
@@ -70,4 +63,34 @@ module Packmule
70
63
  puts "Packaging complete"
71
64
  exit
72
65
  end
66
+
67
+ ##
68
+ # Reads configuration from the `Packfile`
69
+ def self.read_packfile
70
+ begin
71
+ config = YAML::load_file('./Packfile')
72
+ rescue
73
+ puts "No Packfile found, stopping"
74
+ exit;
75
+ end
76
+
77
+ return config
78
+ end
79
+
80
+ ##
81
+ # Runs the specified commands in the specified directory.
82
+ def self.run_commands(dir, commands)
83
+ commands.each do |c|
84
+ # Change to tempdir and run
85
+ `cd #{dir}; #{c}`
86
+ end
87
+ end
88
+
89
+ ##
90
+ # Removes the specified files from the specified directory.
91
+ def self.remove_files(dir, files)
92
+ files.each do |file|
93
+ ::FileUtils.rm_rf Dir["#{dir}/#{file}"], :secure => true
94
+ end
95
+ end
73
96
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packmule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Polgar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-07 00:00:00.000000000 Z
11
+ date: 2015-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shebang
@@ -54,6 +54,8 @@ files:
54
54
  - bin/packmule
55
55
  - lib/packmule.rb
56
56
  - lib/packmule/archiver.rb
57
+ - lib/packmule/archiver/tar.rb
58
+ - lib/packmule/archiver/zip.rb
57
59
  - lib/packmule/cli.rb
58
60
  - lib/packmule/version.rb
59
61
  - packmule.gemspec
@@ -76,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
78
  version: '0'
77
79
  requirements: []
78
80
  rubyforge_project:
79
- rubygems_version: 2.2.0
81
+ rubygems_version: 2.4.5
80
82
  signing_key:
81
83
  specification_version: 4
82
84
  summary: Project packaging made easy.