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.



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

Returns the value of attribute file_bundle.



21
22
23
# File 'lib/trackler/track.rb', line 21

def file_bundle
  @file_bundle
end

#idObject (readonly)

Returns the value of attribute id.



21
22
23
# File 'lib/trackler/track.rb', line 21

def id
  @id
end

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

Returns:

  • (Boolean)


32
33
34
# File 'lib/trackler/track.rb', line 32

def active?
  !!config["active"]
end

#checklist_issueObject



52
53
54
# File 'lib/trackler/track.rb', line 52

def checklist_issue
  config.fetch("checklist_issue", 1)
end

#doc_formatObject



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

#docsObject



82
83
84
# File 'lib/trackler/track.rb', line 82

def docs
  Hash[TOPICS.zip(TOPICS.map { |topic| document_contents(topic) })]
end

#exists?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/trackler/track.rb', line 28

def exists?
  File.exist?(dir)
end

#gitterObject



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

def gitter
  config["gitter"]
end

#global_zipObject



96
97
98
# File 'lib/trackler/track.rb', line 96

def global_zip
  @zip ||= file_bundle.zip
end

#iconObject



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

def icon
  @icon ||= Image.new(File.join(dir, "img/icon.png"))
end

#icon_pathObject



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

#implementationsObject



44
45
46
# File 'lib/trackler/track.rb', line 44

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

#planned?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/trackler/track.rb', line 40

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

#problemsObject



48
49
50
# File 'lib/trackler/track.rb', line 48

def problems
  @problems ||= implementations.map(&:problem)
end

#slugsObject

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_patternObject



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

Returns:

  • (Boolean)


36
37
38
# File 'lib/trackler/track.rb', line 36

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