Class: Giexp::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/giexp/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.



6
7
8
9
# File 'lib/giexp/client.rb', line 6

def initialize(options)
  options.merge({:auto_traversal => true})
  @client = Octokit::Client.new(options)
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/giexp/client.rb', line 66

def authenticated?
  @client.authenticated?
end

#issues(params) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/giexp/client.rb', line 30

def issues(params)
  if params.key?(:organization)
    user = params[:organization]
  else
    user = params[:user]
  end

  if params.key?(:repository)
    repoName = "%s/%s" % [user, params[:repository]]
    repo = self.repository(params)
    if repo.has_issues
      repo["issues"] = self.fetch_issues(repoName)
    end
    repo
  else
    self.repositories(params).map { |repo|
      repoName = "%s/%s" % [user, repo.name]

      if repo.has_issues
        repo["issues"] = self.fetch_issues(repoName)
      end
      repo
    }
  end

end

#oauthed?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/giexp/client.rb', line 70

def oauthed?
  @client.oauthed?
end

#repositories(params) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/giexp/client.rb', line 11

def repositories(params)
  if params.key?(:organization)
    @client.organization_repositories(params[:organization])
  else
    @client.repositories(params[:user])
  end
end

#repository(params) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/giexp/client.rb', line 19

def repository(params)
  if params.key?(:organization)
    user = params[:organization]
  else
    user = params[:user]
  end

  repoName = "%s/%s" % [user, params[:repository]]
  @client.repository(repoName)
end