Class: Jekyll::Versioning::Generator

Inherits:
Generator
  • Object
show all
Defined in:
lib/jekyll/versioning/generator.rb

Instance Method Summary collapse

Instance Method Details

#current_branchObject



37
38
39
# File 'lib/jekyll/versioning/generator.rb', line 37

def current_branch
  %x{git rev-parse --abbrev-ref HEAD}
end

#generate(site) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jekyll/versioning/generator.rb', line 9

def generate(site)
  current_branch = self.current_branch
  %x{git stash}
  tags.each do |tag|
    %x{git checkout #{tag}}

    config = Jekyll.configuration({
      'destination' => site.config["destination"] + "/#{tag}",
      'url' => site.config['url'].to_s + "/#{tag}"
    })

    tagged_site = Jekyll::Site.new(config)
    tagged_site.generators.delete_if {|g| g.to_s == to_s }
    tagged_site.process
  end
  site.keep_files = site.keep_files + tags
  %x{git checkout #{current_branch}}
  %x{git stash pop}
end

#tagsObject



29
30
31
# File 'lib/jekyll/versioning/generator.rb', line 29

def tags
  %x{git tag -l 'v*.0.0'}.split("\n")
end

#to_sObject



33
34
35
# File 'lib/jekyll/versioning/generator.rb', line 33

def to_s
  'Jekyll::Versioning'
end