Class: Arli::Library::MultiVersion
- Inherits:
-
Object
- Object
- Arli::Library::MultiVersion
show all
- Includes:
- Helpers::Output
- Defined in:
- lib/arli/library/multi_version.rb
Constant Summary
Helpers::Output::CHAR_FAILURE, Helpers::Output::CHAR_SUCCESS
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#___, #__p, #__pf, #__pt, #abort?, #action_fail, #action_ok, #backup?, #cursor, #debug, #debug?, disable!, enable!, enabled?, #error, #fuck, #header, #hr, #indent_cursor, #info, #ok, #overwrite?, #print_action_failure, #print_action_starting, #print_action_success, #print_target_dir, #quiet?, #raise_invalid_arli_command!, #report_exception, #verbose?
Constructor Details
#initialize(a_lib = nil, versions = []) ⇒ MultiVersion
Returns a new instance of MultiVersion.
27
28
29
30
31
32
|
# File 'lib/arli/library/multi_version.rb', line 27
def initialize(a_lib = nil, versions = [])
Colored2.disable! if Arli.config.no_color
self.latest_version_library = a_lib if a_lib
self.versions = versions || []
self.versions << a_lib.version if (a_lib && a_lib.respond_to?(:version) && self.versions.empty?)
end
|
Instance Attribute Details
#latest_version_library ⇒ Object
Also known as:
lib
Returns the value of attribute latest_version_library.
15
16
17
|
# File 'lib/arli/library/multi_version.rb', line 15
def latest_version_library
@latest_version_library
end
|
#versions ⇒ Object
Returns the value of attribute versions.
15
16
17
|
# File 'lib/arli/library/multi_version.rb', line 15
def versions
@versions
end
|
Class Method Details
10
11
12
|
# File 'lib/arli/library/multi_version.rb', line 10
def format_methods
new({}).methods.grep(/^to_s_/).map { |m| m.to_s.gsub(/^to_s_/, '') }.map(&:to_sym)
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
19
20
21
|
# File 'lib/arli/library/multi_version.rb', line 19
def ==(other)
other.instance_of?(self.class) && self.name == other.name
end
|
#add_version(library: nil) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/arli/library/multi_version.rb', line 34
def add_version(library: nil)
if library
if lib.nil? || library.version_to_i > lib.version_to_i
self.latest_version_library = library
end
self.versions << library.version
elsif version
self.versions << library.version
end
normalize_version_array!
end
|
#hash ⇒ Object
50
51
52
|
# File 'lib/arli/library/multi_version.rb', line 50
def hash
lib.name.hash
end
|
#name ⇒ Object
46
47
48
|
# File 'lib/arli/library/multi_version.rb', line 46
def name
latest_version_library.name
end
|
#to_s_json ⇒ Object
88
89
90
91
92
|
# File 'lib/arli/library/multi_version.rb', line 88
def to_s_json
append do
JSON.pretty_generate(lib.to_hash) + ","
end
end
|
#to_s_long ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/arli/library/multi_version.rb', line 63
def to_s_long
lib_versions = versions.clone
latest = lib_versions.pop
append do
"\n"
"Name: #{lib.name.bold.yellow}\n" +
"Versions: #{latest.bold.yellow}, #{lib_versions.reverse.join(', ').green}\n" +
(lib.author ? "Author(s): #{lib.author.red}\n" : '') +
(lib.website ? "Website: #{lib.website.cyan}\n" : '') +
"Sentence: #{(lib.sentence).blue}\n" +
((lib.paragraph && (lib.paragraph != lib.sentence)) ?
"Description: #{reformat_wrapped(lib.paragraph).magenta}\n" : "\n")
end
end
|
#to_s_short ⇒ Object
78
79
80
81
82
83
84
85
86
|
# File 'lib/arli/library/multi_version.rb', line 78
def to_s_short
append do
printf append_name[0..45]
indent_cursor 48
printf append_latest_version
indent_cursor 60
printf append_total_versions
end
end
|
#to_s_with_versions(limit = 4) ⇒ Object
Various print formats –format <ARG> is inserted after “to_s_<format>”
56
57
58
59
60
61
|
# File 'lib/arli/library/multi_version.rb', line 56
def to_s_with_versions(limit = 4)
append do |out|
out << library_name
out << append_truncated_version_list(limit)
end
end
|
#to_s_yaml ⇒ Object
94
95
96
97
98
|
# File 'lib/arli/library/multi_version.rb', line 94
def to_s_yaml
append do
YAML.dump(lib.to_hash)
end
end
|