Class: Trackler::Specification
- Inherits:
-
Object
- Object
- Trackler::Specification
- Defined in:
- lib/trackler/specification.rb
Overview
Specification is a language-independent definition of a problem to solve.
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #blurb ⇒ Object
- #canonical_data_url ⇒ Object
- #deprecated? ⇒ Boolean
- #description ⇒ Object
- #description_url ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(slug, root, track = NullTrack.new) ⇒ Specification
constructor
A new instance of Specification.
- #metadata_url ⇒ Object
- #name ⇒ Object
- #source ⇒ Object
- #source_markdown ⇒ Object
- #source_url ⇒ Object
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
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
9 10 11 |
# File 'lib/trackler/specification.rb', line 9 def @metadata end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
9 10 11 |
# File 'lib/trackler/specification.rb', line 9 def root @root end |
#slug ⇒ Object (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
28 29 30 |
# File 'lib/trackler/specification.rb', line 28 def active? exists? && !deprecated? end |
#blurb ⇒ Object
57 58 59 |
# File 'lib/trackler/specification.rb', line 57 def blurb .blurb end |
#canonical_data_url ⇒ Object
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
24 25 26 |
# File 'lib/trackler/specification.rb', line 24 def deprecated? @deprecated ||= File.exist?(file_path(deprecation_file_name, @file_root)) end |
#description ⇒ Object
36 37 38 |
# File 'lib/trackler/specification.rb', line 36 def description description_object.to_s end |
#description_url ⇒ Object
45 46 47 |
# File 'lib/trackler/specification.rb', line 45 def description_url description_object.url end |
#exists? ⇒ Boolean
20 21 22 |
# File 'lib/trackler/specification.rb', line 20 def exists? description_object.exists? && .exists? end |
#metadata_url ⇒ Object
53 54 55 |
# File 'lib/trackler/specification.rb', line 53 def .url end |
#name ⇒ Object
32 33 34 |
# File 'lib/trackler/specification.rb', line 32 def name slug.split('-').map(&:capitalize).join(' ') end |
#source ⇒ Object
61 62 63 |
# File 'lib/trackler/specification.rb', line 61 def source .source end |
#source_markdown ⇒ Object
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_url ⇒ Object
65 66 67 |
# File 'lib/trackler/specification.rb', line 65 def source_url .source_url end |