Class: Trackler::Track

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_bundleObject (readonly)

Returns the value of attribute file_bundle.



23
24
25
# File 'lib/trackler/track.rb', line 23

def file_bundle
  @file_bundle
end

#idObject (readonly)

Returns the value of attribute id.



23
24
25
# File 'lib/trackler/track.rb', line 23

def id
  @id
end

#rootObject (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

Returns:

  • (Boolean)


34
35
36
# File 'lib/trackler/track.rb', line 34

def active?
  !!config.active
end

#checklist_issueObject



55
56
57
# File 'lib/trackler/track.rb', line 55

def checklist_issue
  config.checklist_issue || 1
end

#dirObject



114
115
116
# File 'lib/trackler/track.rb', line 114

def dir
  root.join("tracks", id)
end

#doc_formatObject



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

Returns:

  • (Boolean)


30
31
32
# File 'lib/trackler/track.rb', line 30

def exists?
  File.exist?(dir)
end

#gitterObject



59
60
61
# File 'lib/trackler/track.rb', line 59

def gitter
  config.gitter
end

#global_zipObject



105
106
107
# File 'lib/trackler/track.rb', line 105

def global_zip
  @zip ||= file_bundle.zip
end

#hintsObject



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

#iconObject



67
68
69
# File 'lib/trackler/track.rb', line 67

def icon
  @icon ||= svg_icon.exists? ? svg_icon : png_icon
end

#icon_pathObject



63
64
65
# File 'lib/trackler/track.rb', line 63

def icon_path
  icon.path if icon.exists?
end

#ignore_patternObject



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

#implementationsObject



46
47
48
# File 'lib/trackler/track.rb', line 46

def implementations
  @implementations ||= Implementations.new(repository, active_slugs, root, self)
end

#languageObject



71
72
73
# File 'lib/trackler/track.rb', line 71

def language
  config.language.to_s.strip
end

#planned?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/trackler/track.rb', line 42

def planned?
  !active? && implementations.length.zero?
end

#problemsObject



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

#repositoryObject



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

#slugsObject

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_patternObject



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

Returns:

  • (Boolean)


38
39
40
# File 'lib/trackler/track.rb', line 38

def upcoming?
  !active? && implementations.length > 0
end