Module: Hyhyhy

Defined in:
lib/hyhyhy.rb,
lib/hyhyhy/config.rb,
lib/hyhyhy/frames.rb,
lib/hyhyhy/logger.rb,
lib/hyhyhy/parser.rb,
lib/hyhyhy/version.rb

Defined Under Namespace

Modules: Config, Frames, Logger, Parser

Constant Summary collapse

VERSION =
"1.0.0"
SUMMARY =
%q{Pure & Professional presentations}
DESCRIPTION =
%q{A tool for creating nice looking HTML5 presentations.}

Class Method Summary collapse

Class Method Details

.build(args, options) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/hyhyhy.rb', line 54

def self.build(args, options)
  if options.source == './' && options.destination == './_build'
    Logger.spit("The current folder will be generated into ./_build", :output)
  elsif options.source == './' && options.destination != './_build'
    Logger.spit("The current folder will be generated into " + options.destination, :output)
  else options.source != './'
    Logger.spit("The " + options.source + " folder will be generated into " + options.destination, :output)
  end

  if options.watch == true
    Logger.spit(", watched for changes, and regenerated automatically.", :echo)
  end

  Logger.ahoy() # To inform you about what we do...

  Frames.save(options.source, options.destination)

  if options.serve == true
    Thread.new() do
      self.serve(args, options)
    end
  end

  if options.watch == true
    listener = Listen.to(options.source, :ignore => /_build/) do |modified, added, removed|
      Logger.spit("Regeneration.... #{modified} #{added} #{removed}", :output)
      Logger.ahoy()

      Frames.save(options.source, options.destination)
    end
    listener.start
    sleep
  end
end

.initializeObject



20
21
22
# File 'lib/hyhyhy.rb', line 20

def self.initialize
  trap('INT') { Process.exit!(true) }
end

.new(args, options) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/hyhyhy.rb', line 24

def self.new(args, options)
  if options.title == nil
    options.title = Logger.hear("Title: ")
  end

  if options.description == nil
    options.description = Logger.hear("Description: ")
  end

  if options.author == nil
    options.author = Logger.hear("Author: ")
  end

  if args[0] == nil
    args[0] = './' + options.title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
  end

  FileUtils.copy_entry File.dirname(__FILE__) + '/hyhyhy/structure', args[0]

  Config.load(args[0] + '/.hyhyhy')

  Config['title'] = options.title
  Config['description'] = options.description
  Config['author'] = options.author

  # Informing about the success!
  Logger.spit("Default structure will be generated into " + args[0], :output)
  Logger.ahoy()
end

.serve(args, options) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/hyhyhy.rb', line 89

def self.serve(args, options)
  if args[0] == nil || args[0] = '.'
    args[0] = './_build'
  end

  if options.open == true
    Launchy.open(args[0] + '/index.html')
  end

  Logger.spit("Now browse to http://localhost:4000", :output)
  Logger.ahoy()

  server = WEBrick::HTTPServer.new :Port => 4000
  server.mount "/", WEBrick::HTTPServlet::FileHandler, args[0]
  trap('INT') { server.stop; Process.exit!(true) }
  server.start
end