Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .autotest

This file was deleted.

5 changes: 0 additions & 5 deletions .document

This file was deleted.

4 changes: 4 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--format documentation
--require spec_helper
--color
--order random
70 changes: 59 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,25 +1,73 @@
PATH
remote: .
specs:
os (1.0.1)
os (1.1.4)

GEM
remote: http://rubygems.org/
specs:
diff-lcs (1.1.3)
power_assert (1.0.2)
rake (0.9.6)
test-unit (3.2.3)
coderay (1.1.3)
diff-lcs (1.5.0)
ffi (1.15.5)
formatador (1.1.0)
guard (2.18.0)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.13.0)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-rspec (4.7.3)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
lumberjack (1.2.8)
method_source (1.0.0)
nenv (0.3.0)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
power_assert (2.0.2)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
rake (10.5.0)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.0)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
shellany (0.0.1)
test-unit (3.5.5)
power_assert
thor (1.2.1)

PLATFORMS
ruby
x86-mingw32
x86_64-darwin-19

DEPENDENCIES
rake (~> 0.8)
rspec (~> 2.5.0)
test-unit (~> 3)
guard-rspec (~> 4.7)
os!
rake (~> 10.5)
rspec (~> 3.12)
test-unit (~> 3.5)

BUNDLED WITH
2.1.4
2.3.26
18 changes: 18 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# More info at https://github.com/guard/guard#readme

guard :rspec, cmd: "bundle exec rspec" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)

# Feel free to open issues for suggestions and improvements

# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { "#{rspec.spec_dir}/config" }
watch(rspec.spec_files)

# Ruby files
ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)
end
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
The OS gem allows for some easy telling if you're on windows or not.

## Install

```shell
bundle add os
```

## Usage

```ruby
require 'os'

Expand Down Expand Up @@ -80,7 +88,7 @@ If there are any other features you'd like, let me know, I'll do what I can to a

http://github.com/rdp/os for feedback et al

Related projects:
## Alternatives

rubygems:

Expand All @@ -104,4 +112,15 @@ the ["platform" gem](http://rubydoc.info/github/ffi/ffi/master/FFI/Platform), it
FFI::Platform::OS
```

## Contributing

Develop locally:

```shell
bundle install
bundle exec guard
```

## License

License: MIT (see LICENSE file)
28 changes: 0 additions & 28 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,5 @@
require 'rubygems' if RUBY_VERSION < '1.9.0'

# HOW TO DEPLOY
# bump VERSION file manually
# rake release
# Don't forget to run rake gemspec with each release! ... I think...or rake release might be same thing
# then manually edit os.gemspec remove duplicatee rspecs, circular dependency on os? HUH?
# # then gem build os.gemspec
# rake build doesn't work???
# sooo...
# ...gem push os-1.1.2.gem

begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "os"
gem.summary = %Q{Simple and easy way to know if you're on windows or not (reliably), as well as how many bits the OS is, etc.}
gem.description = %Q{The OS gem allows for some useful and easy functions, like OS.windows? (=> true or false) OS.bits ( => 32 or 64) etc"}
gem.email = "[email protected]"
gem.homepage = "https://github.com/rdp/os"
gem.authors = ["rdp", "David McCullars"]
gem.license = "MIT"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
# gem.add_development_dependency "fast_require"
# gem.add_development_dependency "rspec", ">= 2.0"
end
rescue LoadError => e
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler #{e}"
end

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

1 change: 0 additions & 1 deletion autotest/discover.rb

This file was deleted.

39 changes: 4 additions & 35 deletions os.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,53 +14,22 @@ Gem::Specification.new do |s|
s.date = "2021-11-07"
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
s.email = "[email protected]".freeze
s.extra_rdoc_files = [
"ChangeLog",
"LICENSE",
"README.md"
]
s.files = [
".autotest",
".document",
"ChangeLog",
"Gemfile",
"Gemfile.lock",
"LICENSE",
"README.md",
"Rakefile",
"VERSION",
"autotest/discover.rb",
"lib/os.rb",
"os.gemspec",
"spec/linux_spec.rb",
"spec/os_spec.rb",
"spec/osx_spec.rb",
"spec/spec_helper.rb"
]
s.homepage = "https://github.com/rdp/os".freeze
s.licenses = ["MIT".freeze]
s.rubygems_version = "2.7.6".freeze
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

if s.respond_to? :specification_version then
s.specification_version = 4

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<os>.freeze, [">= 0"])
s.add_development_dependency(%q<rake>.freeze, ["~> 0.8"])
s.add_development_dependency(%q<test-unit>.freeze, ["~> 3"])
s.add_development_dependency(%q<rspec>.freeze, [">= 2.0"])
else
s.add_dependency(%q<os>.freeze, [">= 0"])
s.add_dependency(%q<rake>.freeze, ["~> 0.8"])
s.add_dependency(%q<test-unit>.freeze, ["~> 3"])
s.add_dependency(%q<rspec>.freeze, [">= 2.0"])
end
else
s.add_dependency(%q<os>.freeze, [">= 0"])
s.add_dependency(%q<rake>.freeze, ["~> 0.8"])
s.add_dependency(%q<test-unit>.freeze, ["~> 3"])
s.add_dependency(%q<rspec>.freeze, [">= 2.0"])
end
s.add_development_dependency(%q<rake>.freeze, ["~> 10.5"])
s.add_development_dependency(%q<test-unit>.freeze, ["~> 3.5"])
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.12"])
s.add_development_dependency(%q<guard-rspec>.freeze, ["~> 4.7"])
end

17 changes: 17 additions & 0 deletions spec/config/rspec/rspec_core.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

RSpec.configure do |config|
# RSpec v3+
# Enable flags like --only-failures and --next-failure
# config.example_status_persistence_file_path = '.rspec_status'

# RSpec v3+
# Disable RSpec exposing methods globally on `Module` and `main`
# config.disable_monkey_patching!

config.expect_with :rspec do |c|
c.syntax = :expect
end

config.expect_with :test_unit
end
27 changes: 11 additions & 16 deletions spec/linux_spec.rb
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
require 'rubygems' if RUBY_VERSION < '1.9.0'

require File.dirname(__FILE__) + '/../lib/os.rb' # load before sane to avoid sane being able to requir the gemified version...
require 'rspec' # rspec2

describe 'For Linux, (Ubuntu, Ubuntu 10.04 LTS) ' do
before(:each) do
ENV.should_receive(:[]).with('OS').any_number_of_times.and_return()
allow(ENV).to receive(:[]).with('OS')
## Having difficulties finding a stub for RUBY_PLATFORM
# Looking into something like: http://stackoverflow.com/questions/1698335/can-i-use-rspec-mocks-to-stub-out-version-constants
# For now, simply using RbConfig::CONFIG
# Kernel.stub!(:const_get).with('RUBY_PLATFORM').and_return("i686-linux")
RbConfig::CONFIG.stub!(:[]).with('host_os').and_return('linux_gnu')
RbConfig::CONFIG.stub!(:[]).with('host_cpu').and_return('i686')
allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('linux_gnu')
allow(RbConfig::CONFIG).to receive(:[]).with('host_cpu').and_return('i686')
end

describe OS do
subject { OS } # class, not instance

it { should be_linux }
it { should be_posix }
it { is_expected.to be_linux }
it { is_expected.to be_posix }

it { should_not be_mac }
it { should_not be_osx }
it { should_not be_windows }
it { is_expected.not_to be_mac }
it { is_expected.not_to be_osx }
it { is_expected.not_to be_windows }

end

describe OS::Underlying do
subject { OS::Underlying } # class, not instance

it { should be_linux }
it { is_expected.to be_linux }

it { should_not be_bsd }
it { should_not be_windows }
it { is_expected.not_to be_bsd }
it { is_expected.not_to be_windows }
end
end

Loading