Class: BaseVelocitator
- Inherits:
-
Object
show all
- Includes:
- Helpers
- Defined in:
- lib/gem_velocity/velocitators/base_velocitator.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Helpers
#compute_day_range_from_start_end, #earliest_for, #latest_for, #remove_trailing_x, #time_format_str, #time_format_str_small
Instance Attribute Details
#date_range ⇒ Object
modifiers on the end result image being rendered. Essentially these are the boundries of the graph
38
39
40
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 38
def date_range
@date_range
end
|
#gem_name ⇒ Object
Returns the value of attribute gem_name.
11
12
13
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 11
def gem_name
@gem_name
end
|
#max_value ⇒ Object
modifiers on the end result image being rendered. Essentially these are the boundries of the graph
38
39
40
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 38
def max_value
@max_value
end
|
#min_value ⇒ Object
modifiers on the end result image being rendered. Essentially these are the boundries of the graph
38
39
40
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 38
def min_value
@min_value
end
|
#root ⇒ Object
modifiers on the end result image being rendered. Essentially these are the boundries of the graph
38
39
40
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 38
def root
@root
end
|
#versions ⇒ Object
Returns the value of attribute versions.
11
12
13
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 11
def versions
@versions
end
|
Class Method Details
.create(options) ⇒ Object
13
14
15
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 13
def self.create(options)
Factory.new(options).velocitator
end
|
Instance Method Details
#effective_date_range ⇒ Object
44
45
46
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 44
def effective_date_range
@passed_date_range || default_date_range
end
|
#effective_days_in_range ⇒ Object
51
52
53
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 51
def effective_days_in_range
compute_day_range_from_start_end(effective_start_time,effective_end_time)
end
|
#effective_end_time ⇒ Object
49
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 49
def effective_end_time; effective_date_range.last ;end
|
#effective_max_value ⇒ Object
55
56
57
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 55
def effective_max_value
@passed_max_value || default_max_value
end
|
#effective_min_value ⇒ Object
59
60
61
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 59
def effective_min_value
@passed_min_value || default_min_value
end
|
#effective_start_time ⇒ Object
48
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 48
def effective_start_time; effective_date_range.first ;end
|
#graph(root_arg = root, range = effective_date_range, min = effective_min_value, max = effective_max_value) ⇒ Object
17
18
19
20
21
22
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 17
def graph(root_arg = root, range = effective_date_range, min = effective_min_value, max = effective_max_value)
set_overwritable_attrs(root_arg,range,min,max)
file = gruff_builder(root, graph_options).write
puts "Wrote graph to #{file}"
file
end
|
#graph_options ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 24
def graph_options
opts = {
:title => title,
:labels => ({1 => time_format_str_small(effective_start_time), (line_datas.first.size-2) => time_format_str_small(effective_end_time) }),
:max_value => effective_max_value,
:min_value => effective_min_value,
:line_datas => line_datas,
:hide_legend => hide_legend?,
:type => self.class.to_s
}
end
|
#num_downloads ⇒ Object
72
73
74
75
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 72
def num_downloads
sum_of_all_versions = totals_map_by_version.values.map {|t| t[:version_downloads]}.sum
ActiveSupport::NumberHelper.number_to_delimited(sum_of_all_versions)
end
|
#time_built(version) ⇒ Object
Also known as:
built_at
77
78
79
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 77
def time_built(version)
gem_data.versions_built_at[version]
end
|
#totals_map_by_version ⇒ Object
63
64
65
66
67
68
69
70
|
# File 'lib/gem_velocity/velocitators/base_velocitator.rb', line 63
def totals_map_by_version
h = {}
versions.map do |v|
total_for_version = gem_data.total_for_version(v)
h.merge!(v => total_for_version)
end
h
end
|