Class: Jekyll::Cargodoc::Crate

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/cargodoc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Crate

Returns a new instance of Crate.



8
9
10
11
12
13
# File 'lib/jekyll/cargodoc.rb', line 8

def initialize(config)
  @name = config['crate'] || ''
  @version = config['version'] || '*'
  @destination_root = config['destination_root'] || name
  @git = config['git']
end

Instance Attribute Details

#destination_rootObject (readonly)

Returns the value of attribute destination_root.



6
7
8
# File 'lib/jekyll/cargodoc.rb', line 6

def destination_root
  @destination_root
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/jekyll/cargodoc.rb', line 6

def name
  @name
end

Instance Method Details

#dependency_lineObject



23
24
25
26
27
28
29
# File 'lib/jekyll/cargodoc.rb', line 23

def dependency_line
  if !@git.nil?
    "git = \"#{@git}\""
  else
    "#{@name} = \"#{@version}\"\n"
  end
end

#dependency_sectionObject



15
16
17
18
19
20
21
# File 'lib/jekyll/cargodoc.rb', line 15

def dependency_section
  section = "\n[dependencies"
  section << ".#{name}" unless @git.nil?
  section << "]\n"

  section
end

#doc_files_paths(root) ⇒ Object



31
32
33
34
35
# File 'lib/jekyll/cargodoc.rb', line 31

def doc_files_paths(root)
  Dir.chdir("#{root}/#{name}") do
    Dir.glob("**/*").reject { |path| Dir.exist?(path) }
  end
end