fibonacci 0.1.3 → 0.1.4

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.
@@ -0,0 +1,2 @@
1
+ require 'mkmf'
2
+ create_makefile('fibonacci/fibonacci')
@@ -0,0 +1,350 @@
1
+ /******************************************************************************
2
+ *
3
+ * Fibonacci Series
4
+ *
5
+ * Author: NagaChaitanya Vellanki
6
+ *
7
+ * ***************************************************************************/
8
+
9
+ #include "ruby.h"
10
+
11
+ #define ONE INT2NUM(1)
12
+ #define ZERO INT2NUM(0)
13
+ #define TWO INT2NUM(2)
14
+ #define ARY_LEN 2L
15
+
16
+ static VALUE cFibonacci;
17
+ static ID id_plus;
18
+ static ID id_lte;
19
+ static ID id_gte;
20
+ static ID id_lt;
21
+ static ID id_pow;
22
+ static ID id_minus;
23
+ static ID id_fdiv;
24
+ static ID id_div;
25
+ static ID id_to_i;
26
+ static ID id_log10;
27
+ static ID id_floor;
28
+ static ID id_sqrt;
29
+ static ID id_mul;
30
+ static ID id_eq;
31
+ static ID id_not_eq;
32
+ static ID id_mod;
33
+
34
+ static VALUE
35
+ fibonacci_init(VALUE self)
36
+ {
37
+ return self;
38
+ }
39
+
40
+ static VALUE
41
+ rb_print_num(VALUE num)
42
+ {
43
+ VALUE num_str = rb_funcall(num, rb_intern("to_s"), 0);
44
+ char *cptr = StringValuePtr(num_str);
45
+ printf("%s\n", cptr);
46
+ return Qnil;
47
+ }
48
+
49
+ static VALUE
50
+ rb_matrix_mul(VALUE ary1, VALUE ary2)
51
+ {
52
+ long i, j, k;
53
+ VALUE temp;
54
+ VALUE tmp_ary = rb_ary_new2(ARY_LEN);
55
+ VALUE zero_ary = rb_ary_new2(ARY_LEN);
56
+
57
+ rb_ary_push(zero_ary, ZERO);
58
+ rb_ary_push(zero_ary, ZERO);
59
+ rb_ary_push(tmp_ary, zero_ary);
60
+
61
+ zero_ary = rb_ary_new2(ARY_LEN);
62
+ rb_ary_push(zero_ary, ZERO);
63
+ rb_ary_push(zero_ary, ZERO);
64
+ rb_ary_push(tmp_ary, zero_ary);
65
+
66
+ for(i = 0; i < 2; i++)
67
+ {
68
+ for(j = 0; j < 2; j++)
69
+ {
70
+ for(k = 0; k < 2; k++)
71
+ {
72
+ //tmp[i][j] = (tmp[i][j] + ary1[i][k] * ary2[k][j]);
73
+ temp = rb_funcall(rb_ary_entry(rb_ary_entry(ary1, i), k), id_mul,
74
+ 1, rb_ary_entry(rb_ary_entry(ary2, k), j));
75
+ rb_ary_store(rb_ary_entry(tmp_ary, i), j, rb_funcall(temp, id_plus, 1, rb_ary_entry(rb_ary_entry(tmp_ary, i), j)));
76
+ }
77
+ }
78
+ }
79
+
80
+ return tmp_ary;
81
+ }
82
+
83
+ static VALUE
84
+ rb_matrix_form(VALUE self, VALUE n)
85
+ {
86
+ VALUE base_ary;
87
+ VALUE res_ary;
88
+ VALUE tmp_ary;
89
+ long ary_len = 2;
90
+
91
+ if(TYPE(n) != T_FIXNUM)
92
+ {
93
+ rb_raise(rb_eArgError, "Invalid argument for type Fixnum");
94
+ return Qnil;
95
+ }
96
+
97
+ if(RTEST(rb_funcall(n, id_lt, 1, ZERO)))
98
+ {
99
+ rb_raise(rb_eArgError, "n cannot be negative");
100
+ return Qnil;
101
+ }
102
+ else
103
+ {
104
+ base_ary = rb_ary_new2(ARY_LEN);
105
+ res_ary = rb_ary_new2(ARY_LEN);
106
+ tmp_ary = rb_ary_new2(ARY_LEN);
107
+
108
+ // base is {{1, 1}, {1, 0}}
109
+ rb_ary_push(tmp_ary, ONE);
110
+ rb_ary_push(tmp_ary, ONE);
111
+ rb_ary_push(base_ary, tmp_ary);
112
+
113
+ tmp_ary = rb_ary_new2(ARY_LEN);
114
+ rb_ary_push(tmp_ary, ONE);
115
+ rb_ary_push(tmp_ary, ZERO);
116
+ rb_ary_push(base_ary, tmp_ary);
117
+
118
+ /*// res is {{1, 0}, {0, 1}}*/
119
+ tmp_ary = rb_ary_new2(ARY_LEN);
120
+ rb_ary_push(tmp_ary, ONE);
121
+ rb_ary_push(tmp_ary, ZERO);
122
+ rb_ary_push(res_ary, tmp_ary);
123
+
124
+ tmp_ary = rb_ary_new2(ARY_LEN);
125
+ rb_ary_push(tmp_ary, ZERO);
126
+ rb_ary_push(tmp_ary, ONE);
127
+ rb_ary_push(res_ary, tmp_ary);
128
+
129
+ while(RTEST(rb_funcall(n, id_not_eq, 1, ZERO)))
130
+ {
131
+ if(RTEST(rb_funcall(rb_funcall(n, id_mod, 1, TWO), id_eq, 1, ZERO)))
132
+ {
133
+ n = rb_funcall(n, id_div, 1, TWO);
134
+ base_ary = rb_matrix_mul(base_ary, base_ary);
135
+ }
136
+ else
137
+ {
138
+ n = rb_funcall(n, id_minus, 1, ONE);
139
+ res_ary = rb_matrix_mul(res_ary, base_ary);
140
+ }
141
+ }
142
+ }
143
+
144
+ return res_ary;
145
+ }
146
+
147
+ static VALUE
148
+ rb_iterative_val(VALUE self, VALUE n)
149
+ {
150
+ VALUE start = ZERO;
151
+ VALUE fib_n_1 = ONE;
152
+ VALUE fib_n_2 = ZERO;
153
+ VALUE fib_n = ZERO;
154
+
155
+ if(TYPE(n) != T_FIXNUM)
156
+ {
157
+ rb_raise(rb_eArgError, "Invalid argument for type Fixnum");
158
+ return Qnil;
159
+ }
160
+
161
+ if(RTEST(rb_funcall(n, id_lt, 1, ZERO)))
162
+ {
163
+ rb_raise(rb_eArgError, "n cannot be negative");
164
+ return Qnil;
165
+ }
166
+ else
167
+ {
168
+
169
+ for(start; RTEST(rb_funcall(start, id_lte, 1, n)); start = rb_funcall(start, id_plus, 1, ONE))
170
+ {
171
+ if(RTEST(rb_funcall(start, id_eq, 1, ZERO)))
172
+ {
173
+ fib_n = ZERO;
174
+ }
175
+ else if(RTEST(rb_funcall(start, id_eq, 1, ONE)))
176
+ {
177
+ fib_n = ONE;
178
+ }
179
+ else
180
+ {
181
+ fib_n = rb_funcall(fib_n_1, id_plus, 1, fib_n_2);
182
+ fib_n_2 = fib_n_1;
183
+ fib_n_1 = fib_n;
184
+ }
185
+ }
186
+ }
187
+ return fib_n;
188
+ }
189
+
190
+ static VALUE
191
+ terms(VALUE self, VALUE n)
192
+ {
193
+ long ary_len = NUM2LONG(n);
194
+ long i;
195
+ VALUE ary = Qnil;
196
+
197
+ if(ary_len < 0)
198
+ {
199
+ rb_raise(rb_eArgError, "num terms cannot be negative");
200
+ return ary;
201
+ }
202
+
203
+ ary = rb_ary_new2(ary_len);
204
+
205
+ for(i=0; i < ary_len; i++)
206
+ {
207
+ if(i == 0)
208
+ {
209
+ rb_ary_store(ary, i, ZERO);
210
+ }
211
+ if((i > 0))
212
+ {
213
+ if(i <= 2)
214
+ {
215
+ rb_ary_store(ary, i, ONE);
216
+ }
217
+ else
218
+ {
219
+ rb_ary_store(ary, i, rb_funcall(rb_ary_entry(ary, i-1), id_plus, 1, rb_ary_entry(ary, i-2)));
220
+ }
221
+ }
222
+ }
223
+ return ary;
224
+ }
225
+
226
+ static VALUE
227
+ print(VALUE self, VALUE n)
228
+ {
229
+ VALUE start = ZERO;
230
+ VALUE fib_n_1 = ONE;
231
+ VALUE fib_n_2 = ZERO;
232
+ VALUE fib_n = ZERO;
233
+
234
+ if(TYPE(n) != T_FIXNUM)
235
+ {
236
+ rb_raise(rb_eArgError, "Invalid argument for type Fixnum");
237
+ return Qnil;
238
+ }
239
+
240
+ for(start; RTEST(rb_funcall(start, id_lt, 1, n)); start = rb_funcall(start, id_plus, 1, ONE))
241
+ {
242
+ if(RTEST(rb_funcall(start, id_eq, 1, ZERO)))
243
+ {
244
+ rb_print_num(ZERO);
245
+ }
246
+ else if(RTEST(rb_funcall(start, id_eq, 1, ONE)))
247
+ {
248
+ rb_print_num(ONE);
249
+ }
250
+ else
251
+ {
252
+ fib_n = rb_funcall(fib_n_1, id_plus, 1, fib_n_2);
253
+ fib_n_2 = fib_n_1;
254
+ fib_n_1 = fib_n;
255
+ rb_print_num(fib_n);
256
+ }
257
+ }
258
+
259
+ return Qnil;
260
+ }
261
+
262
+ static VALUE
263
+ index_of(VALUE self, VALUE val)
264
+ {
265
+ return Qnil;
266
+ }
267
+
268
+ static VALUE
269
+ num_digits(VALUE self, VALUE n)
270
+ {
271
+ if(TYPE(n) != T_FIXNUM)
272
+ {
273
+ rb_raise(rb_eArgError, "Invalid argument for type Fixnum");
274
+ return Qnil;
275
+ }
276
+
277
+ if(RTEST(rb_funcall(n, id_lt, 1, ZERO)))
278
+ {
279
+ rb_raise(rb_eArgError, "n cannot be negative");
280
+ return Qnil;
281
+ }
282
+ else
283
+ {
284
+ VALUE phi = ONE;
285
+ VALUE num_digits = ZERO;
286
+ VALUE log_sqrt_5 = ZERO;
287
+ VALUE sqrt_5;
288
+
289
+ if(RTEST(rb_funcall(n, id_eq, 1, ZERO)))
290
+ {
291
+ return ZERO;
292
+ }
293
+
294
+ /* work around since the value log(phi/sqrt(5)) + 1 = 0.8595026380819693
295
+ * converting to integer would be zero
296
+ */
297
+ if(RTEST(rb_funcall(n, id_eq, 1, ONE)))
298
+ {
299
+ return ONE;
300
+ }
301
+
302
+ if(RTEST(rb_funcall(n, id_gte, 1, TWO)))
303
+ {
304
+ sqrt_5 = rb_funcall(rb_mMath, id_sqrt, 1, INT2NUM(5));
305
+ log_sqrt_5 = rb_funcall(rb_mMath, id_log10, 1, sqrt_5);
306
+
307
+ phi = rb_funcall(phi, id_plus, 1, sqrt_5);
308
+ phi = rb_funcall(phi, id_fdiv, 1, TWO);
309
+
310
+ num_digits = rb_funcall(rb_mMath, id_log10, 1, phi);
311
+ num_digits = rb_funcall(num_digits, id_mul, 1, n);
312
+ num_digits = rb_funcall(num_digits, id_minus, 1, log_sqrt_5);
313
+
314
+ num_digits = rb_funcall(num_digits, id_floor, 0);
315
+ num_digits = rb_funcall(num_digits, id_plus, 1, ONE);
316
+ num_digits = rb_funcall(num_digits, id_to_i, 0);
317
+
318
+ return num_digits;
319
+ }
320
+ }
321
+ }
322
+
323
+ void
324
+ Init_fibonacci(void)
325
+ {
326
+ id_plus = rb_intern("+");
327
+ id_lte = rb_intern("<=");
328
+ id_lt = rb_intern("<");
329
+ id_gte = rb_intern(">=");
330
+ id_pow = rb_intern("**");
331
+ id_mul = rb_intern("*");
332
+ id_minus = rb_intern("-");
333
+ id_fdiv = rb_intern("fdiv");
334
+ id_div = rb_intern("/");
335
+ id_to_i = rb_intern("to_i");
336
+ id_log10 = rb_intern("log10");
337
+ id_floor = rb_intern("floor");
338
+ id_sqrt = rb_intern("sqrt");
339
+ id_eq = rb_intern("==");
340
+ id_not_eq = rb_intern("!=");
341
+ id_mod = rb_intern("!=");
342
+
343
+ cFibonacci = rb_define_class("Fibonacci", rb_cObject);
344
+ rb_define_method(cFibonacci, "initialize", fibonacci_init, 0);
345
+ rb_define_method(cFibonacci, "print", print, 1);
346
+ rb_define_method(cFibonacci, "terms", terms, 1);
347
+ rb_define_method(cFibonacci, "num_digits", num_digits, 1);
348
+ rb_define_method(cFibonacci, "[]", rb_iterative_val, 1);
349
+ rb_define_method(cFibonacci, "matrix", rb_matrix_form, 1);
350
+ }
@@ -1,30 +1,2 @@
1
- class Fixnum
2
- def closest_fibonacci
3
- return self if self < 2
4
-
5
- # If we were trying to find the "actual" closest number,
6
- # we would use the inverse of Binet's formula to find the index:
7
- # phi = (1 + 5**0.5) / 2
8
- # index = ((Math.log(self * (5**0.5)) / Math.log(phi)).round)
9
-
10
- cur_in_fib_seq = 2
11
-
12
- number_0 = 0
13
- number_1 = 1
14
-
15
- while(number_0 <= self)
16
- number_0 = 0
17
- number_1 = 1
18
-
19
- for i in 2..cur_in_fib_seq
20
- new_number = number_0 + number_1
21
- number_1 = number_0
22
- number_0 = new_number
23
- end
24
-
25
- cur_in_fib_seq += 1
26
- end
27
-
28
- number_1
29
- end
30
- end
1
+ require 'fibonacci/fibonacci'
2
+ require "fibonacci/version"
@@ -0,0 +1 @@
1
+ VERSION = "0.1.4"
metadata CHANGED
@@ -1,133 +1,50 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fibonacci
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 3
9
- version: 0.1.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
12
- - Cody Johnston
7
+ authors:
8
+ - Chaitanya Vellanki
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-05-13 00:00:00 -07:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: shoulda
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
30
- type: :development
31
- prerelease: false
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: bundler
35
- requirement: &id002 !ruby/object:Gem::Requirement
36
- none: false
37
- requirements:
38
- - - ~>
39
- - !ruby/object:Gem::Version
40
- segments:
41
- - 1
42
- - 0
43
- - 0
44
- version: 1.0.0
45
- type: :development
46
- prerelease: false
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: jeweler
50
- requirement: &id003 !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
53
- - - ~>
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 1
57
- - 6
58
- - 0
59
- version: 1.6.0
60
- type: :development
61
- prerelease: false
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
- name: rcov
65
- requirement: &id004 !ruby/object:Gem::Requirement
66
- none: false
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- segments:
71
- - 0
72
- version: "0"
73
- type: :development
74
- prerelease: false
75
- version_requirements: *id004
76
- description: WOAH!
77
- email: cody@codegobl.in
12
+ date: 2011-12-13 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A Ruby gem for exploring Fibonacci series
15
+ email:
16
+ - me@chaitanyavellanki.com
78
17
  executables: []
