Sha256: f11e78f564b78b87de8ff87126e57d17a421cd86eee590e107aa85503b4c3470

Contents?: true

Size: 786 Bytes

Versions: 7

Compression:

Stored size: 786 Bytes

Contents

module SmallCage
  module BaseHelper
    include ERB::Util

    def _glob(path, rex)
      base_dir = nil
      if path.to_s[0] == ?/
        base_dir = @obj["dirs"][0]["path"]
        base_dir = base_dir.join(path[1..-1])
      else
        base_dir = @obj["dirs"].last["path"]
        base_dir = base_dir.join(path)
      end

      entries = Dir.glob("#{base_dir}/**/*")
      
      result = []
      entries.each do |path|
        result << path if path.to_s =~ rex
      end
      return result.sort
    end

    def _with(o)
      tmpobj = @obj
      @obj = o
      yield
      @obj = tmpobj
    end
    
    def _load(path)
      path = Pathname.new(path)
      @loader.load(path)
    end
    
    def _erb(body)
      @renderer.render_string(body, @obj)
    end
    
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
bluemark-smallcage-0.1.3 project/base/_smc/helpers/base_helper.rb
bluemark-smallcage-0.1.4 project/base/_smc/helpers/base_helper.rb
smallcage-0.1.4 project/base/_smc/helpers/base_helper.rb
smallcage-0.1.0 project/base/_smc/helpers/base_helper.rb
smallcage-0.1.3 project/base/_smc/helpers/base_helper.rb
smallcage-0.1.1 project/base/_smc/helpers/base_helper.rb
smallcage-0.1.2 project/base/_smc/helpers/base_helper.rb