jellyfish 0.5.1 → 0.5.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/CHANGES.md +14 -0
- data/README.md +2 -1
- data/jellyfish.gemspec +2 -2
- data/lib/jellyfish.rb +8 -10
- data/lib/jellyfish/sinatra.rb +18 -4
- data/lib/jellyfish/version.rb +1 -1
- metadata +2 -2
    
        data/CHANGES.md
    CHANGED
    
    | @@ -1,5 +1,19 @@ | |
| 1 1 | 
             
            # CHANGES
         | 
| 2 2 |  | 
| 3 | 
            +
            ## Jellyfish 0.5.2 -- 2012-10-20
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ### Incompatible changes
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            * `protect` method is removed and inlined, reducing the size of call stack.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ### Enhancements for Jellyfish core
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            * `log_error` is now a public method.
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            ### Enhancements for Sinatra flavored controller
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            * Force params encoding to Encoding.default_external
         | 
| 16 | 
            +
             | 
| 3 17 | 
             
            ## Jellyfish 0.5.1 -- 2012-10-19
         | 
| 4 18 |  | 
| 5 19 | 
             
            * Removed accidentally added sinatra files.
         | 
    
        data/README.md
    CHANGED
    
    | @@ -190,11 +190,12 @@ use Rack::ContentType, 'text/plain' | |
| 190 190 | 
             
            run Heater.new
         | 
| 191 191 | 
             
            ```
         | 
| 192 192 |  | 
| 193 | 
            -
            ### Sinatra  | 
| 193 | 
            +
            ### Sinatra flavored controller
         | 
| 194 194 |  | 
| 195 195 | 
             
            Currently support:
         | 
| 196 196 |  | 
| 197 197 | 
             
            * Indifferent params
         | 
| 198 | 
            +
            * Force params encoding to Encoding.default_external
         | 
| 198 199 |  | 
| 199 200 | 
             
            ``` ruby
         | 
| 200 201 | 
             
            require 'jellyfish'
         | 
    
        data/jellyfish.gemspec
    CHANGED
    
    | @@ -2,11 +2,11 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            Gem::Specification.new do |s|
         | 
| 4 4 | 
             
              s.name = "jellyfish"
         | 
| 5 | 
            -
              s.version = "0.5. | 
| 5 | 
            +
              s.version = "0.5.2"
         | 
| 6 6 |  | 
| 7 7 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 8 8 | 
             
              s.authors = ["Lin Jen-Shin (godfat)"]
         | 
| 9 | 
            -
              s.date = "2012-10- | 
| 9 | 
            +
              s.date = "2012-10-20"
         | 
| 10 10 | 
             
              s.description = "Pico web framework for building API-centric web applications.\nFor Rack applications or Rack middlewares. Under 200 lines of code."
         | 
| 11 11 | 
             
              s.email = ["godfat (XD) godfat.org"]
         | 