79
-
80
- extensions: []
81
-
82
- extra_rdoc_files:
83
- - LICENSE.txt
84
- - README.rdoc
85
- files:
86
- - .Rakefile.swp
87
- - .document
88
- - Gemfile
89
- - Gemfile.lock
90
- - LICENSE.txt
91
- - README.rdoc
92
- - Rakefile
93
- - VERSION
94
- - example_usage/example.rb
95
- - fibonacci.gemspec
18
+ extensions:
19
+ - ext/fibonacci/extconf.rb
20
+ extra_rdoc_files: []
21
+ files:
96
22
  - lib/fibonacci.rb
97
- - test/helper.rb
98
- - test/test_fibonacci.rb
99
- has_rdoc: true
100
- homepage: http://github.com/codegoblin/closest_fibonacci
101
- licenses:
102
- - MIT
23
+ - lib/fibonacci/version.rb
24
+ - ext/fibonacci/fibonacci.c
25
+ - ext/fibonacci/extconf.rb
26
+ homepage: http://github.com/chaitanyav/fibonacci
27
+ licenses: []
103
28
  post_install_message:
104
29
  rdoc_options: []
105
-
106
- require_paths:
30
+ require_paths:
107
31
  - lib
108
- required_ruby_version: !ruby/object:Gem::Requirement
32
+ required_ruby_version: !ruby/object:Gem::Requirement
109
33
  none: false
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- hash: 414973634195712941
114
- segments:
115
- - 0
116
- version: "0"
117
- required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
39
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- segments:
123
- - 0
124
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
125
44
  requirements: []
