Class: Hubba::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/hubba/github.rb

Instance Method Summary collapse

Constructor Details

#initialize(cache_dir: './cache') ⇒ Github

Returns a new instance of Github.



62
63
64
65
66
67
68
# File 'lib/hubba/github.rb', line 62

def initialize( cache_dir: './cache' )
   @cache  = Cache.new( cache_dir )
   @client = Client.new( user:     Hubba.configuration.user,
                         password: Hubba.configuration.password )

   @offline = false
end

Instance Method Details

#offline!Object

switch to offline - todo: find a “better” way - why? why not?



70
# File 'lib/hubba/github.rb', line 70

def offline!()  @offline = true; end

#offline?Boolean

Returns:

  • (Boolean)


72
# File 'lib/hubba/github.rb', line 72

def offline?()  @offline == true; end

#online!Object



71
# File 'lib/hubba/github.rb', line 71

def online!()   @offline = false; end

#online?Boolean

Returns:

  • (Boolean)


73
# File 'lib/hubba/github.rb', line 73

def online?()   @offline == false; end

#org(name) ⇒ Object



98
99
100
# File 'lib/hubba/github.rb', line 98

def org( name )
  Resource.new( get "/orgs/#{name}" )
end

#org_repos(name) ⇒ Object



102
103
104
# File 'lib/hubba/github.rb', line 102

def org_repos( name )
  Repos.new( get "/orgs/#{name}/repos?per_page=100" )
end

#repo(full_name) ⇒ Object

full_name (handle) e.g. henrythemes/jekyll-starter-theme



108
109
110
# File 'lib/hubba/github.rb', line 108

def repo( full_name )   ## full_name (handle) e.g. henrythemes/jekyll-starter-theme

  Resource.new( get "/repos/#{full_name}" )
end

#repo_commits(full_name) ⇒ Object



112
113
114
# File 'lib/hubba/github.rb', line 112

def repo_commits( full_name )
  Resource.new( get "/repos/#{full_name}/commits" )
end

#user(name) ⇒ Object



76
77
78
# File 'lib/hubba/github.rb', line 76

def user( name )
  Resource.new( get "/users/#{name}" )
end

#user_orgs(name) ⇒ Object

note: pagination

requests that return multiple items will be paginated to 30 items by default.
 You can specify further pages with the ?page parameter.

For some resources, you can also set a custom page size up to 100

with the ?per_page=100 parameter


93
94
95
# File 'lib/hubba/github.rb', line 93

def user_orgs( name )
  Orgs.new( get "/users/#{name}/orgs?per_page=100" )
end

#user_repos(name) ⇒ Object



81
82
83
# File 'lib/hubba/github.rb', line 81

def user_repos( name )
  Repos.new( get "/users/#{name}/repos" )   ## add ?per_page=100 - why? why not?

end