ruby-nuggets 0.5.4 → 0.5.5

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.
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to ruby-nuggets version 0.5.4
5
+ This documentation refers to ruby-nuggets version 0.5.5
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -0,0 +1,5 @@
1
+ require 'nuggets/string/wc_mixin'
2
+
3
+ class String
4
+ include Nuggets::String::WcMixin
5
+ end
@@ -0,0 +1,96 @@
1
+ #--
2
+ ###############################################################################
3
+ # #
4
+ # A component of ruby-nuggets, some extensions to the Ruby programming #
5
+ # language. #
6
+ # #
7
+ # Copyright (C) 2007-2009 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
+ module Nuggets
29
+ class String
30
+ module WcMixin
31
+
32
+ # call-seq:
33
+ # str.wc => anArray
34
+ #
35
+ # Count number of lines, words, and bytes in _str_.
36
+ def wc
37
+ [wc_l, wc_w, wc_c]
38
+ end
39
+
40
+ # call-seq:
41
+ # str.line_count => anInteger
42
+ #
43
+ # Count number of lines in _str_.
44
+ def line_count
45
+ count_by_re(/#{$/}/)
46
+ end
47
+ alias_method :wc_l, :line_count
48
+
49
+ # call-seq:
50
+ # str.word_count => anInteger
51
+ #
52
+ # Count number of words in _str_.
53
+ def word_count
54
+ count_by_re(/\S+/)
55
+ end
56
+ alias_method :wc_w, :word_count
57
+
58
+ # call-seq:
59
+ # str.byte_count => anInteger
60
+ #
61
+ # Count number of bytes in _str_.
62
+ def byte_count
63
+ respond_to?(:bytesize) ? bytesize : count_by_re(//n) - 1
64
+ end
65
+ alias_method :wc_c, :byte_count
66
+
67
+ # call-seq:
68
+ # str.char_count => anInteger
69
+ #
70
+ # Count number of characters in _str_.
71
+ def char_count
72
+ count_by_re(/./m)
73
+ end
74
+ alias_method :wc_m, :char_count
75
+
76
+ # call-seq:
77
+ # str.count_by_re(re) => anInteger
78
+ #
79
+ # Count number of occurrences of +re+ in _str_.
80
+ def count_by_re(re)
81
+ scan(re).size
82
+ end
83
+
84
+ # call-seq:
85
+ # str.count_by_re2(re) => anInteger
86
+ #
87
+ # A more memory-efficient version of #count_by_re.
88
+ def count_by_re2(re)
89
+ count = 0
90
+ scan(re) { |_| count += 1 }
91
+ count
92
+ end
93
+
94
+ end
95
+ end
96
+ end
@@ -4,7 +4,7 @@ module Nuggets
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 5
7
- TINY = 4
7
+ TINY = 5
8
8
 
9
9
  class << self
10
10
 
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.5.4
4
+ version: 0.5.5
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-03-27 00:00:00 +01:00
12
+ date: 2009-04-23 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -61,8 +61,10 @@ files:
61
61
  - lib/nuggets/uri/exist_mixin.rb
62
62
  - lib/nuggets/string/msub.rb
63
63
  - lib/nuggets/string/capitalize_first.rb
64
+ - lib/nuggets/string/wc_mixin.rb
64
65
  - lib/nuggets/string/evaluate.rb
65
66
  - lib/nuggets/string/case.rb
67
+ - lib/nuggets/string/wc.rb
66
68
  - lib/nuggets/string/sub_with_md.rb
67
69
  - lib/nuggets/string/nsub.rb
68
70
  - lib/nuggets/string/word_wrap.rb
@@ -104,6 +106,8 @@ files:
104
106
  - README
105
107
  has_rdoc: true
106
108
  homepage: http://prometheus.rubyforge.org/ruby-nuggets
109
+ licenses: []
110
+
107
111
  post_install_message:
108
112
  rdoc_options:
109
113
  - --inline-source
@@ -113,8 +117,8 @@ rdoc_options:
113
117
  - UTF-8
114
118
  - --main
115
119
  - README
116
- - --all
117
120
  - --line-numbers
121
+ - --all
118
122
  require_paths:
119
123
  - lib
120
124
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -132,9 +136,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
136
  requirements: []
133
137
 
134
138
  rubyforge_project: prometheus
135
- rubygems_version: 1.3.1
139
+ rubygems_version: 1.3.2
136
140
  signing_key:
137
- specification_version: 2
141
+ specification_version: 3
138
142
  summary: Some extensions to the Ruby programming language.
139
143
  test_files: []
140
144