Module: Mutx::Helpers

Defined in:
lib/mutx/lib/helpers.rb

Instance Method Summary collapse

Instance Method Details

#branchObject



39
40
41
# File 'lib/mutx/lib/helpers.rb', line 39

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

#h_to_query_string(a_hash) ⇒ Object



17
18
19
# File 'lib/mutx/lib/helpers.rb', line 17

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

#headersObject



13
14
15
# File 'lib/mutx/lib/helpers.rb', line 13

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

#last_commit_idObject



47
48
49
# File 'lib/mutx/lib/helpers.rb', line 47

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

#log_last_commitObject



43
44
45
# File 'lib/mutx/lib/helpers.rb', line 43

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

#partial(file, args = {}) ⇒ Object



30
31
32
33
# File 'lib/mutx/lib/helpers.rb', line 30

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

#post_dataObject



9
10
11
# File 'lib/mutx/lib/helpers.rb', line 9

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

#project_nameObject



35
36
37
# File 'lib/mutx/lib/helpers.rb', line 35

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

#query_stringObject



5
6
7
# File 'lib/mutx/lib/helpers.rb', line 5

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

#view(section, args = {}) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/mutx/lib/helpers.rb', line 21

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