Class: Trackler::Track
- Inherits:
-
Object
- Object
- Trackler::Track
- Defined in:
- lib/trackler/track.rb
Overview
Track is a collection of exercises in a given language.
Defined Under Namespace
Classes: Image
Constant Summary collapse
- TOPICS =
%w(about installation tests learning resources)
Instance Attribute Summary collapse
-
#file_bundle ⇒ Object
readonly
Returns the value of attribute file_bundle.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #checklist_issue ⇒ Object
- #doc_format ⇒ Object
- #docs ⇒ Object
- #exists? ⇒ Boolean
- #gitter ⇒ Object
- #global_zip ⇒ Object
- #icon ⇒ Object
- #icon_path ⇒ Object
- #img(file_path) ⇒ Object
- #implementations ⇒ Object
-
#initialize(id, root) ⇒ Track
constructor
A new instance of Track.
- #planned? ⇒ Boolean
- #problems ⇒ Object
-
#slugs ⇒ Object
Every slug mentioned in the configuration.
- #test_pattern ⇒ Object
- #upcoming? ⇒ Boolean
Constructor Details
#initialize(id, root) ⇒ Track
Returns a new instance of Track.
22 23 24 25 26 |
# File 'lib/trackler/track.rb', line 22 def initialize(id, root) @id = id @root = Pathname.new(root) @file_bundle = FileBundle.new(dir.join("global")) end |
Instance Attribute Details
#file_bundle ⇒ Object (readonly)
Returns the value of attribute file_bundle.
21 22 23 |
# File 'lib/trackler/track.rb', line 21 def file_bundle @file_bundle end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
21 22 23 |
# File 'lib/trackler/track.rb', line 21 def id @id end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
21 22 23 |
# File 'lib/trackler/track.rb', line 21 def root @root end |
Instance Method Details
#active? ⇒ Boolean
32 33 34 |
# File 'lib/trackler/track.rb', line 32 def active? !!config["active"] end |
#checklist_issue ⇒ Object
52 53 54 |
# File 'lib/trackler/track.rb', line 52 def checklist_issue config.fetch("checklist_issue", 1) end |
#doc_format ⇒ Object
90 91 92 93 94 |
# File 'lib/trackler/track.rb', line 90 def doc_format default_format = 'md' path = File.join(dir, "docs", "*.*") most_popular_format(path) || default_format end |
#docs ⇒ Object
82 83 84 |
# File 'lib/trackler/track.rb', line 82 def docs Hash[TOPICS.zip(TOPICS.map { |topic| document_contents(topic) })] end |
#exists? ⇒ Boolean
28 29 30 |
# File 'lib/trackler/track.rb', line 28 def exists? File.exist?(dir) end |
#gitter ⇒ Object
56 57 58 |
# File 'lib/trackler/track.rb', line 56 def gitter config["gitter"] end |
#global_zip ⇒ Object
96 97 98 |
# File 'lib/trackler/track.rb', line 96 def global_zip @zip ||= file_bundle.zip end |
#icon ⇒ Object
64 65 66 |
# File 'lib/trackler/track.rb', line 64 def icon @icon ||= Image.new(File.join(dir, "img/icon.png")) end |
#icon_path ⇒ Object
60 61 62 |
# File 'lib/trackler/track.rb', line 60 def icon_path icon.path if icon.exists? end |
#img(file_path) ⇒ Object
86 87 88 |
# File 'lib/trackler/track.rb', line 86 def img(file_path) Image.new(File.join(dir, file_path)) end |
#implementations ⇒ Object
44 45 46 |
# File 'lib/trackler/track.rb', line 44 def implementations @implementations ||= Implementations.new(id, repository, active_slugs, root) end |
#planned? ⇒ Boolean
40 41 42 |
# File 'lib/trackler/track.rb', line 40 def planned? !active? && problems.length.zero? end |
#problems ⇒ Object
48 49 50 |
# File 'lib/trackler/track.rb', line 48 def problems @problems ||= implementations.map(&:problem) end |
#slugs ⇒ Object
Every slug mentioned in the configuration.
101 102 103 |
# File 'lib/trackler/track.rb', line 101 def slugs active_slugs + foregone_slugs + deprecated_slugs end |
#test_pattern ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/trackler/track.rb', line 74 def test_pattern if config.key?('test_pattern') Regexp.new(config['test_pattern']) else /test/i end end |
#upcoming? ⇒ Boolean
36 37 38 |
# File 'lib/trackler/track.rb', line 36 def upcoming? !active? && problems.length > 0 end |