Class: Ossert::Project
- Inherits:
-
Object
- Object
- Ossert::Project
- Includes:
- Saveable
- Defined in:
- lib/ossert/project.rb
Defined Under Namespace
Classes: Agility, BaseStore, Community
Constant Summary collapse
- META_STUB =
{ homepage_url: nil, docs_url: nil, wiki_url: nil, source_url: nil, issue_tracker_url: nil, mailing_list_url: nil, authors: nil, top_10_contributors: [], description: nil, current_version: nil, rubygems_url: nil, github_url: nil }.freeze
- TIME_BOUNDS_CONFIG =
{ base_value: { start: nil, end: nil }, aggregation: { start: :min, end: :max }, extended: { start: nil, end: nil } }.freeze
Constants included from Saveable
Saveable::ATTRIBUTE_EXTRACT_VALUE_MAP, Saveable::UNUSED_REFERENCE
Instance Attribute Summary collapse
-
#agility ⇒ Object
Returns the value of attribute agility.
-
#community ⇒ Object
Returns the value of attribute community.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#github_alias ⇒ Object
Returns the value of attribute github_alias.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#name ⇒ Object
Returns the value of attribute name.
-
#reference ⇒ Object
Returns the value of attribute reference.
-
#rubygems_alias ⇒ Object
Returns the value of attribute rubygems_alias.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Class Method Summary collapse
- .fetch_all(name, reference = Ossert::Saveable::UNUSED_REFERENCE) ⇒ Object
- .projects_by_reference ⇒ Object
Instance Method Summary collapse
- #analyze_by_decisision_tree ⇒ Object
- #assign_data(meta:, agility:, community:, created_at:, updated_at:) ⇒ Object
- #decorated ⇒ Object
- #grade_by_growing_classifier ⇒ Object (also: #grade_by_classifier)
-
#initialize(name, github_alias = nil, rubygems_alias = nil, reference = nil) ⇒ Project
constructor
A new instance of Project.
- #meta_to_json ⇒ Object
- #prepare_time_bounds!(extended_start: nil, extended_end: nil) ⇒ Object
- #time_bound_values(time_bound, config) ⇒ Object
Methods included from Saveable
#attributes, #data_attributes, #dump, #dump_attribute, included, #meta_attributes, #valid?, #validate!, #without_github_data?
Constructor Details
#initialize(name, github_alias = nil, rubygems_alias = nil, reference = nil) ⇒ Project
Returns a new instance of Project.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ossert/project.rb', line 50 def initialize(name, github_alias = nil, rubygems_alias = nil, reference = nil) @name = name.dup @github_alias = github_alias @rubygems_alias = (rubygems_alias || name).dup @reference = reference.dup @agility = Agility.new @community = Community.new @meta = META_STUB.dup end |
Instance Attribute Details
#agility ⇒ Object
Returns the value of attribute agility.
6 7 8 |
# File 'lib/ossert/project.rb', line 6 def agility @agility end |
#community ⇒ Object
Returns the value of attribute community.
6 7 8 |
# File 'lib/ossert/project.rb', line 6 def community @community end |
#created_at ⇒ Object
Returns the value of attribute created_at.
6 7 8 |
# File 'lib/ossert/project.rb', line 6 def created_at @created_at end |
#github_alias ⇒ Object
Returns the value of attribute github_alias.
6 7 8 |
# File 'lib/ossert/project.rb', line 6 def github_alias @github_alias end |
#meta ⇒ Object
Returns the value of attribute meta.
6 7 8 |
# File 'lib/ossert/project.rb', line 6 def @meta end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/ossert/project.rb', line 6 def name @name end |
#reference ⇒ Object
Returns the value of attribute reference.
6 7 8 |
# File 'lib/ossert/project.rb', line 6 def reference @reference end |
#rubygems_alias ⇒ Object
Returns the value of attribute rubygems_alias.
6 7 8 |
# File 'lib/ossert/project.rb', line 6 def rubygems_alias @rubygems_alias end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
6 7 8 |
# File 'lib/ossert/project.rb', line 6 def updated_at @updated_at end |
Class Method Details
.fetch_all(name, reference = Ossert::Saveable::UNUSED_REFERENCE) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/ossert/project.rb', line 26 def fetch_all(name, reference = Ossert::Saveable::UNUSED_REFERENCE) project = find_by_name(name, reference) Ossert::Fetch.all project project.prepare_time_bounds! project.dump end |
.projects_by_reference ⇒ Object
34 35 36 |
# File 'lib/ossert/project.rb', line 34 def projects_by_reference load_referenced.group_by(&:reference) end |
Instance Method Details
#analyze_by_decisision_tree ⇒ Object
45 46 47 48 |
# File 'lib/ossert/project.rb', line 45 def analyze_by_decisision_tree raise unless Classifiers::DecisionTree.current.ready? Classifiers::DecisionTree.current.check(self) end |
#assign_data(meta:, agility:, community:, created_at:, updated_at:) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/ossert/project.rb', line 61 def assign_data(meta:, agility:, community:, created_at:, updated_at:) @agility = agility @community = community @meta = @created_at = created_at @updated_at = updated_at end |
#decorated ⇒ Object
69 70 71 |
# File 'lib/ossert/project.rb', line 69 def decorated @decorated ||= Ossert::Presenters::Project.new(self) end |
#grade_by_growing_classifier ⇒ Object Also known as: grade_by_classifier
39 40 41 42 |
# File 'lib/ossert/project.rb', line 39 def grade_by_growing_classifier raise unless Classifiers::Growing.current.ready? Classifiers::Growing.current.grade(self) end |
#meta_to_json ⇒ Object
107 108 109 |
# File 'lib/ossert/project.rb', line 107 def MultiJson.dump() end |
#prepare_time_bounds!(extended_start: nil, extended_end: nil) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/ossert/project.rb', line 88 def prepare_time_bounds!(extended_start: nil, extended_end: nil) config = TIME_BOUNDS_CONFIG.dup config[:base_value][:start] = Time.now.utc config[:base_value][:end] = 20.years.ago config[:extended][:start] = (extended_start || Time.now.utc).to_datetime config[:extended][:end] = (extended_end || 20.years.ago).to_datetime agility.quarters.fullfill! && community.quarters.fullfill! [:start, :end].map { |time_bound| time_bound_values(time_bound, config).to_date } end |
#time_bound_values(time_bound, config) ⇒ Object
100 101 102 103 104 105 |
# File 'lib/ossert/project.rb', line 100 def time_bound_values(time_bound, config) [ config[:base_value][time_bound], config[:extended][time_bound], agility.quarters.send("#{time_bound}_date"), community.quarters.send("#{time_bound}_date") ].send(config[:aggregation][time_bound]) end |