creepcheck 3181.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README +28 -0
- data/bin/creepcheck +102 -0
- data/lib/creep_check.rb +206 -0
- metadata +79 -0
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Permission is hereby granted by the holder(s) of copyright or other legal
|
2
|
+
privileges, author(s) or assembler(s), and contributor(s) of this work, to any
|
3
|
+
person who obtains a copy of this work in any form, to reproduce, modify,
|
4
|
+
distribute, publish, sell, sublicense, use, and/or otherwise deal in the
|
5
|
+
licensed material without restriction, provided the following conditions are
|
6
|
+
met.
|
7
|
+
|
8
|
+
Redistributions, modified or unmodified, in whole or in part, must make
|
9
|
+
applicable copyright and other legal privilege notices, the above license
|
10
|
+
notice, these conditions, and the following disclaimer, freely available to
|
11
|
+
recipients on distribution through one of the following means, in descending
|
12
|
+
order of preferability: incorporated into the work, provided with the work,
|
13
|
+
presented via the medium or method of distribution for the work, or upon
|
14
|
+
request by recipients of the work while the work is offered for distribution.
|
15
|
+
|
16
|
+
NO WARRANTY OF ANY KIND IS IMPLIED BY, OR SHOULD BE INFERRED FROM, THIS LICENSE
|
17
|
+
OR THE ACT OF DISTRIBUTION UNDER THE TERMS OF THIS LICENSE, INCLUDING BUT NOT
|
18
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
|
19
|
+
AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, ASSEMBLERS, OR HOLDERS OF
|
20
|
+
COPYRIGHT OR OTHER LEGAL PRIVILEGE BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
|
21
|
+
LIABILITY, WHETHER IN ACTION OF CONTRACT, TORT, OR OTHERWISE ARISING FROM, OUT
|
22
|
+
OF, OR IN CONNECTION WITH THE WORK OR THE USE OF OR OTHER DEALINGS IN THE WORK.
|
data/README
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# CreepCheck
|
2
|
+
|
3
|
+
The CreepCheck project provides a library (and sample command line program)
|
4
|
+
that applies the half-plus-seven formula to determine the social acceptability
|
5
|
+
of relationship age differences (or, contrariwise, the "creepiness") in
|
6
|
+
romantic or sexual relationships.
|
7
|
+
|
8
|
+
## Installing
|
9
|
+
|
10
|
+
1. Clone this repository.
|
11
|
+
2. Run `gem build creep_check.gemspec`.
|
12
|
+
3. Run `gem install <gemfile>`, probably as root.
|
13
|
+
|
14
|
+
The `gemfile` mentioned above is the file generated by the `gem build` command,
|
15
|
+
and should look something like `creepcheck-0.0.1.gem`.
|
16
|
+
|
17
|
+
## Using The API
|
18
|
+
|
19
|
+
Do something like this in a Ruby program:
|
20
|
+
|
21
|
+
#!/usr/bin/env ruby
|
22
|
+
require 'creep_check'
|
23
|
+
|
24
|
+
# do stuff with the CreepCheck class here
|
25
|
+
|
26
|
+
## Using The Command Line Utility
|
27
|
+
|
28
|
+
$ creepcheck help
|
data/bin/creepcheck
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'creep_check'
|
3
|
+
|
4
|
+
command = ARGV.shift
|
5
|
+
|
6
|
+
def util
|
7
|
+
File.basename($0)
|
8
|
+
end
|
9
|
+
|
10
|
+
def usage
|
11
|
+
puts %Q{USAGE: #{util} <COMMAND> [PARAMETERS]}
|
12
|
+
end
|
13
|
+
|
14
|
+
if (command == 'help') or (command == '-h') or (command == '--help')
|
15
|
+
usage
|
16
|
+
puts
|
17
|
+
puts %q{By providing the birthdates of two people, in the format}
|
18
|
+
puts %q{YYYY-MM-DD, you can get a judgment of whether the age dif-}
|
19
|
+
puts %q{ference is too great for those people to engage in a roman-}
|
20
|
+
puts %q{tic relationschip, according to a pop culture estimation of}
|
21
|
+
puts %q{common US cultural biases.}
|
22
|
+
puts
|
23
|
+
puts %q{COMMANDS:}
|
24
|
+
puts
|
25
|
+
puts %q{ help}
|
26
|
+
puts %q{ print this help information and exit}
|
27
|
+
puts
|
28
|
+
puts %q{ creepy <OLDER> <YOUNGER> [TARGET_DATE]}
|
29
|
+
puts %q{ determine whether a relationship age}
|
30
|
+
puts %q{ difference is creepy, based on the OLDER}
|
31
|
+
puts %q{ person's age, the YOUNGER person's age,}
|
32
|
+
puts %q{ and a TARGET_DATE (the current date is}
|
33
|
+
puts %q{ default if no TARGET_DATE specified)}
|
34
|
+
puts
|
35
|
+
puts %q{ range <BIRTHDAY> [TARGET_DATE]}
|
36
|
+
puts %q{ show the range from youngest non-creepy}
|
37
|
+
puts %q{ age for a potential partner to oldest}
|
38
|
+
puts %q{ non-creepy age for a potential partner,}
|
39
|
+
puts %q{ given BIRTHDAY (the birthday of the sub-}
|
40
|
+
puts %q{ ject) and a TARGET_DATE (the current}
|
41
|
+
puts %q{ date is default if no TARGET_DATE speci-}
|
42
|
+
puts %q{ fied), rounded to two decimal places}
|
43
|
+
=begin
|
44
|
+
puts
|
45
|
+
puts %q{ older <YOUNGER>}
|
46
|
+
puts %q{ show the oldest non-creepy age for a}
|
47
|
+
puts %q{ younger partner, given YOUNGER (the age}
|
48
|
+
puts %q{ of the younger partner)}
|
49
|
+
puts
|
50
|
+
puts %q{ younger <OLDER>}
|
51
|
+
puts %q{ show the youngest non-creepy age for an}
|
52
|
+
puts %q{ older partner, given OLDER (the age of}
|
53
|
+
puts %q{ the older partner)}
|
54
|
+
=end
|
55
|
+
elsif command == 'creepy'
|
56
|
+
current = Date.today
|
57
|
+
if ARGV.size > 3
|
58
|
+
puts 'You entered too many parameters.'
|
59
|
+
exit
|
60
|
+
elsif ARGV.size > 1
|
61
|
+
older = ARGV.shift
|
62
|
+
younger = ARGV.shift
|
63
|
+
date = ARGV.shift
|
64
|
+
else
|
65
|
+
puts 'You did not provide enough parameters.'
|
66
|
+
end
|
67
|
+
|
68
|
+
creepiness = if date
|
69
|
+
CreepCheck.creep?(older, younger, date)
|
70
|
+
else
|
71
|
+
CreepCheck.creep?(older, younger)
|
72
|
+
end
|
73
|
+
|
74
|
+
puts creepiness ? 'CREEPY' : 'NOT CREEPY'
|
75
|
+
elsif command == 'range'
|
76
|
+
if ARGV.size < 1
|
77
|
+
puts 'You did not provide enough parameters.'
|
78
|
+
elsif ARGV.size < 3
|
79
|
+
bday = ARGV.shift
|
80
|
+
date = ARGV.size == 1 ? ARGV.shift : nil
|
81
|
+
range = if date
|
82
|
+
CreepCheck.uncreepy_range(bday, date)
|
83
|
+
else
|
84
|
+
CreepCheck.uncreepy_range(bday)
|
85
|
+
end.collect {|f| f.round 2 }
|
86
|
+
|
87
|
+
puts "Uncreepy range for birthday #{bday}: #{range[0]}-#{range[1]}"
|
88
|
+
else
|
89
|
+
puts 'You entered too many parameters.'
|
90
|
+
end
|
91
|
+
=begin
|
92
|
+
elsif command == 'older'
|
93
|
+
elsif command == 'younger'
|
94
|
+
=end
|
95
|
+
else
|
96
|
+
usage
|
97
|
+
if command
|
98
|
+
puts %Q{Invalid Command: #{command}}
|
99
|
+
else
|
100
|
+
puts %Q{Try "#{util} help" for more information.}
|
101
|
+
end
|
102
|
+
end
|
data/lib/creep_check.rb
ADDED
@@ -0,0 +1,206 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
=begin rdoc
|
4
|
+
|
5
|
+
CreepCheck provides an API that applies the half-plus-seven formula to
|
6
|
+
determine the social acceptability of a romantic relationship, based on the age
|
7
|
+
difference between two people. This acceptability is codified as "creepiness".
|
8
|
+
|
9
|
+
Given a date of April Fool's Day 2015, a dirty old man born in 1945 dating a
|
10
|
+
young lady born in 2002 would definitely be considered a creep by the standards
|
11
|
+
of the half-plus-seven formula, thus the "true" result.
|
12
|
+
|
13
|
+
Objects are instantiated by providing the birthdate of the subject of a
|
14
|
+
chreepcheck (e.g. yourself) and, optionally, a date you want the program to
|
15
|
+
assume is the "current date"; if that date is not supplied, CreepCheck will use
|
16
|
+
the actual current date for methods that require a "current" date.
|
17
|
+
|
18
|
+
The creep?, creep_limit, creep_limit_age, uncreepy_date, creep_limit_date, and
|
19
|
+
uncreepy_range methods may all be invoked by sending a method to either the
|
20
|
+
class or an instance of the class. Examples follow.
|
21
|
+
|
22
|
+
>> require 'creep_check'
|
23
|
+
=> true
|
24
|
+
>>
|
25
|
+
>> CreepCheck.creep?('1945-12-04', '2002-05-30')
|
26
|
+
=> true
|
27
|
+
>>
|
28
|
+
>> CreepCheck.creep_limit('1945-12-04', '2002-05-30')
|
29
|
+
=> 70.48459958932239
|
30
|
+
>>
|
31
|
+
>> CreepCheck.creep_limit_age('1945-12-04', '2002-05-30')
|
32
|
+
=> 126.96919917864476
|
33
|
+
>>
|
34
|
+
>> CreepCheck.uncreepy_date('1945-12-04', '2002-05-30')
|
35
|
+
=> #<Date: 2072-11-23 ((2478170j,43200s,0n),+0s,2299161j)>
|
36
|
+
>> puts _
|
37
|
+
2072-11-23
|
38
|
+
=> nil
|
39
|
+
>>
|
40
|
+
>> CreepCheck.creep_limit_date('1945-12-04', '2002-05-30')
|
41
|
+
=> #<Date: 2072-11-22 ((2478169j,43200s,0n),+0s,2299161j)>
|
42
|
+
>> puts _
|
43
|
+
2072-11-22
|
44
|
+
=> nil
|
45
|
+
>>
|
46
|
+
>> CreepCheck.uncreepy_range('1945-12-04')
|
47
|
+
=> [41.65982203969884, 124.63928815879535]
|
48
|
+
|
49
|
+
Both the creep? and uncreepy_range methods above optionally take an additional
|
50
|
+
parameter that specifies a "current" date of the programmer's choosing.
|
51
|
+
|
52
|
+
>> subject = CreepCheck.new('1945-12-04')
|
53
|
+
=> #<CreepCheck:0x00000802a68da8 @bday="1945-12-04", @target_date=#<Date:
|
54
|
+
2015-03-31 ((2457113j,0s,0n),+0s,2299161j)>>
|
55
|
+
>>
|
56
|
+
>> subject.creep? '2002-05-30'
|
57
|
+
=> true
|
58
|
+
>>
|
59
|
+
>> subject.creep_limit '2002-05-30'
|
60
|
+
=> 70.48459958932239
|
61
|
+
>>
|
62
|
+
>> subject.creep_limit_age '2002-05-30'
|
63
|
+
=> 126.96919917864476
|
64
|
+
>>
|
65
|
+
>> subject.uncreepy_date '2002-05-30'
|
66
|
+
=> #<Date: 2072-11-23 ((2478170j,43200s,0n),+0s,2299161j)>
|
67
|
+
>> puts _
|
68
|
+
2072-11-23
|
69
|
+
=> nil
|
70
|
+
>>
|
71
|
+
>> subject.creep_limit_date '2002-05-30'
|
72
|
+
=> #<Date: 2072-11-22 ((2478169j,43200s,0n),+0s,2299161j)>
|
73
|
+
>> puts _
|
74
|
+
2072-11-22
|
75
|
+
=> nil
|
76
|
+
>>
|
77
|
+
>> subject.uncreepy_range
|
78
|
+
=> [41.65982203969884, 124.63928815879535]
|
79
|
+
|
80
|
+
When working with an instance of CreepCheck, no methods take a specified
|
81
|
+
"current" date parameter except the new method, because the "current" date is a
|
82
|
+
characteristic of the instance. Thus, the new method takes a specified
|
83
|
+
"current" date as an optional parameter or, without the parameter,
|
84
|
+
automatically sets the "current" date to the current date as of the
|
85
|
+
instantiation of the object. Whether this behavior is "right" is perhaps open
|
86
|
+
to interpretation or debate, so it may change in some future version of
|
87
|
+
CreepCheck.
|
88
|
+
|
89
|
+
=end
|
90
|
+
|
91
|
+
class CreepCheck
|
92
|
+
@@base = 14
|
93
|
+
@@year = 365.25
|
94
|
+
@@days = @@base * @@year
|
95
|
+
@@seven = 7 * @@year
|
96
|
+
|
97
|
+
attr_reader :bday, :target_date
|
98
|
+
|
99
|
+
def initialize(bday, target_date=Date.today)
|
100
|
+
@bday = bday
|
101
|
+
@target_date = target_date
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.version
|
105
|
+
'3181.0.0'
|
106
|
+
end
|
107
|
+
|
108
|
+
def creep?(younger)
|
109
|
+
CreepCheck.creep? @bday, younger, @target_date
|
110
|
+
end
|
111
|
+
|
112
|
+
def creep_limit(younger)
|
113
|
+
CreepCheck.creep_limit @bday, younger
|
114
|
+
end
|
115
|
+
|
116
|
+
def creep_limit_age(younger)
|
117
|
+
CreepCheck.creep_limit_age @bday, younger
|
118
|
+
end
|
119
|
+
|
120
|
+
def uncreepy_date(younger)
|
121
|
+
CreepCheck.uncreepy_date @bday, younger
|
122
|
+
end
|
123
|
+
|
124
|
+
def creep_limit_date(younger)
|
125
|
+
CreepCheck.creep_limit_date @bday, younger
|
126
|
+
end
|
127
|
+
|
128
|
+
def uncreepy_range
|
129
|
+
CreepCheck.uncreepy_range @bday, @target_date
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.creep?(older_bday, newer_bday, target_date=Date.today)
|
133
|
+
older = to_date older_bday
|
134
|
+
newer = to_date newer_bday
|
135
|
+
target = to_date target_date
|
136
|
+
target - newer < creep_limit_days(older, newer)
|
137
|
+
end
|
138
|
+
|
139
|
+
def self.creep_limit(older_bday, newer_bday)
|
140
|
+
creep_limit_days(older_bday, newer_bday) / @@year
|
141
|
+
end
|
142
|
+
|
143
|
+
def self.creep_limit_age(older_bday, newer_bday)
|
144
|
+
creep_limit_age_days(older_bday, newer_bday) / @@year
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.uncreepy_date(older_bday, newer_bday)
|
148
|
+
creep_limit_date(older_bday, newer_bday) + 1
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.creep_limit_date(older_bday, newer_bday)
|
152
|
+
older = to_date older_bday
|
153
|
+
newer = to_date newer_bday
|
154
|
+
newer + creep_limit_days(older, newer)
|
155
|
+
end
|
156
|
+
|
157
|
+
def self.creep_limit_days(older_bday, newer_bday)
|
158
|
+
age_diff = to_date(newer_bday) - to_date(older_bday)
|
159
|
+
@@days + age_diff
|
160
|
+
end
|
161
|
+
|
162
|
+
def self.creep_limit_age_days(older_bday, newer_bday)
|
163
|
+
age_diff = to_date(newer_bday) - to_date(older_bday)
|
164
|
+
@@days + age_diff * 2
|
165
|
+
end
|
166
|
+
|
167
|
+
def self.uncreepy_range(bday, target_date=Date.today)
|
168
|
+
uncreepy_bounds_days(bday, target_date).collect {|days| days / @@year }
|
169
|
+
end
|
170
|
+
|
171
|
+
def self.uncreepy_range_days(bday, target_date=Date.today)
|
172
|
+
uncreepy_bounds_days(bday, target_date).join('-')
|
173
|
+
end
|
174
|
+
|
175
|
+
def self.uncreepy_bounds_days(bday, target_date=Date.today)
|
176
|
+
[
|
177
|
+
uncreepy_lower_bound_days(bday, target_date),
|
178
|
+
uncreepy_upper_bound_days(bday, target_date)
|
179
|
+
]
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.uncreepy_lower_bound_days(bday, target_date=Date.today)
|
183
|
+
(to_date(target_date) - to_date(bday)) / 2.0 + @@seven
|
184
|
+
end
|
185
|
+
|
186
|
+
def self.uncreepy_upper_bound_days(bday, target_date=Date.today)
|
187
|
+
(to_date(target_date) - to_date(bday) - @@seven) * 2
|
188
|
+
end
|
189
|
+
|
190
|
+
def self.to_date(date_value)
|
191
|
+
if date_value.class == Date
|
192
|
+
date_value
|
193
|
+
elsif date_value.class == Array
|
194
|
+
array_to_date date_value
|
195
|
+
elsif date_value.class == Hash
|
196
|
+
Date.new self[:year], self[:month], self[:day]
|
197
|
+
elsif date_value.class == String
|
198
|
+
date_array = date_value.split('-')
|
199
|
+
array_to_date date_array
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
def self.array_to_date(date_array)
|
204
|
+
Date.new date_array[0].to_i, date_array[1].to_i, date_array[2].to_i
|
205
|
+
end
|
206
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: creepcheck
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3181.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chad Perrin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: |2
|
15
|
+
CreepCheck is a Ruby library that provides an API for checking romantic age
|
16
|
+
compatibility based on the popular half-plus-seven formula for determining
|
17
|
+
when it is socially (in)appropriate for people to date based on their rela-
|
18
|
+
tive ages. It comes with a sample command line interface utility.
|
19
|
+
|
20
|
+
Opinions vary on appropriate age differences in romantic relationships, but
|
21
|
+
the half-plus-seven formula seems to approximate United States cultural bi-
|
22
|
+
ases about appropriate age differences pretty well. This library and util-
|
23
|
+
ity package was originally created as a joke related to assessing the ap-
|
24
|
+
propriateness of relationships between characters in fictional contexts,
|
25
|
+
such as in fantasy/sci-fi prose and roleplaying games. It is not intended
|
26
|
+
to be treated as a substitute for moral fiber or individual judgement, and
|
27
|
+
no guarantees are made about the likelihood one's family or local courts of
|
28
|
+
law will approve of a given relationship on the basis of the age of one's
|
29
|
+
partner even if "approved" by the half-plus-seven formula.
|
30
|
+
|
31
|
+
This tool's major release version is published on April Fool's Day under
|
32
|
+
the terms of the DPL, or Detachable Public License. It is intended for
|
33
|
+
entertainment purposes only. It is not even particularly well-written.
|
34
|
+
email: code@apotheon.net
|
35
|
+
executables:
|
36
|
+
- creepcheck
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- LICENSE
|
41
|
+
- README
|
42
|
+
- lib/creep_check.rb
|
43
|
+
- bin/creepcheck
|
44
|
+
homepage: http://fossrec.com/u/apotheon/creepcheck
|
45
|
+
licenses:
|
46
|
+
- DPL
|
47
|
+
post_install_message: |2
|
48
|
+
Thank you for using creepcheck. Usage help for the "creepcheck" command
|
49
|
+
line utility is a "creepcheck help" command away. Unfortunately, that
|
50
|
+
command provides no relationship help for people who have discovered they
|
51
|
+
are engaged in creepy relationships. For that, you are on your own.
|
52
|
+
|
53
|
+
The library used by the command line interface can be used with:
|
54
|
+
|
55
|
+
require 'creep_check'
|
56
|
+
|
57
|
+
. . . and provides the CreepCheck class.
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.9.3
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.8.29
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: CreepCheck - check the creepiness of your relationship
|
79
|
+
test_files: []
|