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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 260ea022d47abe6fc815926edd9e8137ae722b60
4
- data.tar.gz: b3b4208d2e38f59644e2eea0f3456d1c3b83dfa9
3
+ metadata.gz: 86de0bcc86a8cdcd01e14a91d1efc16871b729c5
4
+ data.tar.gz: 6242cc303e802634fad250bdfb26e1c3ebec7291
5
5
  SHA512:
6
- metadata.gz: 6210752ed6b5253703fc1447d4e0c7c43442b4b6eac0074dcf617f6b02cf289f24f1c3512e3cb3a68ba567efc8711605b1971d600b0b6c314988fa00f4d7d480
7
- data.tar.gz: b38bb182c5b02db3565975757a9cb91552839679b9e45178ea0f7419c88ee1a248afdd183b6fd042aa98e2fa11728e0cd550ce490c070f9812acc07482b3b944
6
+ metadata.gz: 60e796522b8c27a83ba1e53ced0e24ee273f11c378a240fdf99c650856fcb4abf7125fe744e24fcb64a8b7ceec05b0caa0bc3e50aea2660064c745b7ec74b577
7
+ data.tar.gz: 7bf74a9ac05c57cd80f8d4af06217b1b1a9c9c1af9d62709aa47155afaa3824bdf0fa9528949cbc792e629383bf7854d8eabd182c6bb3a4f94726da6881df0a9
data/.rubocop.yml ADDED
@@ -0,0 +1,3 @@
1
+ LineLength:
2
+ Enabled: true
3
+ Max: 79
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
1
  ## v0.0.1
2
2
 
3
3
  * initial release
4
+
5
+ ## v0.0.2
6
+
7
+ * added shortname
8
+
9
+ ## v0.0.3
10
+
11
+ Nothing new. Updated rspec tests to v3.0.
12
+
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 [![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)
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 = "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"
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
@@ -1,5 +1,5 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
 
4
- task :default => :spec
5
- RSpec::Core::RakeTask.new
4
+ task default: :spec
5
+ RSpec::Core::RakeTask.new(:spec)
data/lib/user_fullname.rb CHANGED
@@ -1,5 +1,2 @@
1
- require "user_fullname/model"
2
- require "user_fullname/version"
3
-
4
- module UserFullname
5
- end
1
+ require 'user_fullname/model'
2
+ require 'user_fullname/version'
@@ -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 and array = name.split(/\s/)
46
+ if name
47
+ array = name.split(/\s/)
44
48
  array[order]
45
- end or ""
49
+ end || ''
46
50
  end
47
51
  end
@@ -1,3 +1,4 @@
1
+ # Gem version
1
2
  module UserFullname
2
- VERSION = "0.0.2"
3
+ VERSION = '0.0.3'
3
4
  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
@@ -8,5 +8,5 @@ def rand_name
8
8
  end
9
9
 
10
10
  def rand_fullname
11
- [rand_text, rand_text].map(&:capitalize).join
11
+ "#{rand_name} #{rand_name}"
12
12
  end
@@ -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 "set" do
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
- its(:fullname) do
26
- subject.fullname = @fullname
27
- should eq(@fullname)
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
- its(:fullname) do
31
- subject.firstname = firstname
32
- should eq([firstname, @lastname].join(' '))
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
- its(:fullname) do
36
- subject.lastname = lastname
37
- should eq([@firstname, lastname].join(' '))
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 "get" do
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
- # its(:fullname) { should eq(fullname) }
49
- its(:firstname) { should eq(firstname) }
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
- its(:lastname) do
56
- subject.fullname = "#{firstname} "
57
- should eq("")
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
@@ -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 = "user_fullname"
7
+ spec.name = 'user_fullname'
8
8
  spec.version = UserFullname::VERSION
9
- spec.authors = ["Aleksander Malaszkiewicz"]
10
- spec.email = ["info@fractalsoft.org"]
9
+ spec.authors = ['Aleksander Malaszkiewicz']
10
+ spec.email = ['info@fractalsoft.org']
11
11
  spec.summary = %q{Support user full name}
12
- spec.homepage = "https://github.com/fractalsoft/user_fullname"
13
- spec.license = "MIT"
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 = ["lib"]
18
+ spec.require_paths = ['lib']
19
19
 
20
- spec.add_development_dependency "bundler", "~> 1.3"
21
- spec.add_development_dependency "rake"
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.2
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-08-07 00:00:00.000000000 Z
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.3
87
+ rubygems_version: 2.0.7
87
88
  signing_key:
88
89
  specification_version: 4
89
90
  summary: Support user full name