user_fullname 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +3 -1
- data/README.md +17 -9
- data/Rakefile +3 -3
- data/lib/user_fullname.rb +2 -5
- data/lib/user_fullname/model.rb +6 -2
- data/lib/user_fullname/version.rb +2 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/support/randomizer.rb +1 -1
- data/spec/user_fullname/model_spec.rb +63 -21
- data/user_fullname.gemspec +8 -8
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86de0bcc86a8cdcd01e14a91d1efc16871b729c5
|
4
|
+
data.tar.gz: 6242cc303e802634fad250bdfb26e1c3ebec7291
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60e796522b8c27a83ba1e53ced0e24ee273f11c378a240fdf99c650856fcb4abf7125fe744e24fcb64a8b7ceec05b0caa0bc3e50aea2660064c745b7ec74b577
|
7
|
+
data.tar.gz: 7bf74a9ac05c57cd80f8d4af06217b1b1a9c9c1af9d62709aa47155afaa3824bdf0fa9528949cbc792e629383bf7854d8eabd182c6bb3a4f94726da6881df0a9
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -4,10 +4,12 @@ source 'https://rubygems.org'
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
group :development, :test do
|
7
|
+
gem 'codeclimate-test-reporter', require: nil
|
7
8
|
gem 'coveralls', require: false
|
8
|
-
gem 'rspec'
|
9
|
+
gem 'rspec', '~> 3.0.0.beta1'
|
9
10
|
gem 'reek'
|
10
11
|
gem 'guard'
|
11
12
|
gem 'guard-bundler'
|
12
13
|
gem 'guard-rspec'
|
14
|
+
gem 'rb-readline', '~> 0.5.0', require: false
|
13
15
|
end
|
data/README.md
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
# UserFullname
|
1
|
+
# UserFullname
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/user_fullname.png)](http://badge.fury.io/rb/user_fullname)
|
3
|
+
[![Build Status](https://travis-ci.org/fractalsoft/user_fullname.png?branch=master)](https://travis-ci.org/fractalsoft/user_fullname)
|
4
|
+
[![Dependency Status](https://gemnasium.com/fractalsoft/user_fullname.png)](https://gemnasium.com/fractalsoft/user_fullname)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/fractalsoft/user_fullname/badge.png?branch=master)](https://coveralls.io/r/fractalsoft/user_fullname?branch=master)
|
6
|
+
[![Code Climate](https://codeclimate.com/repos/52823cc489af7e26300298a5/badges/3783c14343942947903f/gpa.png)](https://codeclimate.com/repos/52823cc489af7e26300298a5/feed)
|
7
|
+
[![Stories in Ready](https://badge.waffle.io/fractalsoft/user_fullname.png)](http://waffle.io/fractalsoft/user_fullname)
|
2
8
|
[![endorse](https://api.coderwall.com/torrocus/endorsecount.png)](https://coderwall.com/torrocus)
|
3
9
|
|
4
10
|
User fullname is a gem which support first name, last name and full name. You need only full name in Your database.
|
@@ -24,14 +30,16 @@ class User
|
|
24
30
|
include UserFullname
|
25
31
|
end
|
26
32
|
|
27
|
-
user.fullname =
|
28
|
-
user.firstname #=>
|
29
|
-
user.lastname #=>
|
30
|
-
user.fullname #=>
|
31
|
-
user.
|
32
|
-
user.
|
33
|
-
user.
|
34
|
-
user.
|
33
|
+
user.fullname = 'John Smith'
|
34
|
+
user.firstname #=> 'John'
|
35
|
+
user.lastname #=> 'Smith'
|
36
|
+
user.fullname #=> 'John Smith'
|
37
|
+
user.shortname #=> 'J.Smith'
|
38
|
+
user.firstname = 'Bob'
|
39
|
+
user.fullname #=> 'Bob Smith'
|
40
|
+
user.lastname = 'Marley'
|
41
|
+
user.fullname #=> 'Bob Marley'
|
42
|
+
user.shortname #=> 'B.Marley'
|
35
43
|
```
|
36
44
|
|
37
45
|
## Contributing
|
data/Rakefile
CHANGED
data/lib/user_fullname.rb
CHANGED
data/lib/user_fullname/model.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
|
3
|
+
# The most commonly used user's methods
|
2
4
|
module UserFullname
|
3
5
|
def fullname
|
4
6
|
@fullname = super
|
@@ -34,14 +36,16 @@ module UserFullname
|
|
34
36
|
end
|
35
37
|
|
36
38
|
private
|
39
|
+
|
37
40
|
def update_fullname
|
38
41
|
send(:fullname=, [@firstname, @lastname].join(' '))
|
39
42
|
end
|
40
43
|
|
41
44
|
def parse(order)
|
42
45
|
name = fullname
|
43
|
-
if name
|
46
|
+
if name
|
47
|
+
array = name.split(/\s/)
|
44
48
|
array[order]
|
45
|
-
end
|
49
|
+
end || ''
|
46
50
|
end
|
47
51
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,9 +2,10 @@ require 'user_fullname'
|
|
2
2
|
require 'support/randomizer'
|
3
3
|
require 'coveralls'
|
4
4
|
Coveralls.wear!
|
5
|
+
require 'codeclimate-test-reporter'
|
6
|
+
CodeClimate::TestReporter.start
|
5
7
|
|
6
8
|
RSpec.configure do |config|
|
7
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
8
9
|
config.run_all_when_everything_filtered = true
|
9
10
|
config.filter_run :focus
|
10
11
|
end
|
data/spec/support/randomizer.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
+
# Testing class
|
4
5
|
class DummyClass
|
5
6
|
attr_accessor :fullname
|
6
7
|
|
@@ -12,7 +13,7 @@ class DummyClass
|
|
12
13
|
end
|
13
14
|
|
14
15
|
describe DummyClass do
|
15
|
-
context
|
16
|
+
context 'set' do
|
16
17
|
let(:firstname) { rand_name }
|
17
18
|
let(:lastname) { rand_name }
|
18
19
|
subject { DummyClass.new(rand_fullname) }
|
@@ -22,40 +23,81 @@ describe DummyClass do
|
|
22
23
|
@fullname = [firstname, lastname].join(' ')
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
describe '#fullname' do
|
27
|
+
it do
|
28
|
+
subject.fullname = @fullname
|
29
|
+
expect(subject.fullname).to eq(@fullname)
|
30
|
+
end
|
28
31
|
end
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
describe '#firstname' do
|
34
|
+
it do
|
35
|
+
subject.firstname = firstname
|
36
|
+
expect(subject.fullname).to eq([firstname, @lastname].join(' '))
|
37
|
+
end
|
33
38
|
end
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
|
40
|
+
describe '#lastname' do
|
41
|
+
it do
|
42
|
+
subject.lastname = lastname
|
43
|
+
expect(subject.fullname).to eq([@firstname, lastname].join(' '))
|
44
|
+
end
|
38
45
|
end
|
39
46
|
end
|
40
47
|
|
41
|
-
context
|
48
|
+
context 'get' do
|
42
49
|
let(:firstname) { rand_name }
|
43
50
|
let(:lastname) { rand_name }
|
44
51
|
let(:fullname) { [firstname, lastname].join(' ') }
|
45
52
|
let(:shortname) { "#{firstname[0]}.#{lastname}" }
|
46
53
|
subject { DummyClass.new(fullname) }
|
47
54
|
|
48
|
-
#
|
49
|
-
|
50
|
-
its(:lastname) { should eq(lastname) }
|
51
|
-
its(:firstname) do
|
52
|
-
subject.fullname = " #{lastname}"
|
53
|
-
should eq("")
|
55
|
+
describe '#fullname' do
|
56
|
+
it { expect(subject.fullname).to eq(fullname) }
|
54
57
|
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
+
|
59
|
+
describe '#firstname' do
|
60
|
+
it { expect(subject.firstname).to eq(firstname) }
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#lastname' do
|
64
|
+
it { expect(subject.lastname).to eq(lastname) }
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#shortname' do
|
68
|
+
it { expect(subject.shortname).to eq(shortname) }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#firstname' do
|
72
|
+
it do
|
73
|
+
subject.fullname = " #{lastname}"
|
74
|
+
expect(subject.firstname).to eq('')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#lastname' do
|
79
|
+
it do
|
80
|
+
subject.fullname = "#{firstname} "
|
81
|
+
expect(subject.lastname).to eq('')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe 'long name' do
|
87
|
+
it 'double firstname' do
|
88
|
+
names = 'David Lee Roth'
|
89
|
+
subject.fullname = 'David Lee Roth'
|
90
|
+
# subject.firstname = 'David Lee'
|
91
|
+
# subject.lastname = 'Roth'
|
92
|
+
expect(subject.fullname).to eq(names)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'double lastname' do
|
96
|
+
names = 'Abraham Van Helsing'
|
97
|
+
subject.fullname = names
|
98
|
+
# subject.firstname = 'Abraham'
|
99
|
+
# subject.lastname = 'Van Helsing'
|
100
|
+
expect(subject.fullname).to eq(names)
|
58
101
|
end
|
59
|
-
its(:shortname) { should eq(shortname) }
|
60
102
|
end
|
61
103
|
end
|
data/user_fullname.gemspec
CHANGED
@@ -4,19 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'user_fullname/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'user_fullname'
|
8
8
|
spec.version = UserFullname::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Aleksander Malaszkiewicz']
|
10
|
+
spec.email = ['info@fractalsoft.org']
|
11
11
|
spec.summary = %q{Support user full name}
|
12
|
-
spec.homepage =
|
13
|
-
spec.license =
|
12
|
+
spec.homepage = 'https://github.com/fractalsoft/user_fullname'
|
13
|
+
spec.license = 'MIT'
|
14
14
|
|
15
15
|
spec.files = `git ls-files`.split($/)
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
-
spec.require_paths = [
|
18
|
+
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.add_development_dependency
|
21
|
-
spec.add_development_dependency
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
21
|
+
spec.add_development_dependency 'rake'
|
22
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: user_fullname
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksander Malaszkiewicz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -47,6 +47,7 @@ extra_rdoc_files: []
|
|
47
47
|
files:
|
48
48
|
- .gitignore
|
49
49
|
- .rspec
|
50
|
+
- .rubocop.yml
|
50
51
|
- .ruby-gemset
|
51
52
|
- .ruby-version
|
52
53
|
- .travis.yml
|
@@ -83,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
84
|
version: '0'
|
84
85
|
requirements: []
|
85
86
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.0.
|
87
|
+
rubygems_version: 2.0.7
|
87
88
|
signing_key:
|
88
89
|
specification_version: 4
|
89
90
|
summary: Support user full name
|