Class: Circle::CLI::Repo

Inherits:
Object
  • Object
show all
Defined in:
lib/circle/cli/repo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Repo

Returns a new instance of Repo.



9
10
11
# File 'lib/circle/cli/repo.rb', line 9

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/circle/cli/repo.rb', line 7

def errors
  @errors
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/circle/cli/repo.rb', line 7

def options
  @options
end

Instance Method Details

#branch_nameObject



25
26
27
28
29
# File 'lib/circle/cli/repo.rb', line 25

def branch_name
  options.fetch 'branch' do
    repo.head.name.sub(/^refs\/heads\//, '')
  end
end

#circle_tokenObject



31
32
33
# File 'lib/circle/cli/repo.rb', line 31

def circle_token
  repo.config['circleci.token'] || ENV['CIRCLE_CLI_TOKEN']
end

#circle_token=(token) ⇒ Object



35
36
37
# File 'lib/circle/cli/repo.rb', line 35

def circle_token=(token)
  repo.config['circleci.token'] = token
end

#projectObject



21
22
23
# File 'lib/circle/cli/repo.rb', line 21

def project
  uri.project_name
end

#uriObject



13
14
15
# File 'lib/circle/cli/repo.rb', line 13

def uri
  Gitable::URI.parse(origin.url)
end

#user_nameObject



17
18
19
# File 'lib/circle/cli/repo.rb', line 17

def user_name
  uri.path[/^(\/?)(.+)\//, 2]
end