Class: CommitFilter::Model
- Inherits:
-
Object
- Object
- CommitFilter::Model
- Defined in:
- app/models/commit_filter/model.rb
Constant Summary collapse
- HASHTAG_REGEX =
/(?:\s|^)(#(?!([0-9]?:\d+|\w+?_|_\w+?)(?:\s|$))([a-z0-9\-_]+))/i
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#commits_count ⇒ Object
readonly
Returns the value of attribute commits_count.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#first_revision ⇒ Object
readonly
Returns the value of attribute first_revision.
-
#from ⇒ Object
Returns the value of attribute from.
-
#group_by_rails_file_category ⇒ Object
Returns the value of attribute group_by_rails_file_category.
-
#hashtag ⇒ Object
Returns the value of attribute hashtag.
-
#hide_merge_commits ⇒ Object
Returns the value of attribute hide_merge_commits.
-
#id ⇒ Object
Returns the value of attribute id.
-
#issue_url ⇒ Object
Returns the value of attribute issue_url.
-
#last_revision ⇒ Object
readonly
Returns the value of attribute last_revision.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#message ⇒ Object
Returns the value of attribute message.
-
#path ⇒ Object
Returns the value of attribute path.
-
#previous_revision ⇒ Object
readonly
Returns the value of attribute previous_revision.
-
#previous_revision_by_file ⇒ Object
readonly
Returns the value of attribute previous_revision_by_file.
-
#project_slug ⇒ Object
Returns the value of attribute project_slug.
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#repository_host ⇒ Object
Returns the value of attribute repository_host.
-
#repository_provider ⇒ Object
Returns the value of attribute repository_provider.
-
#story ⇒ Object
Returns the value of attribute story.
-
#tasks ⇒ Object
Returns the value of attribute tasks.
-
#to ⇒ Object
Returns the value of attribute to.
-
#user_or_organization ⇒ Object
Returns the value of attribute user_or_organization.
-
#workspace ⇒ Object
Returns the value of attribute workspace.
Class Method Summary collapse
Instance Method Summary collapse
- #commits_by_file ⇒ Object
- #files_count ⇒ Object
-
#initialize(attributes = {}) ⇒ Model
constructor
A new instance of Model.
- #repository_path ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Model
Returns a new instance of Model.
24 25 26 27 28 29 30 |
# File 'app/models/commit_filter/model.rb', line 24 def initialize(attributes = {}) @commits_count, @previous_revision_by_file = 0, {} initialize_attributes(attributes) self end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
4 5 6 |
# File 'app/models/commit_filter/model.rb', line 4 def @author end |
#branch ⇒ Object
Returns the value of attribute branch.
4 5 6 |
# File 'app/models/commit_filter/model.rb', line 4 def branch @branch end |
#commits_count ⇒ Object (readonly)
Returns the value of attribute commits_count.
7 8 9 |
# File 'app/models/commit_filter/model.rb', line 7 def commits_count @commits_count end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'app/models/commit_filter/model.rb', line 7 def errors @errors end |
#first_revision ⇒ Object (readonly)
Returns the value of attribute first_revision.
7 8 9 |
# File 'app/models/commit_filter/model.rb', line 7 def first_revision @first_revision end |
#from ⇒ Object
Returns the value of attribute from.
4 5 6 |
# File 'app/models/commit_filter/model.rb', line 4 def from @from end |
#group_by_rails_file_category ⇒ Object
Returns the value of attribute group_by_rails_file_category.
6 7 8 |
# File 'app/models/commit_filter/model.rb', line 6 def group_by_rails_file_category @group_by_rails_file_category end |
#hashtag ⇒ Object
Returns the value of attribute hashtag.
4 5 6 |
# File 'app/models/commit_filter/model.rb', line 4 def hashtag @hashtag end |
#hide_merge_commits ⇒ Object
Returns the value of attribute hide_merge_commits.
5 6 7 |
# File 'app/models/commit_filter/model.rb', line 5 def hide_merge_commits @hide_merge_commits end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'app/models/commit_filter/model.rb', line 4 def id @id end |
#issue_url ⇒ Object
Returns the value of attribute issue_url.
5 6 7 |
# File 'app/models/commit_filter/model.rb', line 5 def issue_url @issue_url end |
#last_revision ⇒ Object (readonly)
Returns the value of attribute last_revision.
7 8 9 |
# File 'app/models/commit_filter/model.rb', line 7 def last_revision @last_revision end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'app/models/commit_filter/model.rb', line 5 def logger @logger end |
#message ⇒ Object
Returns the value of attribute message.
5 6 7 |
# File 'app/models/commit_filter/model.rb', line 5 def @message end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'app/models/commit_filter/model.rb', line 4 def path @path end |
#previous_revision ⇒ Object (readonly)
Returns the value of attribute previous_revision.
7 8 9 |
# File 'app/models/commit_filter/model.rb', line 7 def previous_revision @previous_revision end |
#previous_revision_by_file ⇒ Object (readonly)
Returns the value of attribute previous_revision_by_file.
7 8 9 |
# File 'app/models/commit_filter/model.rb', line 7 def previous_revision_by_file @previous_revision_by_file end |
#project_slug ⇒ Object
Returns the value of attribute project_slug.
4 5 6 |
# File 'app/models/commit_filter/model.rb', line 4 def project_slug @project_slug end |
#repository ⇒ Object
Returns the value of attribute repository.
4 5 6 |
# File 'app/models/commit_filter/model.rb', line 4 def repository @repository end |
#repository_host ⇒ Object
Returns the value of attribute repository_host.
6 7 8 |
# File 'app/models/commit_filter/model.rb', line 6 def repository_host @repository_host end |
#repository_provider ⇒ Object
Returns the value of attribute repository_provider.
5 6 7 |
# File 'app/models/commit_filter/model.rb', line 5 def repository_provider @repository_provider end |
#story ⇒ Object
Returns the value of attribute story.
5 6 7 |
# File 'app/models/commit_filter/model.rb', line 5 def story @story end |
#tasks ⇒ Object
Returns the value of attribute tasks.
5 6 7 |
# File 'app/models/commit_filter/model.rb', line 5 def tasks @tasks end |
#to ⇒ Object
Returns the value of attribute to.
4 5 6 |
# File 'app/models/commit_filter/model.rb', line 4 def to @to end |
#user_or_organization ⇒ Object
Returns the value of attribute user_or_organization.
5 6 7 |
# File 'app/models/commit_filter/model.rb', line 5 def user_or_organization @user_or_organization end |
#workspace ⇒ Object
Returns the value of attribute workspace.
4 5 6 |
# File 'app/models/commit_filter/model.rb', line 4 def workspace @workspace end |
Class Method Details
.create(attributes = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/commit_filter/model.rb', line 9 def self.create(attributes = {}) resource = new(attributes) if resource.valid? begin resource.commits_by_file rescue Grit::Git::GitTimeout @errors ||= {} @errors['base'] = I18n.t('commit_filter.filters.create.errors.too_many_git_timeouts') end end resource end |
Instance Method Details
#commits_by_file ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/commit_filter/model.rb', line 38 def commits_by_file return {} unless valid? return @files if @files if group_by_rails_file_category @files = { library: { paths: [/^lib\//, /^app\/mailers\//] }, model: { paths: [/^app\/models\//, /^db\//] }, controller: { paths: [/^app\/controllers\//] }, javascript: { paths: [/^app\/assets\/javascripts\//] }, view: { paths: [ /^app\/assets\/stylesheets\//, /^app\/views\//, /^app\/helpers\//, /^app\/presenters\//, /^public\// ] }, tests: { paths: [/^spec\//, /^features\//] }, configuration: { paths: [/^config\//] }, misc: { paths: [] } } else @files = {} end catch(:done) do commits do |page| page.each do |commit| add_commit_to_files(commit) if commit_attributes_match_criteria?(commit) end end end if group_by_rails_file_category @files.each {|category, setting| @files.delete(category) unless setting[:files].try(:any?) } end @files rescue Grit::NoSuchPathError @errors ||= {} @errors['base'] = I18n.t('commit_filter.filters.create.errors.repository_not_found') end |
#files_count ⇒ Object
81 |
# File 'app/models/commit_filter/model.rb', line 81 def files_count; @previous_revision_by_file.keys.length; end |
#repository_path ⇒ Object
32 |
# File 'app/models/commit_filter/model.rb', line 32 def repository_path; self.workspace.to_s + '/' + self.repository.to_s; end |
#valid? ⇒ Boolean
34 35 36 |
# File 'app/models/commit_filter/model.rb', line 34 def valid? @valid = _valid? ? true : false end |