genderize 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +82 -0
- data/Rakefile +39 -0
- data/app/assets/javascripts/genderize/application.js +15 -0
- data/app/assets/stylesheets/genderize/application.css +13 -0
- data/app/controllers/genderize/application_controller.rb +4 -0
- data/app/helpers/genderize/application_helper.rb +4 -0
- data/app/views/layouts/genderize/application.html.erb +14 -0
- data/config/locales/genderize.en.yml +23 -0
- data/config/routes.rb +2 -0
- data/lib/genderize.rb +9 -0
- data/lib/genderize/engine.rb +14 -0
- data/lib/genderize/gender.rb +50 -0
- data/lib/genderize/genderize.rb +44 -0
- data/lib/genderize/version.rb +3 -0
- data/lib/generators/genderize/install/USAGE +8 -0
- data/lib/generators/genderize/install/install_generator.rb +12 -0
- data/lib/tasks/genderize_tasks.rake +4 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/models/user.rb +8 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +59 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20130506080641_create_users.rb +11 -0
- data/spec/dummy/db/schema.rb +23 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +69 -0
- data/spec/dummy/log/test.log +37 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/models/user_spec.rb +49 -0
- data/spec/genderize_spec.rb +5 -0
- data/spec/lib/gender_spec.rb +166 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/deferred_garbage_collection.rb +19 -0
- metadata +168 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
Connecting to database specified by database.yml
|
2
|
+
Connecting to database specified by database.yml
|
3
|
+
Connecting to database specified by database.yml
|
4
|
+
Connecting to database specified by database.yml
|
5
|
+
Connecting to database specified by database.yml
|
6
|
+
Connecting to database specified by database.yml
|
7
|
+
Connecting to database specified by database.yml
|
8
|
+
Connecting to database specified by database.yml
|
9
|
+
Connecting to database specified by database.yml
|
10
|
+
Connecting to database specified by database.yml
|
11
|
+
Connecting to database specified by database.yml
|
12
|
+
Connecting to database specified by database.yml
|
13
|
+
Connecting to database specified by database.yml
|
14
|
+
Connecting to database specified by database.yml
|
15
|
+
Connecting to database specified by database.yml
|
16
|
+
Connecting to database specified by database.yml
|
17
|
+
Connecting to database specified by database.yml
|
18
|
+
Connecting to database specified by database.yml
|
19
|
+
Connecting to database specified by database.yml
|
20
|
+
Connecting to database specified by database.yml
|
21
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
22
|
+
[1m[35mSQL (6.1ms)[0m INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 06 May 2013 08:42:33 UTC +00:00], ["gender", nil], ["name", "f"], ["updated_at", Mon, 06 May 2013 08:42:33 UTC +00:00]]
|
23
|
+
SQLite3::ConstraintException: users.gender may not be NULL: INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?)
|
24
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
25
|
+
Connecting to database specified by database.yml
|
26
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
27
|
+
[1m[35mSQL (3.0ms)[0m INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 06 May 2013 08:43:51 UTC +00:00], ["gender", nil], ["name", "f"], ["updated_at", Mon, 06 May 2013 08:43:51 UTC +00:00]]
|
28
|
+
SQLite3::ConstraintException: users.gender may not be NULL: INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?)
|
29
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
30
|
+
Connecting to database specified by database.yml
|
31
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
32
|
+
[1m[35mSQL (3.2ms)[0m INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 06 May 2013 08:45:07 UTC +00:00], ["gender", "f"], ["name", "f"], ["updated_at", Mon, 06 May 2013 08:45:07 UTC +00:00]]
|
33
|
+
[1m[36m (54.4ms)[0m [1mcommit transaction[0m
|
34
|
+
[1m[35mUser Load (0.2ms)[0m SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
|
35
|
+
Connecting to database specified by database.yml
|
36
|
+
Connecting to database specified by database.yml
|
37
|
+
Connecting to database specified by database.yml
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe User do
|
4
|
+
|
5
|
+
describe "gender" do
|
6
|
+
|
7
|
+
let(:user) { User.new(gender: "f") }
|
8
|
+
|
9
|
+
it "should return a Gender object" do
|
10
|
+
user.gender.should be_an_instance_of(Gender)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be female?" do
|
14
|
+
user.gender.should be_female
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be male when changed" do
|
18
|
+
user.gender = "m"
|
19
|
+
user.gender.should be_male
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
# Since the db column name can be changed, we're using the "name" column to
|
25
|
+
# test this behaviour
|
26
|
+
describe "name" do
|
27
|
+
|
28
|
+
let(:user) { User.new(name: "f", gender: "f") }
|
29
|
+
|
30
|
+
it "should return a Gender object" do
|
31
|
+
user.name.should be_an_instance_of Gender
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should change the name column" do
|
35
|
+
user.save!
|
36
|
+
user = User.last
|
37
|
+
user.name.should == "f"
|
38
|
+
user.name.should be_female
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should not change the gender column" do
|
42
|
+
user.name = "m"
|
43
|
+
user.name.should be_male
|
44
|
+
user.gender.should_not be_male
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Genderize::Gender do
|
4
|
+
|
5
|
+
let(:female) { Gender.new("f") }
|
6
|
+
let(:male) { Gender.new("M") }
|
7
|
+
|
8
|
+
describe :name do
|
9
|
+
|
10
|
+
context "when male" do
|
11
|
+
|
12
|
+
it "should be 'male'" do
|
13
|
+
male.name.should eql("male")
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when female" do
|
19
|
+
|
20
|
+
it "should be 'female'" do
|
21
|
+
female.name.should eql("female")
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe :abbr do
|
29
|
+
|
30
|
+
context "when male" do
|
31
|
+
|
32
|
+
it "should be 'm'" do
|
33
|
+
male.abbr.should eql("m")
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
context "when female" do
|
39
|
+
|
40
|
+
it "should be 'f'" do
|
41
|
+
female.abbr.should eql("f")
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe :subject do
|
49
|
+
|
50
|
+
context "when male" do
|
51
|
+
|
52
|
+
it "should be 'he'" do
|
53
|
+
male.subject.should eql("he")
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
context "when female" do
|
59
|
+
|
60
|
+
it "should be 'she'" do
|
61
|
+
female.subject.should eql("she")
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe :object do
|
68
|
+
|
69
|
+
context "when male" do
|
70
|
+
|
71
|
+
it "should be 'him'" do
|
72
|
+
male.object.should eql("him")
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
context "when female" do
|
78
|
+
|
79
|
+
it "should be 'her'" do
|
80
|
+
female.object.should eql("her")
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
describe :possessive do
|
89
|
+
|
90
|
+
context "when male" do
|
91
|
+
|
92
|
+
it "should be 'his'" do
|
93
|
+
male.possessive.should eql("his")
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
context "when female" do
|
99
|
+
|
100
|
+
it "should be 'her'" do
|
101
|
+
female.possessive.should eql("her")
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
describe :casual do
|
110
|
+
|
111
|
+
context "when male" do
|
112
|
+
|
113
|
+
it "should be 'guy'" do
|
114
|
+
male.casual.should eql("guy")
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
context "when female" do
|
120
|
+
|
121
|
+
it "should be 'girl'" do
|
122
|
+
female.casual.should eql("girl")
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
describe :to_s do
|
130
|
+
|
131
|
+
it "should equal the abbr value" do
|
132
|
+
male.to_s.should eql(male.abbr)
|
133
|
+
female.to_s.should eql(female.abbr)
|
134
|
+
end
|
135
|
+
|
136
|
+
it "returns a string" do
|
137
|
+
male.to_s.should be_an_instance_of(String)
|
138
|
+
female.to_s.should be_an_instance_of(String)
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
describe :capital_abbr do
|
144
|
+
|
145
|
+
it "should equal the abbr value capitalized" do
|
146
|
+
male.capital_abbr.should eql(male.abbr.capitalize)
|
147
|
+
female.capital_abbr.should eql(female.abbr.capitalize)
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
describe :== do
|
153
|
+
|
154
|
+
it "should return true if passed abbr value" do
|
155
|
+
(male == "m").should be_true
|
156
|
+
(female == "f").should be_true
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should return false if not passed abbr value" do
|
160
|
+
(male == "f").should be_false
|
161
|
+
(female == 1).should be_false
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
5
|
+
require 'rspec/rails'
|
6
|
+
require "support/deferred_garbage_collection"
|
7
|
+
|
8
|
+
include Genderize
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.before(:all) { DeferredGarbageCollection.start }
|
12
|
+
config.after(:all) { DeferredGarbageCollection.reconsider }
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class DeferredGarbageCollection
|
2
|
+
|
3
|
+
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 15.0).to_f
|
4
|
+
|
5
|
+
@@last_gc_run = Time.now
|
6
|
+
|
7
|
+
def self.start
|
8
|
+
GC.disable if DEFERRED_GC_THRESHOLD > 0
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.reconsider
|
12
|
+
if DEFERRED_GC_THRESHOLD > 0 && Time.now - @@last_gc_run >= DEFERRED_GC_THRESHOLD
|
13
|
+
GC.enable
|
14
|
+
GC.start
|
15
|
+
GC.disable
|
16
|
+
@@last_gc_run = Time.now
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: genderize
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bodacious
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.13
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.13
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
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
|
+
description: A helpful class for gender-specific models in Ruby applications. Genderize
|
56
|
+
adds useful helper methods for various pronouns and other written forms of male
|
57
|
+
and female genders.
|
58
|
+
email:
|
59
|
+
- bodacious@katanacode.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- app/assets/javascripts/genderize/application.js
|
65
|
+
- app/assets/stylesheets/genderize/application.css
|
66
|
+
- app/controllers/genderize/application_controller.rb
|
67
|
+
- app/helpers/genderize/application_helper.rb
|
68
|
+
- app/views/layouts/genderize/application.html.erb
|
69
|
+
- config/locales/genderize.en.yml
|
70
|
+
- config/routes.rb
|
71
|
+
- lib/genderize/engine.rb
|
72
|
+
- lib/genderize/gender.rb
|
73
|
+
- lib/genderize/genderize.rb
|
74
|
+
- lib/genderize/version.rb
|
75
|
+
- lib/genderize.rb
|
76
|
+
- lib/generators/genderize/install/install_generator.rb
|
77
|
+
- lib/generators/genderize/install/USAGE
|
78
|
+
- lib/tasks/genderize_tasks.rake
|
79
|
+
- MIT-LICENSE
|
80
|
+
- Rakefile
|
81
|
+
- README.md
|
82
|
+
- spec/dummy/app/models/user.rb
|
83
|
+
- spec/dummy/config/application.rb
|
84
|
+
- spec/dummy/config/boot.rb
|
85
|
+
- spec/dummy/config/database.yml
|
86
|
+
- spec/dummy/config/environment.rb
|
87
|
+
- spec/dummy/config/environments/development.rb
|
88
|
+
- spec/dummy/config/environments/production.rb
|
89
|
+
- spec/dummy/config/environments/test.rb
|
90
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
91
|
+
- spec/dummy/config/initializers/inflections.rb
|
92
|
+
- spec/dummy/config/initializers/mime_types.rb
|
93
|
+
- spec/dummy/config/initializers/secret_token.rb
|
94
|
+
- spec/dummy/config/initializers/session_store.rb
|
95
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
96
|
+
- spec/dummy/config/locales/en.yml
|
97
|
+
- spec/dummy/config/routes.rb
|
98
|
+
- spec/dummy/config.ru
|
99
|
+
- spec/dummy/db/development.sqlite3
|
100
|
+
- spec/dummy/db/migrate/20130506080641_create_users.rb
|
101
|
+
- spec/dummy/db/schema.rb
|
102
|
+
- spec/dummy/db/test.sqlite3
|
103
|
+
- spec/dummy/log/development.log
|
104
|
+
- spec/dummy/log/test.log
|
105
|
+
- spec/dummy/Rakefile
|
106
|
+
- spec/dummy/README.rdoc
|
107
|
+
- spec/dummy/script/rails
|
108
|
+
- spec/dummy/spec/models/user_spec.rb
|
109
|
+
- spec/genderize_spec.rb
|
110
|
+
- spec/lib/gender_spec.rb
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
- spec/support/deferred_garbage_collection.rb
|
113
|
+
homepage: http://github.com/KatanaCode/genderize
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata: {}
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 2.0.3
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: A helpful class for gender-specific models in Ruby applications
|
137
|
+
test_files:
|
138
|
+
- spec/dummy/app/models/user.rb
|
139
|
+
- spec/dummy/config/application.rb
|
140
|
+
- spec/dummy/config/boot.rb
|
141
|
+
- spec/dummy/config/database.yml
|
142
|
+
- spec/dummy/config/environment.rb
|
143
|
+
- spec/dummy/config/environments/development.rb
|
144
|
+
- spec/dummy/config/environments/production.rb
|
145
|
+
- spec/dummy/config/environments/test.rb
|
146
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
147
|
+
- spec/dummy/config/initializers/inflections.rb
|
148
|
+
- spec/dummy/config/initializers/mime_types.rb
|
149
|
+
- spec/dummy/config/initializers/secret_token.rb
|
150
|
+
- spec/dummy/config/initializers/session_store.rb
|
151
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
152
|
+
- spec/dummy/config/locales/en.yml
|
153
|
+
- spec/dummy/config/routes.rb
|
154
|
+
- spec/dummy/config.ru
|
155
|
+
- spec/dummy/db/development.sqlite3
|
156
|
+
- spec/dummy/db/migrate/20130506080641_create_users.rb
|
157
|
+
- spec/dummy/db/schema.rb
|
158
|
+
- spec/dummy/db/test.sqlite3
|
159
|
+
- spec/dummy/log/development.log
|
160
|
+
- spec/dummy/log/test.log
|
161
|
+
- spec/dummy/Rakefile
|
162
|
+
- spec/dummy/README.rdoc
|
163
|
+
- spec/dummy/script/rails
|
164
|
+
- spec/dummy/spec/models/user_spec.rb
|
165
|
+
- spec/genderize_spec.rb
|
166
|
+
- spec/lib/gender_spec.rb
|
167
|
+
- spec/spec_helper.rb
|
168
|
+
- spec/support/deferred_garbage_collection.rb
|