Class: Jammer::PackageInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/jammer/package_info.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package_name, package_desc, package_url, package_version = nil) ⇒ PackageInfo

Returns a new instance of PackageInfo.



5
6
7
# File 'lib/jammer/package_info.rb', line 5

def initialize(package_name, package_desc, package_url, package_version = nil)
  @name, @description, @version, @url = package_name, package_desc, package_version, package_url
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/jammer/package_info.rb', line 3

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/jammer/package_info.rb', line 3

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/jammer/package_info.rb', line 3

def url
  @url
end

#versionObject (readonly)

Returns the value of attribute version.



3
4
5
# File 'lib/jammer/package_info.rb', line 3

def version
  @version
end

Class Method Details

.fromJSON(json_string) ⇒ Object



21
22
23
24
# File 'lib/jammer/package_info.rb', line 21

def self.fromJSON(json_string)
  package = JSON.parse json_string
  new(package['name'], package['description'], nil, package['version'])
end

Instance Method Details

#on_github?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/jammer/package_info.rb', line 17

def on_github?
  url.include? 'github.com'
end

#repo_typeObject



13
14
15
# File 'lib/jammer/package_info.rb', line 13

def repo_type
  on_github? ? 'git' : ''
end

#repo_urlObject



9
10
11
# File 'lib/jammer/package_info.rb', line 9

def repo_url
  on_github? ? "#{url}.git" : ''
end