thumblemonks-chicago 0.1.2.4 → 0.2

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.
data/HISTORY.txt CHANGED
@@ -0,0 +1,8 @@
1
+ 0.2
2
+
3
+ * Updated to work with the latest Sinatra (0.9.1) and use proper extension nomenclature
4
+ * Fixed catch_all_css to punt on stylesheets that are not defined as SASS files
5
+
6
+ 0.1.2.4
7
+
8
+ * Updated to work with Sinatra 0.9
data/chicago.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "chicago"
3
- s.version = "0.1.2.4"
4
- s.date = "2009-02-01"
3
+ s.version = "0.2"
4
+ s.date = "2009-03-12"
5
5
  s.summary = "Sinatra runtime and testing extensions used commonly by Thumblemonks"
6
6
  s.email = %w[gus@gusg.us gabriel.gironda@gmail.com]
7
7
  s.homepage = "http://github.com/thumblemonks/chicago/tree/master"
@@ -1,26 +1,30 @@
1
- module Thumblemonks
2
- module Sinatra
1
+ module Sinatra
2
+ module ThumbleMonks
3
3
  module Base
4
4
 
5
5
  # Assumes all CSS is SASS and is referenced as being in a directory named stylesheets
6
+ # If SASS file is not defined, the route will passed on to - theoretically - the real
7
+ # CSS in the public directory.
6
8
  def catch_all_css(path='/stylesheets')
7
9
  get("#{path}/*.css") do
8
- content_type 'text/css'
9
- sass params["splat"].first.to_sym
10
+ begin
11
+ content_type 'text/css'
12
+ sass params["splat"].first.to_sym
13
+ rescue Errno::ENOENT
14
+ pass
15
+ end
10
16
  end
11
17
  end
12
18
 
13
- # When you don't want anything special, but to load a named view
19
+ # When you don't want anything special, but to load a named view as HAML.
14
20
  def get_obvious(name)
15
21
  get "/#{name}" do
16
- title = name.to_s
17
22
  haml name.to_sym
18
23
  end
19
24
  end
20
25
 
21
26
  end # Base
27
+ end # ThumbleMonks
22
28
 
23
- end # Sinatra
24
- end # Thumblemonks
25
-
26
- Sinatra::Base.extend(Thumblemonks::Sinatra::Base)
29
+ register ThumbleMonks::Base
30
+ end # Sinatra
@@ -1,12 +1,37 @@
1
- module Thumblemonks
2
- module Sinatra
1
+ module Sinatra
2
+ module ThumbleMonks
3
3
  module Helpers
4
+ # A basic anchor (link_to) tag
5
+ #
6
+ # Exmaples:
7
+ #
8
+ # anchor('GusGus', 'http://gusg.us')
9
+ # => <a href="http://gusg.us">GusG.us</a>
10
+ #
11
+ # anchor('GusGus', 'http://gusg.us', :title => 'You know who!')
12
+ # => <a href="http://gusg.us" title="You know who!">GusG.us</a>
4
13
  def anchor(name, url, options={})
5
14
  defaults = {:href => url}
6
15
  options_str = hash_to_attributes(defaults.merge(options))
