Class: Create

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions, Util
Defined in:
lib/commands/create.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

#add_to_git, #alter_index_html, #alter_link, #content_root, #each_presentation, #git_repository?, #has_remote?, #init_git, #parse_config, #presentation, #pull_from_git, #request_token

Class Method Details

.source_rootObject



17
18
19
# File 'lib/commands/create.rb', line 17

def self.source_root
  File.expand_path('../',__dir__)
end

Instance Method Details

#append_indexObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/commands/create.rb', line 44

def append_index
  index = "#{content_root}/client/index.html"
  template 'template/overview_index.erb',index unless File.exist?(index)

  alter_index_html do | doc |
    unless doc.xpath('//a').map(&:content).include? @name
      body = doc.at_css 'body'
      h2 = Nokogiri::XML::Node.new 'h2', doc
      link = Nokogiri::XML::Node.new 'a', doc
      link['href'] = "slides/#{@snake_case_name}/"
      link.content= "#{@name}"
      h2 << link
      body << h2
    end
  end
end

#create_clientObject



38
39
40
41
42
# File 'lib/commands/create.rb', line 38

def create_client
  @client = true
  template 'template/index.erb',
           "#{content_root}/client/slides/#{@snake_case_name}/index.html"
end

#create_masterObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/commands/create.rb', line 26

def create_master
  @config = parse_config
  @token = request_token
  @client = false
  template 'template/index.erb',
           "#{content_root}/master/slides/#{@snake_case_name}/index.html"

  template 'template/content.md.erb',
           "#{content_root}/master/slides/" \
           "#{@snake_case_name}/content/content.md"
end

#prepare_parametersObject



21
22
23
# File 'lib/commands/create.rb', line 21

def prepare_parameters
  @snake_case_name = @name.sub ' ','_'
end