Class: VersionControl::Filter
- Inherits:
-
Object
- Object
- VersionControl::Filter
- Defined in:
- app/models/version_control/filter.rb
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.
-
#filter_merges ⇒ Object
Returns the value of attribute filter_merges.
-
#first_revision ⇒ Object
readonly
Returns the value of attribute first_revision.
-
#from ⇒ Object
Returns the value of attribute from.
-
#id ⇒ Object
Returns the value of attribute id.
-
#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.
-
#story ⇒ Object
Returns the value of attribute story.
-
#tasks ⇒ Object
Returns the value of attribute tasks.
-
#to ⇒ Object
Returns the value of attribute to.
-
#workspace ⇒ Object
Returns the value of attribute workspace.
Class Method Summary collapse
Instance Method Summary collapse
- #files_by_category ⇒ Object
- #files_count ⇒ Object
-
#initialize(attributes = {}) ⇒ Filter
constructor
A new instance of Filter.
- #repository_path ⇒ Object
- #users ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Filter
Returns a new instance of Filter.
5 6 7 8 9 10 11 |
# File 'app/models/version_control/filter.rb', line 5 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.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def @author end |
#branch ⇒ Object
Returns the value of attribute branch.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def branch @branch end |
#commits_count ⇒ Object (readonly)
Returns the value of attribute commits_count.
3 4 5 |
# File 'app/models/version_control/filter.rb', line 3 def commits_count @commits_count end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'app/models/version_control/filter.rb', line 3 def errors @errors end |
#filter_merges ⇒ Object
Returns the value of attribute filter_merges.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def filter_merges @filter_merges end |
#first_revision ⇒ Object (readonly)
Returns the value of attribute first_revision.
3 4 5 |
# File 'app/models/version_control/filter.rb', line 3 def first_revision @first_revision end |
#from ⇒ Object
Returns the value of attribute from.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def from @from end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def id @id end |
#last_revision ⇒ Object (readonly)
Returns the value of attribute last_revision.
3 4 5 |
# File 'app/models/version_control/filter.rb', line 3 def last_revision @last_revision end |
#logger ⇒ Object
Returns the value of attribute logger.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def logger @logger end |
#message ⇒ Object
Returns the value of attribute message.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def @message end |
#path ⇒ Object
Returns the value of attribute path.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def path @path end |
#previous_revision ⇒ Object (readonly)
Returns the value of attribute previous_revision.
3 4 5 |
# File 'app/models/version_control/filter.rb', line 3 def previous_revision @previous_revision end |
#previous_revision_by_file ⇒ Object (readonly)
Returns the value of attribute previous_revision_by_file.
3 4 5 |
# File 'app/models/version_control/filter.rb', line 3 def previous_revision_by_file @previous_revision_by_file end |
#project_slug ⇒ Object
Returns the value of attribute project_slug.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def project_slug @project_slug end |
#repository ⇒ Object
Returns the value of attribute repository.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def repository @repository end |
#story ⇒ Object
Returns the value of attribute story.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def story @story end |
#tasks ⇒ Object
Returns the value of attribute tasks.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def tasks @tasks end |
#to ⇒ Object
Returns the value of attribute to.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def to @to end |
#workspace ⇒ Object
Returns the value of attribute workspace.
2 3 4 |
# File 'app/models/version_control/filter.rb', line 2 def workspace @workspace end |
Class Method Details
.create(attributes = {}) ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/models/version_control/filter.rb', line 13 def self.create(attributes = {}) resource = new(attributes) resource.files_by_category if resource.valid? resource end |
Instance Method Details
#files_by_category ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 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 |
# File 'app/models/version_control/filter.rb', line 27 def files_by_category return {} unless valid? return @files_by_category if @files_by_category @files_by_category = { 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: [] } } catch(:done) do commits do |page| page.each do |commit| add_commit_to_files(commit) if commit_attributes_match_criteria?(commit) end end end @files_by_category.each {|category, setting| @files_by_category.delete(category) unless setting[:files].try(:any?) } #get_previous_revision_for_files @files_by_category rescue Grit::NoSuchPathError @errors ||= {} @errors['base'] = 'Repository not found.' end |
#files_count ⇒ Object
66 |
# File 'app/models/version_control/filter.rb', line 66 def files_count; @previous_revision_by_file.keys.length; end |
#repository_path ⇒ Object
21 |
# File 'app/models/version_control/filter.rb', line 21 def repository_path; self.workspace.to_s + '/' + self.repository.to_s; end |
#users ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/models/version_control/filter.rb', line 68 def users return @users if @users @users = [] if files_by_category.is_a? Hash files_by_category.each do |category, setting| next if setting[:files].blank? @users += setting[:files].values.flatten.map{|commit| commit[:author]}.uniq end @users.uniq! end @users.none? ? repository_users : @users end |
#valid? ⇒ Boolean
23 24 25 |
# File 'app/models/version_control/filter.rb', line 23 def valid? @valid = _valid? ? true : false end |