data_attributes 1.0.0 → 1.1.0

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: 13d87816eec1c6d0c9d3f23f54b26d9029104de8
4
- data.tar.gz: ba5bf26281792856d44f9abc2e259ee21fa9fd62
3
+ metadata.gz: a0cc393de9a1b6b73a2bda2ba0dd35359340660b
4
+ data.tar.gz: e17a7fdeddc2c3af32650e3443b00927fe5a777f
5
5
  SHA512:
6
- metadata.gz: 37de7c74094ec28ec7d84c56a2e6a4376d0dbf965e0d9df960e96df0c74698c378439b710028d28082dae48fd65cc1f8714b0d5239f37c6cf043dec1450a0c81
7
- data.tar.gz: b12317c608492d08a89adc4fd7024ec7c17fad9c55f74eb688af66181bb5a8e76f49f37bebbdcb39bf84fd6309c4c478af30ba4e389b3d4d81152a54ad1cdde3
6
+ metadata.gz: 8e215cc000eac4d61afcad275358d02123f5a283034dc482e727e4701623d498fea5f363d036063772e03b29e18a6dcb0a3437bc08000e46d817bce2610362ce
7
+ data.tar.gz: 832ef5059dd1689b8804888bc835fad538a66ab7c3491734a5ced1dadacc223f17861f90d48b64f4811a81d50bfa93cdfd8ac3402ce71ea6c05d18dc424fdb38
@@ -1,7 +1,7 @@
1
1
  # DataAttributes
2
2
 
3
- Convenience helpers to provide [HTML data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes)
4
- from model to view.
3
+ A gem to provide [HTML data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes)
4
+ easily from model to view.
5
5
 
6
6
  ## Setup
7
7
 
@@ -45,15 +45,9 @@ class Article
45
45
  end
46
46
  ```
47
47
 
48
- Then you must add `DataAttribute::View` into Rails `ApplicationHelper`:
48
+ Note that `DataAttributes::Model` mixin is automatically added into
49
+ `ActiveRecord::Base` (if present).
49
50
 
50
- ```ruby
51
- module ApplicationHelper
52
-
53
- include DataAttribute::View
54
-
55
- end
56
- ```
57
51
 
58
52
  Then `content_tag_for` and `div_for` methods from [record_tag_helper](https://rubygems.org/gems/record_tag_helper)
59
53
  gem will add model's data attributes into view:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
5
5
  s.author = 'Alexis Toulotte'
6
6
  s.email = 'al@alweb.org'
7
7
  s.homepage = 'https://github.com/alexistoulotte/data_attributes'
8
- s.summary = 'Helpers for HTML data attributes'
9
- s.description = 'Convenience helpers to provide HTML data attributes from model to view'
8
+ s.summary = 'Provides HTML data attributes from model to view'
9
+ s.description = 'A gem to provide HTML data attributes from model to view'
10
10
  s.license = 'MIT'
11
11
 
12
12
  s.files = `git ls-files`.split("\n")
@@ -5,4 +5,12 @@ require 'active_support/json'
5
5
  lib_path = "#{__dir__}/data_attributes"
6
6
 
7
7
  require "#{lib_path}/model"
8
- require "#{lib_path}/view"
8
+ require "#{lib_path}/helper"
9
+
10
+ ActiveSupport.on_load(:action_view) do
11
+ include DataAttributes::Helper
12
+ end
13
+
14
+ ActiveSupport.on_load(:active_record) do
15
+ ActiveRecord::Base.send(:include, DataAttributes::Model)
16
+ end
@@ -1,6 +1,6 @@
1
1
  module DataAttributes
2
2
 
3
- module View
3
+ module Helper
4
4
 
5
5
  def content_tag_for_single_record(tag_name, record, prefix, options, &block)
6
6
  options, prefix = prefix, nil if prefix.is_a?(Hash)
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe DataAttributes::View do
3
+ describe DataAttributes::Helper do
4
4
 
5
5
  let(:view) { View.new }
6
6
 
@@ -1,5 +1,5 @@
1
1
  class View
2
2
 
3
- include DataAttributes::View
3
+ include DataAttributes::Helper
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Toulotte
@@ -90,7 +90,7 @@ dependencies:
90
90
  - - "<"
91
91
  - !ruby/object:Gem::Version
92
92
  version: 3.6.0
93
- description: Convenience helpers to provide HTML data attributes from model to view
93
+ description: A gem to provide HTML data attributes from model to view
94
94
  email: al@alweb.org
95
95
  executables: []
96
96
  extensions: []
@@ -105,11 +105,11 @@ files:
105
105
  - VERSION
106
106
  - data_attributes.gemspec
107
107
  - lib/data_attributes.rb
108
+ - lib/data_attributes/helper.rb
108
109
  - lib/data_attributes/model.rb
109
- - lib/data_attributes/view.rb
110
110
  - lib/spec_helper.rb
111
+ - spec/data_attributes/helper_spec.rb
111
112
  - spec/data_attributes/model_spec.rb
112
- - spec/data_attributes/view_spec.rb
113
113
  - spec/spec_helper.rb
114
114
  - spec/support/mocks/article.rb
115
115
  - spec/support/mocks/category.rb
@@ -138,10 +138,10 @@ rubyforge_project:
138
138
  rubygems_version: 2.5.2
139
139
  signing_key:
140
140
  specification_version: 4
141
- summary: Helpers for HTML data attributes
141
+ summary: Provides HTML data attributes from model to view
142
142
  test_files:
143
+ - spec/data_attributes/helper_spec.rb
143
144
  - spec/data_attributes/model_spec.rb
144
- - spec/data_attributes/view_spec.rb
145
145
  - spec/spec_helper.rb
146
146
  - spec/support/mocks/article.rb
147
147
  - spec/support/mocks/category.rb