quince 0.6.0 → 0.6.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/quince/component.rb +4 -3
- data/lib/quince/config.rb +39 -0
- data/lib/quince/sinatra.rb +0 -18
- data/lib/quince/struct/typed.rb +4 -0
- data/lib/quince/struct/untyped.rb +7 -0
- data/lib/quince/version.rb +1 -1
- data/lib/quince.rb +28 -1
- metadata +4 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 8fa04a55360919ddbb5c4cbda37d050d6cceb7f0d18b322db647de52391e2aae
         | 
| 4 | 
            +
              data.tar.gz: 42576df0afa49fdc03e1627825f6639b1c7ee78df6257e9a19e4bf1e7f70527d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c23ee9c623006fbaf2b27ead13c7fff34dd2527aba7ad618bd4a53d55105608805746ac56e3e7c6b853620801f14f956062005c6126e0c3f2b858112a02a575a
         | 
| 7 | 
            +
              data.tar.gz: 18d1cca64addec79bef58f47b62006b3ba40ee94d318f74d29e633320aafb2146a9b4c2ff200be56b51177253e889b6e18d7697880ea5c0cd416bc1b42bb736a
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/lib/quince/component.rb
    CHANGED
    
    | @@ -9,7 +9,7 @@ module Quince | |
| 9 9 | 
             
                  end
         | 
| 10 10 |  | 
| 11 11 | 
             
                  def Props(**kw)
         | 
| 12 | 
            -
                    self.const_set "Props",  | 
