raykit 0.0.319 → 0.0.320

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.
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'time'
3
+ require "time"
4
4
 
5
5
  module Raykit
6
6
  # Provides functionality to record the time execution times
7
7
  class Secrets < Hash
8
8
  def initialize
9
- if ENV.key?('RAYKIT_SECRETS_PATH')
10
- secrets_file = ENV['RAYKIT_SECRETS_PATH']
9
+ if ENV.key?("RAYKIT_SECRETS_PATH")
10
+ secrets_file = ENV["RAYKIT_SECRETS_PATH"]
11
11
  if File.exist?(secrets_file)
12
12
  text = IO.read(secrets_file)
13
13
  if text.length > 7
@@ -23,15 +23,15 @@ module Raykit
23
23
  def hide(text)
24
24
  hidden = text
25
25
  each do |_k, v|
26
- hidden = hidden.gsub(v, '****') if !v.nil? && v.length.positive?
26
+ hidden = hidden.gsub(v, "****") if !v.nil? && v.length.positive?
27
27
  end
28
28
  hidden
29
29
  end
30
30
 
31
31
  def save
32
- if ENV.key?('RAYKIT_SECRETS_PATH')
33
- secrets_file = ENV['RAYKIT_SECRETS_PATH']
34
- File.open(secrets_file, 'w') { |f| f.puts to_json }
32
+ if ENV.key?("RAYKIT_SECRETS_PATH")
33
+ secrets_file = ENV["RAYKIT_SECRETS_PATH"]
34
+ File.open(secrets_file, "w") { |f| f.puts to_json }
35
35
  end
36
36
  end
37
37
  end
@@ -3,36 +3,36 @@
3
3
  module Raykit
4
4
  class SourceImport < Hash
5
5
  def initialize(url, source, glob, target, commit)
6
- self['remote'] = url
7
- self['source'] = source
8
- self['glob'] = glob
9
- self['target'] = target
10
- self['commit'] = commit
6
+ self["remote"] = url
7
+ self["source"] = source
8
+ self["glob"] = glob
9
+ self["target"] = target
10
+ self["commit"] = commit
11
11
  end
12
12
 
13
13
  def remote
14
- self['remote']
14
+ self["remote"]
15
15
  end
16
16
 
17
17
  def source
18
- self['source']
18
+ self["source"]
19
19
  end
20
20
 
21
21
  def target
22
- self['target']
22
+ self["target"]
23
23
  end
24
24
 
25
25
  def glob
26
- self['glob']
26
+ self["glob"]
27
27
  end
28
28
 
29
29
  def update
30
- work = self['remote'].work_dir
30
+ work = self["remote"].work_dir
31
31
  work_parent = File.dirname(work)
32
32
  FileUtils.mkdir_p(work_parent) unless Dir.exist?(work_parent)
33
33
  if Dir.exist?(work)
34
34
  Dir.chdir(work) do
35
- cmd = Command.new('git pull')
35
+ cmd = Command.new("git pull")
36
36
  end
37
37
  else
38
38
  PROJECT.run("git clone #{remote} #{work}")
@@ -41,22 +41,22 @@ module Raykit
41
41
  Dir.chdir(work) do
42
42
  text = `git log -n 1`
43
43
  scan = text.scan(/commit (\w+)\s/)
44
- self['commit'] = scan[0][0].to_s
44
+ self["commit"] = scan[0][0].to_s
45
45
  end
46
46
  end
47
47
 
48
48
  def copy
49
49
  if target.length.zero?
50
- puts 'target has not been specified'
50
+ puts "target has not been specified"
51
51
  else
52
52
  FileUtils.remove_dir(target) if Dir.exist?(target)
53
53
  count = 0
54
54
  source_names = []
55
- work = self['remote'].work_dir
55
+ work = self["remote"].work_dir
56
56
  Dir.chdir(work) do
57
- cmd = Command.new('rake clean') if File.exist?('rakefile.rb')
57
+ cmd = Command.new("rake clean") if File.exist?("rakefile.rb")
58
58
  Dir.chdir(source) do
59
- source_names = Dir.glob(self['glob'])
59
+ source_names = Dir.glob(self["glob"])
60
60
  end
61
61
  end
62
62
  source_names.each do |source_name|
@@ -4,7 +4,7 @@ module Raykit
4
4
  class SourceImports < Array
5
5
  def initialize(urls)
