feminizer 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/feminizer.rb +63 -54
  2. data/test/feminizer_test.rb +11 -0
  3. metadata +3 -3
@@ -3,11 +3,19 @@ require 'nokogiri'
3
3
 
4
4
  module Feminizer
5
5
 
6
- VERSION = "1.0.2"
6
+ VERSION = "1.0.3"
7
7
 
8
8
 
9
9
  extend self
10
10
 
11
+ def forms=(hash)
12
+ @forms = hash
13
+ end
14
+
15
+ def forms
16
+ @forms || default_forms
17
+ end
18
+
11
19
  def feminize_html content
12
20
  tree = Nokogiri::HTML content
13
21
  feminize_node! tree
@@ -20,59 +28,6 @@ module Feminizer
20
28
  string = string.dup.without_accents
21
29
  string = string.gsub(/\302\240/, ' ')
22
30
 
23
-
24
- forms = {
25
- 'man' => 'woman',
26
- 'men' => 'women',
27
- 'manly' => 'womanly',
28
- 'manliness' => 'womanliness',
29
- 'manlier' => 'womanlier',
30
- 'manliest' => 'womanliest',
31
- 'manhood' => 'womanhood',
32
- 'manvotional' => 'womanvotional',
33
- 'masculine' => 'feminine',
34
- 'masculinity' => 'femininity',
35
- 'male' => 'female',
36
- 'patriarch' => 'matriarch',
37
- 'mr.' => 'ms.',
38
- 'boy' => 'girl',
39
- 'boys' => 'girls',
40
- 'guy' => 'gal',
41
- 'guys' => 'gals',
42
- 'dude' => 'lady',
43
- 'dudes' => 'ladies',
44
- 'he' => 'she',
45
- 'his' => 'her',
46
- 'him' => 'her',
47
- 'himself' => 'herself',
48
- 'waitress' => 'waiter',
49
- 'waitressed' => 'waited',
50
- 'craftsman' => 'craftswoman',
51
- 'nobleman' => 'noblewoman',
52
- 'gentleman' => 'lady',
53
- 'gentlemen' => 'ladies',
54
- 'prince' => 'princess',
55
- 'princes' => 'princesses',
56
- 'king' => 'queen',
57
- 'kings' => 'queens',
58
- 'sissy' => 'boyish',
59
- 'emasculate' => 'defeminize',
60
- 'cowboy' => 'cowgirl',
61
- 'cowboying' => 'cowgirling',
62
- 'cowboys' => 'cowgirls',
63
- 'dad' => 'mom',
64
- 'daddy' => 'mommy',
65
- 'dick' => 'pussy',
66
- 'ex-wife' => 'ex-husband',
67
- 'father' => 'mother',
68
- 'fathers' => 'mothers',
69
- 'brother' => 'sister',
70
- 'brothers' => 'sisters',
71
- 'Matt' => 'Mattie',
72
- 'David' => 'Davida',
73
- 'Paul' => 'Paula'
74
- }
75
-
76
31
  forms.each do |masculine, feminine|
77
32
  if string =~ /#{feminine}/i
78
33
  string = string_search_replace(string, feminine, masculine, :mark) unless 'his' == masculine
@@ -141,4 +96,58 @@ module Feminizer
141
96
  string
142
97
  end
143
98
 
99
+ def default_forms
100
+ {
101
+ 'man' => 'woman',
102
+ 'men' => 'women',
103
+ 'manly' => 'womanly',
104
+ 'manliness' => 'womanliness',
105
+ 'manlier' => 'womanlier',
106
+ 'manliest' => 'womanliest',
107
+ 'manhood' => 'womanhood',
108
+ 'manvotional' => 'womanvotional',
109
+ 'masculine' => 'feminine',
110
+ 'masculinity' => 'femininity',
111
+ 'male' => 'female',
112
+ 'patriarch' => 'matriarch',
113
+ 'mr.' => 'ms.',
114
+ 'boy' => 'girl',
115
+ 'boys' => 'girls',
116
+ 'guy' => 'gal',
117
+ 'guys' => 'gals',
118
+ 'dude' => 'lady',
119
+ 'dudes' => 'ladies',
120
+ 'he' => 'she',
121
+ 'his' => 'her',
122
+ 'him' => 'her',
123
+ 'himself' => 'herself',
124
+ 'waitress' => 'waiter',
125
+ 'waitressed' => 'waited',
126
+ 'craftsman' => 'craftswoman',
127
+ 'nobleman' => 'noblewoman',
128
+ 'gentleman' => 'lady',
129
+ 'gentlemen' => 'ladies',
130
+ 'prince' => 'princess',
131
+ 'princes' => 'princesses',
132
+ 'king' => 'queen',
133
+ 'kings' => 'queens',
134
+ 'sissy' => 'boyish',
135
+ 'emasculate' => 'defeminize',
136
+ 'cowboy' => 'cowgirl',
137
+ 'cowboying' => 'cowgirling',
138
+ 'cowboys' => 'cowgirls',
139
+ 'dad' => 'mom',
140
+ 'daddy' => 'mommy',
141
+ 'dick' => 'pussy',
142
+ 'ex-wife' => 'ex-husband',
143
+ 'father' => 'mother',
144
+ 'fathers' => 'mothers',
145
+ 'brother' => 'sister',
146
+ 'brothers' => 'sisters',
147
+ 'Matt' => 'Mattie',
148
+ 'David' => 'Davida',
149
+ 'Paul' => 'Paula'
150
+ }
151
+ end
152
+
144
153
  end
@@ -21,6 +21,17 @@ class FeminizerTest < Test::Unit::TestCase
21
21
  @feminized
22
22
  end
23
23
  end
24
+ context "custom forms" do
25
+ setup {
26
+ Feminizer.forms = {'boy-a-boy' => 'girly-girla'}
27
+ @feminized = feminize_text "boy-a-boy is a girl but girly-girla is not."
28
+ Feminizer.forms = nil
29
+ }
30
+ should "turn all girly" do
31
+ assert_equal "girly-girla is a girl but boy-a-boy is not.",
32
+ @feminized
33
+ end
34
+ end
24
35
  context "feminize" do
25
36
  setup {
26
37
  @feminized = feminize_html HTML.dup
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feminizer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jack Danger Canty