junior 0.1.0 → 0.1.1
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 +3 -0
 - data/Rakefile +1 -1
 - data/VERSION +1 -1
 - data/junior.gemspec +6 -5
 - data/lib/junior/dispatcher.rb +16 -12
 - data/lib/junior/helpers.rb +28 -1
 - metadata +4 -3
 
    
        data/HISTORY
    ADDED
    
    
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -12,7 +12,7 @@ begin 
     | 
|
| 
       12 
12 
     | 
    
         
             
                gem.authors = ["Michael Wood"]
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                gem.add_dependency 'rack',       "~> 1.1.0"
         
     | 
| 
       15 
     | 
    
         
            -
                gem.add_dependency 'usher',      "~> 0.6. 
     | 
| 
      
 15 
     | 
    
         
            +
                gem.add_dependency 'usher',      "~> 0.6.3"
         
     | 
| 
       16 
16 
     | 
    
         
             
                gem.add_dependency 'tilt',       "~> 0.4.0"
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
                gem.add_development_dependency 'rspec', '~> 1.2.9'
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.1. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.1.1
         
     | 
    
        data/junior.gemspec
    CHANGED
    
    | 
         @@ -5,11 +5,11 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.name = %q{junior}
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = "0.1. 
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.1.1"
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.authors = ["Michael Wood"]
         
     | 