6
6
  urls.each do |url|
7
- self << SourceImport.new(url, 'src', '**/*.cs', 'dep', '')
7
+ self << SourceImport.new(url, "src", "**/*.cs", "dep", "")
8
8
  end
9
9
  end
10
10
 
@@ -24,7 +24,7 @@ module Raykit
24
24
  end
25
25
 
26
26
  def save(filename)
27
- File.open(filename, 'w') do |f|
27
+ File.open(filename, "w") do |f|
28
28
  f.write(JSON.pretty_generate(self))
29
29
  end
30
30
  end
@@ -33,8 +33,8 @@ module Raykit
33
33
  sourceImports = SourceImports.new([])
34
34
  array = JSON.parse(IO.read(filename))
35
35
  array.each do |hash|
36
- sourceImport = SourceImport.new(hash['remote'], hash['source'], hash['glob'], hash['target'],
37
- hash['commit'])
36
+ sourceImport = SourceImport.new(hash["remote"], hash["source"], hash["glob"], hash["target"],
37
+ hash["commit"])
38
38
  sourceImports << sourceImport
39
39
  end
40
40
  sourceImports
data/lib/raykit/string.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('./environment')
3
+ require_relative("./environment")
4
4
 
5
5
  class String
6
6
  def work_dir
7
- rel_name = sub('https://', '').gsub('http://', '').gsub('.git', '')
8
- "#{Raykit::Environment.get_dev_dir('work')}/#{rel_name}"
7
+ rel_name = sub("https://", "").gsub("http://", "").gsub(".git", "")
8
+ "#{Raykit::Environment.get_dev_dir("work")}/#{rel_name}"
9
9
  end
10
10
 
11
11
  def latest_commit
data/lib/raykit/tasks.rb CHANGED
@@ -1,33 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- desc 'Display project information'
3
+ desc "Display project information"
4
4
  task :info do
5
5
  PROJECT.info
6
6
  end
7
7
 
8
- desc 'integrate changes into the git repository'
8
+ desc "integrate changes into the git repository"
9
9
  task :integrate do
10
- puts Rainbow(':integrate').blue.bright
10
+ puts Rainbow(":integrate").blue.bright
11
11
 
12
12
  git_dir = Raykit::Git::Directory.new(Rake.application.original_dir)
13
13
  if git_dir.detached?
14
- puts 'detached head state, skipping integrate operations'
14
+ puts "detached head state, skipping integrate operations"
15
15
  else
16
16
  if PROJECT.outstanding_commit?
17
- Rake::Task['test'].invoke if Rake::Task.task_defined?('test')
17
+ Rake::Task["test"].invoke if Rake::Task.task_defined?("test")
18
18
  else
19
- puts 'no outstanding commits detected'
19
+ puts "no outstanding commits detected"
20
20
  end
21
21
 
22
- if !File.exist?('.gitignore')
23
- puts 'warning: .gitignore does not exist.'
22
+ if !File.exist?(".gitignore")
23
+ puts "warning: .gitignore does not exist."
24
24
  else
25
- PROJECT.run('git add --all')
26
- unless `git status`.include?('nothing to commit')
25
+ PROJECT.run("git add --all")
26
+ unless `git status`.include?("nothing to commit")
27
27
  # if(PROJECT.outstanding_commit?)
28
- commit_message = 'integrate'
28
+ commit_message = "integrate"
29
29
  PROJECT.run("git commit -m\"#{commit_message}\"") if PROJECT.outstanding_commit?
30
- PROJECT.run('git pull')
30
+ PROJECT.run("git pull")
31
31
  # PROJECT.run("git push")
32
32
  # PROJECT.run("git push --tags")
33
33
  end
@@ -35,40 +35,40 @@ task :integrate do
35
35
  end
36
36
  end
37
37
 
38
- desc 'push changes including tags'
38
+ desc "push changes including tags"
39
39
  task :push do
40
40
  git_dir = Raykit::Git::Directory.new(Rake.application.original_dir)
41
41
  if git_dir.detached?
42
- puts 'detached head state, skipping push operations'
42
+ puts "detached head state, skipping push operations"
43
43
  else
44
- PROJECT.run('git push')
45
- PROJECT.run('git push --tags')
44
+ PROJECT.run("git push")
45
+ PROJECT.run("git push --tags")
46
46
  end
47
47
  end
48
48
 
