Class: Gumdrop::CLI::Internal

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/gumdrop/cli/internal.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



8
9
10
# File 'lib/gumdrop/cli/internal.rb', line 8

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

Instance Method Details

#buildObject



18
19
20
21
22
23
24
25
# File 'lib/gumdrop/cli/internal.rb', line 18

def build
  if options[:quiet]
    Gumdrop.configure do |c|
      c.log_level= :warn
    end
  end
  Gumdrop.run options.merge(mode:'build')
end

#serverObject



28
29
30
31
# File 'lib/gumdrop/cli/internal.rb', line 28

def server
  Gumdrop.site.options = options.merge(mode:'server')
  Gumdrop::Server
end

#template(name) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/gumdrop/cli/internal.rb', line 34

def template(name)
  template= name
  template_path = home_template_path name
  if File.exists? template_path
    say "A template named '#{name}' already exists!"
  
  else
    say "Creating template:  #{name}"
    say "  ~/.gumdrop/templates/#{name}"
    site_root= Gumdrop.site.root
    FileUtils.mkdir_p File.dirname(template_path)
    FileUtils.cp_r (site_root / "."), template_path
  end
end

#urisObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/gumdrop/cli/internal.rb', line 51

def uris
  Gumdrop.configure do |c|
    c.log_level= :error
  end
  Gumdrop.site.scan

  say "Gumdrop found:"
  say ""
  Gumdrop.site.contents.keys.sort.each do |uri|
    content= Gumdrop.site.contents[uri]
    blackout= Gumdrop.site.in_blacklist?(uri) ? 'X' : ' '
    generated= content.generated? ? '*' : ' '
    binary= content.binary? ? '!' : ' '
    say " #{blackout + generated + binary} #{content.uri}"
  end
  say ""
  say "Legend:"
  say "  X = On on the blacklist"
  say "  * = Generated (not on fs)"
  say "  ! = Binary file"
end

#versionObject



74
75
76
# File 'lib/gumdrop/cli/internal.rb', line 74

def version
  say "Gumdrop v#{ Gumdrop::VERSION }"
end