raykit 0.0.319 → 0.0.323

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,8 +1,9 @@
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
+
6
7
  module Raykit
7
8
  class Project
8
9
  attr_accessor :name, :timer, :verbose, :target
@@ -19,8 +20,8 @@ module Raykit
19
20
  def initialize
20
21
  @verbose = false
21
22
  @timer = Raykit::Timer.new
22
- @remote = ''
23
- @commit_message_filename = 'commit_message.tmp'
23
+ @remote = ""
24
+ @commit_message_filename = "commit_message.tmp"
24
25
  if Dir.exist?(RAKE_DIRECTORY)
25
26
  @directory = RAKE_DIRECTORY
26
27
  if Dir.exist?("#{RAKE_DIRECTORY}/.git") && Dir.exist?(@directory)
@@ -28,7 +29,7 @@ module Raykit
28
29
  @remote = @git_directory.remote
29
30
  end
30
31
  else
31
- @directory = ''
32
+ @directory = ""
32
33
  end
33
34
 
34
35
  # @log=Log.new("#{RAKE_DIRECTORY}/tmp/raykit.log")
@@ -36,16 +37,16 @@ module Raykit
36
37
  if defined?(NAME)
37
38
  @name = NAME
38
39
  else
39
- slns = Dir.glob('*.sln')
40
+ slns = Dir.glob("*.sln")
40
41
  if slns.length == 1
41
- @name = slns[0].gsub('.sln', '')
42
+ @name = slns[0].gsub(".sln", "")
42
43
  else
43
- gemspecs = Dir.glob('*.gemspec')
44
+ gemspecs = Dir.glob("*.gemspec")
44
45
  if gemspecs.length == 1
45
- @name = gemspecs[0].gsub('.gemspec', '')
46
+ @name = gemspecs[0].gsub(".gemspec", "")
46
47
  else
47
- remote_parts = @remote.split('/')
48
- @name = remote_parts[-1].gsub('.git', '') if remote_parts.length.positive?
48
+ remote_parts = @remote.split("/")
49
+ @name = remote_parts[-1].gsub(".git", "") if remote_parts.length.positive?
49
50
  end
50
51
  end
51
52
  end
@@ -64,15 +65,17 @@ module Raykit
64
65
  def target_md5
65
66
  return Digest::MD5.file(target).to_s.strip if !target.nil? && File.exist?(target)
66
67
 
67
- ''
68
+ ""
68
69
  end
69
70
 
70
71
  def branch
72
+ return "main" if @git_directory.nil?
71
73
  @git_directory.branch
72
74
  end
73
75
 
74
76
  # latest local commit
75
77
  def latest_commit
78
+ return "" if detached?
76
79
  Dir.chdir(@directory) do
77
80
  text = `git log -n 1`
78
81
  scan = text.scan(/commit (\w+)\s/)
@@ -82,7 +85,7 @@ module Raykit
82
85
 
83
86
  def outstanding_commit?
84
87
  Dir.chdir(@directory) do
85
- return true unless `git status`.include?('nothing to commit')
88
+ return true unless `git status`.include?("nothing to commit")
86
89
  end
87
90
  false
88
91
  end
@@ -91,16 +94,14 @@ module Raykit
91
94
  # puts `git log -n 1`
92
95
  # !latest_tag_commit.eql?(latest_commit)
93
96
  # commit 2e4cb6d6c0721e16cd06afee85b7cdc27354921b (HEAD -> master, tag: 0.0.180, origin/master, origin/HEAD)
94
- outstanding_commit? || !`git log -n 1`.include?('tag:')
97
+ outstanding_commit? || !`git log -n 1`.include?("tag:")
95
98
  end
96
99
 
97
100
  def detached?
98
- return true if @git_directory.nil?
101
+ return true if @git_directory.nil?
99
102
  @git_directory.detached?
100
103
  end
101
104
 
102
-
103
-
104
105
  def has_diff?(filename)
105
106
  Dir.chdir(@directory) do
106
107
  text = `git diff #{filename}`.strip
@@ -139,12 +140,12 @@ module Raykit
139
140
  scan = text.scan(/md5=(\w{32})/)
140
141
  return scan[0][0].to_s.strip if scan.length.positive? && scan[0].length.positive?
141
142
 
142
- ''
143
+ ""
143
144
  end
144
145
 
145
146
  def last_modified_filename
146
147
  Dir.chdir(@directory) do
147
- Dir.glob('**/*.*').select { |f| File.file?(f) }.max_by { |f| File.mtime(f) }
148
+ Dir.glob("**/*.*").select { |f| File.file?(f) }.max_by { |f| File.mtime(f) }
148
149
  end
149
150
  end
150
151
 
@@ -173,36 +174,33 @@ module Raykit
173
174
  def elapsed
174
175
  elapsed = @timer.elapsed
175
176
  if elapsed < 1.0
176
- "#{format('%.1f', @timer.elapsed)}s"
177
+ "#{format("%.1f", @timer.elapsed)}s"
177
178
  else
178
- "#{format('%.0f', @timer.elapsed)}s"
179
+ "#{format("%.0f", @timer.elapsed)}s"
179
180
  end
180
181
  end
181
182
 
182
183
  def info
183
184
  ljust = 35
184
- puts ''
185
- puts 'PROJECT.name'.ljust(ljust) + Rainbow(PROJECT.name).yellow.bright
186
- puts 'PROJECT.version'.ljust(ljust) + Rainbow(PROJECT.version).yellow.bright
187
- puts 'PROJECT.remote'.ljust(ljust) + Rainbow(PROJECT.remote).yellow.bright
188
- puts 'PROJECT.detached?'.ljust(ljust) + Rainbow(PROJECT.detached?).yellow.bright
189
- if !PROJECT.detached?
190
- puts 'PROJECT.branch'.ljust(ljust) + Rainbow(PROJECT.branch).yellow.bright if !branch.nil?
191
-
192
- # puts "PROJECT.target".ljust(ljust) + Rainbow(PROJECT.target).yellow.bright
193
- # puts "PROJECT.target_md5".ljust(ljust) + Rainbow(PROJECT.target_md5).yellow.bright
194
- puts 'PROJECT.latest_tag'.ljust(ljust) + Rainbow(PROJECT.latest_tag).yellow.bright
195
- puts 'PROJECT.latest_tag_commit'.ljust(ljust) + Rainbow(PROJECT.latest_tag_commit).yellow.bright
196
- puts 'PROJECT.latest_tag_md5'.ljust(ljust) + Rainbow(PROJECT.latest_tag_md5).yellow.bright
197
- puts 'PROJECT.latest_commit'.ljust(ljust) + Rainbow(PROJECT.latest_commit).yellow.bright
198
- puts 'PROJECT.last_modified_filename'.ljust(ljust) + Rainbow(PROJECT.last_modified_filename).yellow.bright
199
- # puts "PROJECT.elapsed".ljust(ljust) + Rainbow(PROJECT.elapsed).yellow.bright
200
- puts 'PROJECT.size'.ljust(ljust) + Rainbow(PROJECT.size).yellow.bright
201
- puts 'PROJECT.size_pack'.ljust(ljust) + Rainbow(PROJECT.size_pack).yellow.bright
202
- puts 'PROJECT.outstanding_commit?'.ljust(ljust) + Rainbow(PROJECT.outstanding_commit?).yellow.bright
203
- puts 'PROJECT.outstanding_tag?'.ljust(ljust) + Rainbow(PROJECT.outstanding_tag?).yellow.bright
204
- end
205
- puts ''
185
+ puts ""
186
+ puts "PROJECT.name".ljust(ljust) + Rainbow(PROJECT.name).yellow.bright
187
+ puts "PROJECT.version".ljust(ljust) + Rainbow(PROJECT.version).yellow.bright
188
+ puts "PROJECT.remote".ljust(ljust) + Rainbow(PROJECT.remote).yellow.bright
189
+ puts "PROJECT.branch".ljust(ljust) + Rainbow(PROJECT.branch).yellow.bright
190
+ puts "PROJECT.detached?".ljust(ljust) + Rainbow(PROJECT.detached?).yellow.bright
191
+ # puts "PROJECT.target".ljust(ljust) + Rainbow(PROJECT.target).yellow.bright
192
+ # puts "PROJECT.target_md5".ljust(ljust) + Rainbow(PROJECT.target_md5).yellow.bright
193
+ puts "PROJECT.latest_tag".ljust(ljust) + Rainbow(PROJECT.latest_tag).yellow.bright
194
+ puts "PROJECT.latest_tag_commit".ljust(ljust) + Rainbow(PROJECT.latest_tag_commit).yellow.bright
195
+ puts "PROJECT.latest_tag_md5".ljust(ljust) + Rainbow(PROJECT.latest_tag_md5).yellow.bright
196
+ puts "PROJECT.latest_commit".ljust(ljust) + Rainbow(PROJECT.latest_commit).yellow.bright
197
+ puts "PROJECT.last_modified_filename".ljust(ljust) + Rainbow(PROJECT.last_modified_filename).yellow.bright
198
+ # puts "PROJECT.elapsed".ljust(ljust) + Rainbow(PROJECT.elapsed).yellow.bright
199
+ puts "PROJECT.size".ljust(ljust) + Rainbow(PROJECT.size).yellow.bright
200
+ puts "PROJECT.size_pack".ljust(ljust) + Rainbow(PROJECT.size_pack).yellow.bright
201
+ puts "PROJECT.outstanding_commit?".ljust(ljust) + Rainbow(PROJECT.outstanding_commit?).yellow.bright
202
+ puts "PROJECT.outstanding_tag?".ljust(ljust) + Rainbow(PROJECT.outstanding_tag?).yellow.bright
203
+ puts ""
206
204
  self
