Sha256: e4032805e50c3d5df12e871b4bda7bb656a7e04a58b61baf034b00c2550f0581

Contents?: true

Size: 1.31 KB

Versions: 10

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8
module Mutx
  module Helpers

    def query_string
      @query_string ||= Mutx::Support::QueryString.new(req)
    end

    def post_data
      @post_data ||= req.params.dup
    end

    def headers
      @headers ||= Hash[req.env.select { |k,v| k.start_with?('HTTP_') }.map { |k,v| [k.gsub('HTTP_',''), v] }]
    end

    def h_to_query_string(a_hash)
      CGI.unescape(a_hash.to_query)
    end

    def view(section, args={})
      args[:section] = section
      content_path = File.read("#{Mutx::View.path}/#{Mutx::View::Sections.path_for(section)}.mote")
      args[:content] = Mote.parse(content_path, self, args.keys).call(args)
      body_path = File.read("#{Mutx::View.path}/body.mote")
      template = Mote.parse(body_path, self, args.keys)
      template.call(args)
    end

    def partial(file, args={})
      message_file_path = File.read("#{Mutx::View.path}/#{file}.mote")
      Mote.parse(message_file_path, self, args.keys).call(args)
    end

    def project_name
      @project_name ||= Mutx::Support::Configuration.project_name
    end

    def branch
      @branch ||= Mutx::Support::Git.branch
    end

    def log_last_commit
      @log_last_commit ||= Mutx::Support::Git.log_last_commit
    end

    def last_commit_id
      @last_commit_id ||= Mutx::Support::Git.get_last_commit_id
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mutx-0.2.9 lib/mutx/lib/helpers.rb
mutx-0.2.8 lib/mutx/lib/helpers.rb
mutx-0.2.7 lib/mutx/lib/helpers.rb
mutx-0.2.6 lib/mutx/lib/helpers.rb
mutx-0.2.5 lib/mutx/lib/helpers.rb
mutx-0.2.4 lib/mutx/lib/helpers.rb
mutx-0.2.3 lib/mutx/lib/helpers.rb
mutx-0.2.2 lib/mutx/lib/helpers.rb
mutx-0.2.1 lib/mutx/lib/helpers.rb
mutx-0.2.0 lib/mutx/lib/helpers.rb