santas_little_helper 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/santas_little_helper.rb +35 -1
- metadata +43 -24
data/lib/santas_little_helper.rb
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
# SYSTEM WIDE
|
4
4
|
|
5
5
|
# Determines if Windows platform or not. This will match all windows systems known to me (author). If you find otherwise let me know please.
|
6
|
+
# There is one pitful - if you are running on jruby - it returns "java", as supposedly it it is platform independent. So if you are checking
|
7
|
+
# for os and running jruby - it will return false, since it won't match. You should use it in conjunction with jruby? & mri? if you are
|
8
|
+
# unticipating that to be a problem. I'm not defining java? as it may cause problems with jruby potentially.
|
9
|
+
# Not really worried about maglev & rubinius & ironruby right now - as they are not really mutiplatform, not as widespread and I can't test for
|
10
|
+
# them right now.
|
6
11
|
|
7
12
|
# Works on Windows XP, 2003, 7 running Ruby 1.8.6 & 1.8.7 installed from RubyInstaller
|
8
13
|
def windows?
|
@@ -20,39 +25,68 @@ def mac?
|
|
20
25
|
(/darwin/).match(RUBY_PLATFORM) ? true : false
|
21
26
|
end
|
22
27
|
|
28
|
+
|
29
|
+
|
30
|
+
# I test and deploy some of the project on jruby - this makes it easier to customize my gemfiles.
|
31
|
+
# Works for ruby 1.8.7 & 1.9.3 & 1.9.2 on windows( 7 & xp) & linux ( debian Lenny) using rubyinstaller for windows and using mri ruby buillt from source for linux
|
32
|
+
# Works for jruby 1.7.0.rc1 and jruby 1.6.3 on windows (7 & xp)
|
33
|
+
def jruby?
|
34
|
+
(/java/).match(RUBY_PLATFORM) ? true : false
|
35
|
+
end
|
36
|
+
|
37
|
+
def mri?
|
38
|
+
(/i386|x86_64|x86/).match(RUBY_PLATFORM) ? true : false
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
23
44
|
# When something is True / False and I can to_s it, why can't I to_i it?
|
24
45
|
# There is actually a good theoretical reason, but in real world it really helps if you can output true or false as an int when you are sending soap request to a client, whose api requires it as 1 or 0, or humanize to "yes" & "no" form.
|
25
46
|
# For an alternative solution check out http://www.ruby-forum.com/topic/206789#new
|
26
47
|
|
27
48
|
class TrueClass
|
49
|
+
# Rails conventions for boolean / tinyint
|
28
50
|
def to_i
|
29
51
|
1
|
30
52
|
end
|
53
|
+
|
54
|
+
# Humanize. to_s returns "true"
|
31
55
|
def to_h
|
32
56
|
"yes"
|
33
57
|
end
|
58
|
+
|
59
|
+
# Really I need to spell it out to you?
|
34
60
|
def to_teenager
|
35
|
-
"Yeah, yeah.
|
61
|
+
"Yeah, yeah. Here you go. Did you get what you came for? Now disappear."
|
36
62
|
end
|
37
63
|
end
|
38
64
|
class FalseClass
|
65
|
+
# Rails conventions for boolean / tinyint
|
39
66
|
def to_i
|
40
67
|
0
|
41
68
|
end
|
69
|
+
# Humanize. to_s returns "false".
|
42
70
|
def to_h
|
43
71
|
"no"
|
44
72
|
end
|
73
|
+
# Little obnoxious teenager.
|
45
74
|
def to_teenager
|
46
75
|
"Can't you leave me alone? I don't have anything!"
|
47
76
|
end
|
48
77
|
end
|
49
78
|
class NilClass
|
79
|
+
# Since in if/else nil is interpreted as false, return same as false.
|
50
80
|
def to_i
|
51
81
|
0
|
52
82
|
end
|
83
|
+
|
84
|
+
# Humanize. to_s returns "" as well, this is really to be consistent with other classes.
|
53
85
|
def to_h
|
54
86
|
""
|
55
87
|
end
|
88
|
+
|
89
|
+
# A very rude teenager nihilist.
|
56
90
|
def to_teenager
|
57
91
|
"Zip! Nada! Babkis! Nothing to see here! Get out of my room!"
|
58
92
|
end
|
metadata
CHANGED
@@ -1,50 +1,69 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: santas_little_helper
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Nick Gorbikoff
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2012-10-04 00:00:00 -05:00
|
19
|
+
default_executable:
|
13
20
|
dependencies: []
|
14
|
-
description: ! 'This is a collection of useful little snippets that I used through
|
15
|
-
out various projects. If there is something you would like to add either check it
|
16
|
-
out and modify it the way you want or let me know and I might add it here.
|
17
21
|
|
18
|
-
|
22
|
+
description: |
|
23
|
+
This is a collection of useful little snippets that I used through out various projects. If there is something you would like to add either check it out and modify it the way you want or let me know and I might add it here.
|
24
|
+
|
19
25
|
email: nick.gorbikoff@gmail.com
|
20
26
|
executables: []
|
27
|
+
|
21
28
|
extensions: []
|
29
|
+
|
22
30
|
extra_rdoc_files: []
|
23
|
-
|
31
|
+
|
32
|
+
files:
|
24
33
|
- lib/santas_little_helper.rb
|
34
|
+
has_rdoc: true
|
25
35
|
homepage: http://rubygems.org/gems/santas_little_helper
|
26
36
|
licenses: []
|
37
|
+
|
27
38
|
post_install_message:
|
28
39
|
rdoc_options: []
|
29
|
-
|
40
|
+
|
41
|
+
require_paths:
|
30
42
|
- lib
|
31
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
44
|
none: false
|
33
|
-
requirements:
|
34
|
-
- -
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
|
37
|
-
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
hash: 3
|
49
|
+
segments:
|
50
|
+
- 0
|
51
|
+
version: "0"
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
53
|
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
43
61
|
requirements: []
|
62
|
+
|
44
63
|
rubyforge_project:
|
45
|
-
rubygems_version: 1.
|
64
|
+
rubygems_version: 1.4.1
|
46
65
|
signing_key:
|
47
66
|
specification_version: 3
|
48
|
-
summary: It's dumb just like the famous dog, but it may surprise you. It modifies
|
49
|
-
core classes, use at your own risk!
|
67
|
+
summary: It's dumb just like the famous dog, but it may surprise you. It modifies core classes, use at your own risk!
|
50
68
|
test_files: []
|
69
|
+
|