Class: Circle::CLI::Project
- Inherits:
-
Object
- Object
- Circle::CLI::Project
- Defined in:
- lib/circle/cli/project.rb
Instance Attribute Summary collapse
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
- #build! ⇒ Object
- #builds ⇒ Object
- #clear_cache! ⇒ Object
-
#initialize(repo) ⇒ Project
constructor
A new instance of Project.
- #latest ⇒ Object
- #recent_builds ⇒ Object
- #request(klass, action, *args) ⇒ Object
Constructor Details
#initialize(repo) ⇒ Project
Returns a new instance of Project.
9 10 11 12 |
# File 'lib/circle/cli/project.rb', line 9 def initialize(repo) @repo = repo configure end |
Instance Attribute Details
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
7 8 9 |
# File 'lib/circle/cli/project.rb', line 7 def repo @repo end |
Instance Method Details
#build! ⇒ Object
14 15 16 |
# File 'lib/circle/cli/project.rb', line 14 def build! request CircleCi::Project, :build_branch, repo.branch_name end |
#builds ⇒ Object
18 19 20 |
# File 'lib/circle/cli/project.rb', line 18 def builds @builds ||= to_builds(request(CircleCi::Project, :recent_builds_branch, repo.branch_name)) end |
#clear_cache! ⇒ Object
30 31 32 33 |
# File 'lib/circle/cli/project.rb', line 30 def clear_cache! @builds = nil @recent_builds = nil end |
#latest ⇒ Object
26 27 28 |
# File 'lib/circle/cli/project.rb', line 26 def latest builds.first end |
#recent_builds ⇒ Object
22 23 24 |
# File 'lib/circle/cli/project.rb', line 22 def recent_builds @recent_builds ||= to_builds(request(CircleCi::Project, :recent_builds)) end |
#request(klass, action, *args) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/circle/cli/project.rb', line 35 def request(klass, action, *args) response = klass.send(action, repo.user_name, repo.project, *args) if response.success? response.body else $stderr.puts 'One or more errors occurred:' response.errors.each do |error| $stderr.puts "+ #{error.}" end exit 1 end end |