fortune_gem 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/fortune_gem +0 -2
  2. data/lib/fortune_gem.rb +16 -11
  3. metadata +22 -43
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'fortune_gem'
4
-
5
- print "\n"
6
4
  print FortuneGem.give_fortune(:max_length => ARGV.first)
7
5
  print "\n"
@@ -1,19 +1,24 @@
1
- module FortuneGem
2
-
3
- FORTUNES = File.open("#{File.dirname(__FILE__)}/fortunes").read.split("%").map{|f| f.sub("\n", "").strip }
4
-
5
- # Pass an option of :max_length if you want to limit length of fortunes #
6
- def self.give_fortune(options = {:max_length => nil})
7
- fortune = nil
8
-
1
+ class FortuneGem
2
+
3
+ # Pass an option of :max_length if you want to limit length of fortunes #
4
+ def self.give_fortune(options = {})
5
+
9
6
  if options[:max_length]
10
- short_listed = FORTUNES.find_all{|f| f.length <= options[:max_length].to_i}
7
+ short_listed = fortunes.find_all{|f| f.length <= options[:max_length].to_i}
11
8
  fortune = short_listed[rand(short_listed.length)]
12
9
  else
13
- fortune = FORTUNES[rand(FORTUNES.length)]
10
+ fortune = fortunes[rand(fortunes.length)]
14
11
  end
15
12
 
16
13
  fortune
17
14
  end
18
-
15
+
16
+ def self.fortunes
17
+ @fortunes ||= File.open("#{File.dirname(__FILE__)}/fortunes").read.split("%").map{|f| f.sub("\n", "").strip }
18
+ end
19
+
20
+ def self.fortunes=(path)
21
+ @fortunes = path
22
+ end
23
+
19
24
  end
metadata CHANGED
@@ -1,70 +1,49 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fortune_gem
3
- version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 5
10
- version: 0.0.5
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - nodanaonlyzuul
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-05-02 00:00:00 -04:00
19
- default_executable:
12
+ date: 2013-09-23 00:00:00.000000000 Z
20
13
  dependencies: []
21
-
22
- description:
23
- email:
14
+ description: The unix 'fortune' program - implemented as a ruby gem
15
+ email:
24
16
  - beholdthepanda@gmail.com
25
- executables:
17
+ executables:
26
18
  - fortune_gem
27
19
  extensions: []
28
-
29
20
  extra_rdoc_files: []
30
-
31
- files:
21
+ files:
32
22
  - bin/fortune_gem
33
23
  - lib/fortune_gem.rb
34
24
  - lib/fortunes
35
- has_rdoc: true
36
25
  homepage: https://github.com/nodanaonlyzuul
37
26
  licenses: []
38
-
39
27
  post_install_message:
40
28
  rdoc_options: []
41
-
42
- require_paths:
29
+ require_paths:
43
30
  - lib
44
- required_ruby_version: !ruby/object:Gem::Requirement
31
+ required_ruby_version: !ruby/object:Gem::Requirement
45
32
  none: false
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- hash: 3
50
- segments:
51
- - 0
52
- version: "0"
53
- required_rubygems_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
38
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
62
43
  requirements: []
63
-
64
44
  rubyforge_project: nowarning
65
- rubygems_version: 1.3.7
45
+ rubygems_version: 1.8.24
66
46
  signing_key:
67
47
  specification_version: 3
68
48
  summary: A Ruby gem version of the unix 'fortune' program
69
49
  test_files: []
70
-