middleman-decorators 1.0.0
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 +7 -0
 - data/.gitignore +3 -0
 - data/.rspec +1 -0
 - data/.rubocop.yml +56 -0
 - data/.ruby-gemset +1 -0
 - data/.ruby-version +1 -0
 - data/.travis.yml +9 -0
 - data/Gemfile +18 -0
 - data/LICENSE +8 -0
 - data/README.md +56 -0
 - data/Rakefile +5 -0
 - data/lib/middleman/decorators/base.rb +17 -0
 - data/lib/middleman/decorators/extension.rb +25 -0
 - data/lib/middleman/decorators/version.rb +5 -0
 - data/lib/middleman/decorators.rb +4 -0
 - data/lib/middleman-decorators.rb +1 -0
 - data/middleman-decorators.gemspec +20 -0
 - data/spec/features/rendering_spec.rb +14 -0
 - data/spec/fixtures/base/config.rb +1 -0
 - data/spec/fixtures/base/decorators/data_decorator.rb +5 -0
 - data/spec/fixtures/base/source/index.html.erb +9 -0
 - data/spec/lib/middleman/decorators/extension_spec.rb +13 -0
 - data/spec/lib/middleman/decorators/version_spec.rb +7 -0
 - data/spec/spec_helper.rb +27 -0
 - data/spec/support/fixture.rb +43 -0
 - metadata +82 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 6e7282cea37d32aa9a1b058338494eff35348777
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7d18b45886a53bcfef004c261a2af01477e35c6c
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8e061c318e38de21178e5694a7d4a1d683cd147cc82d1b8d8ff2c55373963dfd82adb9d059380f89a710e1968995447949c9afbebfb4492712bf7922cf0c18af
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 989156aa64d663496d770ee60d3efad193663b9c406302e148757e9d97e9d5f529cc66827acfe9fe097088a8fb54ead97d8d1856a932a1e58f2ff527305292b0
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --color --format 'documentation'
         
     | 
    
        data/.rubocop.yml
    ADDED
    
    | 
         @@ -0,0 +1,56 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            AllCops:
         
     | 
| 
      
 2 
     | 
    
         
            +
              TargetRubyVersion: 2.0
         
     | 
| 
      
 3 
     | 
    
         
            +
              DisplayCopNames: true
         
     | 
| 
      
 4 
     | 
    
         
            +
              DefaultFormatter: simple
         
     | 
| 
      
 5 
     | 
    
         
            +
              Include:
         
     | 
| 
      
 6 
     | 
    
         
            +
                - Rakefile
         
     | 
| 
      
 7 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 8 
     | 
    
         
            +
                - spec/spec_helper.rb
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            # Style
         
     | 
| 
      
 11 
     | 
    
         
            +
            Style/FileName:
         
     | 
| 
      
 12 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Style/StringLiterals:
         
     | 
| 
      
 15 
     | 
    
         
            +
              EnforcedStyle: double_quotes
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            Style/IndentationConsistency:
         
     | 
| 
      
 18 
     | 
    
         
            +
              EnforcedStyle: rails
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            Style/MultilineOperationIndentation:
         
     | 
| 
      
 21 
     | 
    
         
            +
              EnforcedStyle: aligned
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            Style/MultilineMethodCallIndentation:
         
     | 
| 
      
 24 
     | 
    
         
            +
              EnforcedStyle: aligned
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            Style/RegexpLiteral:
         
     | 
| 
      
 27 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            Style/Documentation:
         
     | 
| 
      
 30 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            Style/PercentLiteralDelimiters:
         
     | 
| 
      
 33 
     | 
    
         
            +
              PreferredDelimiters:
         
     | 
| 
      
 34 
     | 
    
         
            +
                '%w': '[]'
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            # can't enforce style to require
         
     | 
| 
      
 37 
     | 
    
         
            +
            # the trailing underscore -- so disabling for now
         
     | 
| 
      
 38 
     | 
    
         
            +
            Style/TrailingUnderscoreVariable:
         
     | 
| 
      
 39 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            Style/NumericPredicate:
         
     | 
| 
      
 42 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            # Metrics
         
     | 
| 
      
 45 
     | 
    
         
            +
            Metrics/LineLength:
         
     | 
| 
      
 46 
     | 
    
         
            +
              Max: 90
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            Metrics/MethodLength:
         
     | 
| 
      
 49 
     | 
    
         
            +
              Max: 15
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            Metrics/AbcSize:
         
     | 
| 
      
 52 
     | 
    
         
            +
              Max: 20
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            # Performance
         
     | 
| 
      
 55 
     | 
    
         
            +
            Performance/RedundantBlockCall:
         
     | 
| 
      
 56 
     | 
    
         
            +
              Enabled: false
         
     | 
    
        data/.ruby-gemset
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            middleman-decorators
         
     | 
    
        data/.ruby-version
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            2.3.1
         
     | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    | 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            source "https://rubygems.org"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            gemspec
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            gem "middleman"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            if RUBY_VERSION >= "2.0.0"
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem "pry-byebug"
         
     | 
| 
      
 9 
     | 
    
         
            +
            else
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem "pry-debugger"
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            gem "rake",     "~> 10"
         
     | 
| 
      
 14 
     | 
    
         
            +
            gem "aruba",    "~> 0.7.4", require: false
         
     | 
| 
      
 15 
     | 
    
         
            +
            gem "rspec",    "~> 3.4",   require: false
         
     | 
| 
      
 16 
     | 
    
         
            +
            gem "cucumber", "~> 2.0",   require: false
         
     | 
| 
      
 17 
     | 
    
         
            +
            gem "capybara", "~> 2.5"
         
     | 
| 
      
 18 
     | 
    
         
            +
            gem "rubocop",  "~> 0.42"
         
     | 
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,8 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            The MIT License (MIT)
         
     | 
| 
      
 2 
     | 
    
         
            +
            Copyright (c) 2016 Jordan Andree
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,56 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Middleman Decorators
         
     | 