207
205
  end
208
206
 
@@ -220,10 +218,10 @@ module Raykit
220
218
  def commit(commit_message)
221
219
  warn "[DEPRECATION] 'commit_message_filename' is deprectated. Use a run command for better transparency."
222
220
  Dir.chdir(@directory) do
223
- if File.exist?('.gitignore')
221
+ if File.exist?(".gitignore")
224
222
  status = `git status`
225
- if status.include?('Changes not staged for commit:')
226
- run('git add --all')
223
+ if status.include?("Changes not staged for commit:")
224
+ run("git add --all")
227
225
  if GIT_DIRECTORY.outstanding_commit?
228
226
  if File.exist?(@commit_message_filename)
229
227
  run("git commit --file #{@commit_message_filename}")
@@ -234,7 +232,7 @@ module Raykit
234
232
  end
235
233
  end
236
234
  else
237
- puts 'warning: .gitignore not found.'
235
+ puts "warning: .gitignore not found."
238
236
  end
239
237
  end
240
238
  self
@@ -244,9 +242,7 @@ module Raykit
244
242
  Dir.chdir(@directory) do
245
243
  status = `git status`
246
244
  if status.include?('use "git push"')
247
- run('git push')
248
-
249
- # run('git push --tags')
245
+ run("git push")
250
246
  end
251
247
  end
252
248
  self
@@ -254,7 +250,7 @@ module Raykit
254
250
 
255
251
  def pull
256
252
  Dir.chdir(@directory) do
257
- run('git pull')
253
+ run("git pull")
258
254
  end
259
255
  self
260
256
  end
@@ -281,17 +277,15 @@ module Raykit
281
277
  self
282
278
  end
283
279
 
284
- def run(command, quit_on_failure = true, success_log_level = Logger::DEBUG)
280
+ def run(command, quit_on_failure = true)
285
281
  if command.is_a?(Array)
286
282
  command.each { |subcommand| run(subcommand, quit_on_failure, success_log_level) }
287
283
  else
288
- cmd = Command.new(command, 0, success_log_level)
284
+ cmd = Command.new(command).set_timeout(0).run
289
285
  cmd.summary
290
286
  cmd.save
291
287
  elapsed_str = Timer.get_elapsed_str(cmd.elapsed, 0)
292
- if cmd.exitstatus.zero?
293
- # puts elapsed_str + " " + Rainbow(cmd.command).yellow.bright
294
- # return elapsed_str + " " + cmd.command
288
+ if !cmd.exitstatus.nil? && cmd.exitstatus.zero?
295
289
  else
296
290
  # display error details
297
291
  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,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