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



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

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

Instance Method Details

#buildObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gumdrop/cli/internal.rb', line 20

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

#serverObject



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

def server
  Gumdrop.configure do |c|
    c.server_port= options[:port]
  end
  Gumdrop.site.options = options.merge(mode:'server')
  Launchy.open "http://127.0.0.1:#{ options[:port] }" if options[:browser]
  Gumdrop.log.warn "Launching dev server at http://127.0.0.1:#{ options[:port] }"
  Gumdrop::Server
end

#template(name) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/gumdrop/cli/internal.rb', line 47

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



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/gumdrop/cli/internal.rb', line 64

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}"
    say " #{blackout + generated } #{content.uri}"
  end
  say ""
  say "Legend:"
  say "  X = On the blacklist"
  say "  * = Generated (not on fs)"
  # say "  ! = Binary file"
end

#versionObject



88
89
90
# File 'lib/gumdrop/cli/internal.rb', line 88

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