| 
      
 2 
     | 
    
         
            +
            [](https://travis-ci.org/jordanandree/middleman-decorators)
         
     | 
| 
      
 3 
     | 
    
         
            +
            [](https://gemnasium.com/github.com/jordanandree/ebookie)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Use Decorators (AKA Presenters) in Middleman.
         
     | 
| 
      
 6 
     | 
    
         
            +
            **This project is not yet stable so use with caution.**
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 13 
     | 
    
         
            +
            gem 'middleman-decorators', '~> 1.0'
         
     | 
| 
      
 14 
     | 
    
         
            +
            ```
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            ```
         
     | 
| 
      
 19 
     | 
    
         
            +
            $ bundle install
         
     | 
| 
      
 20 
     | 
    
         
            +
            ```
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            Activate the extension in `config.rb`:
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 27 
     | 
    
         
            +
            activate :decorators
         
     | 
| 
      
 28 
     | 
    
         
            +
            ```
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            By default, decorators are added to `$app_root/decorators`
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            Example decorator:
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 35 
     | 
    
         
            +
            class WidgetDecorator < Middleman::Decorators::Base
         
     | 
| 
      
 36 
     | 
    
         
            +
              def complex_method
         
     | 
| 
      
 37 
     | 
    
         
            +
                [..]
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
            end
         
     | 
| 
      
 40 
     | 
    
         
            +
            ```
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            To use the decorator in a view:
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 45 
     | 
    
         
            +
            <% decorate(data.widgets, WidgetDecorator).complex_method %>
         
     | 
| 
      
 46 
     | 
    
         
            +
            ```
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            If there is any thing you'd like to contribute or fix, please:
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            - Fork the repo
         
     | 
| 
      
 53 
     | 
    
         
            +
            - Make your changes
         
     | 
| 
      
 54 
     | 
    
         
            +
            - Add specs for any new functionality
         
     | 
| 
      
 55 
     | 
    
         
            +
            - Verify all existing tests work properly
         
     | 
| 
      
 56 
     | 
    
         
            +
            - Make a pull request
         
     | 
    
        data/Rakefile
    ADDED
    
    
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Middleman
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Decorators
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Base
         
     | 
| 
      
 4 
     | 
    
         
            +
                  attr_reader :context
         
     | 
| 
      
 5 
     | 
    
         
            +
                  alias h context
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                  def initialize(attributes, context)
         
     | 
| 
      
 8 
     | 
    
         
            +
                    @attributes = attributes
         
     | 
| 
      
 9 
     | 
    
         
            +
                    @context    = context
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                    @attributes.each do |key, val|
         
     | 
| 
      
 12 
     | 
    
         
            +
                      define_singleton_method(key) { val }
         
     | 
| 
      
 13 
     | 
    
         
            +
                    end
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Middleman
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Decorators
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Extension < ::Middleman::Extension
         
     | 
| 
      
 4 
     | 
    
         
            +
                  option :decorators_path, "decorators", "Path to decorators relative to root"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                  def initialize(*args)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    super
         
     | 
| 
      
 8 
     | 
    
         
            +
                    decorators_path = app.root_path.join(options.decorators_path, "*.rb")
         
     | 
| 
      
 9 
     | 
    
         
            +
                    Dir[decorators_path].each do |f|
         
     | 
| 
      
 10 
     | 
    
         
            +
                      require f
         
     | 
| 
      
 11 
     | 
    
         
            +
                    end
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  module Helpers
         
     | 
| 
      
 15 
     | 
    
         
            +
                    def decorate(object, class_name)
         
     | 
| 
      
 16 
     | 
    
         
            +
                      class_name.send(:new, object, self)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  helpers Helpers
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                ::Middleman::Extensions.register(:decorators, Middleman::Decorators::Extension)
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "middleman/decorators"
         
     | 
| 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            $LOAD_PATH.push File.expand_path("../lib", __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "middleman/decorators/version"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.name        = "middleman-decorators"
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.version     = Middleman::Decorators::VERSION
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.platform    = Gem::Platform::RUBY
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.authors     = ["Jordan Andree"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.email       = ["jordanandree@gmail.com"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.homepage    = "https://github.com/jordanandree/middleman-decorators"
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.summary     = "Use Decorators (Presenters) in Middleman"
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.description = "Use Decorators (Presenters) in Middleman"
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.license     = "MIT"
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.files       = `git ls-files -z`.split("\0")
         
     | 
| 
      
 16 
     | 
    
         
            +
              s.test_files  = `git ls-files -z -- {fixtures,features}/*`.split("\0")
         
     | 
| 
      
 17 
     | 
    
         
            +
              s.require_paths = ["lib"]
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              s.add_dependency "middleman-core", ["~> 4.0"]
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "rendering", type: :feature do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before do
         
     | 
| 
      
 5 
     | 
    
         
            +
                Middleman::Fixture.init(:base)
         
     | 
| 
      
 6 
     | 
    
         
            +
                Middleman::Fixture.browser(Middleman::Fixture.app)
         
     | 
| 
      
 7 
     | 
    
         
            +
                visit "/"
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              it "renders formatted title" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                expect(page).to have_content "Bar"
         
     | 
| 
      
 12 
     | 
    
         
            +
                expect(page).to have_content "Foo"
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            activate :decorators
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Middleman::Decorators::Extension do
         
     | 
| 
      
 4 
     | 
    
         
            +
              let(:base_app) do
         
     | 
| 
      
 5 
     | 
    
         
            +
                Middleman::Fixture.init :base
         
     | 
| 
      
 6 
     | 
    
         
            +
                Middleman::Fixture.app
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              it "is should be registered" do
         
     | 
| 
      
 10 
     | 
    
         
            +
                expect(Middleman::Extensions.registered[:decorators])
         
     | 
| 
      
 11 
     | 
    
         
            +
                  .to eq Middleman::Decorators::Extension
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "bundler/setup"
         
     | 
| 
      
 3 
     | 
    
         
            +
            Bundler.setup
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require "rspec"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "capybara/rspec"
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "middleman-core"
         
     | 
| 
      
 8 
     | 
    
         
            +
            require "middleman-core/rack"
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            Dir["./spec/support/*.rb"].each { |f| require f }
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            if RUBY_VERSION >= "2.0.0"
         
     | 
| 
      
 13 
     | 
    
         
            +
              require "pry-byebug"
         
     | 
| 
      
 14 
     | 
    
         
            +
            else
         
     | 
| 
      
 15 
     | 
    
         
            +
              require "pry-debugger"
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            require "middleman/decorators"
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 21 
     | 
    
         
            +
              config.filter_run :focus
         
     | 
| 
      
 22 
     | 
    
         
            +
              config.run_all_when_everything_filtered = true
         
     | 
| 
      
 23 
     | 
    
         
            +
              config.profile_examples = 10
         
     | 
| 
      
 24 
     | 
    
         
            +
              config.expect_with :rspec do |expectations|
         
     | 
| 
      
 25 
     | 
    
         
            +
                expectations.syntax = :expect
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "fileutils"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Middleman
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Fixture
         
     | 
| 
      
 5 
     | 
    
         
            +
                ROOT = File.expand_path("../..", __dir__).freeze
         
     | 
| 
      
 6 
     | 
    
         
            +
                TMP  = File.join(ROOT, "tmp").freeze
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 9 
     | 
    
         
            +
                  def init(fixture)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    cleanup!
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                    `rsync -av ./spec/fixtures/#{fixture}/ #{TMP}/`
         
     | 
| 
      
 13 
     | 
    
         
            +
                    Dir.chdir TMP
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  def file(name, content)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    file_path = File.join TMP, name
         
     | 
| 
      
 18 
     | 
    
         
            +
                    FileUtils.mkdir_p File.dirname(file_path)
         
     | 
| 
      
 19 
     | 
    
         
            +
                    File.open(file_path, "w") do |file|
         
     | 
| 
      
 20 
     | 
    
         
            +
                      file.write content
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def cleanup!
         
     | 
| 
      
 25 
     | 
    
         
            +
                    Dir.chdir ROOT
         
     | 
| 
      
 26 
     | 
    
         
            +
                    FileUtils.rm_rf TMP
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  def app
         
     | 
| 
      
 30 
     | 
    
         
            +
                    ENV["MM_ROOT"] = TMP
         
     | 
| 
      
 31 
     | 
    
         
            +
                    ::Middleman::Application.new
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  def browser(middleman_app)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    Capybara.app = ::Middleman::Rack.new(middleman_app).to_app do
         
     | 
| 
      
 36 
     | 
    
         
            +
                      set :root, Middleman::Fixture::TMP
         
     | 
| 
      
 37 
     | 
    
         
            +
                      set :environment, :development
         
     | 
| 
      
 38 
     | 
    
         
            +
                      set :show_exceptions, false
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,82 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: middleman-decorators
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Jordan Andree
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-09-21 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: middleman-core
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '4.0'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '4.0'
         
     | 
| 
      
 27 
     | 
    
         
            +
            description: Use Decorators (Presenters) in Middleman
         
     | 
| 
      
 28 
     | 
    
         
            +
            email:
         
     | 
| 
      
 29 
     | 
    
         
            +
            - jordanandree@gmail.com
         
     | 
| 
      
 30 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 31 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 32 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 33 
     | 
    
         
            +
            files:
         
     | 
| 
      
 34 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 35 
     | 
    
         
            +
            - ".rspec"
         
     | 
| 
      
 36 
     | 
    
         
            +
            - ".rubocop.yml"
         
     | 
| 
      
 37 
     | 
    
         
            +
            - ".ruby-gemset"
         
     | 
| 
      
 38 
     | 
    
         
            +
            - ".ruby-version"
         
     | 
| 
      
 39 
     | 
    
         
            +
            - ".travis.yml"
         
     | 
| 
      
 40 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 41 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 42 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 43 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 44 
     | 
    
         
            +
            - lib/middleman-decorators.rb
         
     | 
| 
      
 45 
     | 
    
         
            +
            - lib/middleman/decorators.rb
         
     | 
| 
      
 46 
     | 
    
         
            +
            - lib/middleman/decorators/base.rb
         
     | 
| 
      
 47 
     | 
    
         
            +
            - lib/middleman/decorators/extension.rb
         
     | 
| 
      
 48 
     | 
    
         
            +
            - lib/middleman/decorators/version.rb
         
     | 
| 
      
 49 
     | 
    
         
            +
            - middleman-decorators.gemspec
         
     | 
| 
      
 50 
     | 
    
         
            +
            - spec/features/rendering_spec.rb
         
     | 
| 
      
 51 
     | 
    
         
            +
            - spec/fixtures/base/config.rb
         
     | 
| 
      
 52 
     | 
    
         
            +
            - spec/fixtures/base/decorators/data_decorator.rb
         
     | 
| 
      
 53 
     | 
    
         
            +
            - spec/fixtures/base/source/index.html.erb
         
     | 
| 
      
 54 
     | 
    
         
            +
            - spec/lib/middleman/decorators/extension_spec.rb
         
     | 
| 
      
 55 
     | 
    
         
            +
            - spec/lib/middleman/decorators/version_spec.rb
         
     | 
| 
      
 56 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 57 
     | 
    
         
            +
            - spec/support/fixture.rb
         
     | 
| 
      
 58 
     | 
    
         
            +
            homepage: https://github.com/jordanandree/middleman-decorators
         
     | 
| 
      
 59 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 60 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 61 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 62 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 63 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 64 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 65 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 66 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 67 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 68 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 69 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 70 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 71 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 73 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 74 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 75 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 76 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 77 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 78 
     | 
    
         
            +
            rubygems_version: 2.5.1
         
     | 
| 
      
 79 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 80 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 81 
     | 
    
         
            +
            summary: Use Decorators (Presenters) in Middleman
         
     | 
| 
      
 82 
     | 
    
         
            +
            test_files: []
         
     |