raykit 0.0.309 → 0.0.310

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,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rake/clean"
4
- require "digest"
3
+ require 'rake/clean'
4
+ require 'digest'
5
5
  RAKE_DIRECTORY = Rake.application.original_dir
6
-
7
6
  module Raykit
8
7
  class Project
9
8
  attr_accessor :name, :timer, :verbose, :target
@@ -20,8 +19,8 @@ module Raykit
20
19
  def initialize
21
20
  @verbose = false
22
21
  @timer = Raykit::Timer.new
23
- @remote = ""
24
- @commit_message_filename = "commit_message.tmp"
22
+ @remote = ''
23
+ @commit_message_filename = 'commit_message.tmp'
25
24
  if Dir.exist?(RAKE_DIRECTORY)
26
25
  @directory = RAKE_DIRECTORY
27
26
  if Dir.exist?("#{RAKE_DIRECTORY}/.git") && Dir.exist?(@directory)
@@ -29,7 +28,7 @@ module Raykit
29
28
  @remote = @git_directory.remote
30
29
  end
31
30
  else
32
- @directory = ""
31
+ @directory = ''
33
32
  end
34
33
 
35
34
  # @log=Log.new("#{RAKE_DIRECTORY}/tmp/raykit.log")
@@ -37,16 +36,16 @@ module Raykit
37
36
  if defined?(NAME)
38
37
  @name = NAME
39
38
  else
40
- slns = Dir.glob("*.sln")
39
+ slns = Dir.glob('*.sln')
41
40
  if slns.length == 1
42
- @name = slns[0].gsub(".sln", "")
41
+ @name = slns[0].gsub('.sln', '')
43
42
  else
44
- gemspecs = Dir.glob("*.gemspec")
43
+ gemspecs = Dir.glob('*.gemspec')
45
44
  if gemspecs.length == 1
46
- @name = gemspecs[0].gsub(".gemspec", "")
45
+ @name = gemspecs[0].gsub('.gemspec', '')
47
46
  else
48
- remote_parts = @remote.split("/")
49
- @name = remote_parts[-1].gsub(".git", "") if remote_parts.length.positive?
47
+ remote_parts = @remote.split('/')
48
+ @name = remote_parts[-1].gsub('.git', '') if remote_parts.length.positive?
50
49
  end
51
50
  end
52
51
  end
@@ -65,7 +64,7 @@ module Raykit
65
64
  def target_md5
66
65
  return Digest::MD5.file(target).to_s.strip if !target.nil? && File.exist?(target)
67
66
 
68
- ""
67
+ ''
69
68
  end
70
69
 
71
70
  def branch
@@ -83,7 +82,7 @@ module Raykit
83
82
 
84
83
  def outstanding_commit?
85
84
  Dir.chdir(@directory) do
86
- return true unless `git status`.include?("nothing to commit")
85
+ return true unless `git status`.include?('nothing to commit')
87
86
  end
88
87
  false
89
88
  end
@@ -92,7 +91,7 @@ module Raykit
92
91
  # puts `git log -n 1`
93
92
  # !latest_tag_commit.eql?(latest_commit)
94
93
  # commit 2e4cb6d6c0721e16cd06afee85b7cdc27354921b (HEAD -> master, tag: 0.0.180, origin/master, origin/HEAD)
95
- outstanding_commit? || !`git log -n 1`.include?("tag:")
94
+ outstanding_commit? || !`git log -n 1`.include?('tag:')
96
95
  end
97
96
 
98
97
  def has_diff?(filename)
@@ -133,12 +132,12 @@ module Raykit
133
132
  scan = text.scan(/md5=(\w{32})/)
134
133
  return scan[0][0].to_s.strip if scan.length.positive? && scan[0].length.positive?
135
134
 
136
- ""
135
+ ''
137
136
  end
138
137
 
139
138
  def last_modified_filename
140
139
  Dir.chdir(@directory) do
141
- Dir.glob("**/*.*").select { |f| File.file?(f) }.max_by { |f| File.mtime(f) }
140
+ Dir.glob('**/*.*').select { |f| File.file?(f) }.max_by { |f| File.mtime(f) }
142
141
  end
143
142
  end
144
143
 
@@ -167,32 +166,32 @@ module Raykit
167
166
  def elapsed
168
167
  elapsed = @timer.elapsed
169
168
  if elapsed < 1.0
170
- "#{format("%.1f", @timer.elapsed)}s"
169
+ "#{format('%.1f', @timer.elapsed)}s"
171
170
  else
172
- "#{format("%.0f", @timer.elapsed)}s"
171
+ "#{format('%.0f', @timer.elapsed)}s"
173
172
  end
174
173
  end
175
174
 
176
175
  def info
177
176
  ljust = 35
