mini_form 0.2.2 → 0.2.3

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: 9f69131f99de959569d9b4b360947dad2bbbe6f2
4
- data.tar.gz: 255a876b2e2db8acef095b09fc04f88dfd6f569d
3
+ metadata.gz: af66d71eb698d18223627223fcdd23773c8c44ed
4
+ data.tar.gz: b230cebf0fca7e3287487ab88c3eeae7b8e98063
5
5
  SHA512:
6
- metadata.gz: 3ccb5acd482370f7d2addf843de97d241c3e536c0721797e1b8b53e12a1fe4e1c16983e8b26719349bb40c02287624cfe1a8d8f316aea095b9260523ee7924e5
7
- data.tar.gz: f009f2a287a9fdc3e7694f2c376cb54cc4e4c71ca3a23c7b5a62335f870a05c17ede5ed859367e0c0f7948cf40cd3b90b7cfc0ce76edb02bc19cc2f2d234ae5c
6
+ metadata.gz: b6487e2c427e3e427b140d71830f8a54cc180d4a2db00dce7d414171f729aea38a261c400c5487804fa972a4f13d42ee21312c88fc191c324ed6bff3833f568c
7
+ data.tar.gz: 645b04ee90f9514b74af2e0fecf2cf83f9a15ecd33be71e3849209f4023424f33ac39acad741992cacad0ea19834490f3d12756e78db3c2a05514472a20cb9f3
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .vimrc.local
@@ -0,0 +1,8 @@
1
+ {
2
+ "lib/*.rb": {
3
+ "alternate": "spec/{}_spec.rb"
4
+ },
5
+ "spec/*_spec.rb": {
6
+ "alternate": "lib/{}.rb"
7
+ },
8
+ }
@@ -39,6 +39,10 @@ Style/EachWithObject:
39
39
  Style/CollectionMethods:
40
40
  Enabled: false
41
41
 
42
+ # Disables "%i-literals should be delimited by [ and ]."
43
+ Style/PercentLiteralDelimiters:
44
+ Enabled: false
45
+
42
46
  # Disables "Use tr instead of gsubs"
43
47
  Performance/StringReplacement:
44
48
  Enabled: false
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.2.3
4
+
5
+
6
+ * Fix handling delegated attributes prefixes in `attribute_names` (@rstankov)
7
+
3
8
  ## Version 0.2.2
4
9
 
5
10
  * Bump activemodel requirements (@vestimir)
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- [![Gem Version](https://badge.fury.io/rb/mini_form.png)](http://badge.fury.io/rb/mini_form)
2
- [![Code Climate](https://codeclimate.com/github/RStankov/MiniForm.png)](https://codeclimate.com/github/RStankov/MiniForm)
3
- [![Build Status](https://secure.travis-ci.org/RStankov/MiniForm.png)](http://travis-ci.org/RStankov/MiniForm)
4
- [![Code coverage](https://coveralls.io/repos/RStankov/MiniForm/badge.png?branch=master)](https://coveralls.io/r/RStankov/MiniForm)
1
+ [![Gem Version](https://badge.fury.io/rb/mini_form.svg)](http://badge.fury.io/rb/mini_form)
2
+ [![Code Climate](https://codeclimate.com/github/RStankov/MiniForm.svg)](https://codeclimate.com/github/RStankov/MiniForm)
3
+ [![Build Status](https://secure.travis-ci.org/RStankov/MiniForm.svg)](http://travis-ci.org/RStankov/MiniForm)
4
+ [![Code coverage](https://coveralls.io/repos/RStankov/MiniForm/badge.svg?branch=master)](https://coveralls.io/r/RStankov/MiniForm)
5
5
 
6
6
  # MiniForm
7
7
 
data/Rakefile CHANGED
@@ -5,4 +5,4 @@ require 'rubocop/rake_task'
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
  RuboCop::RakeTask.new(:rubocop)
7
7
 
8
- task default: [:rubocop, :spec]
8
+ task default: %i(rubocop spec)
@@ -140,7 +140,13 @@ module MiniForm
140
140
  end
141
141
 
142
142
  def attributes(*attributes, delegate: nil, prefix: nil, allow_nil: nil)
143
- attribute_names.push(*attributes)
143
+ if prefix
144
+ attribute_names.push(*attributes.map do |name|
145
+ :"#{prefix == true ? delegate : prefix}_#{name}"
146
+ end)
147
+ else
148
+ attribute_names.push(*attributes)
149
+ end
144
150
 
145
151
  if delegate.nil?
146
152
  attr_accessor(*attributes)
@@ -1,3 +1,3 @@
1
1
  module MiniForm
2
- VERSION = '0.2.2'.freeze
2
+ VERSION = '0.2.3'.freeze
3
3
  end
@@ -1,5 +1,5 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
2
+
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'mini_form/version'
5
5
 
@@ -24,6 +24,8 @@ module MiniForm
24
24
  attr_reader :user
25
25
 
26
26
  attributes :name, delegate: :user
27
+ attributes :id, delegate: :user, prefix: true
28
+ attributes :name, delegate: :user, prefix: 'full'
27
29
 
28
30
  def initialize(user)
29
31
  @user = user
@@ -140,6 +142,11 @@ module MiniForm
140
142
  it 'returns attribute names' do
141
143
  expect(Example.attribute_names).to eq %i(name price)
142
144
  end
145
+
146
+ it 'can handle prefixes' do
147
+ expect(ExampleWithDelegate.attribute_names).to include :user_id
148
+ expect(ExampleWithDelegate.attribute_names).to include :full_name
149
+ end
143
150
  end
144
151
 
145
152
  describe '#initialize' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radoslav Stankov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-16 00:00:00.000000000 Z
11
+ date: 2017-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -130,6 +130,7 @@ extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
132
  - ".gitignore"
133
+ - ".projections.json"
133
134
  - ".rspec"
134
135
  - ".rubocop.yml"
135
136
  - ".travis.yml"
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  version: '0'
168
169
  requirements: []
169
170
  rubyforge_project:
170
- rubygems_version: 2.4.5
171
+ rubygems_version: 2.6.13
171
172
  signing_key:
172
173
  specification_version: 4
173
174
  summary: Easy to use form objects in Rails projects