raykit 0.0.514 → 0.0.516

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/raykit/wix.rb +63 -0
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c212653142e4b28eed7367d7ff16f9747d65c75a3f234d2e026798129097635
4
- data.tar.gz: 309fbbc1cea9afae034e3712ad349986011df22a2362d6dc6128d813fd11381a
3
+ metadata.gz: 76635355baf466b8550d3d45d0d5ba97c69e16e4f3a0843977a68fd41c4231d7
4
+ data.tar.gz: b8c857270cd378060206185dfd02a4eb0a8acff6a8f36dca9bda24f27a4fe052
5
5
  SHA512:
6
- metadata.gz: cd53281c439cc9226fd23c3b1c6365d4d7c22ec3d33591aca52871c6e5d5b1ce02dcf843d2ef3e75100d310b4112e9d1737edd485e627b79e31ca5be7ca89b43
7
- data.tar.gz: 87fa11c3445935a41398ed53e1eb063029033418482685324ee1062cc58bb3f64544b00a74eeaa14f4beee6164b4ff4ae9d6728daee708e83e676b5e346c85f8
6
+ metadata.gz: 17603d74c8594cd16957e1c0b120d11f2d77cdcc5340c8e999f831a781503bf95b0e6dc8808cc43a5cbf8c529146d22a66ee0b55139369fd5a43cd2c28e766c3
7
+ data.tar.gz: cc5b7a80bf83c8494e63e0d4bf6dccd17ed62afc2a1d18c4f242d12107d41afa727dae9f855267263817a91ad9882bcd6cd81376690b66fc49c7372d0e0dc281
data/lib/raykit/wix.rb ADDED
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Raykit
4
+ class Wix
5
+ def self.harvest_directory_elements(directory)
6
+ get_nested_directory_element("", directory)
7
+ end
8
+ def self.get_nested_directory_element(id_prefix, directory)
9
+ Dir.chdir(directory) do
10
+ results = Array::new
11
+ Dir.glob("*").reject { |f| !File.directory? f }.each { |d|
12
+ directoryId = "#{d.upcase.gsub("/", "_").gsub("-", "_")}DIR"
13
+ directoryId = "#{id_prefix}#{directoryId}"
14
+ child_elements = get_nested_directory_element("#{directoryId[0...-3]}_", d)
15
+ if (child_elements.length > 0)
16
+ results.push("<Directory Id=\"#{directoryId}\" Name=\"#{d}\">")
17
+ child_elements.each { |child_element|
18
+ results.push("\t#{child_element}")
19
+ }
20
+ results.push("</Directory>")
21
+ else
22
+ results.push("<Directory Id=\"#{directoryId}\" Name=\"#{d}\"/>")
23
+ end
24
+ }
25
+ results
26
+ end
27
+ end
28
+ # given a directory, return an array of string the represent wix components for each file in the directory
29
+ # each string should look like this:
30
+ # <Component Id="IndexHtmlComponent" Directory="WWWDIR" Guid="*">
31
+ # <File Id="IndexHtmlFile" Source="path\to\index.html" KeyPath="yes"/>
32
+ # </Component>
33
+ def self.harvest_file_components(directory)
34
+ components = Array::new
35
+ Dir.chdir(directory) do
36
+ index = 0
37
+ Dir.glob("**/*").reject { |f| File.directory? f }.each { |f|
38
+ puts "file: #{f}"
39
+ index += 1
40
+ component = get_indexed_file_component(f, index)
41
+ puts "component: #{component}"
42
+ components.push(component)
43
+ }
44
+ components
45
+ end
46
+ end
47
+ # given a file and an index, return a string that represents a wix component
48
+ def self.get_indexed_file_component(file, index)
49
+ componentId = "c#{index}"
50
+ guid = SecureRandom.uuid
51
+ fileId = "f#{index}"
52
+ directory = File.dirname(file)
53
+ directory = directory.split(/[\/\\]/).last if File.dirname(file).include?("\\") || File.dirname(file).include?("/")
54
+ directory = "" if directory == "."
55
+ directoryId = "#{File.dirname(file).upcase.gsub("/", "_").gsub("-", "_")}DIR"
56
+ component = "<Component Id=\"#{componentId}\" Guid=\"#{guid}\"><File Id=\"#{fileId}\" Source=\"#{file}\" /></Component>"
57
+ if (directory.length > 0)
58
+ component = "<Component Id=\"#{componentId}\" Guid=\"#{guid}\" Directory=\"#{directoryId}\"><File Id=\"#{fileId}\" Source=\"#{file}\" /></Component>"
59
+ end
60
+ component
61
+ end
62
+ end
63
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raykit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.514
4
+ version: 0.0.516
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lou Parslow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-20 00:00:00.000000000 Z
11
+ date: 2023-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,6 +129,7 @@ files:
129
129
  - lib/raykit/timer.rb
130
130
  - lib/raykit/version.rb
131
131
  - lib/raykit/vstest.rb
132
+ - lib/raykit/wix.rb
132
133
  - lib/raykit/wt.rb
133
134
  - lib/raykit/zip.rb
134
135
  homepage: http://rubygems.org/gems/raykit
@@ -150,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
151
  - !ruby/object:Gem::Version
151
152
  version: '0'
152
153
  requirements: []
153
- rubygems_version: 3.3.26
154
+ rubygems_version: 3.3.7
154
155
  signing_key:
155
156
  specification_version: 4
156
157
  summary: ruby gem to support rake ci/cd tasks