Skip to content

🚑️ Remove circular dependency, fixes #55, #60 #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 15, 2022
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
13 changes: 11 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
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)
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
rspec-mocks (~> 2.5.0)
rspec-core (2.5.2)
rspec-expectations (2.5.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.5.0)
test-unit (3.2.3)
power_assert

Expand All @@ -17,9 +25,10 @@ PLATFORMS
x86-mingw32

DEPENDENCIES
os!
rake (~> 0.8)
rspec (~> 2.5.0)
test-unit (~> 3)
test-unit (~> 3.2.0)

BUNDLED WITH
2.1.4
15 changes: 6 additions & 9 deletions os.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,18 @@ Gem::Specification.new do |s|
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"])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The os gem can't depend on itself. I think this is part of the messy legacy of jeweler.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think jeweler was auto inserting this, scary...

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"])
s.add_development_dependency(%q<test-unit>.freeze, ["~> 3.2.0"])
s.add_development_dependency(%q<rspec>.freeze, ["~> 2.5.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"])
s.add_dependency(%q<test-unit>.freeze, ["~> 3.2.0"])
s.add_dependency(%q<rspec>.freeze, ["~> 2.5.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"])
s.add_dependency(%q<test-unit>.freeze, ["~> 3.2.0"])
s.add_dependency(%q<rspec>.freeze, ["~> 2.5.0"])
end
end

16 changes: 9 additions & 7 deletions spec/os_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
it "has working cpu count method" do
cpu_count = OS.cpu_count
assert cpu_count >= 1
assert (cpu_count & (cpu_count - 1)) == 0 # CPU count is normally a power of 2
Copy link
Collaborator Author

@pboling pboling Dec 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use a 6-core, 12 vCPU Macbook Pro. The power of 2 idea is no longer reasonable, so I have added "or an even number" as a secondary condition.

# CPU count is usually either a power of 2 or an even number.
assert ((cpu_count & (cpu_count - 1)) == 0) || ((cpu_count % 2) == 0)
end

it "has working cpu count method with no env. variable" do
Expand All @@ -144,18 +145,19 @@

it "should provide a path to directory for application config" do
ENV.stub(:[])
home = '/home/user'

if OS.mac?
ENV.stub(:[]).with('HOME').and_return('/home/user')
assert OS.app_config_path('appname') == '/home/xdg/Library/Application Support/appname'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's clear you weren't running this on a Mac 😄

ENV.stub(:[]).with('HOME').and_return(home)
assert OS.app_config_path('appname') == "#{home}/Library/Application Support/appname"
elsif OS.doze?
# TODO
else
ENV.stub(:[]).with('HOME').and_return('/home/user')
assert OS.app_config_path('appname') == '/home/user/.config/appname'
ENV.stub(:[]).with('HOME').and_return(home)
assert OS.app_config_path('appname') == "#{home}/.config/appname"

ENV.stub(:[]).with('XDG_CONFIG_HOME').and_return('/home/xdg/.config')
assert OS.app_config_path('appname') == '/home/xdg/.config/appname'
ENV.stub(:[]).with('XDG_CONFIG_HOME').and_return("#{home}/.config")
assert OS.app_config_path('appname') == "#{home}/.config/appname"
end
end

Expand Down