Module: D3::Basename

Includes:
Comparable
Included in:
Client::Receipt, Package, PuppyTime::PendingPuppy
Defined in:
lib/d3/basename.rb

Overview

This mixin module provides attributes and methods for dealing with d3 basenames, i.e. package families. It’s used by the Package, Client::Receipt, and Client::PendingPuppy classes.

Constant Summary collapse

STATUSES =

The status of D3::Package & D3::Client::Receipt objects, and the integers stored in the DB for each D3::Package

- :unsaved
    D3::Package: a Ruby object that hasn't yet been created  on the server
    D3::Client::Receipt: a Ruby object that hasn't yet been saved to the local
      receipt datastore

- :pilot
    D3::Package: on the server, but not yet been made live,1
    D3::Client::Receipt: installed when the pkg was in that state.

- :live
    D3::Package: the currently active pkg for a given basename,
    D3::Client::Receipt: the matching pkg is current live on the server

- :deprecated
    D3::Package: was once live, now superseded by a new version, but
      still on the server
    D3::Client::Receipt: the rcpt is older than the currently live pkg &
      will be upgraded at sync unless it was installed as a pilot

- :skipped
    D3::Package: never made live, but older than the current live
      installer, still on the server, probably should be deleted

- :missing
    D3::Package: the data is in the D3 Packages table, but the pkg is
      not in the JSS
    D3::Client::Receipt: No matching :pilot, :live, or :deprecated pkg on
      the server

- :deleted
    D3::Package: the matching d3 data has been deleted from the server
    D3::Client::Receipt: the matching receipt has been deleted from the client
[
  :unsaved,
  :pilot,
  :live,
  :deprecated,
  :skipped,
  :missing,
  :deleted
]
STATUSES_FOR_FILTERS =

When filtering lists of pkgs/rcpts, unsaved and deleted are meaningless, so use this list

[
  :pilot,
  :live,
  :deprecated,
  :skipped,
  :missing
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#adminString (readonly)

Returns who’s uploading, releasing, installing, or archiving this thing?.

Returns:

  • (String)

    who’s uploading, releasing, installing, or archiving this thing?



104
105
106
# File 'lib/d3/basename.rb', line 104

def admin
  @admin
end

#basenameString (readonly)

Returns the basname of the thing installed.

Returns:

  • (String)

    the basname of the thing installed



95
96
97
# File 'lib/d3/basename.rb', line 95

def basename
  @basename
end

#expirationInteger (readonly)

Returns the days of disuse before an expirable edition expires. 0=never.

Returns:

  • (Integer)

    the days of disuse before an expirable edition expires. 0=never



121
122
123
# File 'lib/d3/basename.rb', line 121

def expiration
  @expiration
end

#expiration_pathsString (readonly)

Returns the path to the executable that needs come to the foreground to prevent expiration.

Returns:

  • (String)

    the path to the executable that needs come to the foreground to prevent expiration



124
125
126
# File 'lib/d3/basename.rb', line 124

def expiration_paths
  @expiration_paths
end

#idInteger (readonly)

Returns the JSS id of this package.

Returns:

  • (Integer)

    the JSS id of this package



107
108
109
# File 'lib/d3/basename.rb', line 107

def id
  @id
end

#package_typeSymbol (readonly)

Returns Is this package a .dmg or .pkg?.

Returns:

  • (Symbol)

    Is this package a .dmg or .pkg?



113
114
115
# File 'lib/d3/basename.rb', line 113

def package_type
  @package_type
end

#prohibiting_processesArray<String> (readonly)

Returns an array of Strings for matching to the output lines of ‘/bin/ps -A -c -o comm’. If there’s a match, this pkg won’t be installed or uninstalled without a graceful quit.

Returns:

  • (Array<String>)

    an array of Strings for matching to the output lines of ‘/bin/ps -A -c -o comm’. If there’s a match, this pkg won’t be installed or uninstalled without a graceful quit



118
119
120
# File 'lib/d3/basename.rb', line 118

def prohibiting_processes
  @prohibiting_processes
end

#revisionInteger (readonly)

Returns the d3 release number of the thing installed.

Returns:

  • (Integer)

    the d3 release number of the thing installed



101
102
103
# File 'lib/d3/basename.rb', line 101

def revision
  @revision
end

#statusSymbol

Returns whats the d3 status of this package? One of the values of D3::Basename::STATUSES.

Returns:

  • (Symbol)

    whats the d3 status of this package? One of the values of D3::Basename::STATUSES



110
111
112
# File 'lib/d3/basename.rb', line 110

def status
  @status
end

#versionString (readonly)

Returns the version of the thing installed.

Returns:

  • (String)

    the version of the thing installed



98
99
100
# File 'lib/d3/basename.rb', line 98

def version
  @version
end

Instance Method Details

#<=>(other) ⇒ Object

Use comparable to give sortability and equality.



144
145
146
# File 'lib/d3/basename.rb', line 144

def <=> (other)
 self.edition <=> other.edition
end

#deleted?Boolean

Is the status :deleted?

Returns:

  • (Boolean)


200
201
202
# File 'lib/d3/basename.rb', line 200

def deleted?
  @status == :deleted
end

#deprecated?Boolean

Is the status :deprecated?

Returns:

  • (Boolean)


183
184
185
# File 'lib/d3/basename.rb', line 183

def deprecated?
  @status == :deprecated
end

#editionString

While several packages can have the same basename, the combination of basename, version, and revision (called the ‘edition’) must be unique among the d3 packages.

Returns:

  • (String)

    the basename, version ,and revision of this package, joined with hyphens



136
137
138
# File 'lib/d3/basename.rb', line 136

def edition
  "#{@basename}-#{@version}-#{@revision}"
end

#expiration_paths_match?(other_exp_paths) ⇒ Boolean

Does a given array of pathnames have the same elements as This is generally used to compare two @expiration_paths arrays for “equality”

Parameters:

  • other_exp_paths (Array)

    An array if Pathnames to compare to @expiration_paths

Returns:

  • (Boolean)

    Are they the same aside from order?



214
215
216
217
# File 'lib/d3/basename.rb', line 214

def expiration_paths_match?(other_exp_paths)
  return false unless @expiration_paths and @expiration_paths.length == other_exp_paths.length
  (@expiration_paths -  other_exp_paths).empty?
end

#live?Boolean

Is the status :live?

Returns:

  • (Boolean)


168
169
170
# File 'lib/d3/basename.rb', line 168

def live?
  @status == :live
end

#missing?Boolean

Is the status :missing?

Returns:

  • (Boolean)


192
193
194
# File 'lib/d3/basename.rb', line 192

def missing?
  @status == :missing
end

#pilot?Boolean

Is the status :pilot?

Returns:

  • (Boolean)


160
161
162
# File 'lib/d3/basename.rb', line 160

def pilot?
  @status == :pilot
end

#saved?Boolean

Is the status :saved?

Returns:

  • (Boolean)


152
153
154
# File 'lib/d3/basename.rb', line 152

def saved?
  @status != :unsaved
end

#skipped?Boolean

Returns Is this pkg skipped? See Database::PACKAGE_STATUSES for details.

Returns:

  • (Boolean)

    Is this pkg skipped? See Database::PACKAGE_STATUSES for details



175
176
177
# File 'lib/d3/basename.rb', line 175

def skipped?
  @status == :skipped
end