animalcracker 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,18 @@
1
1
  # Animal Cracker
2
2
 
3
- Is yummy ...
3
+ ## Usage
4
+
5
+ In your Sinatra app somewhere:
6
+
7
+ require 'animalcracker'
8
+
9
+ class MyApp < Sinatra::Base
10
+ register AnimalCracker::Server
11
+ get_assets "/assets" # This is the root pathw where assets are to be found
12
+
13
+ configure do
14
+ AnimalCracker::AssetHost.configure(:asset_path => "./assets")
15
+ end
16
+ end
17
+
18
+ NOW: JUST NEED TO MAKE THIS WORK :)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{animalcracker}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin 'Gus' Knowlden"]
12
- s.date = %q{2009-12-21}
12
+ s.date = %q{2010-01-29}
13
13
  s.description = %q{A sweet Sinatra extension for asset hosting. Roarrrrrrrr}
14
14
  s.email = %q{gus@gusg.us}
15
15
  s.extra_rdoc_files = [
@@ -4,10 +4,10 @@ require 'sinatra'
4
4
  module AnimalCracker
5
5
  module Server
6
6
 
7
- def self.extended(base)
8
- base.get("*") do
7
+ def get_assets(root_path="")
8
+ get("#{root_path}/*") do
9
9
  begin
10
- params[:splat].first.split(",").map { |asset_path| AssetHost[asset_path] || not_found }
10
+ "/#{params[:splat].first}".split(",").map { |asset_path| AssetHost[asset_path] || not_found }
11
11
  rescue NotFound
12
12
  not_found
13
13
  end
@@ -1,8 +1,24 @@
1
1
  require 'teststrap'
2
2
 
3
- context "AnimalCracker Server:" do
3
+ context "AnimalCracker Server without an asset path defined" do
4
4
  setup do
5
- mock_app { register AnimalCracker::Server }
5
+ mock_app do
6
+ register AnimalCracker::Server
7
+ AnimalCracker::AssetHost["/some/asset.ext"] = "Foo"
8
+ end
9
+ get "/some/asset.ext"
10
+ end
11
+
12
+ asserts_response_status 404
13
+ end # AnimalCracker Server without an asset path defined
14
+
15
+ context "Default AnimalCracker Server:" do
16
+ setup do
17
+ AnimalCracker::AssetHost.asset_host.clear
18
+ mock_app do
19
+ register AnimalCracker::Server
20
+ get_assets
21
+ end
6
22
  end
7
23
 
8
24
  context "unable to find basic asset" do
@@ -31,4 +47,26 @@ context "AnimalCracker Server:" do
31
47
  asserts_response_body "function a() {}function b() {}"
32
48
  end # get a grouping of assets
33
49
 
34
- end # AnimalCracker Server
50
+ end # Default AnimalCracker Server
51
+
52
+ context "AnimalCracker Server with custom path" do
53
+ setup do
54
+ mock_app do
55
+ register AnimalCracker::Server
56
+ get_assets "/assets"
57
+ AnimalCracker::AssetHost["/some-asset.ext"] = "Foo"
58
+ end
59
+ end
60
+
61
+ context "unable to find basic asset" do
62
+ setup { get "/some-asset.ext" }
63
+ asserts_response_status 404
64
+ end # unable to find basic asset
65
+
66
+ context "asset found with right base path" do
67
+ setup { get "/assets/some-asset.ext" }
68
+ asserts_response_status 200
69
+ asserts_response_body "Foo"
70
+ end # asset found with right base path
71
+
72
+ end # AnimalCracker Server with custom path
@@ -15,6 +15,12 @@ context "Memory Asset Host" do
15
15
  topic.store("/bar/man", "bouncer")
16
16
  topic.find("/bar/man")
17
17
  end.equals("bouncer")
18
+
19
+ asserts("clearing the host's memory first") do
20
+ topic.store("/bar/man", "bouncer")
21
+ topic.clear
22
+ topic.find("/bar/man")
23
+ end.raises(AnimalCracker::NotFound, "Could not find /bar/man")
18
24
  end # Memory Asset Host
19
25
 
20
26
  context "Memory Asset Host accessed as AnimalCracker::AssetHost" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: animalcracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin 'Gus' Knowlden
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-21 00:00:00 -06:00
12
+ date: 2010-01-29 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency