acts_as_human 2.0.3 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a950ba969bc9f0a560ade5b08edf808cde77a4f0
4
+ data.tar.gz: 8e23fc7eb40b9b3d51f049eb700b10353745f101
5
+ SHA512:
6
+ metadata.gz: fd1fabbbdbfd264df1e65030a4e5cf3766c53aa8f33b9bc22ef06ef4a4f42640503c70e6409a1f22da138d6806a09715399515c20e20ea2b5270f4f8708958e2
7
+ data.tar.gz: 2d3b5f07916779123855419b3177b41984ab3f7d369e05a802fa1161e53109fe0c9ec36b05039643b9aebcc81206f2433eb78f55ce8881f44162b3caeb35d584
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1 @@
1
+ acts_as_human
@@ -0,0 +1 @@
1
+ ruby-2.4.2
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.15.4
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in acts_as_human.gemspec
6
+ gemspec
@@ -0,0 +1,47 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ clearing :on
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ watch(%r{^lib/acts_as_human/(.+)\.rb}) do
40
+ "spec/acts_as_human_spec.rb"
41
+ end
42
+
43
+ # Ruby files
44
+ ruby = dsl.ruby
45
+ dsl.watch_spec_files_for(ruby.lib_files)
46
+
47
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Brent
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,72 @@
1
+ # ActsAsHuman
2
+
3
+ class User < ActiveRecord::Base
4
+ # t.string "first_name"
5
+ # t.string "middle_names"
6
+ # t.string "last_name"
7
+
8
+ acts_as_human
9
+ end
10
+
11
+ Supplying first and last names separately:
12
+ `user = User.new(first_name: 'Brent', last_name: 'Greeff')`
13
+
14
+ You can then read the full_name
15
+
16
+ user.full_name
17
+ => "Brent Greeff"
18
+
19
+ Supplying a full_name:
20
+ `user = User.new(full_name: "Brent Wicked Middle Names Greeff")`
21
+
22
+ You can then read the individual names:
23
+
24
+ user.first_name
25
+ => "Brent"
26
+
27
+ user.last_name
28
+ => "Greeff"
29
+
30
+ user.middle_names
31
+ => "Wicked Middle Names"
32
+
33
+
34
+ Enable users to provide their full name in a single text input.
35
+ Saves to 3 separate fields:
36
+ first_name, middle_names and last_name allowing you to easily display their name
37
+ in different formats in different places.
38
+
39
+ Validations limit each name field to 40 characters each, allowing a total length of 120 characters for the full name.
40
+ Non-name like characters are invalid.
41
+
42
+ ## Bundler
43
+
44
+ gem acts_as_human
45
+
46
+ * Adds `full_name` and `full_name=` instance methods to a model.
47
+
48
+ Adds validations to ensure that the names are reasonable.
49
+
50
+ * Requires:
51
+ first_name, last_name and middle_names columns in the database.
52
+
53
+ ## Migration
54
+
55
+ bundle exec acts_as_human migration users
56
+
57
+ Change "users" to the name of your existing table.
58
+
59
+
60
+ ## Contributing
61
+
62
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/acts_as_human.
63
+
64
+ ## License
65
+
66
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
67
+
68
+ ## Development
69
+
70
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
71
+
72
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
data/Rakefile CHANGED
@@ -1,23 +1,6 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
4
3
 
5
- desc 'Default: run unit tests.'
6
- task :default => :test
4
+ RSpec::Core::RakeTask.new(:spec)
7
5
 
