compendium 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDMzZWY3N2Y4MWU5MGUxODg2YzFjZWY2ZDgzNzE0ZTU0MmNkN2IyYw==
4
+ Y2ExNjQ1Y2U2ZjhiZTQ4ZDg4NjI1MmU5NmYxODFmNDYzMDI2MzI0Yw==
5
5
  data.tar.gz: !binary |-
6
- ZDBjNTEwN2NjNGNlZWIxMzhiMWQ5MGRmMzg0NmY4NGQyNTlhYTAwNA==
6
+ OTFhMGQ1Y2U0ZGE5YzM4YWQ0NDg3ODlmZDgwYjU3YmFiYjY0MmNjNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDQ1M2YwZDVjMWEyN2M2NjM4ZDYxOGY4ZTEwOTQ0M2Y0MWIzM2UxNDM2MGVm
10
- YzIwMDFkYzM1ZjliNDUxMjBjNzQxNDkyMTIzYzlhNWQyNjViYTMwYmRhYmUy
11
- ODBiODRhZjRkOGQ0MWVjNDdiNjE4MmE3MjM2OGNkNDZlZTE0NDk=
9
+ YzExMTE2ZjI3ZmZiZGM0OTgyMjQ5NWRmN2I4M2U3YTU1ZTI5OTlkZDhlZGJk
10
+ Y2Y5YTRmYWI2ZGRlM2JiYTY1MWIxNGNlZDMwZDNmMGRlNGZmZmU5MjNjNjU3
11
+ OGJkYTQ3MWRmMzQxZWEyNGY2NTcwMTZjNDhlYzgwNzJmN2UwMzc=
12
12
  data.tar.gz: !binary |-
13
- NjIzZGIwNWY1NTU3MzViOTU5Njc3MzFiNTdiYzdhZWViYjIwOGVlYzZmMDhm
14
- NWI5NzkwNDJjYTUzYjIwNDg4ZjZkZDJhYzE5MDE0ZGQyM2U0Y2JlMGIzNThk
15
- ODY0NDFkY2NhMDg1MWZkYmU3MjlmNjdhMzIxZWUzYWFjNjIyMzU=
13
+ NGNmMWQ3YzllM2E2MDBjZTY3MWI3YTEzZTY3NGRkNDA5MzdjNzk5Y2U5MjRm
14
+ MWM2OWZiZGJjZjljNjc1NWIzYTcxODBmMDk2NWRkNTc1NmM5NmJmZmVhMzEx
15
+ YzQyNDE0Nzk2MWNjM2U0MzY4NjdjZjdlOTgyYWE3NmU2Y2VmNDI=
@@ -48,15 +48,15 @@ module Compendium::Presenters
48
48
  out << date_field(form)
49
49
 
50
50
  when :dropdown
51
- raise ArgumentError, MISSING_CHOICES_ERROR unless option.choices?
51
+ raise ArgumentError, MISSING_CHOICES_ERROR unless option.choices
52
52
 
53
- options = option.choices
54
- options = ctx.instance_exec(&options) if options.respond_to?(:call)
55
- out << dropdown(form, options)
53
+ choices = option.choices
54
+ choices = ctx.instance_exec(&choices) if choices.respond_to?(:call)
55
+ out << dropdown(form, choices, option.options)
56
56
 
57
57
  when :boolean, :radio
58
58
  choices = if option.radio?
59
- raise ArgumentError, MISSING_CHOICES_ERROR unless option.choices?
59
+ raise ArgumentError, MISSING_CHOICES_ERROR unless option.choices
60
60
  option.choices
61
61
  else
62
62
  %w(true false)
@@ -80,9 +80,9 @@ module Compendium::Presenters
80
80
  end
81
81
  end
82
82
 
83
- def dropdown(form, choices = {})
83
+ def dropdown(form, choices = {}, options = {})
84
84
  content_tag('div', class: 'option-dropdown') do
85
- form.select option.name, choices
85
+ form.select option.name, choices, options.symbolize_keys
86
86
  end
87
87
  end
88
88
 
@@ -7,8 +7,16 @@ module Compendium::Presenters::Settings
7
7
  @headings = Hash[headings.zip(headings)].with_indifferent_access
8
8
  end
9
9
 
10
- def override_heading(col, label)
11
- @headings[col] = label
10
+ def override_heading(*args, &block)
11
+ if block_given?
12
+ @headings.each do |key, val|
13
+ res = yield val
14
+ @headings[key] = res if res
15
+ end
16
+ else
17
+ col, label = args
18
+ @headings[col] = label
19
+ end
12
20
  end
13
21
 
14
22
  def format(column, &block)
@@ -1,12 +1,13 @@
1
1
  module Compendium
2
2
  class ReportsController < ::ApplicationController
3
3
  helper Compendium::ReportsHelper
4
+ include Compendium::ReportsHelper
4
5
 
5
6
  before_filter :find_report
6
7
  before_filter :run_report, only: :run
7
8
 
8
9
  def setup
9
- render locals: { report: setup_report, prefix: @prefix }
10
+ render_setup
10
11
  end
11
12
 
12
13
  def run
@@ -14,7 +15,7 @@ module Compendium
14
15
  render action: template, locals: { report: @report }
15
16
  end
16
17
 
17
- private
18
+ private
18
19
 
19
20
  def find_report
20
21
  @prefix = params[:report_name]
@@ -29,6 +30,11 @@ module Compendium
29
30
  end
30
31
  end
31
32
 
33
+ def render_setup(opts = {})
34
+ locals = { report: setup_report, prefix: @prefix }
35
+ render_if_exists(opts.merge(locals: locals)) || render(locals: locals)
36
+ end
37
+
32
38
  def setup_report
33
39
  @report_class.new(params[:report] || {})
34
40
  end
@@ -14,7 +14,7 @@ module Compendium
14
14
 
15
15
  def render_if_exists(options = {})
16
16
  if lookup_context.template_exists?(options[:partial] || options[:template], options[:path], options.key?(:partial))
17
- render options
17
+ render(options)
18
18
  end
19
19
  end
20
20
  end
@@ -5,7 +5,7 @@ require 'active_support/core_ext/module/delegation'
5
5
 
6
6
  module Compendium
7
7
  class Option
8
- attr_reader :name, :type, :default, :options
8
+ attr_reader :name, :type, :default, :choices, :options
9
9
 
10
10
  delegate :boolean?, :date?, :dropdown?, :radio?, :text?, to: :type
11
11
  delegate :merge, :merge!, :[], to: :@options
@@ -15,6 +15,7 @@ module Compendium
15
15
 
16
16
  @name = hash.delete(:name).to_sym
17
17
  @default = hash.delete(:default)
18
+ @choices = hash.delete(:choices)
18
19
  self.type = hash.delete(:type)
19
20
  @options = hash.with_indifferent_access
20
21
  end
@@ -20,7 +20,7 @@ module Compendium
20
20
  options.each do |option_name, metadata|
21
21
  begin
22
22
  klass = "Compendium::#{"#{metadata.type}Param".classify}".constantize
23
- params[option_name] = klass.new(get_default_value(params[option_name], metadata.default), metadata[:choices])
23
+ params[option_name] = klass.new(get_default_value(params[option_name], metadata.default), metadata.choices)
24
24
  rescue IndexError
25
25
  raise IndexError, "invalid index for #{option_name}"
26
26
  end
@@ -1,3 +1,3 @@
1
1
  module Compendium
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compendium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Vandersluis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-23 00:00:00.000000000 Z
11
+ date: 2013-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  type: :runtime