Class: NeetoCompliance::GemVersionVerifier

Inherits:
Object
  • Object
show all
Defined in:
lib/neeto_compliance/verifiers/gem_version_verifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_version, latest_version, gem_name) ⇒ GemVersionVerifier

Returns a new instance of GemVersionVerifier.



7
8
9
10
11
# File 'lib/neeto_compliance/verifiers/gem_version_verifier.rb', line 7

def initialize(current_version, latest_version, gem_name)
  @latest_version = latest_version
  @current_version = current_version
  @gem_name = gem_name
end

Instance Attribute Details

#current_versionObject (readonly)

Returns the value of attribute current_version.



5
6
7
# File 'lib/neeto_compliance/verifiers/gem_version_verifier.rb', line 5

def current_version
  @current_version
end

#gem_nameObject (readonly)

Returns the value of attribute gem_name.



5
6
7
# File 'lib/neeto_compliance/verifiers/gem_version_verifier.rb', line 5

def gem_name
  @gem_name
end

#latest_versionObject (readonly)

Returns the value of attribute latest_version.



5
6
7
# File 'lib/neeto_compliance/verifiers/gem_version_verifier.rb', line 5

def latest_version
  @latest_version
end

Instance Method Details

#app_nameObject



29
30
31
# File 'lib/neeto_compliance/verifiers/gem_version_verifier.rb', line 29

def app_name
  @_app_name ||= `git config --get remote.origin.url`.split("/").last.strip.split(".git").first
end

#equal_app_and_gem_name?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/neeto_compliance/verifiers/gem_version_verifier.rb', line 21

def equal_app_and_gem_name?
  app_name == gem_name
end

#gem_not_installed?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/neeto_compliance/verifiers/gem_version_verifier.rb', line 13

def gem_not_installed?
  current_version.nil?
end

#latest_version_installed?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/neeto_compliance/verifiers/gem_version_verifier.rb', line 17

def latest_version_installed?
  current_version == latest_version
end

#valid?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/neeto_compliance/verifiers/gem_version_verifier.rb', line 25

def valid?
  equal_app_and_gem_name? || gem_not_installed? || latest_version_installed?
end