Class: Ossert::Project

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#agilityObject

Returns the value of attribute agility.



6
7
8
# File 'lib/ossert/project.rb', line 6

def agility
  @agility
end

#communityObject

Returns the value of attribute community.



6
7
8
# File 'lib/ossert/project.rb', line 6

def community
  @community
end

#created_atObject

Returns the value of attribute created_at.



6
7
8
# File 'lib/ossert/project.rb', line 6

def created_at
  @created_at
end

#github_aliasObject

Returns the value of attribute github_alias.



6
7
8
# File 'lib/ossert/project.rb', line 6

def github_alias
  @github_alias
end

#metaObject

Returns the value of attribute meta.



6
7
8
# File 'lib/ossert/project.rb', line 6

def meta
  @meta
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/ossert/project.rb', line 6

def name
  @name
end

#referenceObject

Returns the value of attribute reference.



6
7
8
# File 'lib/ossert/project.rb', line 6

def reference
  @reference
end

#rubygems_aliasObject

Returns the value of attribute rubygems_alias.



6
7
8
# File 'lib/ossert/project.rb', line 6

def rubygems_alias
  @rubygems_alias
end

#updated_atObject

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_referenceObject



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_treeObject



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 = meta
  @created_at = created_at
  @updated_at = updated_at
end

#decoratedObject



69
70
71
# File 'lib/ossert/project.rb', line 69

def decorated
  @decorated ||= Ossert::Presenters::Project.new(self)
end

#grade_by_growing_classifierObject 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_jsonObject



107
108
109
# File 'lib/ossert/project.rb', line 107

def meta_to_json
  MultiJson.dump(meta)
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