Module: GithubDash

Defined in:
lib/github_dash.rb,
lib/github_dash/cli.rb,
lib/github_dash/version.rb,
lib/github_dash/repository.rb,
lib/github_dash/data_depository.rb

Defined Under Namespace

Classes: CLI, DataDepository, Repository

Constant Summary collapse

VERSION =
"1.0.1"

Class Method Summary collapse

Class Method Details

.add_repo_to_following(name, token = nil) ⇒ Object

Add a repository to the list of followed repositories



13
14
15
16
17
18
19
20
# File 'lib/github_dash.rb', line 13

def self.add_repo_to_following(name, token=nil)
  token ||= DataDepository.get_token
  # Check that the repository exists
  client = Octokit::Client.new(:access_token => token)
  client.repository name

  DataDepository.add_repo name, token
end

.add_token(token, token_name) ⇒ Object

Add a token and set it to be used first when fetching repositories



44
45
46
# File 'lib/github_dash.rb', line 44

def self.add_token(token, token_name)
  DataDepository.save_token(token, token_name)
end

.add_user(username, password) ⇒ Object

Save a user’s token for getting private repositories



34
35
36
37
38
39
40
41
# File 'lib/github_dash.rb', line 34

def self.add_user(username, password)
  # Create new token
  client = Octokit::Client.new :login => username, :password => password
  token = client.create_authorization(:scopes => ["repo"], :note => "github-dash token").token

  # Save it
  DataDepository.save_token(token, username)
end

.fetch_repository(repository_name) ⇒ Object

Fetch repository information given a reposoitory name



8
9
10
# File 'lib/github_dash.rb', line 8

def self.fetch_repository(repository_name)
  Repository.new repository_name
end

.get_followingObject

Get an array of the names of followed repositories



29
30
31
# File 'lib/github_dash.rb', line 29

def self.get_following
  DataDepository.get_following
end

.remove_repo_from_following(name) ⇒ Object

Remove a repository from the list of followed repositories



23
24
25
26
# File 'lib/github_dash.rb', line 23

def self.remove_repo_from_following(name)
  # Tell the user whether it removed a repo or not
  DataDepository.remove_repo name
end