178
- puts ""
179
- puts "PROJECT.name".ljust(ljust) + Rainbow(PROJECT.name).yellow.bright
180
- puts "PROJECT.version".ljust(ljust) + Rainbow(PROJECT.version).yellow.bright
181
- puts "PROJECT.remote".ljust(ljust) + Rainbow(PROJECT.remote).yellow.bright
182
- puts "PROJECT.branch".ljust(ljust) + Rainbow(PROJECT.branch).yellow.bright
177
+ puts ''
178
+ puts 'PROJECT.name'.ljust(ljust) + Rainbow(PROJECT.name).yellow.bright
179
+ puts 'PROJECT.version'.ljust(ljust) + Rainbow(PROJECT.version).yellow.bright
180
+ puts 'PROJECT.remote'.ljust(ljust) + Rainbow(PROJECT.remote).yellow.bright
181
+ puts 'PROJECT.branch'.ljust(ljust) + Rainbow(PROJECT.branch).yellow.bright
183
182
  # puts "PROJECT.target".ljust(ljust) + Rainbow(PROJECT.target).yellow.bright
184
183
  # puts "PROJECT.target_md5".ljust(ljust) + Rainbow(PROJECT.target_md5).yellow.bright
185
- puts "PROJECT.latest_tag".ljust(ljust) + Rainbow(PROJECT.latest_tag).yellow.bright
186
- puts "PROJECT.latest_tag_commit".ljust(ljust) + Rainbow(PROJECT.latest_tag_commit).yellow.bright
187
- puts "PROJECT.latest_tag_md5".ljust(ljust) + Rainbow(PROJECT.latest_tag_md5).yellow.bright
188
- puts "PROJECT.latest_commit".ljust(ljust) + Rainbow(PROJECT.latest_commit).yellow.bright
189
- puts "PROJECT.last_modified_filename".ljust(ljust) + Rainbow(PROJECT.last_modified_filename).yellow.bright
184
+ puts 'PROJECT.latest_tag'.ljust(ljust) + Rainbow(PROJECT.latest_tag).yellow.bright
185
+ puts 'PROJECT.latest_tag_commit'.ljust(ljust) + Rainbow(PROJECT.latest_tag_commit).yellow.bright
186
+ puts 'PROJECT.latest_tag_md5'.ljust(ljust) + Rainbow(PROJECT.latest_tag_md5).yellow.bright
187
+ puts 'PROJECT.latest_commit'.ljust(ljust) + Rainbow(PROJECT.latest_commit).yellow.bright
188
+ puts 'PROJECT.last_modified_filename'.ljust(ljust) + Rainbow(PROJECT.last_modified_filename).yellow.bright
190
189
  # puts "PROJECT.elapsed".ljust(ljust) + Rainbow(PROJECT.elapsed).yellow.bright
191
- puts "PROJECT.size".ljust(ljust) + Rainbow(PROJECT.size).yellow.bright
192
- puts "PROJECT.size_pack".ljust(ljust) + Rainbow(PROJECT.size_pack).yellow.bright
193
- puts "PROJECT.outstanding_commit?".ljust(ljust) + Rainbow(PROJECT.outstanding_commit?).yellow.bright
194
- puts "PROJECT.outstanding_tag?".ljust(ljust) + Rainbow(PROJECT.outstanding_tag?).yellow.bright
195
- puts ""
190
+ puts 'PROJECT.size'.ljust(ljust) + Rainbow(PROJECT.size).yellow.bright
191
+ puts 'PROJECT.size_pack'.ljust(ljust) + Rainbow(PROJECT.size_pack).yellow.bright
192
+ puts 'PROJECT.outstanding_commit?'.ljust(ljust) + Rainbow(PROJECT.outstanding_commit?).yellow.bright
193
+ puts 'PROJECT.outstanding_tag?'.ljust(ljust) + Rainbow(PROJECT.outstanding_tag?).yellow.bright
194
+ puts ''
196
195
  self
197
196
  end
198
197
 
@@ -210,10 +209,10 @@ module Raykit
210
209
  def commit(commit_message)
211
210
  warn "[DEPRECATION] 'commit_message_filename' is deprectated. Use a run command for better transparency."
212
211
  Dir.chdir(@directory) do
213
- if File.exist?(".gitignore")
212
+ if File.exist?('.gitignore')
214
213
  status = `git status`
215
- if status.include?("Changes not staged for commit:")
216
- run("git add --all")
214
+ if status.include?('Changes not staged for commit:')
215
+ run('git add --all')
217
216
  if GIT_DIRECTORY.outstanding_commit?
218
217
  if File.exist?(@commit_message_filename)
219
218
  run("git commit --file #{@commit_message_filename}")
@@ -224,7 +223,7 @@ module Raykit
224
223
  end
225
224
  end
226
225
  else
227
- puts "warning: .gitignore not found."
226
+ puts 'warning: .gitignore not found.'
228
227
  end
229
228
  end
230
229
  self
@@ -234,7 +233,7 @@ module Raykit
234
233
  Dir.chdir(@directory) do
235
234
  status = `git status`
236
235
  if status.include?('use "git push"')
237
- run("git push")
236
+ run('git push')
238
237
 
239
238
  # run('git push --tags')
240
239
  end
@@ -244,7 +243,7 @@ module Raykit
244
243
 
245
244
  def pull
246
245
  Dir.chdir(@directory) do
247
- run("git pull")
246
+ run('git pull')
248
247
  end
249
248
  self
250
249
  end
@@ -279,9 +278,9 @@ module Raykit
279
278
  cmd.summary
