This repository has been archived by the owner on Dec 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Take upstream java fixes and put them here
Got some advice from some Puppetlabs people on how to do facts better! :)
- Loading branch information
Showing
6 changed files
with
64 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Fact: java_major_version | ||
# | ||
# Purpose: get Java's major version | ||
# | ||
# Resolution: | ||
# Tests for presence of java, returns nil if not present | ||
# returns output of "java -version" and splits on \n + '"' | ||
# eg. | ||
# | ||
# Caveats: | ||
# none | ||
# | ||
# Notes: | ||
# None | ||
Facter.add(:java_major_version) do | ||
setcode do | ||
java_version = Facter.value(:java_version) | ||
java_patch_level = java_version.strip.split('_')[0].split('.')[1] unless java_version.nil? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require "spec_helper" | ||
|
||
describe Facter::Util::Fact do | ||
before { | ||
Facter.clear | ||
} | ||
|
||
describe "java_major_version" do | ||
context 'returns major version when java_version fact present' do | ||
before :each do | ||
Facter.fact(:java_version).stubs(:value).returns('1.7.0_71') | ||
end | ||
it do | ||
Facter.fact(:java_major_version).value.should == "7" | ||
end | ||
end | ||
|
||
context 'returns nil when java not present' do | ||
before :each do | ||
Facter.fact(:java_version).stubs(:value).returns(nil) | ||
end | ||
it do | ||
Facter.fact(:java_major_version).value.should be_nil | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters