scharfie-bones 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -12,7 +12,7 @@ What it does:
12
12
  Requirements:
13
13
 
14
14
  - ActiveSupport
15
- - rack (0.3.0 only at this time)
15
+ - rack (0.3.0 or later should work)
16
16
 
17
17
  Starting it up:
18
18
 
data/bones.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "bones"
3
- s.version = "0.2.1"
4
- s.date = "2009-02-10"
3
+ s.version = "0.2.2"
4
+ s.date = "2009-04-18"
5
5
  s.authors = ["Chris Scharf", "Ryan Heath"]
6
6
  s.email = "scharfie@gmail.com"
7
7
 
@@ -22,18 +22,24 @@ Gem::Specification.new do |s|
22
22
  'lib/bones',
23
23
  'lib/bones/cache.rb',
24
24
  'lib/bones/initializer.rb',
25
+ 'lib/bones/proxy.rb',
25
26
  'lib/bones/release.rb',
27
+ 'lib/bones/server.rb',
28
+ 'lib/bones/static.rb',
26
29
  'lib/bones/template.rb',
27
30
  'lib/bones/versioned_release.rb',
28
31
  'lib/bones.rb',
29
32
  'lib/boot.rb',
33
+ 'lib/config.ru',
30
34
  'lib/extensions.rb',
31
35
  'lib/helpers',
36
+ 'lib/helpers/application_helper.rb',
32
37
  'lib/helpers/core_helper.rb',
38
+ 'lib/layouts',
39
+ 'lib/layouts/application.html.erb',
33
40
  'lib/pages/directory.html.erb',
34
41
  'lib/pages/intro.html.erb',
35
42
  'lib/Rakefile',
36
- 'lib/server.rb',
37
43
  'lib/tasks',
38
44
  'lib/tasks/bones.rb',
39
45
  'Rakefile',
@@ -68,6 +74,6 @@ Gem::Specification.new do |s|
68
74
  ]
69
75
 
70
76
  # Dependencies
71
- s.add_dependency("rack", ["= 0.3.0"])
77
+ s.add_dependency("rack", [">= 0.3.0"])
72
78
  s.add_dependency("activesupport", [">= 2.1.0"])
73
79
  end
@@ -28,6 +28,7 @@ class Bones
28
28
  pages_new = ensure_directory(Bones.root / 'pages')
29
29
  ensure_directory(Bones.root / 'layouts')
30
30
  ensure_directory(Bones.root / 'helpers')
31
+ ensure_directory(Bones.root / 'tmp')
31
32
 
32
33
  if pages_new
33
34
  ensure_file(Bones.root / 'pages' / 'index.html.erb') do |f|
@@ -36,38 +37,24 @@ class Bones
36
37
  end
37
38
 
38
39
  ensure_file(Bones.root / 'layouts' / 'application.html.erb') do |f|
39
- f.write <<-HTML
40
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
41
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
42
- <html>
43
- <head>
44
- <meta http-equiv="Content-type" content="text/html; charset=utf-8">
45
- <title>Welcome to bones</title>
46
- <%= stylesheet_link_tag 'styles' %>
47
- <%= javascript_include_tag %>
48
- </head>
49
- <body>
50
- <h1>Welcome to <strong>bones</strong></h1>
51
- <%= yield %>
52
- </body>
53
- </html>
54
- HTML
40
+ f.write File.read(Bones.system_path / 'layouts' / 'application.html.erb')
55
41
  end
56
42
 
57
43
  ensure_file(Bones.root / 'public' / 'stylesheets' / 'styles.css')
58
44
 
59
45
  ensure_file(Bones.root / 'helpers' / 'application_helper.rb') do |f|
60
- f.write <<-HELPER
61
- # Provide any custom helpers that want in this module
62
- module ApplicationHelper
63
- end
64
- HELPER
46
+ f.write File.read(Bones.system_path / 'helpers' / 'application_helper.rb')
65
47
  end
66
48
 
67
49
  ensure_file(Bones.root / 'Rakefile') do |f|
68
50
  puts "** Adding Rakefile to parent directory"
69
51
  f.write File.read(Bones.system_path / 'Rakefile')
70
52
  end
53
+
54
+ ensure_file(Bones.root / 'config.ru') do |f|
55
+ puts "** Adding config.ru to parent directory"
56
+ f.write File.read(Bones.system_path / 'config.ru')
57
+ end
71
58
 
72
59
  puts <<-HELP if __FILE__ == $0
73
60
 
@@ -0,0 +1,19 @@
1
+ # BonesProxy is simply a proxy class handler
2
+ # to the actual Bones class - the reason for
3
+ # this is to allow live changes to Bones
4
+ # and helpers, etc. The proxy reloads on every
5
+ # request
6
+ class Bones
7
+ class Proxy
8
+ # Process incoming request
9
+ def call(env)
10
+ reload!
11
+ Bones.new.call(env)
12
+ end
13
+
14
+ # Reloads the application
15
+ def reload!
16
+ force_load 'Bones' => File.join(File.dirname(__FILE__), '..', 'bones.rb')
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ class Bones
2
+ class Server
3
+ def self.run
4
+ statics = public_directories
5
+ app = Rack::Builder.new do
6
+ use Rack::CommonLogger
7
+ use Rack::ShowExceptions
8
+ use Rack::Reloader
9
+ use Bones::Static
10
+ run Bones::Proxy.new
11
+ end
12
+
13
+ port = ARGV.shift || 3000
14
+ puts "** Starting bones server on http://0.0.0.0:#{port}"
15
+ puts "** Public directories: #{statics.to_sentence}"
16
+
17
+ Rack::Handler::Mongrel.run app, :Port => port do |server|
18
+ puts "** Use CTRL-C to stop."
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ Bones::Server.run if __FILE__ == $0
@@ -0,0 +1,8 @@
1
+ class Bones
2
+ class Static < Rack::Static
3
+ def initialize(app, *args, &block)
4
+ super app, :urls => public_directories,
5
+ :root => Bones.root / 'public', &block
6
+ end
7
+ end
8
+ end
@@ -76,6 +76,10 @@ class Bones
76
76
  # Compiles the template (along with the layout
77
77
  # if necessary)
78
78
  def compile
79
+ unless File.exist?(filename)
80
+ raise "Template missing\n#{filename}"
81
+ end
82
+
79
83
  src = ERB.new(File.read(filename)).src
80
84
  src = (local_assigns_source || '') + (src || '')
81
85
  @content_for_layout = eval(src) # erb.result(binding)
data/lib/bones.rb CHANGED
@@ -57,9 +57,10 @@ class Bones
57
57
  output = template.compile
58
58
 
59
59
  # Build a rack response
60
- Rack::Response.new.finish do |response|
61
- response.write output
62
- end
60
+ # Rack::Response.new.finish do |response|
61
+ # response.write output
62
+ # end
63
+ [200, { 'Content-Type' => 'text/html'}, output]
63
64
  end
64
65
 
65
66
  # Returns array of all pages (excluding partials)
data/lib/boot.rb CHANGED
@@ -4,14 +4,9 @@ require 'activesupport'
4
4
  require File.join(File.dirname(__FILE__), 'bones.rb')
5
5
  require File.join(File.dirname(__FILE__), 'extensions.rb')
6
6
 
7
- # Bones.root = BONES_ROOT if Object.const_defined?(:BONES_ROOT)
8
7
  ActiveSupport::Dependencies.load_paths.push << Bones.system_path
9
8
 
10
9
  require 'yaml'
11
- require 'rack'
12
- require 'rack/request'
13
- require 'rack/response'
14
-
15
10
  require 'fileutils'
16
11
  require 'optparse'
17
12
  require 'ostruct'
data/lib/config.ru ADDED
@@ -0,0 +1,6 @@
1
+ require File.join(File.dirname(__FILE__), 'boot.rb')
2
+ use Rack::CommonLogger
3
+ use Rack::ShowExceptions
4
+ use Rack::Reloader
5
+ use Bones::Static
6
+ run Bones::Proxy.new
@@ -0,0 +1,3 @@
1
+ # Provide any custom helpers that want in this module
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html>
4
+ <head>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6
+ <title>Welcome to bones</title>
7
+ <%= stylesheet_link_tag 'styles' %>
8
+ <%= javascript_include_tag %>
9
+ </head>
10
+ <body>
11
+ <h1>Welcome to <strong>bones</strong></h1>
12
+ <%= yield %>
13
+ </body>
14
+ </html>
data/lib/tasks/bones.rb CHANGED
@@ -6,7 +6,7 @@ desc "Start bones server"
6
6
  task :server do
7
7
  ARGV.shift
8
8
  load File.join(File.dirname(__FILE__), '..', 'server.rb')
9
- BonesServer.run
9
+ Bones::Server.run
10
10
  end
11
11
 
12
12
  desc "Cache page templates for redistribution (non-versioned)"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scharfie-bones
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Scharf
@@ -10,20 +10,22 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-02-10 00:00:00 -08:00
13
+ date: 2009-04-18 00:00:00 -07:00
14
14
  default_executable: bones
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rack
18
+ type: :runtime
18
19
  version_requirement:
19
20
  version_requirements: !ruby/object:Gem::Requirement
20
21
  requirements:
21
- - - "="
22
+ - - ">="
22
23
  - !ruby/object:Gem::Version
23
24
  version: 0.3.0
24
25
  version:
25
26
  - !ruby/object:Gem::Dependency
26
27
  name: activesupport
28
+ type: :runtime
27
29
  version_requirement:
28
30
  version_requirements: !ruby/object:Gem::Requirement
29
31
  requirements:
@@ -46,18 +48,24 @@ files:
46
48
  - lib/bones
47
49
  - lib/bones/cache.rb
48
50
  - lib/bones/initializer.rb
51
+ - lib/bones/proxy.rb
49
52
  - lib/bones/release.rb
53
+ - lib/bones/server.rb
54
+ - lib/bones/static.rb
50
55
  - lib/bones/template.rb
51
56
  - lib/bones/versioned_release.rb
52
57
  - lib/bones.rb
53
58
  - lib/boot.rb
59
+ - lib/config.ru
54
60
  - lib/extensions.rb
55
61
  - lib/helpers
62
+ - lib/helpers/application_helper.rb
56
63
  - lib/helpers/core_helper.rb
64
+ - lib/layouts
65
+ - lib/layouts/application.html.erb
57
66
  - lib/pages/directory.html.erb
58
67
  - lib/pages/intro.html.erb
59
68
  - lib/Rakefile
60
- - lib/server.rb
61
69
  - lib/tasks
62
70
  - lib/tasks/bones.rb
63
71
  - Rakefile
data/lib/server.rb DELETED
@@ -1,41 +0,0 @@
1
- # BonesProxy is simply a proxy class handler
2
- # to the actual Bones class - the reason for
3
- # this is to allow live changes to Bones
4
- # and helpers, etc. The proxy reloads on every
5
- # request
6
- class BonesProxy
7
- # Process incoming request
8
- def call(env)
9
- reload!
10
- Bones.new.call(env)
11
- end
12
-
13
- # Reloads the application
14
- def reload!
15
- force_load 'Bones' => 'bones.rb'
16
- end
17
- end
18
-
19
- class BonesServer
20
- def self.run
21
- statics = public_directories
22
-
23
- app = Rack::Builder.new do
24
- use Rack::CommonLogger
25
- use Rack::ShowExceptions
26
- use Rack::Reloader
27
- use Rack::Static, :urls => statics, :root => Bones.root / 'public'
28
- run BonesProxy.new
29
- end
30
-
31
- port = ARGV.shift || 3000
32
- puts "** Starting bones server on http://0.0.0.0:#{port}"
33
- puts "** Public directories: #{statics.to_sentence}"
34
-
35
- Rack::Handler::Mongrel.run app, :Port => port do |server|
36
- puts "** Use CTRL-C to stop."
37
- end
38
- end
39
- end
40
-
41
- BonesServer.run if __FILE__ == $0