ruby-nuggets 0.3.2.280 → 0.3.3.285
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/lib/nuggets/env/user_encoding.rb +53 -0
- data/lib/nuggets/{object/boolean.rb → env/user_home.rb} +19 -34
- data/lib/nuggets/numeric/limit.rb +2 -1
- data/lib/nuggets/version.rb +1 -1
- metadata +9 -8
data/README
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
#--
|
2
|
+
###############################################################################
|
3
|
+
# #
|
4
|
+
# A component of ruby-nuggets, some extensions to the Ruby programming #
|
5
|
+
# language. #
|
6
|
+
# #
|
7
|
+
# Copyright (C) 2008 Jens Wille #
|
8
|
+
# #
|
9
|
+
# Authors: #
|
10
|
+
# Jens Wille <jens.wille@uni-koeln.de> #
|
11
|
+
# #
|
12
|
+
# ruby-nuggets is free software; you can redistribute it and/or modify it #
|
13
|
+
# under the terms of the GNU General Public License as published by the Free #
|
14
|
+
# Software Foundation; either version 3 of the License, or (at your option) #
|
15
|
+
# any later version. #
|
16
|
+
# #
|
17
|
+
# ruby-nuggets is distributed in the hope that it will be useful, but WITHOUT #
|
18
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
20
|
+
# more details. #
|
21
|
+
# #
|
22
|
+
# You should have received a copy of the GNU General Public License along #
|
23
|
+
# with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>. #
|
24
|
+
# #
|
25
|
+
###############################################################################
|
26
|
+
#++
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'win32console'
|
30
|
+
rescue LoadError
|
31
|
+
end
|
32
|
+
|
33
|
+
class << ENV
|
34
|
+
|
35
|
+
# call-seq:
|
36
|
+
# ENV.user_encoding => aString or nil
|
37
|
+
#
|
38
|
+
# Finds the user's selected encoding.
|
39
|
+
def user_encoding
|
40
|
+
ENV['ENCODING'] ||
|
41
|
+
ENV['LANG'][/\.(.*)/, 1] ||
|
42
|
+
if defined?(Win32::Console)
|
43
|
+
"CP#{Win32::Console.InputCP}"
|
44
|
+
else
|
45
|
+
cp = %x{chcp}[/:\s*(.*?)\./, 1] and "CP#{cp}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
if $0 == __FILE__
|
52
|
+
p ENV.user_encoding
|
53
|
+
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# A component of ruby-nuggets, some extensions to the Ruby programming #
|
5
5
|
# language. #
|
6
6
|
# #
|
7
|
-
# Copyright (C)
|
7
|
+
# Copyright (C) 2008 Jens Wille #
|
8
8
|
# #
|
9
9
|
# Authors: #
|
10
10
|
# Jens Wille <jens.wille@uni-koeln.de> #
|
@@ -25,45 +25,30 @@
|
|
25
25
|
###############################################################################
|
26
26
|
#++
|
27
27
|
|
28
|
-
class
|
28
|
+
class << ENV
|
29
29
|
|
30
30
|
# call-seq:
|
31
|
-
#
|
31
|
+
# ENV.user_home => aString
|
32
32
|
#
|
33
|
-
#
|
34
|
-
def
|
35
|
-
|
33
|
+
# Finds the user's home directory. Stolen from RubyGems ;-)
|
34
|
+
def user_home
|
35
|
+
%w[HOME USERPROFILE].each { |homekey|
|
36
|
+
return ENV[homekey] if ENV[homekey]
|
37
|
+
}
|
38
|
+
|
39
|
+
if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
|
40
|
+
return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}"
|
41
|
+
end
|
42
|
+
|
43
|
+
begin
|
44
|
+
File.expand_path('~')
|
45
|
+
rescue ArgumentError
|
46
|
+
File::ALT_SEPARATOR ? 'C:/' : '/'
|
47
|
+
end
|
36
48
|
end
|
37
49
|
|
38
|
-
# call-seq:
|
39
|
-
# object.negate => true or false
|
40
|
-
#
|
41
|
-
#
|
42
|
-
def negate
|
43
|
-
not self
|
44
|
-
end
|
45
|
-
|
46
|
-
alias_method :false?, :negate
|
47
|
-
|
48
|
-
# call-seq:
|
49
|
-
# object.to_bool => true or false
|
50
|
-
#
|
51
|
-
#
|
52
|
-
def to_bool
|
53
|
-
negate.negate
|
54
|
-
end
|
55
|
-
|
56
|
-
alias_method :true?, :to_bool
|
57
|
-
|
58
50
|
end
|
59
51
|
|
60
52
|
if $0 == __FILE__
|
61
|
-
|
62
|
-
p o
|
63
|
-
p o.boolean?
|
64
|
-
p o.negate
|
65
|
-
p o.to_bool
|
66
|
-
p o.true?
|
67
|
-
p o.false?
|
68
|
-
}
|
53
|
+
p ENV.user_home
|
69
54
|
end
|
data/lib/nuggets/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-nuggets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3.285
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Wille
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-17 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -34,7 +34,6 @@ files:
|
|
34
34
|
- lib/nuggets/object/ghost_class.rb
|
35
35
|
- lib/nuggets/object/eigenclass.rb
|
36
36
|
- lib/nuggets/object/blank.rb
|
37
|
-
- lib/nuggets/object/boolean.rb
|
38
37
|
- lib/nuggets/object/msend.rb
|
39
38
|
- lib/nuggets/object/uniclass.rb
|
40
39
|
- lib/nuggets/enumerable/agrep.rb
|
@@ -48,6 +47,8 @@ files:
|
|
48
47
|
- lib/nuggets/string/word_wrap.rb
|
49
48
|
- lib/nuggets/string/nsub.rb
|
50
49
|
- lib/nuggets/string/capitalize_first.rb
|
50
|
+
- lib/nuggets/env/user_home.rb
|
51
|
+
- lib/nuggets/env/user_encoding.rb
|
51
52
|
- lib/nuggets/hash/at.rb
|
52
53
|
- lib/nuggets/hash/only.rb
|
53
54
|
- lib/nuggets/hash/in_order.rb
|
@@ -87,15 +88,15 @@ has_rdoc: true
|
|
87
88
|
homepage: http://prometheus.rubyforge.org/ruby-nuggets
|
88
89
|
post_install_message:
|
89
90
|
rdoc_options:
|
90
|
-
- --
|
91
|
-
- UTF-8
|
92
|
-
- --title
|
93
|
-
- ruby-nuggets Application documentation
|
91
|
+
- --line-numbers
|
94
92
|
- --main
|
95
93
|
- README
|
96
94
|
- --all
|
97
|
-
- --line-numbers
|
98
95
|
- --inline-source
|
96
|
+
- --title
|
97
|
+
- ruby-nuggets Application documentation
|
98
|
+
- --charset
|
99
|
+
- UTF-8
|
99
100
|
require_paths:
|
100
101
|
- lib
|
101
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|