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
- #dir ⇒ Object
- #doc_format ⇒ Object
- #docs(image_path: DocFile::DEFAULT_IMAGE_PATH) ⇒ Object
- #exists? ⇒ Boolean
- #gitter ⇒ Object
- #global_zip ⇒ Object
- #hints ⇒ Object
- #icon ⇒ Object
- #icon_path ⇒ Object
- #ignore_pattern ⇒ Object
- #img(file_path) ⇒ Object
- #implementations ⇒ Object
-
#initialize(id, root) ⇒ Track
constructor
A new instance of Track.
- #language ⇒ Object
- #planned? ⇒ Boolean
- #problems ⇒ Object
- #repository ⇒ 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.
24 25 26 27 28 |
# File 'lib/trackler/track.rb', line 24 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.
23 24 25 |
# File 'lib/trackler/track.rb', line 23 def file_bundle @file_bundle end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
23 24 25 |
# File 'lib/trackler/track.rb', line 23 def id @id end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
23 24 25 |
# File 'lib/trackler/track.rb', line 23 def root @root end |
Instance Method Details
#active? ⇒ Boolean
34 35 36 |
# File 'lib/trackler/track.rb', line 34 def active? !!config.active end |
#checklist_issue ⇒ Object
55 56 57 |
# File 'lib/trackler/track.rb', line 55 def checklist_issue config.checklist_issue || 1 end |
#dir ⇒ Object
114 115 116 |
# File 'lib/trackler/track.rb', line 114 def dir root.join("tracks", id) end |
#doc_format ⇒ Object
99 100 101 102 103 |
# File 'lib/trackler/track.rb', line 99 def doc_format default_format = 'md' path = File.join(dir, "docs", "*.*") most_popular_format(path) || default_format end |
#docs(image_path: DocFile::DEFAULT_IMAGE_PATH) ⇒ Object
91 92 93 |
# File 'lib/trackler/track.rb', line 91 def docs(image_path: DocFile::DEFAULT_IMAGE_PATH) OpenStruct.new(docs_by_topic(image_path)) end |
#exists? ⇒ Boolean
30 31 32 |
# File 'lib/trackler/track.rb', line 30 def exists? File.exist?(dir) end |
#gitter ⇒ Object
59 60 61 |
# File 'lib/trackler/track.rb', line 59 def gitter config.gitter end |
#global_zip ⇒ Object
105 106 107 |
# File 'lib/trackler/track.rb', line 105 def global_zip @zip ||= file_bundle.zip end |
#hints ⇒ Object
118 119 120 121 122 |
# File 'lib/trackler/track.rb', line 118 def hints path = File.join(dir, 'config', 'exercise-readme-insert.md') return File.read(path) if File.exist?(path) DocFile.find(basename: 'EXERCISE_README_INSERT', track_dir: dir).render end |
#icon ⇒ Object
67 68 69 |
# File 'lib/trackler/track.rb', line 67 def icon @icon ||= svg_icon.exists? ? svg_icon : png_icon end |
#icon_path ⇒ Object
63 64 65 |
# File 'lib/trackler/track.rb', line 63 def icon_path icon.path if icon.exists? end |
#ignore_pattern ⇒ Object
87 88 89 |
# File 'lib/trackler/track.rb', line 87 def ignore_pattern config.ignore_pattern || 'example' end |
#img(file_path) ⇒ Object
95 96 97 |
# File 'lib/trackler/track.rb', line 95 def img(file_path) Image.new(File.join(dir, file_path)) end |
#implementations ⇒ Object
46 47 48 |
# File 'lib/trackler/track.rb', line 46 def implementations @implementations ||= Implementations.new(repository, active_slugs, root, self) end |
#language ⇒ Object
71 72 73 |
# File 'lib/trackler/track.rb', line 71 def language config.language.to_s.strip end |
#planned? ⇒ Boolean
42 43 44 |
# File 'lib/trackler/track.rb', line 42 def planned? !active? && implementations.length.zero? end |
#problems ⇒ Object
50 51 52 53 |
# File 'lib/trackler/track.rb', line 50 def problems warn "DEPRECATION WARNING: A track only has implementations, call track.implementations instead" implementations end |
#repository ⇒ Object
75 76 77 |
# File 'lib/trackler/track.rb', line 75 def repository @repository ||= (config.repository || "https://github.com/exercism/%s" % id).to_s.strip end |
#slugs ⇒ Object
Every slug mentioned in the configuration.
110 111 112 |
# File 'lib/trackler/track.rb', line 110 def slugs active_slugs + foregone_slugs + deprecated_slugs end |
#test_pattern ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/trackler/track.rb', line 79 def test_pattern if !!config.test_pattern Regexp.new(config.test_pattern) else /test/i end end |
#upcoming? ⇒ Boolean
38 39 40 |
# File 'lib/trackler/track.rb', line 38 def upcoming? !active? && implementations.length > 0 end |