ruby-nuggets 0.4.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,65 +1,5 @@
1
- #--
2
- ###############################################################################
3
- # #
4
- # A component of ruby-nuggets, some extensions to the Ruby programming #
5
- # language. #
6
- # #
7
- # Copyright (C) 2007-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
- require 'socket'
29
- require 'open-uri'
1
+ require 'nuggets/uri/content_type_mixin'
30
2
 
31
3
  module URI
32
-
33
- class << self
34
-
35
- # call-seq:
36
- # URI.content_type(uri) => aString or nil
37
- #
38
- # Return the content type of +uri+, or +nil+ if not found.
39
- def content_type(uri)
40
- open(uri.to_s).content_type
41
- rescue OpenURI::HTTPError, SocketError, Errno::ENOENT, Errno::EHOSTUNREACH, NoMethodError
42
- nil
43
- end
44
-
45
- end
46
-
47
- end
48
-
49
- if $0 == __FILE__
50
- %w[
51
- http://www.google.de
52
- htp://www.google.de
53
- www.google.de
54
- http://blackwinter.de/misc/
55
- http://blackwinter.de/misc/ww.png
56
- http://blackwinter.de/misc/suicide_is_painless.mid
57
- http://blackwinter.de/misc/expand_macros.pl.gz
58
- http://blackwinter.de/misc/blanc60302523.nth
59
- http://blackwinter.de/bla
60
- http://blawinter.de
61
- http://192.168.12.34/foo/bar
62
- ].each { |u|
63
- p [u, URI.content_type(u)]
64
- }
4
+ extend Nuggets::URI::ContentTypeMixin
65
5
  end
@@ -0,0 +1,47 @@
1
+ #--
2
+ ###############################################################################
3
+ # #
4
+ # A component of ruby-nuggets, some extensions to the Ruby programming #
5
+ # language. #
6
+ # #
7
+ # Copyright (C) 2007-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
+ require 'socket'
29
+ require 'open-uri'
30
+
31
+ module Nuggets
32
+ module URI
33
+ module ContentTypeMixin
34
+
35
+ # call-seq:
36
+ # URI.content_type(uri) => aString or nil
37
+ #
38
+ # Return the content type of +uri+, or +nil+ if not found.
39
+ def content_type(uri)
40
+ open(uri.to_s).content_type
41
+ rescue OpenURI::HTTPError, SocketError, Errno::ENOENT, Errno::EHOSTUNREACH, NoMethodError
42
+ nil
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -1,63 +1,5 @@
1
- #--
2
- ###############################################################################
3
- # #
4
- # A component of ruby-nuggets, some extensions to the Ruby programming #
5
- # language. #
6
- # #
7
- # Copyright (C) 2007-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
- require 'open-uri'
1
+ require 'nuggets/uri/exist_mixin'
29
2
 
30
3
  module URI
31
-
32
- class << self
33
-
34
- # call-seq:
35
- # URI.exist?(uri) => true or false
36
- #
37
- # Return +true+ if the named URI exists.
38
- def exist?(uri)
39
- open(uri.to_s)
40
- true
41
- rescue OpenURI::HTTPError, SocketError, Errno::ENOENT
42
- false
43
- end
44
- alias_method :exists?, :exist?
45
-
46
- end
47
-
48
- end
49
-
50
- if $0 == __FILE__
51
- %w[
52
- http://www.google.de
53
- htp://www.google.de
54
- www.google.de
55
- http://xuugle.de
56
- http://blackwinter.de
57
- http://blackwinter.de/bla
58
- http://blackwinter.de/index.html
59
- http://blackwinter.de/index.htm
60
- ].each { |u|
61
- p [u, URI.exist?(u)]
62
- }
4
+ extend Nuggets::URI::ExistMixin
63
5
  end
@@ -0,0 +1,48 @@
1
+ #--
2
+ ###############################################################################
3
+ # #
4
+ # A component of ruby-nuggets, some extensions to the Ruby programming #
5
+ # language. #
6
+ # #
7
+ # Copyright (C) 2007-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
+ require 'open-uri'
29
+
30
+ module Nuggets
31
+ module URI
32
+ module ExistMixin
33
+
34
+ # call-seq:
35
+ # URI.exist?(uri) => true or false
36
+ #
37
+ # Return +true+ if the named URI exists.
38
+ def exist?(uri)
39
+ open(uri.to_s)
40
+ true
41
+ rescue OpenURI::HTTPError, SocketError, Errno::ENOENT
42
+ false
43
+ end
44
+ alias_method :exists?, :exist?
45
+
46
+ end
47
+ end
48
+ end
@@ -3,8 +3,8 @@ module Nuggets
3
3
  module Version