280
279
  cmd.save
281
280
  elapsed_str = Timer.get_elapsed_str(cmd.elapsed, 0)
282
- if !cmd.exitstatus.nil? && cmd.exitstatus.zero?
283
- # puts elapsed_str + " " + Rainbow(cmd.command).yellow.bright
284
- # return elapsed_str + " " + cmd.command
281
+ if cmd.exitstatus.zero?
282
+ # puts elapsed_str + " " + Rainbow(cmd.command).yellow.bright
283
+ # return elapsed_str + " " + cmd.command
285
284
  else
286
285
  # display error details
287
286
  puts cmd.output
data/lib/raykit/rake.rb CHANGED
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "time"
3
+ require 'time'
4
4
 
5
5
  module Raykit
6
6
  class Rake
7
- def self.run(remote, branch, task = "default")
7
+ def self.run(remote, branch, task = 'default')
8
8
  repo = Raykit::Git::Repository.new(remote)
9
9
  rel_dir = repo.relative_path
10
10
  commit = repo.latest_commit(branch)
11
- log_filename = "#{Environment.get_dev_dir("log")}/RayKit.Runner/#{rel_dir}/#{branch}/#{commit}.json"
11
+ log_filename = "#{Environment.get_dev_dir('log')}/RayKit.Runner/#{rel_dir}/#{branch}/#{commit}.json"
12
12
  if File.exist?(log_filename)
13
13
  Command.parse(File.read(log_filename))
14
14
  else
15
- run_dir = "#{Environment.get_dev_dir("tmp")}/#{rel_dir}.#{branch}.#{commit}"
15
+ run_dir = "#{Environment.get_dev_dir('tmp')}/#{rel_dir}.#{branch}.#{commit}"
16
16
  unless Dir.exist?(run_dir)
17
- parent_dir = File.expand_path("..", run_dir)
17
+ parent_dir = File.expand_path('..', run_dir)
18
18
  FileUtils.mkdir_p(parent_dir) unless Dir.exist?(parent_dir)
19
19
  cmd = Command.new("git clone #{remote} #{run_dir}")
20
20
  end
@@ -22,7 +22,7 @@ module Raykit
22
22
  cmd = Command.new("rake #{task}")
23
23
  parent_dir = File.dirname(log_filename)
24
24
  FileUtils.mkdir_p(parent_dir) unless Dir.exist?(parent_dir)
25
- File.open(log_filename, "w") do |f|
25
+ File.open(log_filename, 'w') do |f|
26
26
  f.write(JSON.generate(cmd.to_hash))
27
27
  end
28
28
  return cmd
data/lib/raykit/runner.rb CHANGED
@@ -1,25 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "yaml"
3
+ require 'yaml'
4
4
 
5
5
  module Raykit
6
6
  class Runner
7
7
  def self.run(git_url)
8
8
  commands = []
9
- local_dir = Dir.mktmpdir("runner")
9
+ local_dir = Dir.mktmpdir('runner')
10
10
  puts "local_dir : #{local_dir}"
11
11
  commands << Raykit::Command.new("git clone #{git_url} #{local_dir}")
12
12
  Dir.chdir(local_dir) do
13
- commands << Raykit::Command.new("git log -n 1")
13
+ commands << Raykit::Command.new('git log -n 1')
14
14
  yaml = get_build_yaml(local_dir)
15
15
  build_hash = YAML.safe_load(yaml)
16
16
  build_commands = Raykit::Command.parse_yaml_commands(yaml)
17
- if build_hash.key?("image")
18
- image = build_hash["image"]
19
- build_commands.insert(0, "cd home")
17
+ if build_hash.key?('image')
18
+ image = build_hash['image']
19
+ build_commands.insert(0, 'cd home')
20
20
  build_commands.insert(1, "git clone #{git_url} build")
21
- build_commands.insert(2, "cd build")
22
- build_commands_string = build_commands.join(";")
21
+ build_commands.insert(2, 'cd build')
22
+ build_commands_string = build_commands.join(';')
23
23
  commands << Raykit::Command.new("docker run #{image} sh -c \"#{build_commands_string}\"")
24
24
  else
25
25
  build_commands.each do |cmd_string|
@@ -32,9 +32,9 @@ module Raykit
32
32
  end
33
33
 
34
34
  def self.get_build_yaml(directory)
35
- yaml = ""
35
+ yaml = ''
36
36
  Dir.chdir(directory) do
37
- yaml = File.open(".gitlab-ci.yml").read if File.exist?(".gitlab-ci.yml")
37
+ yaml = File.open('.gitlab-ci.yml').read if File.exist?('.gitlab-ci.yml')
38
38
  end
39
39
  yaml
40
40
  end
@@ -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,7 +10,7 @@ module Raykit
10
10
  text1 = IO.read(filename)
11
11
  text2 = text1.gsub(search) { |_str| str = replace }
12
12
  unless text1 == text2
13
- File.open(filename, "w") { |f| f.puts text2 }
13
+ File.open(filename, 'w') { |f| f.puts text2 }
14
14
  return true
15
15
  end
16
16
  false
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)