raykit 0.0.471 → 0.0.473

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.
data/lib/raykit/zip.rb CHANGED
@@ -1,73 +1,73 @@
1
- require "zip"
2
-
3
- module Raykit
4
- class Zip
5
- @filename
6
- @source_dir
7
- @include_globs
8
- @exclude_globs
9
-
10
- def initialize(filename)
11
- @filename = filename
12
- @source_dir = Dir.pwd
13
- @include_globs = []
14
- @exclude_globs = []
15
- self
16
- end
17
-
18
- def source_dir(dir)
19
- @source_dir = dir
20
- self
21
- end
22
-
23
- def include_glob(glob)
24
- @include_globs << glob
25
- self
26
- end
27
-
28
- def exclude_glob(glob)
29
- @exclude_globs << glob
30
- self
31
- end
32
-
33
- def zip
34
- path = File.dirname(@filename)
35
- FileUtils.mkdir_p(path) unless Dir.exist?(path)
36
-
37
- files_to_archive = Array::new()
38
- Dir.chdir(@source_dir) do
39
- #include_files = []
40
- @include_globs.each do |include_glob|
41
- Dir.glob(include_glob) { |f|
42
- #puts "\n" + f
43
- files_to_archive << f
44
- }
45
- end
46
- end
47
-
48
- ::Zip::File::open(@filename, ::Zip::File::CREATE) { |zipfile|
49
- count = 0
50
- files_to_archive.each do |file|
51
- zipfile.get_output_stream(file) { |f|
52
- fr = ::File.open("#{@source_dir}/#{file}", "rb")
53
- f.puts(fr.read)
54
- fr.close()
55
- f.close()
56
- count = count + 1
57
- }
58
- end
59
- zipfile.close
60
- puts " added " << count.to_s << " files to " << @filename
61
- }
62
- end
63
-
64
- def self.zip_directory(directory, zipfile_name, overwrite = true)
65
- File.delete(zipfile_name) if File.exist?(zipfile_name) && overwrite
66
- ::Zip::File.open(zipfile_name, ::Zip::File::CREATE) do |zipfile|
67
- Dir[File.join(directory, "**", "**")].each do |file|
68
- zipfile.add(file.sub(directory + "/", ""), file)
69
- end
70
- end
71
- end
72
- end
73
- end
1
+ require "zip"
2
+
3
+ module Raykit
4
+ class Zip
5
+ @filename
6
+ @source_dir
7
+ @include_globs
8
+ @exclude_globs
9
+
10
+ def initialize(filename)
11
+ @filename = filename
12
+ @source_dir = Dir.pwd
13
+ @include_globs = []
14
+ @exclude_globs = []
15
+ self
16
+ end
17
+
18
+ def source_dir(dir)
19
+ @source_dir = dir
20
+ self
21
+ end
22
+
23
+ def include_glob(glob)
24
+ @include_globs << glob
25
+ self
26
+ end
27
+
28
+ def exclude_glob(glob)
29
+ @exclude_globs << glob
30
+ self
31
+ end
32
+
33
+ def zip
34
+ path = File.dirname(@filename)
35
+ FileUtils.mkdir_p(path) unless Dir.exist?(path)
36
+
37
+ files_to_archive = Array::new()
38
+ Dir.chdir(@source_dir) do
39
+ #include_files = []
40
+ @include_globs.each do |include_glob|
41
+ Dir.glob(include_glob) { |f|
42
+ #puts "\n" + f
43
+ files_to_archive << f
44
+ }
45
+ end
46
+ end
47
+
48
+ ::Zip::File::open(@filename, ::Zip::File::CREATE) { |zipfile|
49
+ count = 0
50
+ files_to_archive.each do |file|
51
+ zipfile.get_output_stream(file) { |f|
52
+ fr = ::File.open("#{@source_dir}/#{file}", "rb")
53
+ f.puts(fr.read)
54
+ fr.close()
55
+ f.close()
56
+ count = count + 1
57
+ }
58
+ end
59
+ zipfile.close
60
+ puts " added " << count.to_s << " files to " << @filename
61
+ }
62
+ end
63
+
64
+ def self.zip_directory(directory, zipfile_name, overwrite = true)
65
+ File.delete(zipfile_name) if File.exist?(zipfile_name) && overwrite
66
+ ::Zip::File.open(zipfile_name, ::Zip::File::CREATE) do |zipfile|
67
+ Dir[File.join(directory, "**", "**")].each do |file|
68
+ zipfile.add(file.sub(directory + "/", ""), file)
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
data/lib/raykit.rb CHANGED
@@ -1,103 +1,116 @@
1
- # frozen_string_literal: true
2
-
3
- require "rainbow"
4
- require "rake/clean"
5
- require "open3"
6
- require "rake/testtask"
7
- require "digest"
8
-
9
- lib_dir = File.dirname(__FILE__)
10
- Dir.glob("#{lib_dir}/raykit/**/*.rb").sort.each { |file| require file }
11
-
12
- PROJECT = Raykit::Project.new
13
-
14
- SECRETS = Raykit::Secrets.new
15
-
16
- REPOSITORIES = Raykit::Git::Repositories.new("#{Raykit::Environment.get_dev_dir("log")}/Raykit.Git.Repositories.json")
17
- GIT_DIRECTORY = Raykit::Git::Directory.new(Rake.application.original_dir)
18
-
19
- NUGET_DIR = Raykit::Environment::get_dev_dir("nuget")
20
- PUBLISH_DIR = Raykit::Environment::get_dev_dir("publish")
21
-
22
- Raykit::MsBuild::fix_msbuild_path
23
-
24
- # include Raykit::TopLevel to make run method accessible from the global scope
25
- module Raykit
26
- module TopLevel
27
- def self.run(command, quit_on_failure = true)
28
- PROJECT.run(command, quit_on_failure)
29
- end
30
- end
31
- end
32
-
33
- RAYKIT_GLOBALS = true
34
- if defined?(RAYKIT_GLOBALS)
35
- def run(command, quit_on_failure = true)
36
- Raykit::TopLevel.run(command, quit_on_failure)
37
- end
38
-
39
- def try(command)
40
- Raykit::TopLevel.run(command, false)
41
- end
42
-
43
- def dir(name)
44
- FileUtils.mkdir("artifacts") if (!Dir.exist?(name))
45
- end
46
-
47
- def make(artifact, command)
48
- if (File.exist?(artifact))
49
- puts " #{artifact} exists"
50
- else
51
- cmd = run(command)
52
- if (cmd.exitstatus != 0)
53
- File.delete(artifact) if (File.exist?(artifact))
54
- end
55
- cmd
56
- end
57
- end
58
-
59
- def make_log(artifact, command)
60
- if (File.exist?(artifact))
61
- puts " #{artifact} exists"
62
- else
63
- cmd = run(command).log_to_file(artifact)
64
- if (cmd.exitstatus != 0)
65
- File.delete(artifact) if (File.exist?(artifact))
66
- end
67
- cmd
68
- end
69
- end
70
-
71
- def tag(name)
72
- puts Rainbow(": #{name}").blue.bright
73
- end
74
-
75
- def start_task(task_name)
76
- Raykit::Log.start_task(task_name)
77
- end
78
-
79
- def show(symbol)
80
- show_binding(symbol, binding)
81
- end
82
-
83
- def show_binding(symbol, the_binding)
84
- show_value symbol.to_s, eval(symbol.to_s, the_binding)
85
- end
86
-
87
- def show_value(name, value)
88
- Raykit::Log.show_value(name, value)
89
- PROJECT.values[name] = value
90
- end
91
-
92
- def show_table(symbols)
93
- Raykit::Log.show_table(symbols)
94
- end
95
-
96
- def copy_files(src_dir, target_dir, glob)
97
- Raykit::FileSystem::copy_files(src_dir, target_dir, glob)
98
- end
99
-
100
- def copy_file_to_dir(file, dir)
101
- Raykit::FileSystem::copy_file_to_dir(file, dir)
102
- end
103
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "rainbow"
4
+ require "rake/clean"
5
+ require "open3"
6
+ require "rake/testtask"
7
+ require "digest"
8
+
9
+ # Constants
10
+ BUFFER_SIZE = 1024 unless defined?(BUFFER_SIZE)
11
+ RAKE_DIRECTORY = Rake.application.original_dir unless defined?(RAKE_DIRECTORY)
12
+ DEFAULT_SUBDIRECTORIES = %w[src test examples] unless defined?(DEFAULT_SUBDIRECTORIES)
13
+ DEFAULT_FILES = %w[README.md LICENSE.md .gitignore] unless defined?(DEFAULT_FILES)
14
+ RAYKIT_GLOBALS = true unless defined?(RAYKIT_GLOBALS)
15
+ RAYKIT_AUTO_SETUP = false unless defined?(RAYKIT_AUTO_SETUP)
16
+
17
+ # Load all the files in the raykit directory
18
+
19
+ lib_dir = File.dirname(__FILE__)
20
+ Dir.glob("#{lib_dir}/raykit/**/*.rb").sort.each { |file| require file }
21
+
22
+ # Constants
23
+ PROJECT = Raykit::Project.new
24
+ SECRETS = Raykit::Secrets.new
25
+ REPOSITORIES = Raykit::Git::Repositories.new("#{Raykit::Environment.get_dev_dir("log")}/Raykit.Git.Repositories.json")
26
+ GIT_DIRECTORY = Raykit::Git::Directory.new(Rake.application.original_dir)
27
+ NUGET_DIR = Raykit::Environment::get_dev_dir("nuget")
28
+ PUBLISH_DIR = Raykit::Environment::get_dev_dir("publish")
29
+
30
+ LOG = Raykit::Logging.new
31
+ MARKDOWN = Raykit::Markdown.new
32
+
33
+ Raykit::MsBuild::fix_msbuild_path
34
+
35
+ if RAYKIT_AUTO_SETUP
36
+ GIT_DIRECTORY.setup
37
+ end
38
+ # include Raykit::TopLevel to make run method accessible from the global scope
39
+ module Raykit
40
+ module TopLevel
41
+ def self.run(command, quit_on_failure = true)
42
+ PROJECT.run(command, quit_on_failure)
43
+ end
44
+ end
45
+ end
46
+
47
+ if defined?(RAYKIT_GLOBALS)
48
+ def run(command, quit_on_failure = true)
49
+ Raykit::TopLevel.run(command, quit_on_failure)
50
+ end
51
+
52
+ def try(command)
53
+ Raykit::TopLevel.run(command, false)
54
+ end
55
+
56
+ def dir(name)
57
+ FileUtils.mkdir("artifacts") if (!Dir.exist?(name))
58
+ end
59
+
60
+ def make(artifact, command)
61
+ if (File.exist?(artifact))
62
+ puts " #{artifact} exists"
63
+ else
64
+ cmd = run(command)
65
+ if (cmd.exitstatus != 0)
66
+ File.delete(artifact) if (File.exist?(artifact))
67
+ end
68
+ cmd
69
+ end
70
+ end
71
+
72
+ def make_log(artifact, command)
73
+ if (File.exist?(artifact))
74
+ puts " #{artifact} exists"
75
+ else
76
+ cmd = run(command).log_to_file(artifact)
77
+ if (cmd.exitstatus != 0)
78
+ File.delete(artifact) if (File.exist?(artifact))
79
+ end
80
+ cmd
81
+ end
82
+ end
83
+
84
+ def tag(name)
85
+ puts Rainbow(": #{name}").blue.bright
86
+ end
87
+
88
+ def start_task(task_name)
89
+ Raykit::Log.start_task(task_name)
90
+ end
91
+
92
+ def show(symbol)
93
+ show_binding(symbol, binding)
94
+ end
95
+
96
+ def show_binding(symbol, the_binding)
97
+ show_value symbol.to_s, eval(symbol.to_s, the_binding)
98
+ end
99
+
100
+ def show_value(name, value)
101
+ Raykit::Log.show_value(name, value)
102
+ PROJECT.values[name] = value
103
+ end
104
+
105
+ def show_table(symbols)
106
+ Raykit::Log.show_table(symbols)
107
+ end
108
+
109
+ def copy_files(src_dir, target_dir, glob)
110
+ Raykit::FileSystem::copy_files(src_dir, target_dir, glob)
111
+ end
112
+
113
+ def copy_file_to_dir(file, dir)
114
+ Raykit::FileSystem::copy_file_to_dir(file, dir)
115
+ end
116
+ 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.471
4
+ version: 0.0.473
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-09-18 00:00:00.000000000 Z
11
+ date: 2023-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler