sinatra-effigy 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -23,6 +23,8 @@ Create your Sinatra app:
23
23
  require 'sinatra'
24
24
  require 'sinatra/effigy'
25
25
 
26
+ set :app_file, __FILE__
27
+
26
28
  get '/jobs/:id' do |id|
27
29
  effigy :job, Job.find(id)
28
30
  end
@@ -31,20 +33,22 @@ Create your template (fresh from a designer?) at /templates/job.html:
31
33
 
32
34
  <!DOCTYPE html>
33
35
  <html>
34
- <head>
36
+ <head lang="en">
37
+ <meta charset="utf-8">
35
38
  <title>Web Designer at thoughtbot</title>
36
39
  </head>
37
40
  <body>
38
- <h1>Web Designer</h1>
39
- <h2><a href="http://example.com">thoughtbot</a></h2>
40
- <h3>Boston or New York</h3>
41
+ <header>
42
+ <hgroup>
43
+ <h1>Web Designer</h1>
44
+ <h2><a href="http://example.com">thoughtbot</a></h2>
45
+ <h3>Boston or New York</h3>
46
+ </hgroup>
47
+ </header>
41
48
 
42
49
  <div id="description">
43
50
  <p>Graphic design, typography, CSS, HTML.</p>
44
51
  </div>
45
-
46
- <h3>Apply</h3>
47
- <p>Please contact <span id="apply-at">jobs@example.com</span>.</p>
48
52
  </body>
49
53
  </html>
50
54
 
@@ -60,10 +64,8 @@ Create a view at /views/job.rb that responds to #transform:
60
64
  def transform
61
65
  f('title').text("#{job.position} at #{job.company}")
62
66
  f('h1').text(job.position)
63
- f('h2 a').attr(:href => job.company_url).
64
- text(job.company)
67
+ f('h2 a').attr(:href => job.company_url).text(job.company)
65
68
  f('#description').html(job.description)
66
- f('#apply-at').text(job.apply_at)
67
69
  end
68
70
  end
69
71
 
@@ -78,6 +80,13 @@ Use a string if you need directories:
78
80
  effigy 'jobs/edit', Job.find(id)
79
81
  end
80
82
 
83
+ Gotchas
84
+ -------
85
+
86
+ If you use Gem Bundler, set the app_file option in your Sinatra app:
87
+
88
+ set :app_file, __FILE__
89
+
81
90
  Resources
82
91
  ---------
83
92
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -3,17 +3,15 @@ require 'effigy'
3
3
 
4
4
  module Sinatra
5
5
  module EffigyHelper
6
- if File.directory?('views')
7
- Dir['views/*'].each {|view| require view }
8
- end
6
+ Dir['views/*'].each {|view| require view }
9
7
 
10
8
  def effigy(name, *locals)
11
9
  camel_name = "#{name}_view".
12
10
  gsub(' ', '_').
13
11
  gsub(/\/(.)/) { "::#{$1.upcase}" }.
14
12
  gsub(/(?:^|_)(.)/) { $1.upcase }
15
- view = Object.const_get(camel_name).new(*locals)
16
- template = File.read(File.join(options.root, "templates", "#{name}.html"))
13
+ view = Object.const_get(camel_name).new(*locals)
14
+ template = File.read("templates/#{name}.html")
17
15
  view.render(template)
18
16
  end
19
17
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra-effigy}
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Croak"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-effigy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Croak