49
- desc 'clean files not tracked by git'
49
+ desc "clean files not tracked by git"
50
50
  task :clean do
51
- puts Rainbow(':clean').blue.bright
52
- PROJECT.run('git clean -dXf')
51
+ puts Rainbow(":clean").blue.bright
52
+ PROJECT.run("git clean -dXf")
53
53
  end
54
54
 
55
- desc 'update_source from sourceImports.json'
55
+ desc "update_source from sourceImports.json"
56
56
  task :update_source do
57
- if File.exist?('sourceImports.json')
58
- puts Rainbow(':update_source').blue.bright
59
- sourceImports = Raykit::SourceImports.load('sourceImports.json')
57
+ if File.exist?("sourceImports.json")
58
+ puts Rainbow(":update_source").blue.bright
59
+ sourceImports = Raykit::SourceImports.load("sourceImports.json")
60
60
  json = sourceImports.to_json
61
61
  sourceImports.update
62
62
 
63
63
  json2 = sourceImports.to_json
64
64
  if json2 != json || !sourceImports.targets_exist?
65
- sourceImports.save('sourceImports.json')
65
+ sourceImports.save("sourceImports.json")
66
66
  sourceImports.copy
67
67
  else
68
- puts ' no update required.'
68
+ puts " no update required."
69
69
  end
70
70
  end
71
71
  end
72
72
 
73
- desc 'update source files'
73
+ desc "update source files"
74
74
  task update: [:update_source]
data/lib/raykit/text.rb CHANGED
@@ -10,10 +10,8 @@ module Raykit
10
10
  text1 = IO.read(filename)
11
11
  text2 = text1.gsub(search) { |_str| str = replace }
12
12
  unless text1 == text2
13
- if File.writable?(filename)
14
- File.open(filename, 'w') { |f| f.puts text2 }
15
- return true
16
- end
13
+ File.open(filename, "w") { |f| f.puts text2 }
14
+ return true
17
15
  end
18
16
  false
19
17
  end
data/lib/raykit/timer.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'time'
3
+ require "time"
4
4
 
5
5
  module Raykit
6
6
  # Provides functionality to record the time execution times
@@ -25,7 +25,7 @@ module Raykit
25
25
  # Converts a time span in seconds to a formatted string
26
26
  def self.get_elapsed_str(elapsed, pad = 0)
27
27
  # "[" + "%.0f" % (elapsed) + "s]".ljust(pad)
28
- format('%.0f', elapsed) + 's'.ljust(pad)
28
+ format("%.0f", elapsed) + "s".ljust(pad)
29
29
  end
30
30
  end
31
31
  end
@@ -27,19 +27,19 @@ module Raykit
27
27
 
28
28
  if verbose
29
29
  warning = "\u26A0"
30
- symbol = Rainbow(warning.encode('utf-8')).yellow
30
+ symbol = Rainbow(warning.encode("utf-8")).yellow
31
31
  puts "#{symbol} version not detected"
32
32
  end
33
- ''
33
+ ""
34
34
  end
35
35
 
36
36
  def self.detect_from_file(filename, regex, verbose)
37
- version = ''
37
+ version = ""
38
38
  if File.exist?(filename)
39
39
  match = IO.read(filename).match(regex)
40
40
  version = match.captures[0] if !match.nil? && match.captures.length.positive?
41
41
  else
42
- return ''
42
+ return ""
43
43
  end
44
44
  if verbose
45
45
  if version.length.positive?
@@ -53,12 +53,12 @@ module Raykit
53
53
 
54
54
  def self.set_version_in_file(filename, version)
55
55
  text = IO.read(filename)
