jenkinsutil 0.8.44 → 0.8.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96e02492550beae8d073d2ea124d135f2918df1a
4
- data.tar.gz: 62b3e44e43440c42c3ddc8e14f7f25fc5b4ced65
3
+ metadata.gz: 4c98d7525cff4691d9d259be7477540ecf0185b2
4
+ data.tar.gz: 1617fef607e77906913137a68c16b3c0106586e4
5
5
  SHA512:
6
- metadata.gz: aad957c7472f8699e933c3a61c0dbff0de4dc508606950a47bc2bc1ba5a0849019019362c7dc2f23b4dd3d15a9f058b5d9aa4de528b421ec175501baf10cff33
7
- data.tar.gz: 55ad3a4c63224836fbdabfc33eab1894fde9a34e19ef9f310a26b94e12be1b5eefbd731f8527f132b71032ea9cb39958ea913dce1f83cc3c3f393669f93103a1
6
+ metadata.gz: 2967db84f090c883f18cce2fa6a417dcff7ccb100d3ac8ce8b6db84e1531ea57f8df0438a10b28fd976f83c4dabca8b4e6c66106a58e9addce87a643e37b4c8b
7
+ data.tar.gz: 1f13b8911aff6a632c46e92f900af1ba35722a1c7719b15502a2bd1391ac66ffdb380cf11c5db9184d765c1e48a4eca04fbbb3a41cc981e303d76b4159241891
data/JenkinsUtil.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'sys-proctable', '~> 1.0'
24
24
  spec.add_dependency 'dropbox-sdk', '~> 1.6'
25
25
  spec.add_dependency 'xcodeproj', '~> 1.1'
26
+ spec.add_dependency 'rubyzip', '~> 1.2'
26
27
 
27
28
  spec.add_development_dependency 'bundler', '~> 1.11'
28
29
  spec.add_development_dependency 'rake', '~> 11.1'
data/lib/JenkinsUtil.rb CHANGED
@@ -7,6 +7,7 @@ require 'JenkinsUtil/argument_handler'
7
7
  require 'JenkinsUtil/logger_util'
8
8
  require 'JenkinsUtil/process_util'
9
9
  require 'JenkinsUtil/dropbox_util'
10
+ require 'JenkinsUtil/zip_util'
10
11
 
11
12
  module JenkinsUtil
12
13
  include LoggerUtil
@@ -28,14 +29,24 @@ module JenkinsUtil
28
29
  if args.kill_simulators
29
30
  SimulatorUtil.reset_all_simulators
30
31
  end
31
-
32
+
32
33
  if !args.xcode_project_path.nil? && !args.xcode_target.nil? && !args.xcode_build_configuration.nil?
33
34
  if !args.xcode_bundle_identifier.nil?
34
35
  XcodeUtil.set_project_bundle_identifier(args.xcode_project_path, args.xcode_target, args.xcode_build_configuration, args.xcode_bundle_identifier)
35
36
  end
36
-
37
+
37
38
  if !args.xcode_bundle_version.nil?
38
39
  XcodeUtil.set_project_bundle_version(args.xcode_project_path, args.xcode_target, args.xcode_build_configuration, args.xcode_bundle_version)
39
40
  end
40
41
  end
42
+
43
+ if (!args.zip_sources.empty? || !args.zip_archive.nil?) && !args.zip_destination.nil?
44
+ if !args.zip_sources.empty?
45
+ ZipUtil.compress(*args.zip_sources, args.zip_destination)
46
+ end
47
+
48
+ if !args.zip_archive.nil?
49
+ ZipUtil.uncompress(args.zip_archive, args.zip_destination)
50
+ end
51
+ end
41
52
  end
@@ -1,5 +1,6 @@
1
1
  require 'optparse'
2
2
 
3
+ # rubocop:disable Metrics/ClassLength
3
4
  class ArgumentHandler
4
5
  attr_reader :keychain,
5
6
  :keychain_password,
@@ -15,6 +16,9 @@ class ArgumentHandler
15
16
  :xcode_build_configuration,
16
17
  :xcode_bundle_identifier,
17
18
  :xcode_bundle_version,
19
+ :zip_sources,
20
+ :zip_archive,
21
+ :zip_destination,
18
22
  :verbose
19
23
 
20
24
  # rubocop:disable Metrics/AbcSize
