Class: Gitgo::Helper::Form
- Inherits:
-
Object
- Object
- Gitgo::Helper::Form
- Includes:
- Rack::Utils
- Defined in:
- lib/gitgo/helper/form.rb
Constant Summary collapse
- DEFAULT_STATES =
%w{open closed}
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
-
#at(sha) ⇒ Object
documents.
- #author_value(author) ⇒ Object
- #content_value(content) ⇒ Object
-
#each_ref(refs, selected_name) ⇒ Object
:yields: value, select_or_check, content.
-
#each_ref_name(refs, selected_name) ⇒ Object
:yields: value, select_or_check, content.
-
#each_tag(tags, *selected) ⇒ Object
:yields: value, select_or_check, content.
-
#initialize(controller) ⇒ Form
constructor
A new instance of Form.
- #tags_value(tags) ⇒ Object
- #title_value(title) ⇒ Object
- #url(*paths) ⇒ Object
- #value(str) ⇒ Object
Constructor Details
#initialize(controller) ⇒ Form
Returns a new instance of Form.
12 13 14 |
# File 'lib/gitgo/helper/form.rb', line 12 def initialize(controller) @controller = controller end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
10 11 12 |
# File 'lib/gitgo/helper/form.rb', line 10 def controller @controller end |
Instance Method Details
#at(sha) ⇒ Object
documents
32 33 34 35 36 37 38 39 40 |
# File 'lib/gitgo/helper/form.rb', line 32 def at(sha) return '(unknown)' unless sha refs = refs.select {|ref| ref.commit.sha == sha } refs.collect! {|ref| escape_html ref.name } ref_names = refs.empty? ? nil : " (#{refs.join(', ')})" "#{sha_a(sha)}#{ref_names}" end |
#author_value(author) ⇒ Object
42 43 44 |
# File 'lib/gitgo/helper/form.rb', line 42 def () escape_html() end |
#content_value(content) ⇒ Object
54 55 56 |
# File 'lib/gitgo/helper/form.rb', line 54 def content_value(content) content end |
#each_ref(refs, selected_name) ⇒ Object
:yields: value, select_or_check, content
64 65 66 67 68 |
# File 'lib/gitgo/helper/form.rb', line 64 def each_ref(refs, selected_name) # :yields: value, select_or_check, content refs.each do |ref| yield escape_html(ref.commit), selected_name == ref.name, escape_html(ref.name) end end |
#each_ref_name(refs, selected_name) ⇒ Object
:yields: value, select_or_check, content
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/gitgo/helper/form.rb', line 70 def each_ref_name(refs, selected_name) # :yields: value, select_or_check, content found_selected_name = false refs.each do |ref| select_or_check = selected_name == ref.name found_selected_name = true if select_or_check yield escape_html(ref.name), select_or_check, escape_html(ref.name) end if found_selected_name yield("", false, "(none)") else yield(selected_name, true, selected_name.to_s.empty? ? "(none)" : selected_name) end end |
#each_tag(tags, *selected) ⇒ Object
:yields: value, select_or_check, content
58 59 60 61 62 |
# File 'lib/gitgo/helper/form.rb', line 58 def each_tag(, *selected) # :yields: value, select_or_check, content .sort.each do |tag| yield escape_html(tag), selected.include?(tag), escape_html(tag) end end |
#tags_value(tags) ⇒ Object
50 51 52 |
# File 'lib/gitgo/helper/form.rb', line 50 def () ? .join(', ') : '' end |
#title_value(title) ⇒ Object
46 47 48 |
# File 'lib/gitgo/helper/form.rb', line 46 def title_value(title) escape_html(title) end |
#url(*paths) ⇒ Object
16 17 18 |
# File 'lib/gitgo/helper/form.rb', line 16 def url(*paths) controller.url(paths) end |
#value(str) ⇒ Object
24 25 26 |
# File 'lib/gitgo/helper/form.rb', line 24 def value(str) str end |