| 12 12 | 
             
              s.files = [
         | 
    
        data/lib/jellyfish.rb
    CHANGED
    
    | @@ -135,7 +135,11 @@ module Jellyfish | |
| 135 135 | 
             
                ctrl.call(env)
         | 
| 136 136 | 
             
              rescue NotFound => e # forward
         | 
| 137 137 | 
             
                if app
         | 
| 138 | 
            -
                   | 
| 138 | 
            +
                  begin
         | 
| 139 | 
            +
                    app.call(env)
         | 
| 140 | 
            +
                  rescue Exception => e
         | 
| 141 | 
            +
                    handle(ctrl, e, env['rack.errors'])
         | 
| 142 | 
            +
                  end
         | 
| 139 143 | 
             
                else
         | 
| 140 144 | 
             
                  handle(ctrl, e)
         | 
| 141 145 | 
             
                end
         | 
| @@ -143,10 +147,9 @@ module Jellyfish | |
| 143 147 | 
             
                handle(ctrl, e, env['rack.errors'])
         | 
| 144 148 | 
             
              end
         | 
| 145 149 |  | 
| 146 | 
            -
              def  | 
| 147 | 
            -
                 | 
| 148 | 
            -
             | 
| 149 | 
            -
                handle(ctrl, e, env['rack.errors'])
         | 
| 150 | 
            +
              def log_error e, stderr
         | 
| 151 | 
            +
                return unless stderr
         | 
| 152 | 
            +
                stderr.puts("[#{self.class.name}] #{e.inspect} #{e.backtrace}")
         | 
| 150 153 | 
             
              end
         | 
| 151 154 |  | 
| 152 155 | 
             
              private
         | 
| @@ -166,11 +169,6 @@ module Jellyfish | |
| 166 169 | 
             
                end
         | 
| 167 170 | 
             
              end
         | 
| 168 171 |  | 
| 169 | 
            -
              def log_error e, stderr
         | 
| 170 | 
            -
                return unless stderr
         | 
| 171 | 
            -
                stderr.puts("[#{self.class.name}] #{e.inspect} #{e.backtrace}")
         | 
| 172 | 
            -
              end
         | 
| 173 | 
            -
             | 
| 174 172 | 
             
              # -----------------------------------------------------------------
         | 
| 175 173 |  | 
| 176 174 | 
             
              def self.included mod
         | 
    
        data/lib/jellyfish/sinatra.rb
    CHANGED
    
    | @@ -7,13 +7,13 @@ module Jellyfish | |
| 7 7 | 
             
                attr_reader :request, :params
         | 
| 8 8 | 
             
                def block_call argument, block
         | 
| 9 9 | 
             
                  @request = Rack::Request.new(env)
         | 
| 10 | 
            -
                  @params  = indifferent_params( | 
| 11 | 
            -
                   | 
| 10 | 
            +
                  @params  = force_encoding(indifferent_params(
         | 
| 11 | 
            +
                  if argument.kind_of?(MatchData)
         | 
| 12 | 
            +
                    # merge captured data from matcher into params as sinatra
         | 
| 12 13 | 
             
                    request.params.merge(Hash[argument.names.zip(argument.captures)])
         | 
| 13 14 | 
             
                  else
         | 
| 14 15 | 
             
                    request.params
         | 
| 15 | 
            -
                  end)
         | 
| 16 | 
            -
             | 
| 16 | 
            +
                  end))
         | 
| 17 17 | 
             
                  super
         | 
| 18 18 | 
             
                end
         | 
| 19 19 |  | 
| @@ -33,5 +33,19 @@ module Jellyfish | |
| 33 33 | 
             
                def indifferent_hash
         | 
| 34 34 | 
             
                  Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
         | 
| 35 35 | 
             
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                # stolen from sinatra
         | 
| 38 | 
            +
                # Fixes encoding issues by casting params to Encoding.default_external
         | 
| 39 | 
            +
                def force_encoding(data, encoding=Encoding.default_external)
         | 
| 40 | 
            +
                  return data if data.respond_to?(:rewind) # e.g. Tempfile, File, etc
         | 
| 41 | 
            +
                  if data.respond_to?(:force_encoding)
         | 
| 42 | 
            +
                    data.force_encoding(encoding).encode!
         | 
| 43 | 
            +
                  elsif data.respond_to?(:each_value)
         | 
| 44 | 
            +
                    data.each_value{ |v| force_encoding(v, encoding) }
         | 
| 45 | 
            +
                  elsif data.respond_to?(:each)
         | 
| 46 | 
            +
                    data.each{ |v| force_encoding(v, encoding) }
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
                  data
         | 
| 49 | 
            +
                end
         | 
| 36 50 | 
             
              end
         | 
| 37 51 | 
             
            end
         | 
    
        data/lib/jellyfish/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: jellyfish
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.5. | 
| 4 | 
            +
              version: 0.5.2
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2012-10- | 
| 12 | 
            +
            date: 2012-10-20 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: rack
         |