Class: Love::Author

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, fetch = true) ⇒ Author

Returns a new instance of Author.



6
7
8
9
10
# File 'lib/love/author.rb', line 6

def initialize(name, fetch = true)
  @name = name
  @gems = []
  fetch_info if fetch
end

Instance Attribute Details

#gemsObject (readonly)

Returns the value of attribute gems.



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

def gems
  @gems
end

#infoObject (readonly)

Returns the value of attribute info.



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

def info
  @info
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#usernameObject (readonly)

Returns the value of attribute username.



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

def username
  @username
end

Instance Method Details

#add_gem(gem) ⇒ Object



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

def add_gem(gem)
  @gems << gem
end

#fetch_infoObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/love/author.rb', line 12

def fetch_info
  uri = ERB::Util.url_encode(name)
  puts "search for #{name}"
  begin
    search_person = Love.octokit.search_users uri
    @info = \
      if search_person.count > 1
        puts '!!! THERE ARE SEVERAL PERSONS WITH THIS NAME IN GITHUB !!!'
        user_num = pick_user(search_person)

        Love.octokit.user search_person[user_num].
      else
        Love.octokit.user search_person.first.
      end
    puts "found #{@info.}"
  rescue Octokit::Forbidden
    puts 'github have some unfair limits =('
  rescue
    puts 'not found'
  end
end