attributes_for 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 633bf6456c48d8b75050959f4f0786b85ac02bd9
4
- data.tar.gz: 76ff6f4065a1b89f808d4e2addd44ae100c3b9ee
3
+ metadata.gz: fbe5caa06296a883ff1be0b0aef988668c71c94d
4
+ data.tar.gz: 446b2c7ea7b75df3a1d477ea6188e9498a0381a3
5
5
  SHA512:
6
- metadata.gz: 713784bbaecc27c3e47ce57d5cbf5572e87e26b595ff1c6f64a9255000349ca98cb2bc7e83240bcf1c93de30b8f8ec4dbaec7e6dee2ef8013d9513ce20c0f1d4
7
- data.tar.gz: bf7757d513774c5ba0d826f59d71ab96ebd1a36af84bb9676c7c12ca80bfc5f2453912e7ccb71580fec43752d56e9aa0f064d573d65769cc7ecacb615be23db7
6
+ metadata.gz: 562b36098e0dcd9f39ef1c447246ab7c6e1153ced1c003f9ca19cf6cad93201d4801a16ab801637895af587bd5192da307015394c7158f80c9c0989d8310e25a
7
+ data.tar.gz: 40af89eccc208a8f45e3a8ab303f064aae50cb5a586f6bba7a5f4148d5c48bfb38fb73fdc53f98c220c5bdc954486528be353977438c0286f79e02fb12ef6ae5
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *.gem
1
2
  /.bundle/
2
3
  /.yardoc
3
4
  /Gemfile.lock
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.0] - 2015-08-04
4
+ ### Added
5
+ - `boolean` formatting helper, will show 'Yes' or 'No' depending on
6
+ attribute value.
7
+ - Install generator. Copies locales into project.
8
+
3
9
  ## [0.1.1] - 2015-08-04
4
10
  ### Fixed
5
11
  - Disabeling label with format helpers shows unescaped HTML.
data/README.md CHANGED
@@ -37,6 +37,7 @@ strings can also be presented using the `string` method.
37
37
  <li><%= b.url :website %></li>
38
38
  <li><%= b.date :created_at %></li>
39
39
  <li><%= b.attribute :credit_rating %></li>
40
+ <li><%= b.boolean :active %></li>
40
41
  <li><%= b.string "A string" %></li>
41
42
  <% end %>
42
43
  </ul>
@@ -15,6 +15,14 @@ module AttributesFor
15
15
  @object = object
16
16
  end
17
17
 
18
+ def boolean(attribute_name, options = {})
19
+ options[:class] ||= 'fa fa-check'
20
+
21
+ content(attribute_name, options) do |value|
22
+ I18n.t("attributes_for.#{value.to_s}")
23
+ end
24
+ end
25
+
18
26
  def phone(attribute_name, options = {})
19
27
  options[:class] ||= 'fa fa-phone'
20
28
 
@@ -67,8 +75,8 @@ module AttributesFor
67
75
  end
68
76
 
69
77
  def prepare_value(value, &block)
70
- if !value.present?
71
- I18n.t(:not_set)
78
+ if value.to_s.empty?
79
+ I18n.t "attributes_for.not_set"
72
80
  elsif block_given?
73
81
  yield value
74
82
  else
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib", "app"]
20
20
 
21
+ spec.required_ruby_version = '~> 2.0'
22
+
21
23
  spec.add_development_dependency "bundler", "~> 1.10"
22
24
  spec.add_development_dependency "rake", "~> 10.0"
23
25
  spec.add_development_dependency "rspec", "~> 2.3"
@@ -4,6 +4,6 @@ require "action_view"
4
4
  require "attributes_for/engine"
5
5
  require "helpers/attributes_for/attributes_for_helper"
6
6
 
7
- module ViewBuilder
7
+ module AttributesFor
8
8
  # Your code goes here...
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module AttributesFor
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,13 @@
1
+ module AttributesFor
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc "Copy AttributesFor translations"
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ def copy_translations
8
+ copy_file 'attributes_for.en.yml', 'config/locales/attributes_for.en.yml'
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ en:
2
+ attributes_for:
3
+ not_set: "Not set"
4
+ "true": "Yes"
5
+ "false": "No"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attributes_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ole J. Rosendahl
@@ -103,6 +103,8 @@ files:
103
103
  - lib/attributes_for.rb
104
104
  - lib/attributes_for/engine.rb
105
105
  - lib/attributes_for/version.rb
106
+ - lib/generators/attributes_for/install_generator.rb
107
+ - lib/generators/attributes_for/templates/attributes_for.en.yml
106
108
  homepage: https://github.com/blacktangent/attributes_for
107
109
  licenses:
108
110
  - MIT
@@ -114,9 +116,9 @@ require_paths:
114
116
  - app
115
117
  required_ruby_version: !ruby/object:Gem::Requirement
116
118
  requirements:
117
- - - ">="
119
+ - - "~>"
118
120
  - !ruby/object:Gem::Version
119
- version: '0'
121
+ version: '2.0'
120
122
  required_rubygems_version: !ruby/object:Gem::Requirement
121
123
  requirements:
122
124
  - - ">="