os 1.0.0 → 1.0.1

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
  SHA1:
3
- metadata.gz: dc56c95ef4834741ffeced9727a5750f13fafe33
4
- data.tar.gz: a2844070c1b7e6abcc8ed1d121f9b7d47e360be3
3
+ metadata.gz: 1477aa871c9207710b6d5ac5ffbac3d3ce68b5c6
4
+ data.tar.gz: e7ea7749f846a01f4906d4ecf1cc83692b8ddfc6
5
5
  SHA512:
6
- metadata.gz: 9defce3f1298173d446d40af5d7c1b99c945f8daf02159874cc90ad39ba7148327bc004a5891c864ed7df5bfe480280546aa01f2160d9924a4fd7c7a899842b7
7
- data.tar.gz: e554eef3d21a36fbf876f6230050d43837ba9f4eb8a77c40c9d11ec5966d77839742cad6b621d5320ba362771e6089600a7d9c16d7a5099c8271806bb7cd75a3
6
+ metadata.gz: fda9a548d80869cc3fdc0fc3da2593889e0f147e845ad79ab5b7b74b23c64d3483a230778ee1d3b92b397767f45a3a498cf2f5601765d80eb1e82e4656108089
7
+ data.tar.gz: 9424bce41996a0a77429377f274df819e213ab7e1f704d2e85c96d2ddae7d681598ec463676892f3ba5e2022e1b8535b058f93fce61d0bcf84df0fd1c949b923
data/ChangeLog CHANGED
@@ -1,3 +1,6 @@
1
+ 1.0.1
2
+ add within docker method
3
+
1
4
  0.10.0
2
5
  freebsd? also some cleanup
3
6
 
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- #gem 'rspec', ">= 2"
3
+ gemspec
@@ -1,29 +1,34 @@
1
1
  PATH
2
2
  remote: .
3
+ specs:
4
+ os (1.0.1)
3
5
 
4
6
  GEM
5
7
  remote: http://rubygems.org/
6
8
  specs:
7
- diff-lcs (1.1.2)
8
- git (1.2.5)
9
- jeweler (1.6.0)
10
- bundler (~> 1.0.0)
11
- git (>= 1.2.5)
12
- rake
13
- rake (0.8.7)
9
+ diff-lcs (1.1.3)
10
+ power_assert (1.0.2)
11
+ rake (0.9.6)
14
12
  rspec (2.5.0)
15
13
  rspec-core (~> 2.5.0)
16
14
  rspec-expectations (~> 2.5.0)
17
15
  rspec-mocks (~> 2.5.0)
18
- rspec-core (2.5.1)
16
+ rspec-core (2.5.2)
19
17
  rspec-expectations (2.5.0)
20
18
  diff-lcs (~> 1.1.2)
21
19
  rspec-mocks (2.5.0)
20
+ test-unit (3.2.3)
21
+ power_assert
22
22
 
23
23
  PLATFORMS
24
24
  ruby
25
25
  x86-mingw32
26
26
 
27
27
  DEPENDENCIES
28
- jeweler
29
- rspec (>= 2.0)
28
+ os!
29
+ rake (~> 0.8)
30
+ rspec (~> 2.5.0)
31
+ test-unit (~> 3)
32
+
33
+ BUNDLED WITH
34
+ 1.14.5
@@ -52,6 +52,9 @@ The OS gem allows for some easy telling if you're on windows or not.
52
52
  >> OS::Underlying.bsd?
53
53
  => true # true for OS X
54
54
 
55
+ >> OS::Underlying.docker?
56
+ => false # true if running inside a Docker container
57
+
55
58
  If there are any other features you'd like, let me know, I'll do what I can to add them :)
56
59
 
57
60
  http://github.com/rdp/os for feedback et al
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ begin
11
11
  gem.email = "rogerpack2005@gmail.com"
12
12
  gem.homepage = "http://github.com/rdp/os"
13
13
  gem.authors = ["rdp", "David McCullars"]
14
+ gem.license = "MIT"
14
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
16
  # gem.add_development_dependency "fast_require"
16
17
  gem.add_development_dependency "rspec", ">= 2.0"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
data/lib/os.rb CHANGED
@@ -183,6 +183,10 @@ class OS
183
183
  OS.host_os =~ /linux/ ? true : false
184
184
  end
185
185
 
186
+ def self.docker?
187
+ system('grep -q docker /proc/self/cgroup') if OS.linux?
188
+ end
189
+
186
190
  end
187
191
 
188
192
  def self.cygwin?
@@ -260,6 +264,24 @@ class OS
260
264
 
261
265
  end
262
266
 
267
+ def self.app_config_path(name)
268
+ if OS.doze?
269
+ if ENV['LOCALAPPDATA']
270
+ return File.join(ENV['LOCALAPPDATA'], name)
271
+ end
272
+
273
+ File.join ENV['USERPROFILE'], 'Local Settings', 'Application Data', name
274
+ elsif OS.mac?
275
+ File.join ENV['HOME'], 'Library', 'Application Support', name
276
+ else
277
+ if ENV['XDG_CONFIG_HOME']
278
+ return File.join(ENV['XDG_CONFIG_HOME'], name)
279
+ end
280
+
281
+ File.join ENV['HOME'], '.config', name
282
+ end
283
+ end
284
+
263
285
  class << self