| 
       12 
     | 
    
         
            -
              s.date = %q{2010-01- 
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = %q{2010-01-09}
         
     | 
| 
       13 
13 
     | 
    
         
             
              s.description = %q{A Mini MVC Web Framework for Ruby built on Rack and a lot of inspiration from Sinatra}
         
     | 
| 
       14 
14 
     | 
    
         
             
              s.email = %q{mike@michaelwood.com}
         
     | 
| 
       15 
15 
     | 
    
         
             
              s.extra_rdoc_files = [
         
     | 
| 
         @@ -18,6 +18,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       18 
18 
     | 
    
         
             
              ]
         
     | 
| 
       19 
19 
     | 
    
         
             
              s.files = [
         
     | 
| 
       20 
20 
     | 
    
         
             
                ".gitignore",
         
     | 
| 
      
 21 
     | 
    
         
            +
                 "HISTORY",
         
     | 
| 
       21 
22 
     | 
    
         
             
                 "LICENSE",
         
     | 
| 
       22 
23 
     | 
    
         
             
                 "README.md",
         
     | 
| 
       23 
24 
     | 
    
         
             
                 "Rakefile",
         
     | 
| 
         @@ -52,20 +53,20 @@ Gem::Specification.new do |s| 
     | 
|
| 
       52 
53 
     | 
    
         | 
| 
       53 
54 
     | 
    
         
             
                if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
         
     | 
| 
       54 
55 
     | 
    
         
             
                  s.add_runtime_dependency(%q<rack>, ["~> 1.1.0"])
         
     | 
| 
       55 
     | 
    
         
            -
                  s.add_runtime_dependency(%q<usher>, ["~> 0.6. 
     | 
| 
      
 56 
     | 
    
         
            +
                  s.add_runtime_dependency(%q<usher>, ["~> 0.6.3"])
         
     | 
| 
       56 
57 
     | 
    
         
             
                  s.add_runtime_dependency(%q<tilt>, ["~> 0.4.0"])
         
     | 
| 
       57 
58 
     | 
    
         
             
                  s.add_development_dependency(%q<rspec>, ["~> 1.2.9"])
         
     | 
| 
       58 
59 
     | 
    
         
             
                  s.add_development_dependency(%q<yard>, ["~> 0.5.2"])
         
     | 
| 
       59 
60 
     | 
    
         
             
                else
         
     | 
| 
       60 
61 
     | 
    
         
             
                  s.add_dependency(%q<rack>, ["~> 1.1.0"])
         
     | 
| 
       61 
     | 
    
         
            -
                  s.add_dependency(%q<usher>, ["~> 0.6. 
     | 
| 
      
 62 
     | 
    
         
            +
                  s.add_dependency(%q<usher>, ["~> 0.6.3"])
         
     | 
| 
       62 
63 
     | 
    
         
             
                  s.add_dependency(%q<tilt>, ["~> 0.4.0"])
         
     | 
| 
       63 
64 
     | 
    
         
             
                  s.add_dependency(%q<rspec>, ["~> 1.2.9"])
         
     | 
| 
       64 
65 
     | 
    
         
             
                  s.add_dependency(%q<yard>, ["~> 0.5.2"])
         
     | 
| 
       65 
66 
     | 
    
         
             
                end
         
     | 
| 
       66 
67 
     | 
    
         
             
              else
         
     | 
| 
       67 
68 
     | 
    
         
             
                s.add_dependency(%q<rack>, ["~> 1.1.0"])
         
     | 
| 
       68 
     | 
    
         
            -
                s.add_dependency(%q<usher>, ["~> 0.6. 
     | 
| 
      
 69 
     | 
    
         
            +
                s.add_dependency(%q<usher>, ["~> 0.6.3"])
         
     | 
| 
       69 
70 
     | 
    
         
             
                s.add_dependency(%q<tilt>, ["~> 0.4.0"])
         
     | 
| 
       70 
71 
     | 
    
         
             
                s.add_dependency(%q<rspec>, ["~> 1.2.9"])
         
     | 
| 
       71 
72 
     | 
    
         
             
                s.add_dependency(%q<yard>, ["~> 0.5.2"])
         
     | 
    
        data/lib/junior/dispatcher.rb
    CHANGED
    
    | 
         @@ -14,22 +14,26 @@ module Junior 
     | 
|
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                      #puts app.env['rack.input'].read
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
                      controller = app.env[ 'usher.response' ].last.destination[ :controller ].to_s
         
     | 
| 
       18 
     | 
    
         
            -
                      
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
                      controller = app.env[ 'usher.response' ] ? app.env[ 'usher.response' ].last.destination[ :controller ].to_s : nil
         
     | 
| 
      
 18 
     | 
    
         
            +
                      if controller
         
     | 
| 
      
 19 
     | 
    
         
            +
                        
         
     | 
| 
      
 20 
     | 
    
         
            +
                        if controller[ '/' ] # a nested route
         
     | 
| 
      
 21 
     | 
    
         
            +
                          controller = controller[(controller.rindex( '/' ) + 1)..controller.length]
         
     | 
| 
      
 22 
     | 
    
         
            +
                          puts controller
         
     | 
| 
      
 23 
     | 
    
         
            +
                        end
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
                        action     = app.env[ 'usher.response' ].last.destination[ :action ].to_s
         
     | 
| 
      
 26 
     | 
    
         
            +
                        id         = app.env[ 'usher.params' ][ :id ].to_s
         
     | 
| 
       26 
27 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 28 
     | 
    
         
            +
                        controller_instance = controller.camelize.to_class.new(app, id)
         
     | 
| 
       28 
29 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 30 
     | 
    
         
            +
                        if controller_instance.respond_to?(action)
         
     | 
| 
      
 31 
     | 
    
         
            +
                          controller_instance.send(action)
         
     | 
| 
      
 32 
     | 
    
         
            +
                        else
         
     | 
| 
      
 33 
     | 
    
         
            +
                          controller_instance.not_found('Not found')
         
     | 
| 
      
 34 
     | 
    
         
            +
                        end
         
     | 
| 
       31 
35 
     | 
    
         
             
                      else
         
     | 
| 
       32 
     | 
    
         
            -
                         
     | 
| 
      
 36 
     | 
    
         
            +
                        Junior::Controller.new(app).not_found('Not found')
         
     | 
| 
       33 
37 
     | 
    
         
             
                      end
         
     | 
| 
       34 
38 
     | 
    
         
             
                    end
         
     | 
| 
       35 
39 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/junior/helpers.rb
    CHANGED
    
    | 
         @@ -65,7 +65,7 @@ module Junior 
     | 
|
| 
       65 
65 
     | 
    
         
             
                # Set the Content-Type of the response body given a media type or file
         
     | 
| 
       66 
66 
     | 
    
         
             
                # extension.
         
     | 
| 
       67 
67 
     | 
    
         
             
                def content_type(type, params={})
         
     | 
| 
       68 
     | 
    
         
            -
                  mime_type = self.mime_type(type)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  mime_type = self.mime_type( ".#{type}" )
         
     | 
| 
       69 
69 
     | 
    
         
             
                  fail "Unknown media type: %p" % type if mime_type.nil?
         
     | 
| 
       70 
70 
     | 
    
         
             
                  if params.any?
         
     | 
| 
       71 
71 
     | 
    
         
             
                    params = params.collect { |kv| "%s=%s" % kv }.join(', ')
         
     | 
| 
         @@ -84,6 +84,21 @@ module Junior 
     | 
|
| 
       84 
84 
     | 
    
         
             
                    response['Content-Disposition'] << params
         
     | 
| 
       85 
85 
     | 
    
         
             
                  end
         
     | 
| 
       86 
86 
     | 
    
         
             
                end
         
     | 
| 
      
 87 
     | 
    
         
            +
                
         
     | 
| 
      
 88 
     | 
    
         
            +
                # Set the last modified time of the resource (HTTP 'Last-Modified' header)
         
     | 
| 
      
 89 
     | 
    
         
            +
                # and halt if conditional GET matches. The +time+ argument is a Time,
         
     | 
| 
      
 90 
     | 
    
         
            +
                # DateTime, or other object that responds to +to_time+.
         
     | 
| 
      
 91 
     | 
    
         
            +
                #
         
     | 
| 
      
 92 
     | 
    
         
            +
                # When the current request includes an 'If-Modified-Since' header that
         
     | 
| 
      
 93 
     | 
    
         
            +
                # matches the time specified, execution is immediately halted with a
         
     | 
| 
      
 94 
     | 
    
         
            +
                # '304 Not Modified' response.
         
     | 
| 
      
 95 
     | 
    
         
            +
                def last_modified(time)
         
     | 
| 
      
 96 
     | 
    
         
            +
                  time = time.to_time if time.respond_to?(:to_time)
         
     | 
| 
      
 97 
     | 
    
         
            +
                  time = time.httpdate if time.respond_to?(:httpdate)
         
     | 
| 
      
 98 
     | 
    
         
            +
                  response['Last-Modified'] = time
         
     | 
| 
      
 99 
     | 
    
         
            +
                  halt 304 if time == request.env['HTTP_IF_MODIFIED_SINCE']
         
     | 
| 
      
 100 
     | 
    
         
            +
                  time
         
     | 
| 
      
 101 
     | 
    
         
            +
                end
         
     | 
| 
       87 
102 
     | 
    
         | 
| 
       88 
103 
     | 
    
         
             
                # Use the contents of the file at +path+ as the response body.
         
     | 
| 
       89 
104 
     | 
    
         
             
                def send_file(path, opts={})
         
     | 
| 
         @@ -108,4 +123,16 @@ module Junior 
     | 
|
| 
       108 
123 
     | 
    
         
             
                  not_found
         
     | 
| 
       109 
124 
     | 
    
         
             
                end
         
     | 
| 
       110 
125 
     | 
    
         
             
              end
         
     | 
| 
      
 126 
     | 
    
         
            +
            end
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
            # Rack response body used to deliver static files. The file contents are
         
     | 
| 
      
 129 
     | 
    
         
            +
            # generated iteratively in 8K chunks.
         
     | 
| 
      
 130 
     | 
    
         
            +
            class StaticFile < ::File #:nodoc:
         
     | 
| 
      
 131 
     | 
    
         
            +
              alias_method :to_path, :path
         
     | 
| 
      
 132 
     | 
    
         
            +
              def each
         
     | 
| 
      
 133 
     | 
    
         
            +
                rewind
         
     | 
| 
      
 134 
     | 
    
         
            +
                while buf = read(8192)
         
     | 
| 
      
 135 
     | 
    
         
            +
                  yield buf
         
     | 
| 
      
 136 
     | 
    
         
            +
                end
         
     | 
| 
      
 137 
     | 
    
         
            +
              end
         
     | 
| 
       111 
138 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: junior
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Michael Wood
         
     | 
| 
         @@ -9,7 +9,7 @@ autorequire: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date: 2010-01- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2010-01-09 00:00:00 -08:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -30,7 +30,7 @@ dependencies: 
     | 
|
| 
       30 
30 
     | 
    
         
             
                requirements: 
         
     | 
| 
       31 
31 
     | 
    
         
             
                - - ~>
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
       33 
     | 
    
         
            -
                    version: 0.6. 
     | 
| 
      
 33 
     | 
    
         
            +
                    version: 0.6.3
         
     | 
| 
       34 
34 
     | 
    
         
             
                version: 
         
     | 
| 
       35 
35 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       36 
36 
     | 
    
         
             
              name: tilt
         
     | 
| 
         @@ -73,6 +73,7 @@ extra_rdoc_files: 
     | 
|
| 
       73 
73 
     | 
    
         
             
            - README.md
         
     | 
| 
       74 
74 
     | 
    
         
             
            files: 
         
     | 
| 
       75 
75 
     | 
    
         
             
            - .gitignore
         
     | 
| 
      
 76 
     | 
    
         
            +
            - HISTORY
         
     | 
| 
       76 
77 
     | 
    
         
             
            - LICENSE
         
     | 
| 
       77 
78 
     | 
    
         
             
            - README.md
         
     | 
| 
       78 
79 
     | 
    
         
             
            - Rakefile
         
     |