Class: Jekyll::GeneratorSingleSource::Product::Release

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/generator-single-source/product/release.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(release_hash) ⇒ Release

Returns a new instance of Release.



9
10
11
12
13
# File 'lib/jekyll/generator-single-source/product/release.rb', line 9

def initialize(release_hash)
  @release_hash = release_hash

  validate!
end

Instance Attribute Details

#release_hashObject (readonly)

Returns the value of attribute release_hash.



7
8
9
# File 'lib/jekyll/generator-single-source/product/release.rb', line 7

def release_hash
  @release_hash
end

Instance Method Details

#default_versionObject



49
50
51
# File 'lib/jekyll/generator-single-source/product/release.rb', line 49

def default_version
  @default_version ||= versions['default']
end

#editionObject



15
16
17
# File 'lib/jekyll/generator-single-source/product/release.rb', line 15

def edition
  @edition ||= @release_hash.fetch('edition')
end

#labelObject



27
28
29
# File 'lib/jekyll/generator-single-source/product/release.rb', line 27

def label
  @label ||= @release_hash['label']
end

#latest?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/jekyll/generator-single-source/product/release.rb', line 23

def latest?
  @release_hash['latest']
end

#ltsObject



31
32
33
# File 'lib/jekyll/generator-single-source/product/release.rb', line 31

def lts
  @lts ||= @release_hash['lts']
end

#tagObject



45
46
47
# File 'lib/jekyll/generator-single-source/product/release.rb', line 45

def tag
  @tag ||= value.split('.')[0..1].join('.')
end

#to_hObject



70
71
72
# File 'lib/jekyll/generator-single-source/product/release.rb', line 70

def to_h
  @release_hash
end

#to_liquidObject



66
67
68
# File 'lib/jekyll/generator-single-source/product/release.rb', line 66

def to_liquid
  Liquid::Drops::Release.new(self)
end

#to_semverObject



62
63
64
# File 'lib/jekyll/generator-single-source/product/release.rb', line 62

def to_semver
  value.gsub('-x', '.x').gsub(/\.x/, '.0')
end

#to_strObject Also known as: to_s



53
54
55
56
57
58
59
# File 'lib/jekyll/generator-single-source/product/release.rb', line 53

def to_str
  if @release_hash.key?('label')
    label
  else
    value
  end
end

#valueObject



19
20
21
# File 'lib/jekyll/generator-single-source/product/release.rb', line 19

def value
  @value ||= @release_hash['release']
end

#versionsObject



35
36
37
38
39
40
41
42
43
# File 'lib/jekyll/generator-single-source/product/release.rb', line 35

def versions
  @versions ||= begin
                  if @release_hash.has_key?('version')
                    { 'default' => @release_hash['version'] }
                  else
                    versions_without_suffix
                  end
                end
end