rhymes 0.0.3 → 0.0.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.
Files changed (4) hide show
  1. data/Gemfile +0 -1
  2. data/lib/rhymes.rb +9 -27
  3. data/lib/rhymes/version.rb +1 -1
  4. metadata +5 -5
data/Gemfile CHANGED
@@ -3,7 +3,6 @@ source :rubygems
3
3
  # Specify your gem's dependencies in rhymes.gemspec
4
4
  gemspec
5
5
 
6
- gem 'rake'
7
6
  group :test do
8
7
  gem 'rspec'
9
8
  end
@@ -1,25 +1,15 @@
1
1
  require 'rhymes/version'
2
2
 
3
3
  module Rhymes
4
- DEFAULTS = {:raw_dict => '/tmp/cmudict.0.7a', :compiled => '/tmp/rhymes.dat'}
4
+ @@options = {:raw_dict => '/tmp/cmudict.0.7a', :compiled => '/tmp/rhymes.dat'}
5
5
 
6
6
  class << self
7
- ##
8
- # Sets the raw dictionary location. Default: /tmp/cmudict.0.7a
9
- attr_writer :raw_dict
10
-
11
- ##
12
- # Sets the location to store/retrieve precompiled dictionary. Default: /tmp/rhymes.dat
13
- attr_writer :compiled
14
-
15
7
  ##
16
8
  # Sets up options.
17
9
  # - :raw_dict - location of raw dictionary file. Default: /tmp/cmudict.0.7a
18
10
  # - :compiled - location to store/retrieve precompiled dictionary. Default: /tmp/rhymes.dat
19
- def setup(options = DEFAULTS)
20
- @raw_dict = options[:raw_dict] || @raw_dict || DEFAULTS[:raw_dict]
21
- @compiled = options[:compiled] || @compiled || DEFAULTS[:compiled]
22
- {:raw_dict => @raw_dict, :compiled => @compiled}
11
+ def setup(options)
12
+ @@options.merge!(options)
23
13
  end
24
14
 
25
15
  ##
@@ -48,12 +38,11 @@ module Rhymes
48
38
  end
49
39
 
50
40
  def init
51
- setup unless @compiled && @raw_dict
52
- if File.exists?(@compiled)
53
- @words, @rhymes = Marshal.load(File.open(@compiled, 'rb'){|f| f.read })
54
- elsif File.exists?(@raw_dict)
41
+ if File.exists?(@@options[:compiled])
42
+ @words, @rhymes = Marshal.load(File.open(@@options[:compiled], 'rb'){|f| f.read })
43
+ elsif File.exists?(@@options[:raw_dict])
55
44
  @words, @rhymes = {}, {}
56
- File.open(@raw_dict) do |f|
45
+ File.open(@@options[:raw_dict]) do |f|
57
46
  while l = f.gets do
58
47
  next if l =~ /^[^A-Z]/
59
48
  word, *pron = l.strip.split(' ')
@@ -65,22 +54,15 @@ module Rhymes
65
54
  end
66
55
  end
67
56
  begin
68
- File.open(@compiled, 'wb'){|f| f.write(Marshal.dump([@words, @rhymes]))}
57
+ File.open(@@options[:compiled], 'wb'){|f| f.write(Marshal.dump([@words, @rhymes]))}
69
58
  rescue
70
59
  # ????
71
60
  end
72
61
  else
73
- raise "File #{@data_dir + RAW} does not exist. You can download latest dictionary " +
62
+ raise "File #{@@options[:raw_dict]} does not exist. You can download latest dictionary " +
74
63
  "from https://cmusphinx.svn.sourceforge.net/svnroot/cmusphinx/trunk/cmudict and provide "
75
64
  "file location with Rhymes.setup(:raw_dict => file_full_path) (/tmp/cmudict.0.7a by default)"
76
65
  end
77
66
  end
78
67
  end
79
68
  end
80
-
81
-
82
- if __FILE__ == $0
83
- input = ARGV.empty? ? ['laughter', 'soaring', 'antelope'] : ARGV
84
- input.each{|w| puts "# #{w} - #{Rhymes.rhyme(w).map(&:downcase).join(', ')}"}
85
- end
86
-
@@ -1,3 +1,3 @@
1
1
  module Rhymes
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhymes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-18 00:00:00.000000000Z
12
+ date: 2012-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &82209270 !ruby/object:Gem::Requirement
16
+ requirement: &79065380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *82209270
24
+ version_requirements: *79065380
25
25
  description: Lookup perfect and identical rhymes
26
26
  email:
27
27
  - rubify@softover.com
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  version: '0'
61
61
  requirements: []
62
62
  rubyforge_project: rhymes
63
- rubygems_version: 1.8.11
63
+ rubygems_version: 1.8.15
64
64
  signing_key:
65
65
  specification_version: 3
66
66
  summary: Lookup perfect and identical rhymes