Class: Serverspec::Type::JenkinsPlugin

Inherits:
JenkinsBase show all
Defined in:
lib/serverspec_extra_types/types/jenkins_plugin.rb

Instance Method Summary collapse

Methods inherited from ApiBase

#[]

Constructor Details

#initialize(name = nil, options = {}) ⇒ JenkinsPlugin

Returns a new instance of JenkinsPlugin.



11
12
13
# File 'lib/serverspec_extra_types/types/jenkins_plugin.rb', line 11

def initialize(name = nil, options = {})
  super(name, options)
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/serverspec_extra_types/types/jenkins_plugin.rb', line 27

def exist?
  inspection != nil
end

#has_version?(version) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/serverspec_extra_types/types/jenkins_plugin.rb', line 35

def has_version?(version)
  self.version == version.to_s
end

#inspectionObject



15
16
17
# File 'lib/serverspec_extra_types/types/jenkins_plugin.rb', line 15

def inspection
  @inspection ||= ::MultiJson.load(get_inspection.stdout)['plugins'].find { |plugin| plugin['shortName'] == @name }
end

#installed?(_provider = nil, version = nil) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
# File 'lib/serverspec_extra_types/types/jenkins_plugin.rb', line 19

def installed?(_provider = nil, version = nil)
  if version
    !inspection.nil? && inspection['version'].to_s == version.to_s
  else
    !inspection.nil?
  end
end

#lengthObject



43
44
45
46
47
48
49
50
51
# File 'lib/serverspec_extra_types/types/jenkins_plugin.rb', line 43

def length
  if inspection.is_a? String
    inspection.length
  elsif inspection.is_a? Array
    inspection.length
  else
    1
  end
end

#urlObject



31
32
33
# File 'lib/serverspec_extra_types/types/jenkins_plugin.rb', line 31

def url
  "#{@url_base}/pluginManager/api/json?depth=1"
end

#versionObject



39
40
41
# File 'lib/serverspec_extra_types/types/jenkins_plugin.rb', line 39

def version
  inspection['version'].to_s
end