html_tables 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00bbe3d09e255e86b9a2e5317394df3ce66d9fc1
4
- data.tar.gz: a8651091f16dcff9b92e24ccedb950a1dc562df0
3
+ metadata.gz: 2e0bae9b4cbf7907485ab3be3a13d8ca01682a9b
4
+ data.tar.gz: e525363a740bf4af8a7e8b865a4c3a37ae1c3d0a
5
5
  SHA512:
6
- metadata.gz: 66ad98813aed0275709e7beeb1b84601ed4d92e64033c01ea378c646b0a0f062e56c16f405a34c89900d49b17e32e62a64f7e5814286b7e03c763b17af3eac67
7
- data.tar.gz: 7f8e2452b0f543989f876862e24db2a3d37e602e3beadc3c89923d04bf6eb3cc614355378efd6fe4b6838c98457d177c7e7a0ee62d37cb09ba49950411ac774d
6
+ metadata.gz: 5f69ca9e6d5df648a5bbfe1482424714d6971364cb050afa59f106275ae107201f893d5334c741c126eacda5375aa6022594fa833df34d3a11a2e985b49d44c9
7
+ data.tar.gz: c8af413fa4c711a9e16f235392ce79d0b72f2633f45f9014003e0d7bbcc98e928d7a2af3897107ac8cc973262d8f3ad4a6c497a50bf4b7a7192afd25b9c10e67
@@ -0,0 +1,19 @@
1
+ require 'singleton'
2
+
3
+ module HtmlTables
4
+ def self.setup
5
+ yield Configuration.instance
6
+ end
7
+
8
+ class Configuration
9
+ include Singleton
10
+
11
+ attr_accessor :use_entity_shortcuts, :url_generator_proc, :default_table_classes
12
+
13
+ def initialize
14
+ @use_entity_shortcuts = ::Rails.env.development?
15
+ @url_generator_proc = -> obj { url_for(obj) }
16
+ @default_table_classes = %w(table table-striped table-bordered)
17
+ end
18
+ end
19
+ end
@@ -3,6 +3,8 @@
3
3
  module HtmlTables
4
4
  module DataTableHelper
5
5
  def data_table_for(collection, options = {})
6
+ config = HtmlTables::Configuration.instance
7
+
6
8
  t = DataTable.new(self, collection, options)
7
9
  if block_given?
8
10
  yield t.object_to_yield
@@ -10,7 +12,7 @@ module HtmlTables
10
12
  t.auto_generate_columns!
11
13
  end
12
14
 
13
- cls = %w(table table-striped table-bordered)
15
+ cls = config.default_table_classes.dup
14
16
  cls << 'table-condensed' if options[:condensed]
15
17
  cls << options[:class] if options[:class]
16
18
  table_html_options = { class: cls }
@@ -98,9 +100,9 @@ module HtmlTables
98
100
  tmp
99
101
  end
100
102
 
101
- if ::Rails.env.development? && v.is_a?(ActiveRecord::Base)
103
+ if config.use_entity_shortcuts && v.is_a?(ActiveRecord::Base)
102
104
  btn = content_tag(:div, class: 'entity-shortcut') do
103
- link_to(url_for(v), class: 'btn btn-small') do
105
+ link_to(config.url_generator_proc.(v), class: 'btn btn-small') do
104
106
  content_tag(:i, nil, class: 'icon-share')
105
107
  end
106
108
  end rescue nil
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module HtmlTables
4
- VERSION = '0.0.11'
4
+ VERSION = '0.0.12'
5
5
  end
data/lib/html_tables.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  require 'html_tables/version'
4
+ require 'html_tables/config'
4
5
 
5
6
  require 'html_tables/to_label'
6
7
  require 'html_tables/format_for_output'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html_tables
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fábio David Batista
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-12 00:00:00.000000000 Z
11
+ date: 2013-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -81,6 +81,7 @@ files:
81
81
  - Rakefile
82
82
  - html_tables.gemspec
83
83
  - lib/html_tables.rb
84
+ - lib/html_tables/config.rb
84
85
  - lib/html_tables/data_table.rb
85
86
  - lib/html_tables/data_table_helper.rb
86
87
  - lib/html_tables/format_for_output.rb