126
-
127
- rubyforge_project:
128
- rubygems_version: 1.3.7
45
+ rubyforge_project: fibonacci
46
+ rubygems_version: 1.8.5
129
47
  signing_key:
130
48
  specification_version: 3
131
- summary: extends fixnum so that you can find the largest value in the fibonacci sequence smaller than a given number
49
+ summary: Fibonacci
132
50
  test_files: []
133
-
Binary file
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
-
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
- group :development do
9
- gem "shoulda", ">= 0"
10
- gem "bundler", "~> 1.0.0"
11
- gem "jeweler", "~> 1.6.0"
12
- gem "rcov", ">= 0"
13
- end
@@ -1,20 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- git (1.2.5)
5
- jeweler (1.6.0)
6
- bundler (~> 1.0.0)
7
- git (>= 1.2.5)
8
- rake
9
- rake (0.8.7)
10
- rcov (0.9.9)
11
- shoulda (2.11.3)
12
-
13
- PLATFORMS
14
- ruby
15
-
16
- DEPENDENCIES
17
- bundler (~> 1.0.0)
18
- jeweler (~> 1.6.0)
19
- rcov
20
- shoulda
@@ -1,20 +0,0 @@
1
- Copyright (c) 2011 Cody Johnston
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,19 +0,0 @@
1
- = fibonacci
2
-
3
- Description goes here.
4
-
5
- == Contributing to fibonacci
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
- * Fork the project
10
- * Start a feature/bugfix branch
11
- * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2011 Cody Johnston. See LICENSE.txt for
18
- further details.
19
-
data/Rakefile DELETED
@@ -1,52 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "fibonacci"
18
- gem.homepage = "http://github.com/codegoblin/closest_fibonacci"
19
- gem.license = "MIT"
20
- gem.summary = %Q{extends fixnum so that you can find the largest value in the fibonacci sequence smaller than a given number}
21
- gem.description = %Q{WOAH!}
22
- gem.email = "cody@codegobl.in"
23
- gem.authors = ["Cody Johnston"]
24
- end
25
- Jeweler::RubygemsDotOrgTasks.new
26
-
27
- require 'rake/testtask'
28
- Rake::TestTask.new(:test) do |test|
29
- test.libs << 'lib' << 'test'
30
- test.pattern = 'test/**/test_*.rb'
31
- test.verbose = true
32
- end
33
-
34
- require 'rcov/rcovtask'
35
- Rcov::RcovTask.new do |test|
36
- test.libs << 'test'
37
- test.pattern = 'test/**/test_*.rb'
38
- test.verbose = true
39
- test.rcov_opts << '--exclude "gems/*"'
40
- end
41
-
42
- task :default => :test
43
-
44
- require 'rake/rdoctask'
45
- Rake::RDocTask.new do |rdoc|
46
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
-
48
- rdoc.rdoc_dir = 'rdoc'
49
- rdoc.title = "fibonacci #{version}"
50
- rdoc.rdoc_files.include('README*')
51
- rdoc.rdoc_files.include('lib/**/*.rb')
52
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.3
@@ -1,4 +0,0 @@
1
- require 'fibonacci'
2
-
3
- puts "#{156.closest_fibonacci}"
4
- puts "#{99.closest_fibonacci}"
@@ -1,62 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{fibonacci}
8
- s.version = "0.1.3"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Cody Johnston"]
12
- s.date = %q{2011-05-13}
13
- s.description = %q{WOAH!}
14
- s.email = %q{cody@codegobl.in}
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".Rakefile.swp",
21
- ".document",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE.txt",
25
- "README.rdoc",
26
- "Rakefile",
27
- "VERSION",
28
- "example_usage/example.rb",
29
- "fibonacci.gemspec",
30
- "lib/fibonacci.rb",
31
- "test/helper.rb",
32
- "test/test_fibonacci.rb"
33
- ]
34
- s.homepage = %q{http://github.com/codegoblin/closest_fibonacci}
35
- s.licenses = ["MIT"]
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.7}
38
- s.summary = %q{extends fixnum so that you can find the largest value in the fibonacci sequence smaller than a given number}
39
-
40
- if s.respond_to? :specification_version then
41
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
- s.specification_version = 3
43
-
44
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
- s.add_development_dependency(%q<shoulda>, [">= 0"])
46
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
47
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
48
- s.add_development_dependency(%q<rcov>, [">= 0"])
49
- else
50
- s.add_dependency(%q<shoulda>, [">= 0"])
51
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
52
- s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
53
- s.add_dependency(%q<rcov>, [">= 0"])
54
- end
55
- else
56
- s.add_dependency(%q<shoulda>, [">= 0"])
57
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
- s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
59
- s.add_dependency(%q<rcov>, [">= 0"])
60
- end
61
- end
62
-
@@ -1,18 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
- require 'shoulda'
12
-
13
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- require 'fibonacci'
16
-
17
- class Test::Unit::TestCase
18
- end
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestFibonacci < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end