4
4
 
5
5
  MAJOR = 0
6
- MINOR = 4
7
- TINY = 5
6
+ MINOR = 5
7
+ TINY = 0
8
8
 
9
9
  class << self
10
10
 
data/lib/nuggets.rb CHANGED
@@ -53,8 +53,8 @@ def Nuggets(*nuggets)
53
53
  $LOAD_PATH.each { |dir|
54
54
  if File.directory?(dir_path = File.join(dir, path))
55
55
  load_nuggets[path, *Dir[File.join(dir_path, '*')].map { |file|
56
- File.basename(file, '.rb')
57
- }]
56
+ File.basename(file, '.rb') unless file =~ /_mixin\.rb\z/
57
+ }.compact]
58
58
  break
59
59
  end
60
60
  } and raise # otherwise, re-raise
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.4.5
4
+ version: 0.5.0
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: 2009-01-26 00:00:00 +01:00
12
+ date: 2009-02-25 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -50,8 +50,11 @@ files:
50
50
  - lib/nuggets/io/agrep.rb
51
51
  - lib/nuggets/io/modes.rb
52
52
  - lib/nuggets/all.rb
53
+ - lib/nuggets/all_mixins.rb
53
54
  - lib/nuggets/uri/content_type.rb
54
55
  - lib/nuggets/uri/exist.rb
56
+ - lib/nuggets/uri/content_type_mixin.rb
57
+ - lib/nuggets/uri/exist_mixin.rb
55
58
  - lib/nuggets/string/msub.rb
56
59
  - lib/nuggets/string/capitalize_first.rb
57
60
  - lib/nuggets/string/evaluate.rb
@@ -59,17 +62,26 @@ files:
59
62
  - lib/nuggets/string/sub_with_md.rb
60
63
  - lib/nuggets/string/nsub.rb
61
64
  - lib/nuggets/string/word_wrap.rb
65
+ - lib/nuggets/integer/length.rb
62
66
  - lib/nuggets/integer/to_binary_s.rb
67
+ - lib/nuggets/integer/length_mixin.rb
63
68
  - lib/nuggets/integer/factorial.rb
69
+ - lib/nuggets/object/singleton_class_mixin.rb
64
70
  - lib/nuggets/object/uniclass.rb
65
71
  - lib/nuggets/object/virtual_class.rb
72
+ - lib/nuggets/object/silence_mixin.rb
73
+ - lib/nuggets/object/msend_mixin.rb
66
74
  - lib/nuggets/object/blank.rb
67
75
  - lib/nuggets/object/ghost_class.rb
68
76
  - lib/nuggets/object/metaclass.rb
69
77
  - lib/nuggets/object/singleton_class.rb
78
+ - lib/nuggets/object/silence.rb
70
79
  - lib/nuggets/object/eigenclass.rb
80
+ - lib/nuggets/object/boolean_mixin.rb
81
+ - lib/nuggets/object/blank_mixin.rb
71
82
  - lib/nuggets/object/msend.rb
72
83
  - lib/nuggets/object/boolean.rb
84
+ - lib/nuggets/proc/bind_mixin.rb
73
85
  - lib/nuggets/proc/bind.rb
74
86
  - lib/nuggets/util/added_methods.rb
75
87
  - lib/nuggets/util/content_type.rb
@@ -79,6 +91,7 @@ files:
79
91
  - lib/nuggets/util/added_methods/init.rb
80
92
  - lib/nuggets/version.rb
81
93
  - lib/nuggets/tempfile/open.rb
94
+ - lib/nuggets/file/which_mixin.rb
82
95
  - lib/nuggets/file/which.rb
83
96
  - lib/nuggets.rb
84
97
  - Rakefile
@@ -90,11 +103,11 @@ homepage: http://prometheus.rubyforge.org/ruby-nuggets
90
103
  post_install_message:
91
104
  rdoc_options:
92
105
  - --line-numbers
93
- - --main
94
- - README
95
106
  - --inline-source
96
107
  - --title
97
108
  - ruby-nuggets Application documentation
109
+ - --main
110
+ - README
98
111
  - --charset
99
112
  - UTF-8
100
113
  - --all