Class: AggregatedVelocitator
- Inherits:
-
BaseVelocitator
- Object
- BaseVelocitator
- AggregatedVelocitator
- Defined in:
- lib/gem_velocity/velocitators/aggregated_velocitator.rb
Instance Attribute Summary collapse
-
#aggregated_versions ⇒ Object
readonly
TODO can probably get rid of this.
-
#version ⇒ Object
readonly
the one with the wildcard.
-
#versions ⇒ Object
readonly
all of the ones matched, aggregated_versions.
Attributes inherited from BaseVelocitator
#date_range, #gem_name, #max_value, #min_value, #root
Instance Method Summary collapse
- #default_max_value ⇒ Object
- #default_start ⇒ Object
- #hide_legend? ⇒ Boolean
-
#initialize(gem_name, top_level_ver) ⇒ AggregatedVelocitator
constructor
A new instance of AggregatedVelocitator.
- #line_data(start_t = nil, end_t = nil) ⇒ Object
- #title ⇒ Object
Methods inherited from BaseVelocitator
create, #effective_date_range, #effective_days_in_range, #effective_end_time, #effective_max_value, #effective_min_value, #effective_start_time, #graph, #graph_options, #num_downloads, #time_built, #totals_map_by_version
Methods included from Helpers
#compute_day_range_from_start_end, #earliest_for, #latest_for, #remove_trailing_x, #time_format_str, #time_format_str_small
Constructor Details
#initialize(gem_name, top_level_ver) ⇒ AggregatedVelocitator
Returns a new instance of AggregatedVelocitator.
12 13 14 15 16 17 18 |
# File 'lib/gem_velocity/velocitators/aggregated_velocitator.rb', line 12 def initialize(gem_name, top_level_ver) @gem_name = gem_name @version = top_level_ver #with a wildcard/x @versions = @aggregated_versions = gem_data.versions.select{|v| v.match(/^#{Regexp.escape(remove_trailing_x(top_level_ver))}/) } raise NoSuchVersion, "no versions found for #{@version}!" if @aggregated_versions.empty? after_init end |
Instance Attribute Details
#aggregated_versions ⇒ Object (readonly)
TODO can probably get rid of this
4 5 6 |
# File 'lib/gem_velocity/velocitators/aggregated_velocitator.rb', line 4 def aggregated_versions @aggregated_versions end |
#version ⇒ Object (readonly)
the one with the wildcard
7 8 9 |
# File 'lib/gem_velocity/velocitators/aggregated_velocitator.rb', line 7 def version @version end |
#versions ⇒ Object (readonly)
all of the ones matched, aggregated_versions
10 11 12 |
# File 'lib/gem_velocity/velocitators/aggregated_velocitator.rb', line 10 def versions @versions end |
Instance Method Details
#default_max_value ⇒ Object
25 26 27 |
# File 'lib/gem_velocity/velocitators/aggregated_velocitator.rb', line 25 def default_max_value base_max_for(@aggregated_versions) * @aggregated_versions.size end |
#default_start ⇒ Object
20 21 22 23 |
# File 'lib/gem_velocity/velocitators/aggregated_velocitator.rb', line 20 def default_start smallest_version = @aggregated_versions.map{|v| ComparableVersion.new(v)}.sort.first.str built_at(smallest_version) end |
#hide_legend? ⇒ Boolean
50 51 52 |
# File 'lib/gem_velocity/velocitators/aggregated_velocitator.rb', line 50 def hide_legend? true end |
#line_data(start_t = nil, end_t = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/gem_velocity/velocitators/aggregated_velocitator.rb', line 29 def line_data(start_t = nil, end_t = nil) range = nil if start_t && end_t range = compute_day_range_from_start_end(start_t,end_t) else range = effective_days_in_range end ret = Hash.new(0) @aggregated_versions.each do |v| range.each do |d| ret[d] += downloads_per_day(v)[d] || 0 end end range.map{|d| ret[d] } end |
#title ⇒ Object
46 47 48 |
# File 'lib/gem_velocity/velocitators/aggregated_velocitator.rb', line 46 def title "#{@gem_name}: #{@version}\n(downloads: #{num_downloads})" end |