attributes_for 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +3 -2
- data/app/helpers/attributes_for/attributes_for_helper.rb +11 -9
- data/attributes_for.gemspec +1 -0
- data/lib/attributes_for/engine.rb +1 -0
- data/lib/attributes_for/version.rb +1 -1
- data/lib/generators/attributes_for/install_generator.rb +18 -3
- data/{app/assets/stylesheets → lib/generators/attributes_for/templates}/attributes_for.css +0 -0
- data/lib/generators/attributes_for/templates/attributes_for.css.scss +1 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5ce46b00c35f4c575e32426c6cb3ef0e24b6401
|
4
|
+
data.tar.gz: 2304e39bc30bcc62ec8e682f223ba906b00af16a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37f9c9ca4406e6cebd13ff2a72536b41d7e9142d85fee57363d49ea5f8b927095a1cc680b548ec261f3dc5d932f2646fd02414b91544e8994ff26750f8ffe372
|
7
|
+
data.tar.gz: 934b04a52d750bc0ba16c1e92b02404b3701aa0a7fe36a34126f3e9a313380f90f00c88b8d89ef711cf2e88274ce967c5a82dcad95e0f85c0a5338dfdc0c6d54
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.4.0] - 2015-08-07
|
4
|
+
### Added
|
5
|
+
- `duration` helper. Displays and integer in days, hours, minutes and
|
6
|
+
seconds
|
7
|
+
|
8
|
+
### Fixed
|
9
|
+
- Handle installation in projects using SASS.
|
10
|
+
|
3
11
|
## [0.3.2] - 2015-08-06
|
4
12
|
### Changed
|
5
13
|
- Rewrote implementation using method_missing
|
data/README.md
CHANGED
@@ -26,9 +26,9 @@ Or install it yourself as:
|
|
26
26
|
Run generator to add I18n locales:
|
27
27
|
|
28
28
|
$ rails generate attributes_for:install
|
29
|
-
|
29
|
+
|
30
30
|
## Screenshot
|
31
|
-
![Screenshot](https://cloud.githubusercontent.com/assets/1222916/
|
31
|
+
![Screenshot](https://cloud.githubusercontent.com/assets/1222916/9128630/e3bf2cda-3cf5-11e5-804b-c481734d0197.png)
|
32
32
|
|
33
33
|
## Usage
|
34
34
|
|
@@ -48,6 +48,7 @@ strings can also be presented using the `string` method.
|
|
48
48
|
<%= link_to @company.user_name, url_for(@company.user) %>
|
49
49
|
<% end %>
|
50
50
|
</li>
|
51
|
+
<li><%= b.duration :duration %></li>
|
51
52
|
<li><%= b.boolean :active %></li>
|
52
53
|
<li><%= b.date :created_at, format: :long %> </li>
|
53
54
|
<% end %>
|
@@ -2,14 +2,13 @@ module AttributesFor
|
|
2
2
|
module AttributesForHelper
|
3
3
|
|
4
4
|
def attributes_for(object, options = {}, &block)
|
5
|
-
|
6
|
-
capture builder, &block
|
5
|
+
capture AttributeBuilder.new(object, self), &block
|
7
6
|
end
|
8
7
|
|
9
8
|
class AttributeBuilder
|
10
9
|
include ActionView::Helpers
|
11
10
|
|
12
|
-
attr_accessor :object, :template
|
11
|
+
attr_accessor :object, :template
|
13
12
|
|
14
13
|
def initialize(object, template)
|
15
14
|
@object, @template = object, template
|
@@ -20,7 +19,7 @@ module AttributesFor
|
|
20
19
|
end
|
21
20
|
|
22
21
|
def method_missing(m, *args, &block)
|
23
|
-
|
22
|
+
build_content(m, *args, &block)
|
24
23
|
end
|
25
24
|
|
26
25
|
private
|
@@ -38,6 +37,8 @@ module AttributesFor
|
|
38
37
|
I18n.t("attributes_for.#{value.to_s}")
|
39
38
|
when :date
|
40
39
|
I18n.l(value, format: options[:format])
|
40
|
+
when :duration
|
41
|
+
ChronicDuration.output(value)
|
41
42
|
when :email
|
42
43
|
mail_to(" #{value}", value, title: human_name(attribute_name))
|
43
44
|
when :phone
|
@@ -78,11 +79,12 @@ module AttributesFor
|
|
78
79
|
|
79
80
|
def icon_map(method)
|
80
81
|
{
|
81
|
-
boolean:
|
82
|
-
date:
|
83
|
-
|
84
|
-
|
85
|
-
|
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',
|
86
88
|
}[method]
|
87
89
|
end
|
88
90
|
|
data/attributes_for.gemspec
CHANGED
@@ -9,10 +9,25 @@ module AttributesFor
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def inject_stylesheets
|
12
|
-
|
12
|
+
in_root do
|
13
|
+
{
|
14
|
+
"css" => {
|
15
|
+
require_string: " *= require font-awesome",
|
16
|
+
where: {before: %r{.*require_self}},
|
17
|
+
},
|
18
|
+
"css.scss" => {
|
19
|
+
require_string: "@import \"font-awesome\";",
|
20
|
+
where: {after: %r{\A}},
|
21
|
+
},
|
22
|
+
}.each do |extension, strategy|
|
23
|
+
file = "app/assets/stylesheets/application.#{extension}"
|
13
24
|
|
14
|
-
|
15
|
-
|
25
|
+
if File.exists?(Rails.root.join(file))
|
26
|
+
unless File.foreach(file).grep(/#{strategy[:require_string]}/).any?
|
27
|
+
inject_into_file file, strategy[:require_string] + "\n", strategy[:where]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
16
31
|
end
|
17
32
|
end
|
18
33
|
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "font-awesome";
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attributes_for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
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-08-
|
11
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '4.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: chronic_duration
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.10'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.10'
|
83
97
|
description: Helper for displaying model attributes with icons
|
84
98
|
email:
|
85
99
|
- ole.johnny.rosendahl@gmail.com
|
@@ -96,7 +110,6 @@ files:
|
|
96
110
|
- LICENSE.txt
|
97
111
|
- README.md
|
98
112
|
- Rakefile
|
99
|
-
- app/assets/stylesheets/attributes_for.css
|
100
113
|
- app/helpers/attributes_for/attributes_for_helper.rb
|
101
114
|
- attributes_for.gemspec
|
102
115
|
- bin/console
|
@@ -105,6 +118,8 @@ files:
|
|
105
118
|
- lib/attributes_for/engine.rb
|
106
119
|
- lib/attributes_for/version.rb
|
107
120
|
- lib/generators/attributes_for/install_generator.rb
|
121
|
+
- lib/generators/attributes_for/templates/attributes_for.css
|
122
|
+
- lib/generators/attributes_for/templates/attributes_for.css.scss
|
108
123
|
- lib/generators/attributes_for/templates/attributes_for.en.yml
|
109
124
|
homepage: https://github.com/blacktangent/attributes_for
|
110
125
|
licenses:
|