atk_toolbox 0.0.93 → 0.0.94
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.
- checksums.yaml +4 -4
- data/lib/atk/console.rb +2 -6
- data/lib/atk/os.rb +45 -1
- data/lib/atk/version.rb +8 -1
- data/lib/atk_toolbox/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ce2d5d70547d1bffd0041e5d7b9c504cf8b44fad6e77019ff69ed05c6d00ff2
|
4
|
+
data.tar.gz: 9804fc2f8af7ff355304ece47284da19bce9182a29e55ccbb8ab6ea73a6d8b1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 348f483690a7e3ac5b15bdb404fb7709ac4812278f66bb1a5c4432e95afbf9c72d352312b23491779068554b03e44c6d654916ecdd5becf40c83e15f0152bba2
|
7
|
+
data.tar.gz: 9ba6af93b93fe6ff713a6cfd6965d0dd7c482d0c6175695fc2122643d55249eefcb6f7300a507ca3c933ef458ecde069d935f4126c8d4d0aad04d0d882b51552
|
data/lib/atk/console.rb
CHANGED
@@ -51,15 +51,11 @@ class TTY::Prompt
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def path_for(name_of_executable)
|
54
|
-
|
55
|
-
return `where '#{name_of_executable}'`.strip
|
56
|
-
else
|
57
|
-
return `which '#{name_of_executable}'`.strip
|
58
|
-
end
|
54
|
+
return OS.path_for_executable(name_of_executable)
|
59
55
|
end
|
60
56
|
|
61
57
|
def has_command(name_of_executable)
|
62
|
-
return
|
58
|
+
return OS.has_command(name_of_executable)
|
63
59
|
end
|
64
60
|
|
65
61
|
def single_quote_escape(string)
|
data/lib/atk/os.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require_relative './version.rb'
|
1
2
|
# every OS version is a perfect heirarchy of versions and sub verisons that may or may not be chronological
|
2
3
|
# every OS gets it's own custom heirarchy since there are issues like x86 support and "student edition" etc
|
3
4
|
# the plan is to release this heirarchy on its own repo, and to get pull requests for anyone who wants to add their own OS
|
@@ -59,7 +60,7 @@ module OS
|
|
59
60
|
# this is a function created for convenience, so it doesn't have to be perfect
|
60
61
|
# you can use it to ask about random qualities of the current OS and get a boolean response
|
61
62
|
# convert to string (if its a symbol)
|
62
|
-
adjective = adjective.to_s
|
63
|
+
adjective = adjective.to_s.downcase
|
63
64
|
case adjective
|
64
65
|
when 'windows'
|
65
66
|
return (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
@@ -71,6 +72,49 @@ module OS
|
|
71
72
|
return not( OS.is?(:windows))
|
72
73
|
when 'debian'
|
73
74
|
return File.file?('/etc/debian_version')
|
75
|
+
when 'ubuntu'
|
76
|
+
return OS.has_command('lsb_release') && `lsb_release -a`.match(/Distributor ID: Ubuntu/)
|
74
77
|
end
|
75
78
|
end
|
79
|
+
|
80
|
+
def self.version
|
81
|
+
# these statements need to be done in order from least to greatest
|
82
|
+
if OS.is?("ubuntu")
|
83
|
+
if OS.has_command('lsb_release')
|
84
|
+
version_info = `lsb_release -a`
|
85
|
+
version = Version.extract_from(version_info)
|
86
|
+
name_area = version_info.match(/Codename: *(.+)/)
|
87
|
+
if name_area
|
88
|
+
version.codename = name_area[1].strip
|
89
|
+
end
|
90
|
+
return version
|
91
|
+
end
|
92
|
+
elsif OS.is?("debian")
|
93
|
+
# TODO: support debian version
|
94
|
+
return nil
|
95
|
+
elsif OS.is?('mac')
|
96
|
+
version = Version.extract_from(`system_profiler SPSoftwareDataType`)
|
97
|
+
agreement_file = `cat '/System/Library/CoreServices/Setup Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf'`
|
98
|
+
codename_match = agreement_file.match(/SOFTWARE LICENSE AGREEMENT FOR *(?:macOS)? *(.+)\\\n/)
|
99
|
+
if codename_match
|
100
|
+
version.codename = codename_match[1].strip
|
101
|
+
end
|
102
|
+
return version
|
103
|
+
elsif OS.is?('windows')
|
104
|
+
# TODO: support windows version
|
105
|
+
return nil
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.path_for_executable(name_of_executable)
|
110
|
+
if OS.is?(:windows)
|
111
|
+
return `where '#{name_of_executable}'`.strip
|
112
|
+
else
|
113
|
+
return `which '#{name_of_executable}'`.strip
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.has_command(name_of_executable)
|
118
|
+
return OS.path_for_executable(name_of_executable) != ''
|
119
|
+
end
|
76
120
|
end
|
data/lib/atk/version.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
# create a variable for the current ruby version
|
2
2
|
|
3
3
|
class Version
|
4
|
-
attr_accessor :levels
|
4
|
+
attr_accessor :levels, :codename
|
5
|
+
|
6
|
+
def self.extract_from(string)
|
7
|
+
match = string.match(/\d+\.\d+(\.\d+)*/)
|
8
|
+
if match != nil
|
9
|
+
return Version.new(match[0])
|
10
|
+
end
|
11
|
+
end
|
5
12
|
|
6
13
|
def initialize(version_as_string)
|
7
14
|
@levels = version_as_string.split('.')
|
data/lib/atk_toolbox/version.rb
CHANGED