56
- new_text = text.gsub(/version\s?=\s?['|"]([.\d]+)['|"]/, "version='#{version}'") if filename.include?('.gemspec')
57
- new_text = text.gsub(/<Version>([-\w\d.]+)</, "<Version>#{version}<") if filename.include?('.csproj')
56
+ new_text = text.gsub(/version\s?=\s?['|"]([.\d]+)['|"]/, "version='#{version}'") if filename.include?(".gemspec")
57
+ new_text = text.gsub(/<Version>([-\w\d.]+)</, "<Version>#{version}<") if filename.include?(".csproj")
58
58
  # new_text=text.gsub(/<Version>([-\w\d.]+)</,"<Version>#{version}<")
59
59
  # new_text=new_text.gsub(/version[\s]+=\s?['|"]([.\d]+)['|"]/,"version='#{version}'")
60
60
  # new_text=new_text.gsub(/Version="([.\d]+)"/,"Version=\"#{version}\"")
61
- File.open(filename, 'w') { |f| f.write(new_text) } if new_text != text
61
+ File.open(filename, "w") { |f| f.write(new_text) } if new_text != text
62
62
  end
63
63
 
64
64
  def self.sync_file_versions(source_filename, destination_filename)
@@ -69,19 +69,19 @@ module Raykit
69
69
  # increment to last digit of a version string
70
70
  def self.bump(version)
71
71
  # major.minor[.build[.revision]] (example: 1.2.12.102)
72
- version_ints = version.split('.').map(&:to_i)
72
+ version_ints = version.split(".").map(&:to_i)
73
73
  version_ints[-1] = version_ints.last + 1
74
- version_ints.map(&:to_s).join('.')
74
+ version_ints.map(&:to_s).join(".")
75
75
  end
76
76
 
77
77
  def self.bump_file(filename)
78
78
  warn "Raykit::Version.bump_file filename '#{filename}' does not exist." unless File.exist?(filename)
79
79
 
80
- old_version = ''
81
- if filename.include?('.gemspec')
80
+ old_version = ""
81
+ if filename.include?(".gemspec")
82
82
  old_version = detect_from_file(filename, /version\s?=\s?['|"]([.\d]+)['|"]/, false)
83
83
  end
84
- old_version = detect_from_file(filename, /<Version>([-\w\d.]+)</, false) if filename.include?('.csproj')
84
+ old_version = detect_from_file(filename, /<Version>([-\w\d.]+)</, false) if filename.include?(".csproj")
85
85
 
86
86
  if old_version.length.positive?
87
87
  new_version = bump(old_version)
data/lib/raykit/vstest.rb CHANGED
@@ -3,19 +3,19 @@
3
3
  module Raykit
4
4
  class VsTest
5
5
  def self.vstest_path
6
- ['2019/Community/Common7/IDE/CommonExtensions/Microsoft',
7
- '2019/Professional/Common7/IDE/Extensions/TestPlatform',
8
- '2019/Community/Common7/IDE/Extensions',
9
- '2019/Community/Common7/IDE/Extensions/TestPlatform',
10
- '2022/Preview/Common7/IDE/Extensions/TestPlatform'].each do |relative_path|
11
- ['C:/Program Files (x86)/Microsoft Visual Studio/',
12
- 'C:/Program Files/Microsoft Visual Studio/'].each do |root_path|
6
+ ["2019/Community/Common7/IDE/CommonExtensions/Microsoft",
7
+ "2019/Professional/Common7/IDE/Extensions/TestPlatform",
8
+ "2019/Community/Common7/IDE/Extensions",
9
+ "2019/Community/Common7/IDE/Extensions/TestPlatform",
10
+ "2022/Preview/Common7/IDE/Extensions/TestPlatform"].each do |relative_path|
11
+ ["C:/Program Files (x86)/Microsoft Visual Studio/",
12
+ "C:/Program Files/Microsoft Visual Studio/"].each do |root_path|
13
13
  path = root_path + relative_path
14
14
  exe_path = "#{path}/vstest.console.exe"
15
15
  return path if Dir.exist?(path) && File.exist?(exe_path)
16
16
  end
17
17
  end
18
- 'vstest_path not found'
18
+ "vstest_path not found"
19
19
  end
20
20
  end
21
21
  end
data/lib/raykit.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rainbow'
4
- require 'rake/clean'
5
- require 'open3'
6
- require 'rake/testtask'
7
- require 'digest'
3
+ require "rainbow"
4
+ require "rake/clean"
5
+ require "open3"
6
+ require "rake/testtask"
7
+ require "digest"
8
8
 
9
9
  lib_dir = File.dirname(__FILE__)
10
10
  Dir.glob("#{lib_dir}/raykit/**/*.rb").sort.each { |file| require file }
@@ -13,5 +13,5 @@ PROJECT = Raykit::Project.new
13
13
  SECRETS = Raykit::Secrets.new
14
14
  # TIMER=Raykit::Timer.new
15
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) #if Dir.exist?('.git')
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) if Dir.exist?(".git")
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.319
4
+ version: 0.0.320
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lou Parslow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-24 00:00:00.000000000 Z
11
+ date: 2021-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler