attributes_for 0.4.1 → 0.4.2
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 +4 -4
- data/.coveralls.yml +1 -0
- data/.gitignore +9 -9
- data/.travis.yml +1 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +12 -1
- data/Gemfile.lock +106 -0
- data/MIT-LICENSE +20 -0
- data/README.md +10 -1
- data/Rakefile +32 -4
- data/app/helpers/attributes_for/rails/attributes_for_helper.rb +87 -0
- data/attributes_for.gemspec +6 -8
- data/lib/attributes_for.rb +1 -8
- data/lib/attributes_for/version.rb +1 -1
- data/lib/tasks/attributes_for_tasks.rake +4 -0
- metadata +32 -51
- data/app/helpers/attributes_for/attributes_for_helper.rb +0 -93
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0df8d175cc3ec8856f90ac1b31aeaa570d1af17e
|
|
4
|
+
data.tar.gz: cd47f8a1e9da4a4c2bdd12d8df6aae2647449420
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5a78a9a45ef9bb1ebd38df8e37758e471141f6fcb86316d98e65e5b6507af151503d1d8f515fc28d1dbf7690182964d58d0b342caaa00a22062225cac6db9f4a
|
|
7
|
+
data.tar.gz: b662c1a626998a68ba7c908c6092e1512d4ef8a538040436c30e14eac89d5c77b8b84c01d4d4e996bd501edd9347f58d4ff65c4d0484a69edc789c5116953fdc
|
data/.coveralls.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
*.gem
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/
|
|
6
|
-
/
|
|
7
|
-
/
|
|
8
|
-
/
|
|
9
|
-
/
|
|
10
|
-
/
|
|
2
|
+
.bundle/
|
|
3
|
+
coverage/
|
|
4
|
+
log/*.log
|
|
5
|
+
pkg/
|
|
6
|
+
test/dummy/db/*.sqlite3
|
|
7
|
+
test/dummy/db/*.sqlite3-journal
|
|
8
|
+
test/dummy/log/*.log
|
|
9
|
+
test/dummy/tmp/
|
|
10
|
+
test/dummy/.sass-cache
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
## [0.4.2] - 2015-09-05
|
|
5
|
+
## Changed
|
|
6
|
+
- Use minitest instead of rspec
|
|
7
|
+
- Replaced `phony_rails` with `phony`.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- `string` helper now working as expected. Requires block to be passed
|
|
11
|
+
for content.
|
|
12
|
+
|
|
3
13
|
## [0.4.1] - 2015-08-18
|
|
4
14
|
### Added
|
|
5
15
|
- Use `phony_rails` to format phone numbers.
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# Declare your gem's dependencies in attributes_for.gemspec.
|
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
|
5
|
+
# development dependencies will be added by default to the :development group.
|
|
4
6
|
gemspec
|
|
7
|
+
|
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
|
11
|
+
# your gem to rubygems.org.
|
|
12
|
+
|
|
13
|
+
# To use a debugger
|
|
14
|
+
# gem 'byebug', group: [:development, :test]
|
|
15
|
+
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
attributes_for (0.4.2)
|
|
5
|
+
chronic_duration (~> 0.10)
|
|
6
|
+
font-awesome-rails (~> 4.0)
|
|
7
|
+
phony (~> 2.0)
|
|
8
|
+
railties (>= 3.2, < 5.0)
|
|
9
|
+
|
|
10
|
+
GEM
|
|
11
|
+
remote: https://rubygems.org/
|
|
12
|
+
specs:
|
|
13
|
+
actionpack (4.2.4)
|
|
14
|
+
actionview (= 4.2.4)
|
|
15
|
+
activesupport (= 4.2.4)
|
|
16
|
+
rack (~> 1.6)
|
|
17
|
+
rack-test (~> 0.6.2)
|
|
18
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
19
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
20
|
+
actionview (4.2.4)
|
|
21
|
+
activesupport (= 4.2.4)
|
|
22
|
+
builder (~> 3.1)
|
|
23
|
+
erubis (~> 2.7.0)
|
|
24
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
25
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
26
|
+
activesupport (4.2.4)
|
|
27
|
+
i18n (~> 0.7)
|
|
28
|
+
json (~> 1.7, >= 1.7.7)
|
|
29
|
+
minitest (~> 5.1)
|
|
30
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
31
|
+
tzinfo (~> 1.1)
|
|
32
|
+
builder (3.2.2)
|
|
33
|
+
chronic_duration (0.10.6)
|
|
34
|
+
numerizer (~> 0.1.1)
|
|
35
|
+
coveralls (0.8.2)
|
|
36
|
+
json (~> 1.8)
|
|
37
|
+
rest-client (>= 1.6.8, < 2)
|
|
38
|
+
simplecov (~> 0.10.0)
|
|
39
|
+
term-ansicolor (~> 1.3)
|
|
40
|
+
thor (~> 0.19.1)
|
|
41
|
+
docile (1.1.5)
|
|
42
|
+
domain_name (0.5.24)
|
|
43
|
+
unf (>= 0.0.5, < 1.0.0)
|
|
44
|
+
erubis (2.7.0)
|
|
45
|
+
font-awesome-rails (4.4.0.0)
|
|
46
|
+
railties (>= 3.2, < 5.0)
|
|
47
|
+
http-cookie (1.0.2)
|
|
48
|
+
domain_name (~> 0.5)
|
|
49
|
+
i18n (0.7.0)
|
|
50
|
+
json (1.8.3)
|
|
51
|
+
loofah (2.0.3)
|
|
52
|
+
nokogiri (>= 1.5.9)
|
|
53
|
+
mime-types (2.6.1)
|
|
54
|
+
mini_portile (0.6.2)
|
|
55
|
+
minitest (5.8.0)
|
|
56
|
+
netrc (0.10.3)
|
|
57
|
+
nokogiri (1.6.6.2)
|
|
58
|
+
mini_portile (~> 0.6.0)
|
|
59
|
+
numerizer (0.1.1)
|
|
60
|
+
phony (2.15.0)
|
|
61
|
+
rack (1.6.4)
|
|
62
|
+
rack-test (0.6.3)
|
|
63
|
+
rack (>= 1.0)
|
|
64
|
+
rails-deprecated_sanitizer (1.0.3)
|
|
65
|
+
activesupport (>= 4.2.0.alpha)
|
|
66
|
+
rails-dom-testing (1.0.7)
|
|
67
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
|
68
|
+
nokogiri (~> 1.6.0)
|
|
69
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
|
70
|
+
rails-html-sanitizer (1.0.2)
|
|
71
|
+
loofah (~> 2.0)
|
|
72
|
+
railties (4.2.4)
|
|
73
|
+
actionpack (= 4.2.4)
|
|
74
|
+
activesupport (= 4.2.4)
|
|
75
|
+
rake (>= 0.8.7)
|
|
76
|
+
thor (>= 0.18.1, < 2.0)
|
|
77
|
+
rake (10.4.2)
|
|
78
|
+
rest-client (1.8.0)
|
|
79
|
+
http-cookie (>= 1.0.2, < 2.0)
|
|
80
|
+
mime-types (>= 1.16, < 3.0)
|
|
81
|
+
netrc (~> 0.7)
|
|
82
|
+
simplecov (0.10.0)
|
|
83
|
+
docile (~> 1.1.0)
|
|
84
|
+
json (~> 1.8)
|
|
85
|
+
simplecov-html (~> 0.10.0)
|
|
86
|
+
simplecov-html (0.10.0)
|
|
87
|
+
term-ansicolor (1.3.2)
|
|
88
|
+
tins (~> 1.0)
|
|
89
|
+
thor (0.19.1)
|
|
90
|
+
thread_safe (0.3.5)
|
|
91
|
+
tins (1.6.0)
|
|
92
|
+
tzinfo (1.2.2)
|
|
93
|
+
thread_safe (~> 0.1)
|
|
94
|
+
unf (0.1.4)
|
|
95
|
+
unf_ext
|
|
96
|
+
unf_ext (0.0.7.1)
|
|
97
|
+
|
|
98
|
+
PLATFORMS
|
|
99
|
+
ruby
|
|
100
|
+
|
|
101
|
+
DEPENDENCIES
|
|
102
|
+
attributes_for!
|
|
103
|
+
coveralls
|
|
104
|
+
|
|
105
|
+
BUNDLED WITH
|
|
106
|
+
1.10.3
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2015 Ole J. Rosendahl
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
[travis]: https://travis-ci.org/blacktangent/attributes_for
|
|
2
2
|
[codeclimate]: https://codeclimate.com/github/blacktangent/attributes_for
|
|
3
|
+
[coveralls]: https://coveralls.io/r/blacktangent/attributes_for
|
|
4
|
+
[rubygems]: https://rubygems.org/gems/attributes_for
|
|
5
|
+
|
|
3
6
|
|
|
4
7
|
# AttributesFor
|
|
5
8
|
|
|
6
9
|
[][travis]
|
|
7
10
|
[][codeclimate]
|
|
8
|
-
[][coveralls]
|
|
12
|
+
[][rubygems]
|
|
9
13
|
|
|
10
14
|
ActiveView Helper to present formatted ActiveModel attributes with
|
|
11
15
|
icons.
|
|
@@ -56,6 +60,11 @@ strings can also be presented using the `string` method.
|
|
|
56
60
|
<li><%= b.duration :duration %></li>
|
|
57
61
|
<li><%= b.boolean :active %></li>
|
|
58
62
|
<li><%= b.date :created_at, format: :long %> </li>
|
|
63
|
+
<li>
|
|
64
|
+
<%= b.string "Label" do %>
|
|
65
|
+
Content
|
|
66
|
+
<% end %>
|
|
67
|
+
</li>
|
|
59
68
|
<% end %>
|
|
60
69
|
</ul>
|
|
61
70
|
```
|
data/Rakefile
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
require
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
3
6
|
|
|
4
|
-
|
|
7
|
+
require 'rdoc/task'
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'AttributesFor'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Bundler::GemHelper.install_tasks
|
|
23
|
+
|
|
24
|
+
require 'rake/testtask'
|
|
25
|
+
|
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
|
27
|
+
t.libs << 'lib'
|
|
28
|
+
t.libs << 'test'
|
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
|
30
|
+
t.verbose = false
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
task default: :test
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
module AttributesFor
|
|
2
|
+
module Rails
|
|
3
|
+
module AttributesForHelper
|
|
4
|
+
|
|
5
|
+
def attributes_for(object, options = {}, &block)
|
|
6
|
+
capture AttributeBuilder.new(object, self), &block
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class AttributeBuilder
|
|
10
|
+
include ActionView::Helpers
|
|
11
|
+
|
|
12
|
+
attr_accessor :object, :template
|
|
13
|
+
|
|
14
|
+
def initialize(object, template)
|
|
15
|
+
@object, @template = object, template
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def string(label, options = {}, &block)
|
|
19
|
+
wrap_content(" #{label}: " + template.capture(&block), options)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def method_missing(m, *args, &block)
|
|
23
|
+
build_content(m, *args, &block)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def build_content(method, attribute_name, options = {}, &block)
|
|
29
|
+
value = object.public_send(attribute_name)
|
|
30
|
+
|
|
31
|
+
content = if block_given?
|
|
32
|
+
template.capture(&block)
|
|
33
|
+
elsif value.to_s.empty?
|
|
34
|
+
I18n.t "attributes_for.not_set"
|
|
35
|
+
else
|
|
36
|
+
case method.to_sym
|
|
37
|
+
when :boolean
|
|
38
|
+
I18n.t("attributes_for.#{value.to_s}")
|
|
39
|
+
when :date
|
|
40
|
+
I18n.l(value, format: options[:format])
|
|
41
|
+
when :duration
|
|
42
|
+
ChronicDuration.output(value, :keep_zero => true)
|
|
43
|
+
when :email
|
|
44
|
+
mail_to(value, value, title: human_name(attribute_name))
|
|
45
|
+
when :phone
|
|
46
|
+
link_to(Phony.format(value.to_s), "tel:+#{value}", title: human_name(attribute_name))
|
|
47
|
+
when :url
|
|
48
|
+
link_to(value, value, title: human_name(attribute_name))
|
|
49
|
+
else
|
|
50
|
+
value
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
options[:class] ||= icon_map(method)
|
|
55
|
+
options[:id] ||= attribute_name.to_s
|
|
56
|
+
|
|
57
|
+
wrap_content(label(attribute_name, options) + content, options)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def wrap_content(content, options = {})
|
|
61
|
+
content_tag(:i, content, id: options[:id], class: options[:class])
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def label(attribute, options)
|
|
65
|
+
return " ".html_safe if options[:label] === false
|
|
66
|
+
" #{human_name(attribute)}: ".html_safe
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def human_name(attribute)
|
|
70
|
+
object.class.human_attribute_name(attribute)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def icon_map(method)
|
|
74
|
+
{
|
|
75
|
+
boolean: 'fa fa-check',
|
|
76
|
+
date: 'fa fa-calendar',
|
|
77
|
+
duration: 'fa fa-clock-o',
|
|
78
|
+
email: 'fa fa-envelope',
|
|
79
|
+
phone: 'fa fa-phone',
|
|
80
|
+
url: 'fa fa-globe',
|
|
81
|
+
}[method]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
data/attributes_for.gemspec
CHANGED
|
@@ -16,16 +16,14 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
17
17
|
spec.bindir = "exe"
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
|
-
spec.require_paths = ["lib"
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
20
|
|
|
21
|
-
spec.required_ruby_version = '
|
|
21
|
+
spec.required_ruby_version = '>= 1.9.3'
|
|
22
22
|
|
|
23
|
-
spec.
|
|
24
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
|
25
|
-
spec.add_development_dependency "rspec", "~> 2.3"
|
|
26
|
-
|
|
27
|
-
spec.add_dependency 'rails', '~> 4.0'
|
|
23
|
+
spec.add_dependency 'railties', '>= 3.2', '< 5.0'
|
|
28
24
|
spec.add_dependency 'font-awesome-rails', '~> 4.0'
|
|
29
25
|
spec.add_dependency 'chronic_duration', '~> 0.10'
|
|
30
|
-
spec.add_dependency '
|
|
26
|
+
spec.add_dependency 'phony', '~> 2.0'
|
|
27
|
+
|
|
28
|
+
spec.add_development_dependency 'coveralls'
|
|
31
29
|
end
|
data/lib/attributes_for.rb
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
require "attributes_for/version"
|
|
2
|
-
require "rails/engine"
|
|
3
|
-
require "action_view"
|
|
4
2
|
require "attributes_for/engine"
|
|
5
|
-
require "
|
|
6
|
-
require "phony_rails"
|
|
7
|
-
|
|
8
|
-
module AttributesFor
|
|
9
|
-
# Your code goes here...
|
|
10
|
-
end
|
|
3
|
+
require "phony"
|
metadata
CHANGED
|
@@ -1,59 +1,37 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: attributes_for
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ole J. Rosendahl
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-09-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: railties
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '1.10'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
17
|
+
- - ">="
|
|
25
18
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
27
|
-
-
|
|
28
|
-
name: rake
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
19
|
+
version: '3.2'
|
|
20
|
+
- - "<"
|
|
32
21
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
34
|
-
type: :
|
|
22
|
+
version: '5.0'
|
|
23
|
+
type: :runtime
|
|
35
24
|
prerelease: false
|
|
36
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
26
|
requirements:
|
|
38
|
-
- - "
|
|
27
|
+
- - ">="
|
|
39
28
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
41
|
-
-
|
|
42
|
-
name: rspec
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
29
|
+
version: '3.2'
|
|
30
|
+
- - "<"
|
|
46
31
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '2.3'
|
|
32
|
+
version: '5.0'
|
|
55
33
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rails
|
|
34
|
+
name: font-awesome-rails
|
|
57
35
|
requirement: !ruby/object:Gem::Requirement
|
|
58
36
|
requirements:
|
|
59
37
|
- - "~>"
|
|
@@ -67,47 +45,47 @@ dependencies:
|
|
|
67
45
|
- !ruby/object:Gem::Version
|
|
68
46
|
version: '4.0'
|
|
69
47
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
48
|
+
name: chronic_duration
|
|
71
49
|
requirement: !ruby/object:Gem::Requirement
|
|
72
50
|
requirements:
|
|
73
51
|
- - "~>"
|
|
74
52
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
53
|
+
version: '0.10'
|
|
76
54
|
type: :runtime
|
|
77
55
|
prerelease: false
|
|
78
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
57
|
requirements:
|
|
80
58
|
- - "~>"
|
|
81
59
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
60
|
+
version: '0.10'
|
|
83
61
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
62
|
+
name: phony
|
|
85
63
|
requirement: !ruby/object:Gem::Requirement
|
|
86
64
|
requirements:
|
|
87
65
|
- - "~>"
|
|
88
66
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '0
|
|
67
|
+
version: '2.0'
|
|
90
68
|
type: :runtime
|
|
91
69
|
prerelease: false
|
|
92
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
71
|
requirements:
|
|
94
72
|
- - "~>"
|
|
95
73
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '0
|
|
74
|
+
version: '2.0'
|
|
97
75
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
76
|
+
name: coveralls
|
|
99
77
|
requirement: !ruby/object:Gem::Requirement
|
|
100
78
|
requirements:
|
|
101
|
-
- - "
|
|
79
|
+
- - ">="
|
|
102
80
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '0
|
|
104
|
-
type: :
|
|
81
|
+
version: '0'
|
|
82
|
+
type: :development
|
|
105
83
|
prerelease: false
|
|
106
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
85
|
requirements:
|
|
108
|
-
- - "
|
|
86
|
+
- - ">="
|
|
109
87
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '0
|
|
88
|
+
version: '0'
|
|
111
89
|
description: ActiveView Helper to present formatted ActiveModel attributes with icons.
|
|
112
90
|
email:
|
|
113
91
|
- ole.johnny.rosendahl@gmail.com
|
|
@@ -115,16 +93,19 @@ executables: []
|
|
|
115
93
|
extensions: []
|
|
116
94
|
extra_rdoc_files: []
|
|
117
95
|
files:
|
|
96
|
+
- ".coveralls.yml"
|
|
118
97
|
- ".gitignore"
|
|
119
98
|
- ".rspec"
|
|
120
99
|
- ".travis.yml"
|
|
121
100
|
- CHANGELOG.md
|
|
122
101
|
- CODE_OF_CONDUCT.md
|
|
123
102
|
- Gemfile
|
|
103
|
+
- Gemfile.lock
|
|
124
104
|
- LICENSE.txt
|
|
105
|
+
- MIT-LICENSE
|
|
125
106
|
- README.md
|
|
126
107
|
- Rakefile
|
|
127
|
-
- app/helpers/attributes_for/attributes_for_helper.rb
|
|
108
|
+
- app/helpers/attributes_for/rails/attributes_for_helper.rb
|
|
128
109
|
- attributes_for.gemspec
|
|
129
110
|
- bin/console
|
|
130
111
|
- bin/setup
|
|
@@ -135,6 +116,7 @@ files:
|
|
|
135
116
|
- lib/generators/attributes_for/templates/attributes_for.css
|
|
136
117
|
- lib/generators/attributes_for/templates/attributes_for.css.scss
|
|
137
118
|
- lib/generators/attributes_for/templates/attributes_for.en.yml
|
|
119
|
+
- lib/tasks/attributes_for_tasks.rake
|
|
138
120
|
homepage: https://github.com/blacktangent/attributes_for
|
|
139
121
|
licenses:
|
|
140
122
|
- MIT
|
|
@@ -143,12 +125,11 @@ post_install_message:
|
|
|
143
125
|
rdoc_options: []
|
|
144
126
|
require_paths:
|
|
145
127
|
- lib
|
|
146
|
-
- app
|
|
147
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
129
|
requirements:
|
|
149
|
-
- - "
|
|
130
|
+
- - ">="
|
|
150
131
|
- !ruby/object:Gem::Version
|
|
151
|
-
version:
|
|
132
|
+
version: 1.9.3
|
|
152
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
134
|
requirements:
|
|
154
135
|
- - ">="
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
module AttributesFor
|
|
2
|
-
module AttributesForHelper
|
|
3
|
-
|
|
4
|
-
def attributes_for(object, options = {}, &block)
|
|
5
|
-
capture AttributeBuilder.new(object, self), &block
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
class AttributeBuilder
|
|
9
|
-
include ActionView::Helpers
|
|
10
|
-
|
|
11
|
-
attr_accessor :object, :template
|
|
12
|
-
|
|
13
|
-
def initialize(object, template)
|
|
14
|
-
@object, @template = object, template
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def string(content, options = {})
|
|
18
|
-
wrap_content(" #{content}", options)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def method_missing(m, *args, &block)
|
|
22
|
-
build_content(m, *args, &block)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
def build_content(method, attribute_name, options = {}, &block)
|
|
28
|
-
value = attribute_value(attribute_name)
|
|
29
|
-
|
|
30
|
-
content = if block_given?
|
|
31
|
-
template.capture(&block)
|
|
32
|
-
elsif value.to_s.empty?
|
|
33
|
-
I18n.t "attributes_for.not_set"
|
|
34
|
-
else
|
|
35
|
-
case method.to_sym
|
|
36
|
-
when :boolean
|
|
37
|
-
I18n.t("attributes_for.#{value.to_s}")
|
|
38
|
-
when :date
|
|
39
|
-
I18n.l(value, format: options[:format])
|
|
40
|
-
when :duration
|
|
41
|
-
ChronicDuration.output(value, :keep_zero => true)
|
|
42
|
-
when :email
|
|
43
|
-
mail_to(" #{value}", value, title: human_name(attribute_name))
|
|
44
|
-
when :phone
|
|
45
|
-
link_to(" #{value.to_s.phony_formatted(:format => :international)}", "tel:+#{value}", title: human_name(attribute_name))
|
|
46
|
-
when :url
|
|
47
|
-
link_to(" #{value}", value, title: human_name(attribute_name))
|
|
48
|
-
else
|
|
49
|
-
value
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
options[:class] ||= icon_map(method)
|
|
54
|
-
options[:id] ||= attribute_name.to_s
|
|
55
|
-
|
|
56
|
-
wrap_content(label(attribute_name, options) + content, options)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def wrap_content(content, options = {})
|
|
60
|
-
content_tag(:i, content, id: options[:id], class: options[:class])
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def attribute_value(attribute_name)
|
|
64
|
-
if attribute_name.is_a?(String)
|
|
65
|
-
attribute_name
|
|
66
|
-
else
|
|
67
|
-
object.public_send(attribute_name)
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def label(attribute, options)
|
|
72
|
-
return " ".html_safe if options[:label] === false
|
|
73
|
-
" #{human_name(attribute)}: ".html_safe
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def human_name(attribute)
|
|
77
|
-
object.class.human_attribute_name(attribute)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def icon_map(method)
|
|
81
|
-
{
|
|
82
|
-
boolean: 'fa fa-check',
|
|
83
|
-
date: 'fa fa-calendar',
|
|
84
|
-
duration: 'fa fa-clock-o',
|
|
85
|
-
email: 'fa fa-envelope',
|
|
86
|
-
phone: 'fa fa-phone',
|
|
87
|
-
url: 'fa fa-globe',
|
|
88
|
-
}[method]
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|