Class: Repository
- Inherits:
-
Object
- Object
- Repository
- Defined in:
- lib/codespicuous/repositories.rb
Instance Attribute Summary collapse
-
#commits ⇒ Object
readonly
Returns the value of attribute commits.
-
#name ⇒ Object
Returns the value of attribute name.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #==(repository) ⇒ Object
- #add_commit(commit) ⇒ Object
- #amount_of_commits ⇒ Object
- #amount_of_commits_in_week(week_start) ⇒ Object
- #clone_without_commits ⇒ Object
-
#initialize(name, url) ⇒ Repository
constructor
A new instance of Repository.
Constructor Details
#initialize(name, url) ⇒ Repository
Returns a new instance of Repository.
12 13 14 15 16 |
# File 'lib/codespicuous/repositories.rb', line 12 def initialize(name, url) @name = name @url = url @commits = Commits.new end |
Instance Attribute Details
#commits ⇒ Object (readonly)
Returns the value of attribute commits.
9 10 11 |
# File 'lib/codespicuous/repositories.rb', line 9 def commits @commits end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/codespicuous/repositories.rb', line 10 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
10 11 12 |
# File 'lib/codespicuous/repositories.rb', line 10 def url @url end |
Instance Method Details
#==(repository) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/codespicuous/repositories.rb', line 34 def ==(repository) is_equal = @name == repository.name && @url == repository.url raise SameRepositoriesWithDifferentCommitsError.new if is_equal && @commits != repository.commits is_equal end |
#add_commit(commit) ⇒ Object
22 23 24 |
# File 'lib/codespicuous/repositories.rb', line 22 def add_commit commit @commits.add(commit) end |
#amount_of_commits ⇒ Object
26 27 28 |
# File 'lib/codespicuous/repositories.rb', line 26 def amount_of_commits @commits.amount end |
#amount_of_commits_in_week(week_start) ⇒ Object
30 31 32 |
# File 'lib/codespicuous/repositories.rb', line 30 def amount_of_commits_in_week(week_start) @commits.amount_of_commits_to_repository_in_week(name, week_start) end |
#clone_without_commits ⇒ Object
18 19 20 |
# File 'lib/codespicuous/repositories.rb', line 18 def clone_without_commits Repository.new(@name, @url) end |