Class: Trackler::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/trackler/specification.rb

Overview

Specification is a language-independent definition of a problem to solve.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(slug, root, track = NullTrack.new) ⇒ Specification

Returns a new instance of Specification.



10
11
12
13
14
15
16
17
18
# File 'lib/trackler/specification.rb', line 10

def initialize(slug, root, track = NullTrack.new)
  @slug = slug
  @root = root
  @file_root = File.join(root, 'problem-specifications', 'exercises', self.slug)
  @repo_root = "https://github.com/exercism/problem-specifications/blob/master/exercises/%s/" % self.slug

  @metadata = Metadata.for(specification: self, track: track)
  self.description_object = Description.for(specification: self, track: track)
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



9
10
11
# File 'lib/trackler/specification.rb', line 9

def 
  @metadata
end

#rootObject (readonly)

Returns the value of attribute root.



9
10
11
# File 'lib/trackler/specification.rb', line 9

def root
  @root
end

#slugObject (readonly)

Returns the value of attribute slug.



9
10
11
# File 'lib/trackler/specification.rb', line 9

def slug
  @slug
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


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

def active?
  exists? && !deprecated?
end

#blurbObject



57
58
59
# File 'lib/trackler/specification.rb', line 57

def blurb
  .blurb
end

#canonical_data_urlObject



49
50
51
# File 'lib/trackler/specification.rb', line 49

def canonical_data_url
  repo_url(canonical_data_file_name) if File.exist?(file_path(canonical_data_file_name, @file_root))
end

#deprecated?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/trackler/specification.rb', line 24

def deprecated?
  @deprecated ||= File.exist?(file_path(deprecation_file_name, @file_root))
end

#descriptionObject



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

def description
  description_object.to_s
end

#description_urlObject



45
46
47
# File 'lib/trackler/specification.rb', line 45

def description_url
  description_object.url
end

#exists?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/trackler/specification.rb', line 20

def exists?
  description_object.exists? && .exists?
end

#metadata_urlObject



53
54
55
# File 'lib/trackler/specification.rb', line 53

def 
  .url
end

#nameObject



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

def name
  slug.split('-').map(&:capitalize).join(' ')
end

#sourceObject



61
62
63
# File 'lib/trackler/specification.rb', line 61

def source
  .source
end

#source_markdownObject



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

def source_markdown
  text = [source, markdown_link(source_url)].reject(&:empty?).join(" ")
  text.empty? ? text : "## Source\n\n#{text}"
end

#source_urlObject



65
66
67
# File 'lib/trackler/specification.rb', line 65

def source_url
  .source_url
end