8
- desc 'Test the acts_as_human plugin.'
9
- Rake::TestTask.new(:test) do |t|
10
- t.libs << 'lib'
11
- t.libs << 'test'
12
- t.pattern = 'test/**/*_test.rb'
13
- t.verbose = true
14
- end
15
-
16
- desc 'Generate documentation for the acts_as_human plugin.'
17
- Rake::RDocTask.new(:rdoc) do |rdoc|
18
- rdoc.rdoc_dir = 'rdoc'
19
- rdoc.title = 'ActsAsHuman'
20
- rdoc.options << '--line-numbers' << '--inline-source'
21
- rdoc.rdoc_files.include('README')
22
- rdoc.rdoc_files.include('lib/**/*.rb')
23
- end
6
+ task :default => :spec
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "acts_as_human/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{acts_as_human}
8
+ s.version = ActsAsHuman::VERSION
9
+ s.authors = ["Brent"]
10
+ s.email = ["brentgreeff@gmail.com"]
11
+
12
+ s.summary = %q{Rails plugin to handle first_name, middle_names and last_name combinations.}
13
+ s.homepage = %q{http://github.com/brentgreeff/acts_as_human}
14
+ s.license = "MIT"
15
+
16
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ s.bindir = "exe"
20
+ s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_development_dependency "activesupport", "~> 5.1"
24
+ s.add_development_dependency "activerecord", "~> 5.1"
25
+ s.add_development_dependency "sqlite3"
26
+
27
+ s.add_development_dependency "bundler", "~> 1.15"
28
+ s.add_development_dependency "rake", "~> 10.0"
29
+ s.add_development_dependency "rspec", "~> 3.0"
30
+ s.add_development_dependency "guard-rspec"
31
+ s.add_development_dependency "cucumber"
32
+ s.add_development_dependency "aruba"
33
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+
5
+ require 'active_support'
6
+ require 'active_record'
7
+ require './spec/init_schema'
8
+
9
+ require "acts_as_human"
10
+
11
+ require "pry"
12
+ Pry.start
13
+
14
+ # require "irb"
15
+ # IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'acts_as_human/cli'
4
+ ActsAsHuman::CLI.start
File without changes
@@ -1,48 +1,41 @@
1
1
  module ActsAs
2
2
  module Human
3
- mattr_accessor :acceptable_name, :bad_name_message
4
-
5
- self.acceptable_name = /\A[^[:cntrl:]\\<>\/&]*\z/
6
- self.bad_name_message = "some characters in your name are not allowed".freeze
7
-
8
- def self.included(base)
9
- base.send :extend, ClassMethods
10
- end
11
-
12
3
  module ClassMethods
13
-
4
+
14
5
  def acts_as_human(options={})
15
6
  cattr_accessor :require_last_name
16
-
7
+
17
8
  if options.has_key? :require_last_name
18
- @require_last_name = options[:require_last_name]
9
+ self.require_last_name = options[:require_last_name]
19
10
  else
20
- @require_last_name = true
11
+ self.require_last_name = true
21
12
  end
22
- send :include, InstanceMethods
23
-
13
+
24
14
  class_eval do
25
- validates_presence_of :first_name, :message => 'first name is required'
26
- validates_length_of :first_name, :maximum => 40,
27
- :message => 'first name is too long (max 40 characters)'
28
- validates_as_person_name :first_name
29
-
30
- validates_length_of :middle_names, :maximum => 40,
31
- :allow_blank => true,
32
- :message => 'middle names are too long (max 40 characters)'
33
- validates_as_person_name :middle_names, :allow_nil => true
34
-
35
- validates_presence_of :last_name, :if => Proc.new { @require_last_name },
36
- :message => 'last name is required'
37
- validates_length_of :last_name, :maximum => 40,
38
- :allow_blank => true,
39
- :message => 'last name is too long (max 40 characters)'
40
- validates_as_person_name :last_name
15
+ validates_presence_of :first_name, message: 'first name is required'
16
+ validates_length_of :first_name, maximum: 40,
17
+ message: 'first name is too long (max 40 characters)'
18
+
19
+ validates_as_person_name :first_name
20
+
21
+ validates_length_of :middle_names, maximum: 40,
22
+ allow_blank: true,
23
+ message: 'middle names are too long (max 40 characters)'
24
+
25
+ validates_as_person_name :middle_names, allow_nil: true
26
+
27
+ validates_presence_of :last_name, if: -> { self.require_last_name },
28
+ message: 'last name is required'
29
+
30
+ validates_length_of :last_name, maximum: 40,
31
+ allow_blank: true,
32
+ message: 'last name is too long (max 40 characters)'
33
+
34
+ validates_as_person_name :last_name
41
35
  end
42
36
  end
43
37
  end
44
38
  end
45
39
  end
46
40
 
47
- ActiveRecord::Base.send(:include, ActsAs::Human)
48
-
41
+ ActiveRecord::Base.send(:extend, ActsAs::Human::ClassMethods)
@@ -0,0 +1,16 @@
1
+ require 'active_support'
2
+ require 'active_record'
3
+ require 'acts_as_human'
4
+ require 'thor'
5
+ require 'acts_as_human/generators/migration'
6
+
7
+ module ActsAsHuman
8
+
9
+ class CLI < Thor
10
+
11
+ desc "migration", "Generates migration to add name fields"
12
+ def migration( table_name )
13
+ Generators::Migration.start( [table_name] )
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ module ActsAsHuman
2
+
3
+ module Generators
4
+
5
+ class Migration < Thor::Group
6
+ include Thor::Actions
7
+
8
+ argument :table_name, type: :string
9
+
10
+ def self.source_root
11
+ File.dirname(__FILE__) + '/migration'
12
+ end
13
+
14
+ def copy_migration
15
+ time = ActiveRecord::Migration.next_migration_number(1)
16
+ file = "db/migrate/#{time}_add_names_to_#{table_name}.rb"
17
+ template("migration.rb", file)
18
+ puts 'Migration created'
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ class AddNamesTo<%= table_name.capitalize %> < ActiveRecord::Migration[5.1]
2
+
3
+ def change
4
+ add_column :<%= table_name %>, :first_name, :string
5
+ add_column :<%= table_name %>, :middle_names, :string
6
+ add_column :<%= table_name %>, :last_name, :string
7
+ end
8
+ end
@@ -1,27 +1,27 @@
1
1
  module ActsAs
2
2
  module Human
3
-
3
+
4
4
  module InstanceMethods
5
5
  def full_name
6
6
  return '' if first_name.blank? and last_name.blank?
7
-
7
+
8
8
  return "#{first_name} #{last_name}" if middle_names.blank?
9
9
  return "#{first_name} #{middle_names} #{last_name}"
10
10
  end
11
-
11
+
12
12
  def full_name=(names)
13
13
  names_array = names.titlecase.split
14
-
14
+
15
15
  self.first_name = names_array.first
16
16
  return if names_array.size < 2
17
-
17
+
18
18
  self.last_name = get_last_name(names_array)
19
-
19
+
20
20
  assign_middle_names(names_array)
21
21
  end
22
-
22
+
23
23
  private
24
-
24
+
25
25
  def get_last_name(names_array)
26
26
  if names_array.size > 2 and names_array[-2].eql? 'Mc'
27
27
  surname = names_array.pop
@@ -29,7 +29,7 @@ module ActsAs
29
29
  end
30
30
  names_array.last
31
31
  end
32
-
32
+
33
33
  def assign_middle_names(names_array)
34
34
  if names_array.size > 2
35
35
  self.middle_names = get_middle_names(names_array)
@@ -37,7 +37,7 @@ module ActsAs
37
37
  self.middle_names = nil
38
38
  end
39
39
  end
40
-
40
+
41
41
  def get_middle_names(names_array)
42
42
  names_array[1..(names_array.size-2)].join(' ')
43
43
  end
@@ -45,3 +45,4 @@ module ActsAs
45
45
  end
46
46
  end
47
47
 
48
+ ActiveRecord::Base.send(:include, ActsAs::Human::InstanceMethods)
@@ -1,22 +1,30 @@
1
+ module ActsAs
2
+ module Human
3
+ mattr_accessor :acceptable_name, :bad_name_message
4
+
5
+ self.acceptable_name = /\A[^[:cntrl:]\\<>\/&]*\z/
6
+ self.bad_name_message = "some characters in your name are not allowed".freeze
7
+ end
8
+ end
9
+
1
10
  module ActiveRecord
2
11
  module Validations
3
12
  module ClassMethods
4
-
13
+
5
14
  def validates_as_person_name(*attr_names)
6
15
  config = {
7
- :with => ActsAs::Human.acceptable_name,
8
- :message => ActsAs::Human.bad_name_message
16
+ with: ActsAs::Human.acceptable_name,
17
+ message: ActsAs::Human.bad_name_message
9
18
  }
10
19
  check_format(attr_names, config)
11
20
  end
12
-
21
+
13
22
  private
14
-
23
+
15
24
  def check_format(attr_names, config)
16
25
  config.update(attr_names.pop) if attr_names.last.is_a?(Hash)
17
26
  validates_format_of attr_names, config
18
27
  end
19
-
20
28
  end
21
29
  end
22
30
  end
@@ -0,0 +1,3 @@
1
+ module ActsAsHuman
2
+ VERSION = "3.0.2"
3
+ end
metadata CHANGED
@@ -1,79 +1,193 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: acts_as_human
3
- version: !ruby/object:Gem::Version
4
- hash: 9
5
- prerelease: false
6
- segments:
7
- - 2
8
- - 0
9
- - 3
10
- version: 2.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.2
11
5
  platform: ruby
12
- authors:
13
- - Brent Greeff
6
+ authors:
7
+ - Brent
14
8
  autorequire:
15
- bindir: bin
9
+ bindir: exe
16
10
  cert_chain: []
17
-
18
- date: 2010-11-15 00:00:00 +00:00
19
- default_executable:
20
- dependencies: []
21
-
22
- description: Rails plugin to handle first_name, middle_names and last_name combinations.
23
- email: email@brentgreeff.com
24
- executables: []
25
-
11
+ date: 2017-10-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.1'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.15'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.15'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: cucumber
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: aruba
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description:
140
+ email:
141
+ - brentgreeff@gmail.com
142
+ executables:
143
+ - acts_as_human
26
144
  extensions: []
27
-
28
- extra_rdoc_files:
29
- - MIT-LICENSE
30
- - README.rdoc
31
- files:
32
- - MIT-LICENSE
33
- - README.rdoc
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".ruby-gemset"
150
+ - ".ruby-version"
151
+ - ".travis.yml"
152
+ - Gemfile
153
+ - Guardfile
154
+ - LICENSE.txt
155
+ - README.md
34
156
  - Rakefile
35
- - VERSION
157
+ - acts_as_human.gemspec
158
+ - bin/console
159
+ - bin/setup
160
+ - exe/acts_as_human
36
161
  - lib/acts_as_human.rb
37
- - lib/acts_as_human/validations.rb
38
- - lib/acts_as_human/instance_methods.rb
39
162
  - lib/acts_as_human/class_methods.rb
40
- - test/acts_as_human_test.rb
41
- - test/database.yml
42
- - test/schema.rb
43
- - test/test_helper.rb
44
- has_rdoc: true
163
+ - lib/acts_as_human/cli.rb
164
+ - lib/acts_as_human/generators/migration.rb
165
+ - lib/acts_as_human/generators/migration/migration.rb
166
+ - lib/acts_as_human/instance_methods.rb
167
+ - lib/acts_as_human/validations.rb
168
+ - lib/acts_as_human/version.rb
45
169
  homepage: http://github.com/brentgreeff/acts_as_human
46
- licenses: []
47
-
170
+ licenses:
171
+ - MIT
172
+ metadata: {}
48
173
  post_install_message:
49
- rdoc_options:
50
- - --charset=UTF-8
51
- require_paths:
174
+ rdoc_options: []
175
+ require_paths:
52
176
  - lib
53
- required_ruby_version: !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
177
+ required_ruby_version: !ruby/object:Gem::Requirement
178
+ requirements:
56
179
  - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
62
- required_rubygems_version: !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ required_rubygems_version: !ruby/object:Gem::Requirement
183
+ requirements:
65
184
  - - ">="
66
- - !ruby/object:Gem::Version
67
- hash: 3
68
- segments:
69
- - 0
70
- version: "0"
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
71
187
  requirements: []
72
-
73
188
  rubyforge_project:
74
- rubygems_version: 1.3.7
189
+ rubygems_version: 2.6.13
75
190
  signing_key:
76
- specification_version: 3
191
+ specification_version: 4
77
192
  summary: Rails plugin to handle first_name, middle_names and last_name combinations.
78
193
  test_files: []
79
-
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 [Brent Greeff]
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,46 +0,0 @@
1
- = ActsAsHuman
2
-
3
- == Install
4
- Use the Gem:
5
-
6
- gem install acts_as_human
7
-
8
- With braid:
9
-
10
- braid add git://github.com/brentgreeff/acts_as_human.git -p
11
-
12
-
13
- * Adds:
14
- full_name
15
- * and
16
- full_name=
17
- instance methods to a model
18
-
19
- Adds validations to ensure that the names are reasonable.
20
-
21
- * Requires:
22
- first_name, last_name and middle_names columns on the model
23
-
24
- @todo Need to add rake task to add fields to model.
25
-
26
- == Example
27
-
28
- class User < ActiveRecord::Base
29
- acts_as_human
30
- end
31
-
32
- * user = User.new(:first_name => 'Brent', :last_name => 'Greeff')
33
- user.full_name
34
- => "Brent Greeff"
35
-
36
- * user = User.new(:full_name => "Brent Wicked Middle Names Greeff")
37
- user.first_name
38
- => "Brent"
39
-
40
- user.last_name
41
- => "Greeff"
42
-
43
- user.middle_names
44
- => "Wicked Middle Names"
45
-
46
- Copyright (c) 2009 [Brent Greeff], released under the MIT license
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 2.0.2
@@ -1,145 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class ActsAsHumanTest < ActiveSupport::TestCase
4
-
5
- class User < ActiveRecord::Base
6
- acts_as_human
7
- end
8
-
9
- class Customer < ActiveRecord::Base
10
- acts_as_human :require_last_name => false
11
- end
12
-
13
- test "should require a first name" do
14
- user = create_user
15
- user.first_name = ''
16
-
17
- deny user.valid?, 'Should not be valid without a first name'
18
- assert_equal 'first name is required', user.errors[:first_name]
19
- end
20
-
21
- test "should have a first name that is less than 40 characters" do
22
- user = User.new(:first_name => 'aaaaabbbbbcccccdddddeeeeefffffggggghhhhhi')
23
-
24
- deny user.valid?
25
- assert_equal 'first name is too long (max 40 characters)', user.errors[:first_name]
26
- end
27
-
28
- test "should require a last name" do
29
- user = User.new(:first_name => 'Brent')
30
-
31
- deny user.valid?
32
- assert_equal 'last name is required', user.errors[:last_name]
33
- end
34
-
35
- test "should not require a last name if it is not required" do
36
- someone_else = Customer.new(:first_name => 'Brent')
37
- assert someone_else.valid?
38
- end
39
-
40
- test "should have a last name that is less than 40 characters" do
41
- user = create_user
42
- user.last_name = 'aaaaabbbbbcccccdddddeeeeefffffggggghhhhhi'
43
-
44
- deny user.valid?
45
- assert_equal 'last name is too long (max 40 characters)', user.errors[:last_name]
46
- end
47
-
48
- test "should have a last name when assigned through full name" do
49
- user = User.new(:full_name => 'Brent')
50
-
51
- deny user.valid?
52
- assert_equal 'last name is required', user.errors[:last_name]
53
- end
54
-
55
- test "should have a full name composed of first and last names" do
56
- user = User.new(:first_name => 'Brent', :last_name => 'Greeff')
57
- assert_equal 'Brent Greeff', user.full_name
58
- end
59
-
60
- test "should have a full name composed of first middle and last names" do
61
- user = User.new(
62
- :first_name => 'Brent',
63
- :middle_names => 'Middle Names',
64
- :last_name => 'Greeff'
65
- )
66
- assert_equal 'Brent Middle Names Greeff', user.full_name
67
- end
68
-
69
- test "should assign first and last name when assigning to full name" do
70
- user = User.new(:full_name => 'Brent Greeff')
71
-
72
- assert_equal 'Brent', user.first_name
73
- assert_equal 'Greeff', user.last_name
74
- end
75
-
76
- test "should assign first last and middle names when assigning to full name" do
77
- user = User.new(:full_name => 'Brent Middle Names Greeff')
78
-
79
- assert_equal 'Brent', user.first_name
80
- assert_equal 'Middle Names', user.middle_names
81
- assert_equal 'Greeff', user.last_name
82
- end
83
-
84
- test "should have middle names that are less than 40 characters" do
85
- user = create_user
86
- user.middle_names = 'aaaaabbbbbcccccdddddeeeeefffffggggghhhhhi'
87
-
88
- deny user.valid?
89
- assert_equal 'middle names are too long (max 40 characters)', user.errors[:middle_names]
90
- end
91
-
92
- test "should have an empty full name when user is new" do
93
- user = User.new
94
- assert_equal '', user.full_name
95
- end
96
-
97
- test "should not allow non name like characters" do
98
- user = User.new(:full_name => "<Brent> Middle >< Names Gre&eff")
99
-
100
- deny user.valid?
101
- assert_equal 'some characters in your name are not allowed', user.errors[:first_name]
102
- assert_equal 'some characters in your name are not allowed', user.errors[:last_name]
103
- assert_equal 'some characters in your name are not allowed', user.errors[:middle_names]
104
- end
105
-
106
- test "should split up scottish names correctly" do
107
- user = User.new(:full_name => "Ewan Mc Greggor")
108
-
109
- assert_equal 'Ewan', user.first_name
110
- assert_equal 'Mc Greggor', user.last_name
111
- assert_nil user.middle_names
112
- end
113
-
114
- test "should split up scottish names with middle names correctly" do
115
- user = User.new(:full_name => "Jade Frances Roseanne Mc Cracken")
116
-
117
- assert_equal 'Jade', user.first_name
118
- assert_equal 'Mc Cracken', user.last_name
119
- assert_equal 'Frances Roseanne', user.middle_names
120
- end
121
-
122
- private
123
-
124
- def create_user(options={})
125
- default_options = {
126
- :first_name => "Brent",
127
- :last_name => "Greeff"
128
- }
129
-
130
- return User.create!(default_options.merge(options))
131
- end
132
-
133
- def create_customer(options={})
134
- default_options = {
135
- :first_name => "Brent",
136
- :last_name => "Greeff"
137
- }
138
-
139
- return Customer.create!(default_options.merge(options))
140
- end
141
-
142
- def deny(expected_to_be_false, message = '')
143
- assert ! expected_to_be_false, message
144
- end
145
- end
@@ -1,3 +0,0 @@
1
- test:
2
- adapter: sqlite3
3
- database: ":memory:"
@@ -1,14 +0,0 @@
1
- ActiveRecord::Schema.define(:version => 20090628014113) do
2
-
3
- create_table "users", :force => true do |t|
4
- t.string "first_name"
5
- t.string "middle_names"
6
- t.string "last_name"
7
- end
8
-
9
- create_table "customers", :force => true do |t|
10
- t.string "first_name"
11
- t.string "middle_names"
12
- t.string "last_name"
13
- end
14
- end
@@ -1,29 +0,0 @@
1
- require 'rubygems'
2
- require 'active_support'
3
- require 'active_support/test_case'
4
- require 'test/unit'
5
-
6
- require 'active_record'
7
-
8
- CurrentDir = File.expand_path(File.dirname(__FILE__))
9
-
10
- # log_path = File.join(CurrentDir, "debug.log")
11
- # ActiveRecord::Base.logger = Logger.new(log_path)
12
-
13
- def load_db_config
14
- database_yml = File.join(CurrentDir, 'database.yml')
15
- config = YAML::load(IO.read(database_yml))
16
- config['test']
17
- end
18
-
19
- ActiveRecord::Base.establish_connection(load_db_config)
20
- load(File.join(CurrentDir, "schema.rb"))
21
-
22
- $: << (File.join(CurrentDir, "..", "lib"))
23
-
24
- begin
25
- require 'redgreen' unless ENV['TM_MODE']
26
- rescue LoadError
27
- end
28
-
29
- require 'acts_as_human.rb'