atk_toolbox 0.0.128 → 0.0.129

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 609e53aff4279d2541828ac6e13462a3b1d2608e9056c7574f1ffe293f454d1c
4
- data.tar.gz: 2014ab87c955c48d19a6fef6a31f86f01db450387ceeb7fa9fc792dee1ea4167
3
+ metadata.gz: f2f9360594ff9688633f537e595460ce9f4047ab4e7683a55453f4ddd852f702
4
+ data.tar.gz: 85259724896a5f69ab8bc4ef16ffd859063d1658758d1f29f2988d6dc15aea0d
5
5
  SHA512:
6
- metadata.gz: 244b47b1d8aafe47ec8f6b93b3fe544bf74bcd858fa9036d1d217bd65de54ff3c65f76fed47a976b970ada02e30e9e8408c96b1eb8267f7799f42b52053c727b
7
- data.tar.gz: '080ed7ebfb16e892e8bfa49a21407e98431710a395414cbe83087b6795f202e4ebe3ff497a6398a5def993e69e49ae08694b16810630e718dca4cdde854dd965'
6
+ metadata.gz: 0f27efc85e09e207e15b78d465d8e56cb4a7ec4c7c9b6b46f7c431d0a5d62919e4b2c8b3a58ca38f34d924f3b00966f8bb511632bf1ac3498893c98eaddef3fe
7
+ data.tar.gz: 468182f80cc8fe99b60a4b65188429698bf857342fbdf8997ee57bbe0eacd6bc65fb2e97269a2dcc7b733cfe5112c5d42c048d99ac3325db197a603ce3aaa62d
data/lib/atk/console.rb CHANGED
@@ -94,8 +94,8 @@ class TTY::Prompt
94
94
  else
95
95
  # find any backslashes that come before a double quote or the ending of the argument
96
96
  # then double the number of slashes
97
- escaped = argument.gsub(/(?<slashes>\/+)(?="|\z)/) do |each_match|
98
- "\/" * (each_match['slashes'].size * 2)
97
+ escaped = argument.gsub(/(\/+)(?="|\z)/) do |each_match|
98
+ "\/" * ($1.size * 2)
99
99
  end
100
100
 
101
101
  # then find all the double quotes and escape them
@@ -46,6 +46,13 @@ module FileSystem
46
46
  # actually download the file
47
47
  IO.write(to, data)
48
48
  end
49
+
50
+ def self.append(data, to:nil)
51
+ FileSystem.makedirs(File.dirname(to))
52
+ return open(to, 'a') do |file|
53
+ file << data
54
+ end
55
+ end
49
56
 
50
57
  def self.save(value, to:nil, as:nil)
51
58
  # assume string if as was not given
@@ -179,8 +186,11 @@ module FileSystem
179
186
  File.rename(path, to)
180
187
  end
181
188
 
182
- def self.touch(*args)
183
- return FileUtils.touch(*args)
189
+ def self.touch(path)
190
+ FileSystem.makedirs(File.dirname(path))
191
+ if not FileSystem.file?(path)
192
+ return IO.write(path, "")
193
+ end
184
194
  end
185
195
  singleton_class.send(:alias_method, :touch_file, :touch)
186
196
  singleton_class.send(:alias_method, :new_file, :touch)
data/lib/atk/os.rb CHANGED
@@ -23,7 +23,7 @@ module OS
23
23
 
24
24
  # create a singleton class
25
25
  class << (OS::CACHE = Object.new)
26
- attr_accessor :is_windows, :is_mac, :is_linux, :is_unix, :is_debian, :is_ubuntu
26
+ attr_accessor :is_windows, :is_mac, :is_linux, :is_unix, :is_debian, :is_ubuntu, :version
27
27
  end
28
28
 
29
29
  def self.is?(adjective)
@@ -67,6 +67,7 @@ module OS
67
67
  end
68
68
 
69
69
  def self.version
70
+ return OS::CACHE::version if OS::CACHE::version != nil
70
71
  # these statements need to be done in order from least to greatest
71
72
  if OS.is?("ubuntu")
72
73
  version_info = `lsb_release -a`
@@ -75,10 +76,9 @@ module OS
75
76
  if name_area
76
77
  version.codename = name_area[1].strip
77
78
  end
78
- return version
79
79
  elsif OS.is?("debian")
80
80
  # FUTURE: support debian version
81
- return nil
81
+ version = nil
82
82
  elsif OS.is?('mac')
83
83
  version = Version.extract_from(`system_profiler SPSoftwareDataType`)
84
84
  agreement_file = `cat '/System/Library/CoreServices/Setup Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf'`
@@ -86,11 +86,10 @@ module OS
86
86
  if codename_match
87
87
  version.codename = codename_match[1].strip
88
88
  end
89
- return version
90
89
  elsif OS.is?('windows')
91
- # TODO: support windows version
92
- return nil
90
+ version = nil
93
91
  end
92
+ OS::CACHE::version = version
94
93
  end
95
94
 
96
95
  def self.path_for_executable(name_of_executable)
data/lib/atk/version.rb CHANGED
@@ -1,5 +1,3 @@
1
- # create a variable for the current ruby version
2
-
3
1
  class Version
4
2
  attr_accessor :levels, :codename
5
3
 
@@ -23,7 +21,7 @@ class Version
23
21
  HEREDOC
24
22
  end
25
23
  @levels = version_as_string.split('.')
26
- @comparable = @levels[0] =~ /\A\d+\z/
24
+ @comparable = (@levels[0] =~ /\A\d+\z/) != nil
27
25
  # convert values into integers where possible
28
26
  index = -1
29
27
  for each in @levels.dup
@@ -66,13 +64,7 @@ class Version
66
64
  other_levels = other_version.levels.dup
67
65
  loop do
68
66
  if self_levels.size == 0 || other_levels.size == 0
69
- if self_levels.size > other_levels.size
70
- return 1
71
- elsif self_levels.size < other_levels.size
72
- return -1
73
- else
74
- return 0
75
- end
67
+ return 0
76
68
  end
77
69
  comparision = self_levels.shift() <=> other_levels.shift()
78
70
  if comparision != 0
@@ -1,3 +1,3 @@
1
1
  module AtkToolbox
2
- VERSION = '0.0.128'
2
+ VERSION = '0.0.129'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atk_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.128
4
+ version: 0.0.129
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Hykin