Class: Love::Gem

Inherits:
Object
  • Object
show all
Defined in:
lib/love/gem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec, fetch = true) ⇒ Gem

Returns a new instance of Gem.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/love/gem.rb', line 6

def initialize(spec, fetch = true)
  @spec = spec
  @name = spec.name
  @plain_authors = spec.authors
  if spec.homepage.nil? or spec.homepage.empty?
    @url = "http://rubygems.org/gems/#{name}"
  else
    @url = spec.homepage
  end
  @authors = []
  fetch_authors if fetch
end

Instance Attribute Details

#authorsObject (readonly)

Returns the value of attribute authors.



4
5
6
# File 'lib/love/gem.rb', line 4

def authors
  @authors
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/love/gem.rb', line 4

def name
  @name
end

#plain_authorsObject (readonly)

Returns the value of attribute plain_authors.



4
5
6
# File 'lib/love/gem.rb', line 4

def plain_authors
  @plain_authors
end

#specObject (readonly)

Returns the value of attribute spec.



4
5
6
# File 'lib/love/gem.rb', line 4

def spec
  @spec
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/love/gem.rb', line 4

def url
  @url
end

Instance Method Details

#add_author(author) ⇒ Object



34
35
36
# File 'lib/love/gem.rb', line 34

def add_author(author)
  @authors << author
end

#fetch_authorsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/love/gem.rb', line 19

def fetch_authors
  plain_authors.each do |name|
    author = Love.authors.select { |a| a.name == name }.first
    if author
      add_author author
      author.add_gem self
    else
      person = Love::Author.new(name)
      person.add_gem self
      add_author person
      Love.authors << person
    end
  end
end