@@ -34,6 +38,9 @@ class ArgumentHandler
34
38
  @xcode_build_configuration = nil
35
39
  @xcode_bundle_identifier = nil
36
40
  @xcode_bundle_version = nil
41
+ @zip_sources = []
42
+ @zip_archive = nil
43
+ @zip_destination = nil
37
44
  @verbose = false
38
45
 
39
46
  ARGV.push('-h') if ARGV.empty?
@@ -110,6 +117,21 @@ class ArgumentHandler
110
117
  @xcode_bundle_version = bundle_version
111
118
  end
112
119
 
120
+ # zip_util
121
+ opts.on('--zip-compress s1,s2,s3', Array, 'Compress files into zip archive') do |sources|
122
+ @zip_sources = sources
123
+ end
124
+
125
+ opts.on('--zip-uncompress zip_archive', 'Uncompress zip archive') do |zip_archive|
126
+ @zip_archive = zip_archive
127
+ end
128
+
129
+ opts.on('--zip-destination destination',
130
+ 'The path to save a new zip archive for a --zip-compress',
131
+ 'The path to a directory to uncompress a zip archive for --zip-uncompress') do |destination|
132
+ @zip_destination = destination
133
+ end
134
+
113
135
  # logger_util
114
136
  opts.on('-v', '--verbose', 'Output more information') do
115
137
  @verbose = true
@@ -0,0 +1,68 @@
1
+ require 'JenkinsUtil/command_line_script'
2
+ require 'JenkinsUtil/logger_util'
3
+ require 'zip'
4
+
5
+ class ZipError < Exception
6
+ attr_reader :code, :message
7
+
8
+ def initialize(code, message)
9
+ @code = code
10
+ @message = message
11
+ end
12
+
13
+ def to_s
14
+ format('code: %d, message: %s', @code, @message)
15
+ end
16
+ end
17
+
18
+ class ZipUtil
19
+ def self.compress(*sources, destination)
20
+ Zip::File.open(destination, ::Zip::File::CREATE) do |zip_archive|
21
+ sources.each do |source|
22
+ write_path_to_archive(zip_archive, source)
23
+ end
24
+ end
25
+ end
26
+
27
+ def self.uncompress(source, destination)
28
+ Zip::File.open(source) do |zip_file|
29
+ zip_file.each do |entry|
30
+ path = File.join(destination, entry.name)
31
+ LoggerUtil.log.debug("Extracting #{path}")
32
+ entry.extract(File.join(destination, entry.name))
33
+ end
34
+ end
35
+ end
36
+
37
+ def self.write_path_to_archive(zip_archive, disk_path)
38
+ unless File.exist?(disk_path)
39
+ LoggerUtil.log.error("Path does not exist: #{disk_path}")
40
+ exit(-1)
41
+ end
42
+
43
+ LoggerUtil.log.debug("Archiving #{disk_path}")
44
+
45
+ if File.directory?(disk_path)
46
+ write_directory_to_archive(zip_archive, disk_path)
47
+ else
48
+ write_file_to_archive(zip_archive, disk_path)
49
+ end
50
+ end
51
+
52
+ def self.write_directory_to_archive(zip_archive, disk_path)
53
+ zip_archive.mkdir disk_path
54
+ entries = Dir.entries(disk_path) - %w(. ..)
55
+
56
+ entries.each do |entry|
57
+ write_path_to_archive(zip_archive, File.join(disk_path, entry))
58
+ end
59
+ end
60
+
61
+ def self.write_file_to_archive(zip_archive, disk_path)
62
+ zip_archive.get_output_stream(disk_path) do |output_stream|
63
+ output_stream.write(File.open(disk_path, 'rb').read)
64
+ end
65
+ end
66
+
67
+ private_class_method :write_path_to_archive, :write_directory_to_archive, :write_file_to_archive
68
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jenkinsutil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.44
4
+ version: 0.8.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett McGinnis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-14 00:00:00.000000000 Z
11
+ date: 2016-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: open4
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubyzip
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.2'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -206,6 +220,7 @@ files:
206
220
  - lib/JenkinsUtil/simulator_util.rb
207
221
  - lib/JenkinsUtil/version.rb
208
222
  - lib/JenkinsUtil/xcode_util.rb
223
+ - lib/JenkinsUtil/zip_util.rb
209
224
  homepage: http://www.l4digital.com/
210
225
  licenses:
211
226
  - MIT