264
286
  alias :doze? :windows? # a joke name but I use it and like it :P
265
287
  alias :jruby? :java?
data/os.gemspec CHANGED
@@ -6,12 +6,12 @@
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "os".freeze
9
- s.version = "1.0.0"
9
+ s.version = "1.0.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["rdp".freeze, "David McCullars".freeze]
14
- s.date = "2017-02-20"
14
+ s.date = "2017-10-18"
15
15
  s.description = "The OS gem allows for some useful and easy functions, like OS.windows? (=> true or false) OS.bits ( => 32 or 64) etc\"".freeze
16
16
  s.email = "rogerpack2005@gmail.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -38,19 +38,11 @@ Gem::Specification.new do |s|
38
38
  "spec/spec_helper.rb"
39
39
  ]
40
40
  s.homepage = "http://github.com/rdp/os".freeze
41
+ s.licenses = ["MIT".freeze]
41
42
  s.rubygems_version = "2.5.2".freeze
42
43
  s.summary = "Simple and easy way to know if you're on windows or not (reliably), as well as how many bits the OS is, etc.".freeze
43
44
 
44
- if s.respond_to? :specification_version then
45
- s.specification_version = 4
46
-
47
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
- s.add_development_dependency(%q<rspec>.freeze, [">= 2.0"])
49
- else
50
- s.add_dependency(%q<rspec>.freeze, [">= 2.0"])
51
- end
52
- else
53
- s.add_dependency(%q<rspec>.freeze, [">= 2.0"])
54
- end
45
+ s.add_development_dependency('rake', '~> 0.8')
46
+ s.add_development_dependency('rspec', '~> 2.5.0')
47
+ s.add_development_dependency('test-unit', '~> 3')
55
48
  end
56
-
@@ -119,10 +119,9 @@ describe "OS" do
119
119
  end
120
120
 
121
121
  it "has working cpu count method" do
122
- assert OS.cpu_count >= 1
123
- if OS.mac?
124
- assert OS.cpu_count == 2 # my own developer box :P
125
- end
122
+ cpu_count = OS.cpu_count
123
+ assert cpu_count >= 1
124
+ assert (cpu_count & (cpu_count - 1)) == 0 # CPU count is normally a power of 2
126
125
  end
127
126
 
128
127
  it "has working cpu count method with no env. variable" do
@@ -143,6 +142,23 @@ describe "OS" do
143
142
  end
144
143
  end
145
144
 
145
+ it "should provide a path to directory for application config" do
146
+ ENV.stub(:[])
147
+
148
+ if OS.mac?
149
+ ENV.stub(:[]).with('HOME').and_return('/home/user')
150
+ assert OS.app_config_path('appname') == '/home/xdg/Library/Application Support/appname'
151
+ elsif OS.doze?
152
+ # TODO
153
+ else
154
+ ENV.stub(:[]).with('HOME').and_return('/home/user')
155
+ assert OS.app_config_path('appname') == '/home/user/.config/appname'
156
+
157
+ ENV.stub(:[]).with('XDG_CONFIG_HOME').and_return('/home/xdg/.config')
158
+ assert OS.app_config_path('appname') == '/home/xdg/.config/appname'
159
+ end
160
+ end
161
+
146
162
  it "should have a freebsd? method" do
147
163
  if OS.host_os =~ /freebsd/
148
164
  assert OS.freebsd? == true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: os
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - rdp
@@ -9,22 +9,50 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-20 00:00:00.000000000 Z
12
+ date: 2017-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '0.8'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '0.8'
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: rspec
16
30
  requirement: !ruby/object:Gem::Requirement
17
31
  requirements:
18
- - - ">="
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 2.5.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 2.5.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: test-unit
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
19
47
  - !ruby/object:Gem::Version
20
- version: '2.0'
48
+ version: '3'
21
49
  type: :development
22
50
  prerelease: false
23
51
  version_requirements: !ruby/object:Gem::Requirement
24
52
  requirements:
25
- - - ">="
53
+ - - "~>"
26
54
  - !ruby/object:Gem::Version
27
- version: '2.0'
55
+ version: '3'
28
56
  description: The OS gem allows for some useful and easy functions, like OS.windows?
29
57
  (=> true or false) OS.bits ( => 32 or 64) etc"
30
58
  email: rogerpack2005@gmail.com
@@ -52,7 +80,8 @@ files:
52
80
  - spec/osx_spec.rb
53
81
  - spec/spec_helper.rb
54
82
  homepage: http://github.com/rdp/os
55
- licenses: []
83
+ licenses:
84
+ - MIT
56
85
  metadata: {}
57
86
  post_install_message:
58
87
  rdoc_options: []
@@ -70,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
99
  version: '0'
71
100
  requirements: []
72
101
  rubyforge_project:
73
- rubygems_version: 2.5.2
102
+ rubygems_version: 2.5.2.3
74
103
  signing_key:
75
104
  specification_version: 4
76
105
  summary: Simple and easy way to know if you're on windows or not (reliably), as well