rfortune 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ == Changelog
2
+
3
+ === 0.2.0 (2009-12-07)
4
+
5
+ * Added summation (+)
6
+ * Added file CHANGELOG.rdoc
7
+ * Method 'all_formated' depricated, use 'formated'
8
+ * Method 'all' deprecated, use 'to_a'
9
+
10
+
data/LICENSE CHANGED
File without changes
File without changes
data/TODO.rdoc CHANGED
File without changes
data/VERSION CHANGED
File without changes
@@ -57,6 +57,8 @@ class RFortune
57
57
 
58
58
  end
59
59
 
60
+ self
61
+
60
62
  end
61
63
 
62
64
 
@@ -75,31 +77,62 @@ class RFortune
75
77
 
76
78
  end
77
79
 
78
- # Adds a cookie to the jar
79
- def add cookie
80
+ # Adds one or more cookies to the jar. Takes a String, Array or RFortune as an argument.
81
+ def add cookies
82
+ @cookies += case cookies.class.to_s
83
+ when 'String' then cookies.split('%')
84
+ when 'Array' then cookies
85
+ when 'RFortune' then cookies.to_a
86
+ else raise TypeError, 'Argument has to be of type String, Array or RFortune, but was of type ' + cookies.class.to_s
87
+ end
80
88
 
81
- @cookies += [ cookie ] unless cookie.empty?
89
+ self
82
90
 
83
91
  end
84
92
 
85
- # Returns all cookies as an array
86
- def all
93
+
94
+ # Summation, takes String, Array or RFortune
95
+ def + cookies
96
+
97
+ RFortune.new.add( @cookies ).add( cookies )
98
+
99
+ end
100
+
101
+
102
+ # Returns all cookies in an Array
103
+ def to_a
87
104
 
88
105
  @cookies
89
106
 
90
107
  end
91
108
 
109
+
110
+ # Depricated, alias for to_a
111
+ def all
112
+
113
+ to_a
114
+
115
+ end
116
+
117
+
92
118
  # Returns all cookies in cookie jar file format
93
- def all_formated
119
+ def formated
94
120
 
95
- all_cookies = @cookies.collect { |c| c = "\n%\n" + c }
121
+ cookies = @cookies.collect { |c| c = "\n%\n" + c }
96
122
 
97
- all_cookies += [ "\n%\n" ]
123
+ cookies += [ "\n%\n" ]
98
124
 
99
- all_cookies.to_s.sub( /^\n+/, '' )
125
+ cookies.to_s.sub( /^\n+/, '' )
100
126
 
101
127
  end
102
128
 
129
+
130
+ # Depricated, alias for formated
131
+ def all_formated
132
+ formated
133
+ end
134
+
135
+
103
136
  # Saves the content of the jar to the file specified by argument given
104
137
  # to itself or to the initialize method
105
138
  def save new_file_path = nil
@@ -60,5 +60,17 @@ class RFortuneTest < Test::Unit::TestCase
60
60
 
61
61
  end
62
62
 
63
+ def test_summation
64
+
65
+ first = RFortune.new
66
+ first.add 'fu'
67
+
68
+ second = RFortune.new
69
+ second.add 'bar'
70
+
71
+ assert_equal( "%\nfu\n%\nbar\n%\n", (first + second).formated )
72
+
73
+ end
74
+
63
75
  end
64
76
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfortune
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Helge Rausch
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-05 00:00:00 +01:00
12
+ date: 2009-12-07 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: RFortune provides handling of cookie jar files as known from 'fortune'
16
+ description: For further details consult the README file.
17
17
  email: helge@rauschenimweltnetz.de
18
18
  executables: []
19
19
 
@@ -22,8 +22,10 @@ extensions: []
22
22
  extra_rdoc_files:
23
23
  - README.rdoc
24
24
  - TODO.rdoc
25
+ - CHANGELOG.rdoc
25
26
  files:
26
27
  - lib/rfortune.rb
28
+ - CHANGELOG.rdoc
27
29
  - test/test_rfortune.rb
28
30
  - LICENSE
29
31
  - README.rdoc