ruby-nuggets 0.8.8 → 0.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,12 +49,11 @@ module Nuggets
49
49
  target = first.respond_to?(:to_ary) ? self :
50
50
  ::Array.new(size) { |i| i + 1 }.zip(self)
51
51
 
52
- sx = target.std { |x, _| x }
53
- sy = target.std { |_, y| y }
54
-
55
52
  c = target.cov
56
53
 
57
- sx.zero? || sy.zero? ? c < 0 ? -1.0 : 1.0 : c / (sx * sy)
54
+ (sx = target.std { |x, _| x }).zero? ||
55
+ (sy = target.std { |_, y| y }).zero? ?
56
+ c < 0 ? -1.0 : 1.0 : c / (sx * sy)
58
57
  end
59
58
 
60
59
  alias_method :corr, :correlation_coefficient
@@ -0,0 +1,45 @@
1
+ #--
2
+ ###############################################################################
3
+ # #
4
+ # A component of ruby-nuggets, some extensions to the Ruby programming #
5
+ # language. #
6
+ # #
7
+ # Copyright (C) 2007-2012 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 Affero General Public License as published by #
14
+ # the Free Software Foundation; either version 3 of the License, or (at your #
15
+ # option) 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 Affero General Public License #
20
+ # for more details. #
21
+ # #
22
+ # You should have received a copy of the GNU Affero General Public License #
23
+ # along with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>. #
24
+ # #
25
+ ###############################################################################
26
+ #++
27
+
28
+ module Util
29
+
30
+ module LazyAttr
31
+
32
+ private
33
+
34
+ def lazy_attr(attr, freeze = true)
35
+ class << self; self; end.class_eval { attr_reader attr }
36
+
37
+ value = instance_variable_get(name = "@#{attr}") ||
38
+ instance_variable_set(name, yield)
39
+
40
+ freeze ? value.freeze : value
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -4,7 +4,7 @@ module Nuggets
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 8
7
- TINY = 8
7
+ TINY = 9
8
8
 
9
9
  class << self
10
10
 
@@ -26,10 +26,10 @@ describe URI, 'when extended by', Nuggets::URI::ContentTypeMixin do
26
26
  }
27
27
 
28
28
  {
29
- 'http://blackwinter.de/misc/ww.png' => 'image/png',
30
- 'http://blackwinter.de/misc/suicide_is_painless.mid' => 'audio/midi',
31
- 'http://blackwinter.de/misc/expand_macros.pl.gz' => 'application/x-gzip',
32
- 'http://blackwinter.de/misc/blanc60302523.nth' => 'application/vnd.nok-s40theme'
29
+ 'http://blackwinter.de/misc/ww.png' => 'image/png',
30
+ 'http://blackwinter.de/misc/suicide_is_painless.mid' => 'audio/midi',
31
+ 'http://blackwinter.de/misc/fugmann/wille_-_fugmann-slides.tar.gz' => 'application/x-gzip',
32
+ 'http://blackwinter.de/misc/i_hate_ms.pdf' => 'application/pdf'
33
33
  }.each { |u, t|
34
34
  example { URI.content_type(u).should == t }
35
35
  }
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.8.8
4
+ version: 0.8.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-06 00:00:00.000000000 Z
12
+ date: 2012-08-16 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Some extensions to the Ruby programming language.
15
15
  email: jens.wille@uni-koeln.de
@@ -111,6 +111,7 @@ files:
111
111
  - lib/nuggets/util/i18n.rb
112
112
  - lib/nuggets/util/cli.rb
113
113
  - lib/nuggets/util/log_parser.rb
114
+ - lib/nuggets/util/lazy_attr.rb
114
115
  - lib/nuggets/util/pluggable.rb
115
116
  - lib/nuggets/util/added_methods/init.rb
116
117
  - lib/nuggets/util/content_type.rb
@@ -204,7 +205,7 @@ rdoc_options:
204
205
  - --line-numbers
205
206
  - --all
206
207
  - --title
207
- - ruby-nuggets Application documentation (v0.8.8)
208
+ - ruby-nuggets Application documentation (v0.8.9)
208
209
  - --main
209
210
  - README
210
211
  require_paths: