guinness 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.expand_path('../../lib/guinness', __FILE__)
4
4
 
5
- cmd = ARGV[0] || 'drink'
5
+ cmd = ARGV[0] || 'serve'
6
6
  dir = ARGV[1] || '_source'
7
7
  puts "#{Guinness::EMOJI} Guinness : App root is: '#{dir}'"
8
8
 
@@ -10,17 +10,21 @@ case cmd
10
10
 
11
11
  when 'new'
12
12
  require 'fileutils'
13
+
13
14
  File.open(File.join(FileUtils.mkpath(dir), 'index.html'), 'w') do |f|
14
15
  f.puts 'Cheers from Guinness!'
15
16
  end
16
17
 
17
- when 'build', 'drink'
18
+ ["/stylesheets", "/javascripts", "/images"].each do |path|
19
+ FileUtils.mkdir_p(File.join(dir, path)) unless File.exists?(path)
20
+ end
21
+
22
+ when 'serve'
18
23
  abort "#{Guinness::EMOJI} Guinness : Unable to locate: '#{dir}'" unless Dir.exists?(dir)
19
24
  @app = Guinness::Application.new(root: dir)
20
- @app.send cmd
25
+ @app.send(cmd)
21
26
 
22
27
  else
23
28
  puts "'#{cmd}' is not a valid guinness command"
24
- puts 'Usage: guinness (build,drink,new) <directory>'
25
-
29
+ puts 'Usage: guinness (serve,new) <directory>'
26
30
  end
@@ -5,8 +5,8 @@ require 'tilt'
5
5
 
6
6
  require "guinness/version"
7
7
  require "guinness/application"
8
- require "guinness/server"
9
8
  require "guinness/view"
9
+ require "guinness/server"
10
10
 
11
11
  module Guinness
12
12
  EMOJI = "🍻 "
@@ -4,38 +4,19 @@ class Guinness::Application
4
4
 
5
5
  def initialize(options = {})
6
6
  @settings = { output_dir: '../' }.merge options
7
-
7
+
8
8
  app = self
9
- @builder = Rack::Builder.new do
9
+ @builder = Rack::Builder.new do |builder|
10
10
  use Rack::CommonLogger
11
11
  use Rack::ShowStatus # Nice looking 404s and other messages
12
12
  use Rack::ShowExceptions # Nice looking errors
13
+ use Rack::Static, :urls => ["/stylesheets", "/javascripts", "/images"]
13
14
  run Guinness::Server.new app
14
15
  end
15
16
  end
16
17
 
17
- def drink
18
+ def serve
18
19
  Rack::Handler::Thin.run @builder, Port: 9393
19
20
  end
20
21
 
21
- def build
22
- FileUtils.cd @settings[:root] do
23
- # collect all files that don't start with '_'
24
- files = Dir[File.join('**', '*')].reject { |f| f =~ /(^_|\/_)/ }
25
-
26
- files.each do |file|
27
- path = File.join @settings[:output_dir], file
28
-
29
- if Tilt[path]
30
- body = Guinness::View.new(file).render
31
- File.open(path.chomp(File.extname(path)), 'w') { |f| f.write body }
32
- elsif Dir.exists? file
33
- FileUtils.mkpath path
34
- else
35
- FileUtils.cp file, path
36
- end
37
- end
38
- end
39
- end
40
-
41
22
  end
@@ -1,3 +1,3 @@
1
1
  module Guinness
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -4,18 +4,6 @@ class Guinness::View
4
4
  @template = template
5
5
  end
6
6
 
7
- def partial(path, locals = {})
8
- filepath = File.join File.dirname(@template), path.to_s
9
- # insert a '_' before the filename before we search
10
- _partial = Dir["#{filepath.sub(/\/(?!.*\/)/, '/_')}*"].first
11
-
12
- if _partial
13
- Tilt.new(_partial).render(self, locals)
14
- else
15
- raise "#{Guinness::EMOJI} Guinness : Unable to locate partial at: '#{filepath}'"
16
- end
17
- end
18
-
19
7
  # return a view body or nil if adequate template cannot be found
20
8
  def render
21
9
  template_body = Tilt.new(@template).render(self)
@@ -0,0 +1 @@
1
+ <h1> Sampleton App </h1>
@@ -0,0 +1 @@
1
+ require 'minitest/autorun'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guinness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-21 00:00:00.000000000 Z
12
+ date: 2014-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -89,6 +89,8 @@ files:
89
89
  - lib/guinness/version.rb
90
90
  - lib/guinness/view.rb
91
91
  - lib/guinness.rb
92
+ - test/sampleton/index.html
93
+ - test/spec_helper.rb
92
94
  homepage: ''
93
95
  licenses:
94
96
  - MIT