| 12 | 
            +
                    self.const_set "Props", Quince::Config.props_struct_type.new(
         | 
| 13 13 | 
             
                      Quince::Component::PARENT_SELECTOR_ATTR => String,
         | 
| 14 14 | 
             
                      Quince::Component::SELF_SELECTOR => String,
         | 
| 15 15 | 
             
                      **kw,
         | 
| @@ -17,7 +17,7 @@ module Quince | |
| 17 17 | 
             
                  end
         | 
| 18 18 |  | 
| 19 19 | 
             
                  def State(**kw)
         | 
| 20 | 
            -
                    st = kw.empty? ? nil :  | 
| 20 | 
            +
                    st = kw.empty? ? nil : Quince::Config.state_struct_type.new(**kw)
         | 
| 21 21 | 
             
                    self.const_set "State", st
         | 
| 22 22 | 
             
                  end
         | 
| 23 23 |  | 
| @@ -99,7 +99,8 @@ module Quince | |
| 99 99 | 
             
                  Thread.current[:request_binding].receiver
         | 
| 100 100 | 
             
                end
         | 
| 101 101 |  | 
| 102 | 
            -
                def_delegators :request_context, | 
| 102 | 
            +
                def_delegators :request_context,
         | 
| 103 | 
            +
                  :attachment, :request, :response, :redirect, :halt, :session, :cache_control, :send_file, :to, :status, :headers, :body
         | 
| 103 104 |  | 
| 104 105 | 
             
                private
         | 
| 105 106 |  | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            module Quince
         | 
| 2 | 
            +
              class Config
         | 
| 3 | 
            +
                class << self
         | 
| 4 | 
            +
                  attr_reader :props_struct_type, :state_struct_type
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  def base
         | 
| 7 | 
            +
                    props typed: ENV["RACK_ENV"] != "production"
         | 
| 8 | 
            +
                    state typed: ENV["RACK_ENV"] != "production"
         | 
| 9 | 
            +
                    sinatra_config do
         | 
| 10 | 
            +
                      configure :development do
         | 
| 11 | 
            +
                        if Object.const_defined? "Sinatra::Reloader"
         | 
| 12 | 
            +
                          register Sinatra::Reloader
         | 
| 13 | 
            +
                          dont_reload __FILE__
         | 
| 14 | 
            +
                          also_reload $0
         | 
| 15 | 
            +
                        end
         | 
| 16 | 
            +
                      end
         | 
| 17 | 
            +
                      enable :logging
         | 
| 18 | 
            +
                      use Rack::JSONBodyParser
         | 
| 19 | 
            +
                      use Rack::Deflater
         | 
| 20 | 
            +
                      set :public_folder, File.join(File.dirname(File.expand_path($0)), "public")
         | 
| 21 | 
            +
                    end
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  private
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  def props(typed:)
         | 
| 27 | 
            +
                    @props_struct_type = typed ? Quince::TypedStruct : Quince::Struct
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def state(typed:)
         | 
| 31 | 
            +
                    @state_struct_type = typed ? Quince::TypedStruct : Quince::Struct
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  def sinatra_config(&block)
         | 
| 35 | 
            +
                    Quince::SinatraApp.instance_exec &block
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
            end
         | 
    
        data/lib/quince/sinatra.rb
    CHANGED
    
    | @@ -1,24 +1,6 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            ENV["RACK_ENV"] ||= "development"
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            require "sinatra/base"
         | 
| 6 | 
            -
            require "sinatra/reloader" if ENV["RACK_ENV"] == "development"
         | 
| 7 | 
            -
            require "rack/contrib"
         | 
| 8 | 
            -
             | 
| 9 2 | 
             
            module Quince
         | 
| 10 3 | 
             
              class SinatraApp < Sinatra::Base
         | 
| 11 | 
            -
                configure :development do
         | 
| 12 | 
            -
                  if Object.const_defined? "Sinatra::Reloader"
         | 
| 13 | 
            -
                    register Sinatra::Reloader
         | 
| 14 | 
            -
                    dont_reload __FILE__
         | 
| 15 | 
            -
                    also_reload $0
         | 
| 16 | 
            -
                  end
         | 
| 17 | 
            -
                end
         | 
| 18 | 
            -
                use Rack::JSONBodyParser
         | 
| 19 | 
            -
                use Rack::Deflater
         | 
| 20 | 
            -
                set :public_folder, File.join(File.dirname(File.expand_path($0)), "public")
         | 
| 21 | 
            -
             | 
| 22 4 | 
             
                class << self
         | 
| 23 5 | 
             
                  def create_route_handler(verb:, route:, &blck)
         | 
| 24 6 | 
             
                    meth = case verb
         | 
    
        data/lib/quince/version.rb
    CHANGED
    
    
    
        data/lib/quince.rb
    CHANGED
    
    | @@ -1,8 +1,35 @@ | |
| 1 | 
            +
            ENV["RACK_ENV"] ||= "development"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "sinatra/base"
         | 
| 4 | 
            +
            require "sinatra/reloader" if ENV["RACK_ENV"] == "development"
         | 
| 5 | 
            +
            require "rack/contrib"
         | 
| 6 | 
            +
             | 
| 1 7 | 
             
            require "securerandom"
         | 
| 2 8 | 
             
            require "typed_struct"
         | 
| 3 9 | 
             
            require "cgi"
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            require_relative "quince/config"
         | 
| 12 | 
            +
            require_relative "quince/struct/typed"
         | 
| 13 | 
            +
            require_relative "quince/struct/untyped"
         | 
| 14 | 
            +
            require_relative "quince/sinatra"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            module Quince
         | 
| 17 | 
            +
              def self.load_config!
         | 
| 18 | 
            +
                Quince::Config.base
         | 
| 19 | 
            +
                app_dir = File.dirname(File.expand_path($0))
         | 
| 20 | 
            +
                conf = Pathname(File.join(app_dir, "config.rb"))
         | 
| 21 | 
            +
                require conf.to_s if conf.exist?
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                rack_env = ENV["RACK_ENV"]
         | 
| 24 | 
            +
                if Quince::Config.respond_to? rack_env
         | 
| 25 | 
            +
                  Quince::Config.send rack_env
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
            end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            Quince.load_config!
         | 
| 31 | 
            +
             | 
| 4 32 | 
             
            require_relative "quince/singleton_methods"
         | 
| 5 33 | 
             
            require_relative "quince/component"
         | 
| 6 34 | 
             
            require_relative "quince/html_tag_components"
         | 
| 7 35 | 
             
            require_relative "quince/version"
         | 
| 8 | 
            -
            require_relative "quince/sinatra"
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: quince
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.6. | 
| 4 | 
            +
              version: 0.6.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Joseph Johansen
         | 
| @@ -102,10 +102,13 @@ files: | |
| 102 102 | 
             
            - lib/quince/callback.js.erb
         | 
| 103 103 | 
             
            - lib/quince/callback.rb
         | 
| 104 104 | 
             
            - lib/quince/component.rb
         | 
| 105 | 
            +
            - lib/quince/config.rb
         | 
| 105 106 | 
             
            - lib/quince/html_tag_components.rb
         | 
| 106 107 | 
             
            - lib/quince/serialiser.rb
         | 
| 107 108 | 
             
            - lib/quince/sinatra.rb
         | 
| 108 109 | 
             
            - lib/quince/singleton_methods.rb
         | 
| 110 | 
            +
            - lib/quince/struct/typed.rb
         | 
| 111 | 
            +
            - lib/quince/struct/untyped.rb
         | 
| 109 112 | 
             
            - lib/quince/types.rb
         | 
| 110 113 | 
             
            - lib/quince/version.rb
         | 
| 111 114 | 
             
            - quince.gemspec
         |