user_fullname 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +13 -0
- data/Guardfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +5 -0
- data/lib/user_fullname/model.rb +42 -0
- data/lib/user_fullname/version.rb +3 -0
- data/lib/user_fullname.rb +5 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/randomizer.rb +12 -0
- data/spec/user_fullname/model_spec.rb +59 -0
- data/user_fullname.gemspec +22 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e8f55008a0e84046eb048435fa145da34ffa8a2d
|
4
|
+
data.tar.gz: 1569c991aabac797010ead15a24675332e83d049
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d1f6cb4ead952609fc08c01ed6c00a545477e77eb33fbf7e582afb89dc6367fced8204d799465a2264a9be3d33d2b6f6c3d6a1f71ad5e0250263615b16412bef
|
7
|
+
data.tar.gz: d38ce58d5641cfe4b3ccfc30619e432e2ced708902119e716fd8098749df17f5dd1fa91afe5adf05233baf40b7b9655a6e1124d829c91969197107668eb39d9e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
user_fullname
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in user_fullname.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development, :test do
|
7
|
+
gem 'coveralls', require: false
|
8
|
+
gem 'rspec'
|
9
|
+
gem 'reek'
|
10
|
+
gem 'guard'
|
11
|
+
gem 'guard-bundler'
|
12
|
+
gem 'guard-rspec'
|
13
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
guard 'bundler' do
|
2
|
+
watch('Gemfile')
|
3
|
+
watch(/^.+\.gemspec/)
|
4
|
+
end
|
5
|
+
|
6
|
+
guard :rspec do
|
7
|
+
watch(%r{^spec/.+_spec\.rb$})
|
8
|
+
watch(%r{^lib/(.+)\.rb$}) do |array|
|
9
|
+
name = array.last
|
10
|
+
"spec/#{name}_spec.rb"
|
11
|
+
end
|
12
|
+
watch('spec/spec_helper.rb') { "spec" }
|
13
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Fractal Soft
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# UserFullname [![Gem Version](https://badge.fury.io/rb/user_fullname.png)](http://badge.fury.io/rb/user_fullname) [![Build Status](https://travis-ci.org/fractalsoft/user_fullname.png)](https://travis-ci.org/fractalsoft/user_fullname) [![Dependency Status](https://gemnasium.com/fractalsoft/user_fullname.png)](https://gemnasium.com/fractalsoft/user_fullname) [![Coverage Status](https://coveralls.io/repos/fractalsoft/user_fullname/badge.png)](https://coveralls.io/r/fractalsoft/user_fullname) [![Stories in Ready](https://badge.waffle.io/fractalsoft/user_fullname.png)](http://waffle.io/fractalsoft/user_fullname)
|
2
|
+
[![endorse](https://api.coderwall.com/torrocus/endorsecount.png)](https://coderwall.com/torrocus)
|
3
|
+
|
4
|
+
User fullname is a gem which support first name, last name and full name. You need only full name in Your database.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'user_fullname'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install user_fullname
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
class User
|
24
|
+
include UserFullname
|
25
|
+
end
|
26
|
+
|
27
|
+
user.fullname = "John Smith"
|
28
|
+
user.firstname #=> "John"
|
29
|
+
user.lastname #=> "Smith"
|
30
|
+
user.fullname #=> "John Smith"
|
31
|
+
user.firstname = "Bob"
|
32
|
+
user.fullname #=> "Bob Smith"
|
33
|
+
user.lastname = "Marley"
|
34
|
+
user.fullname #=> "Bob Marley"
|
35
|
+
```
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
43
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module UserFullname
|
3
|
+
def fullname
|
4
|
+
@fullname = super
|
5
|
+
end
|
6
|
+
|
7
|
+
def fullname=(value)
|
8
|
+
array = value.split /\s/
|
9
|
+
@firstname, @lastname = array[0], array[1]
|
10
|
+
@fullname = value
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def firstname
|
15
|
+
name = fullname
|
16
|
+
@firstname = if name and array = name.split(/\s/)
|
17
|
+
array[0]
|
18
|
+
end or ""
|
19
|
+
end
|
20
|
+
|
21
|
+
def firstname=(value)
|
22
|
+
@firstname, @lastname = value, lastname
|
23
|
+
update_fullname
|
24
|
+
end
|
25
|
+
|
26
|
+
def lastname
|
27
|
+
name = fullname
|
28
|
+
@lastname = if name and array = name.split(/\s/)
|
29
|
+
array[1]
|
30
|
+
end or ""
|
31
|
+
end
|
32
|
+
|
33
|
+
def lastname=(value)
|
34
|
+
@firstname, @lastname = firstname, value
|
35
|
+
update_fullname
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def update_fullname
|
40
|
+
send(:fullname=, [@firstname, @lastname].join(' '))
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'user_fullname'
|
2
|
+
require 'support/randomizer'
|
3
|
+
require 'coveralls'
|
4
|
+
Coveralls.wear!
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
8
|
+
config.run_all_when_everything_filtered = true
|
9
|
+
config.filter_run :focus
|
10
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
class DummyClass
|
5
|
+
attr_accessor :fullname
|
6
|
+
|
7
|
+
def initialize(fullname = nil)
|
8
|
+
@fullname = fullname
|
9
|
+
end
|
10
|
+
|
11
|
+
include UserFullname
|
12
|
+
end
|
13
|
+
|
14
|
+
describe DummyClass do
|
15
|
+
context "set" do
|
16
|
+
let(:firstname) { rand_name }
|
17
|
+
let(:lastname) { rand_name }
|
18
|
+
subject { DummyClass.new(rand_fullname) }
|
19
|
+
|
20
|
+
before do
|
21
|
+
@firstname, @lastname = subject.firstname, subject.lastname
|
22
|
+
@fullname = [firstname, lastname].join(' ')
|
23
|
+
end
|
24
|
+
|
25
|
+
its(:fullname) do
|
26
|
+
subject.fullname = @fullname
|
27
|
+
should eq(@fullname)
|
28
|
+
end
|
29
|
+
|
30
|
+
its(:fullname) do
|
31
|
+
subject.firstname = firstname
|
32
|
+
should eq([firstname, @lastname].join(' '))
|
33
|
+
end
|
34
|
+
|
35
|
+
its(:fullname) do
|
36
|
+
subject.lastname = lastname
|
37
|
+
should eq([@firstname, lastname].join(' '))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "get" do
|
42
|
+
let(:firstname) { rand_name }
|
43
|
+
let(:lastname) { rand_name }
|
44
|
+
let(:fullname) { [firstname, lastname].join(' ') }
|
45
|
+
subject { DummyClass.new(fullname) }
|
46
|
+
|
47
|
+
# its(:fullname) { should eq(fullname) }
|
48
|
+
its(:firstname) { should eq(firstname) }
|
49
|
+
its(:lastname) { should eq(lastname) }
|
50
|
+
its(:firstname) do
|
51
|
+
subject.fullname = " #{lastname}"
|
52
|
+
should eq("")
|
53
|
+
end
|
54
|
+
its(:lastname) do
|
55
|
+
subject.fullname = "#{firstname} "
|
56
|
+
should eq("")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'user_fullname/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "user_fullname"
|
8
|
+
spec.version = UserFullname::VERSION
|
9
|
+
spec.authors = ["Aleksander Malaszkiewicz"]
|
10
|
+
spec.email = ["info@fractalsoft.org"]
|
11
|
+
spec.summary = %q{Support user full name}
|
12
|
+
spec.homepage = "https://github.com/fractalsoft/user_fullname"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: user_fullname
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aleksander Malaszkiewicz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- info@fractalsoft.org
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- .rspec
|
50
|
+
- .ruby-gemset
|
51
|
+
- .ruby-version
|
52
|
+
- .travis.yml
|
53
|
+
- CHANGELOG.md
|
54
|
+
- Gemfile
|
55
|
+
- Guardfile
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- lib/user_fullname.rb
|
60
|
+
- lib/user_fullname/model.rb
|
61
|
+
- lib/user_fullname/version.rb
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
- spec/support/randomizer.rb
|
64
|
+
- spec/user_fullname/model_spec.rb
|
65
|
+
- user_fullname.gemspec
|
66
|
+
homepage: https://github.com/fractalsoft/user_fullname
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.0.3
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Support user full name
|
90
|
+
test_files:
|
91
|
+
- spec/spec_helper.rb
|
92
|
+
- spec/support/randomizer.rb
|
93
|
+
- spec/user_fullname/model_spec.rb
|