7
16
  %Q[<a #{options_str}>#{name}</a>]
8
17
  end
9
18
 
19
+ # A helper to include stylesheet links. Currently defaults everything to
20
+ # load from a /stylesheets directory.
21
+ #
22
+ # Exmaples:
23
+ #
24
+ # stylesheet_include('foo')
25
+ # => <link href="/stylsheets/foo.css" media="screen" rel="stylesheet" type="text/css" />
26
+ #
27
+ # stylesheet_include('foo/bar')
28
+ # => <link href="/stylsheets/foo/bar.css" media="screen" rel="stylesheet" type="text/css" />
29
+ #
30
+ # stylesheet_include('foo', :media => "print")
31
+ # => <link href="/stylsheets/foo.css" media="print" rel="stylesheet" type="text/css" />
32
+ #
33
+ # stylesheet_include('http://example.com/foo.css')
34
+ # => <link href="http://example.com/foo.css" media="print" rel="stylesheet" type="text/css" />
10
35
  def stylesheet_include(name, options={})
11
36
  name = "/stylesheets/#{name}.css" unless remote_asset?(name)
12
37
  defaults = {:href => name, :media => "screen",
@@ -15,6 +40,22 @@ module Thumblemonks
15
40
  %Q[<link #{options_str}/>]
16
41
  end
17
42
 
43
+ # A helper to include javascript source tags. Currently defaults everything
44
+ # to load from a /javascripts directory.
45
+ #
46
+ # Exmaples:
47
+ #
48
+ # javascript_include('foo')
49
+ # => <javascript src="/javascripts/foo.js" type="text/javascript"></script>
50
+ #
51
+ # javascript_include('foo/bar')
52
+ # => <javascript src="/javascripts/foo/bar.js" type="text/javascript"></script>
53
+ #
54
+ # javascript_include('foo', :something => "great")
55
+ # => <javascript src="/javascripts/foo.js" type="text/javascript" something="great"></script>
56
+ #
57
+ # javascript_include('http://example.com/foo.js')
58
+ # => <javascript src="http://example.com/foo.js" type="text/javascript"></script>
18
59
  def javascript_include(name, options={})
19
60
  name = "/javascripts/#{name}.js" unless remote_asset?(name)
20
61
  defaults = {:src => name, :type => "text/javascript"}
@@ -30,7 +71,7 @@ module Thumblemonks
30
71
  options.map {|k,v| "#{k}=\"#{v}\""}.join(' ')
31
72
  end
32
73
  end # Helpers
33
- end # Sinatra
34
- end # Thumblemonks
74
+ end # ThumbleMonks
35
75
 
36
- Sinatra::Base.instance_eval { include Thumblemonks::Sinatra::Helpers }
76
+ helpers ThumbleMonks::Helpers
77
+ end # Sinatra
@@ -1,5 +1,5 @@
1
- module Thumblemonks
2
- module Sinatra
1
+ module Sinatra
2
+ module Thumblemonks
3
3
  module Responders
4
4
 
5
5
  # Returns a JSON response for an object
@@ -9,7 +9,7 @@ module Thumblemonks
9
9
  end
10
10
 
11
11
  end # Responders
12
- end # Sinatra
13
- end # Thumblemonks
12
+ end # Thumblemonks
14
13
 
15
- Sinatra::Base.instance_eval { include Thumblemonks::Sinatra::Responders }
14
+ helpers Thumblemonks::Responders
15
+ end # Sinatra
@@ -1,7 +1,7 @@
1
1
  require 'json'
2
2
  require 'ostruct'
3
3
 
4
- module Thumblemonks
4
+ module ThumbleMonks
5
5
  module Shoulda
6
6
  module Sinatra
7
7
 
@@ -32,20 +32,6 @@ module Thumblemonks
32
32
  assert_response_body json
33
33
  end
34
34
  end
35
-
36
- # Will invoke a helper method in the EventContext and set the result of
37
- # output to @response.body.
38
- #
39
- # NOTE: This will probably break right now if you need access to specific
40
- # event context methods or Sinatra.app options in your helper.
41
- def should_invoke_helper(name, *args, &assert_block)
42
- should "invoke helper #{name} with #{args.inspect}" do
43
- @response = OpenStruct.new(:body => nil)
44
- event_context = ::Sinatra::EventContext.new(nil, @response, nil)
45
- @response.body = event_context.send(name, *args)
46
- self.instance_eval(&assert_block)
47
- end
48
- end
49
35
  end # Macros
50
36
 
51
37
  module Helpers
@@ -80,6 +66,6 @@ module Thumblemonks
80
66
 
81
67
  end # Sinatra
82
68
  end # Shoulda
83
- end # Thumblemonks
69
+ end # ThumbleMonks
84
70
 
85
- Test::Unit::TestCase.instance_eval { include Thumblemonks::Shoulda::Sinatra }
71
+ Test::Unit::TestCase.instance_eval { include ThumbleMonks::Shoulda::Sinatra }
data/lib/chicago.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'sinatra/base'
1
2
  require 'chicago/application'
2
3
  require 'chicago/responders'
3
4
  require 'chicago/helpers'
@@ -34,6 +34,16 @@ class ApplicationTest < Test::Unit::TestCase
34
34
  should_have_content_type 'text/css'
35
35
  should_have_response_body %r[.car \{\s+display: some; \}\s]
36
36
  end
37
+
38
+ context "with path that's not a defined a sass file" do
39
+ setup do
40
+ mock_app { catch_all_css }
41
+ get '/stylesheets/goo.css'
42
+ end
43
+
44
+ should_have_response_status 404
45
+ should_have_content_type 'text/css'
46
+ end
37
47
  end # catching all css
38
48
 
39
49
  context "getting obvious views" do
data/test/test_helper.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  require 'rubygems'
2
2
 
3
- require 'shoulda'
4
-
5
- require 'sinatra/base'
3
+ require 'haml'
4
+ require 'sinatra'
5
+ require 'test/unit'
6
6
  require 'sinatra/test'
7
- require 'sinatra/test/unit'
7
+
8
+ require 'shoulda'
8
9
 
9
10
  require 'chicago'
10
11
  require 'chicago/shoulda'
@@ -13,7 +14,11 @@ module Sinatra::Test
13
14
  # Sets up a Sinatra::Base subclass defined with the block
14
15
  # given. Used in setup or individual spec methods to establish
15
16
  # the application.
16
- def mock_app(base=Sinatra::Base, &block)
17
+ def mock_app(base=Sinatra::Default, &block)
17
18
  @app = Sinatra.new(base, &block)
18
19
  end
19
20
  end
21
+
22
+ class Test::Unit::TestCase
23
+ include Sinatra::Test
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thumblemonks-chicago
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.4
4
+ version: "0.2"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Knowlden
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-02-01 00:00:00 -08:00
13
+ date: 2009-03-12 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16