wc 0.93.0 → 0.94.0
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/VERSION +1 -1
 - data/lib/wc.rb +25 -3
 - data/wc.gemspec +2 -2
 - metadata +4 -4
 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.94.0
         
     | 
    
        data/lib/wc.rb
    CHANGED
    
    | 
         @@ -3,9 +3,18 @@ class Wc 
     | 
|
| 
       3 
3 
     | 
    
         
             
              attr_accessor :hide_list
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              def initialize(filename, words, hide_list)
         
     | 
| 
       6 
     | 
    
         
            -
                 
     | 
| 
       7 
     | 
    
         
            -
                 
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
                puts filename
         
     | 
| 
      
 7 
     | 
    
         
            +
                if ! filename.nil?
         
     | 
| 
      
 8 
     | 
    
         
            +
                  @filename = filename
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @hide_list = hide_list
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @occurrences = read
         
     | 
| 
      
 11 
     | 
    
         
            +
                else
         
     | 
| 
      
 12 
     | 
    
         
            +
                  @filename = STDIN
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @hide_list = hide_list
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @occurrences = feed
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
                
         
     | 
| 
      
 17 
     | 
    
         
            +
                
         
     | 
| 
       9 
18 
     | 
    
         
             
                @sorted = Array(occurrences).sort { |one, two| -(one[1] <=> two[1]) }
         
     | 
| 
       10 
19 
     | 
    
         
             
                @words = words
         
     | 
| 
       11 
20 
     | 
    
         
             
              end
         
     | 
| 
         @@ -64,6 +73,19 @@ class Wc 
     | 
|
| 
       64 
73 
     | 
    
         
             
                occurrences
         
     | 
| 
       65 
74 
     | 
    
         
             
              end
         
     | 
| 
       66 
75 
     | 
    
         | 
| 
      
 76 
     | 
    
         
            +
              def feed() 
         
     | 
| 
      
 77 
     | 
    
         
            +
                occurrences = Hash.new { |h, k| h[k] = 0 }
         
     | 
| 
      
 78 
     | 
    
         
            +
                filename.each_line { |line|
         
     | 
| 
      
 79 
     | 
    
         
            +
                  words = line.split
         
     | 
| 
      
 80 
     | 
    
         
            +
                  words.each { |w|
         
     | 
| 
      
 81 
     | 
    
         
            +
                    if ! hide_list.include?(w.downcase)
         
     | 
| 
      
 82 
     | 
    
         
            +
                      occurrences[w.downcase] += 1
         
     | 
| 
      
 83 
     | 
    
         
            +
                    end
         
     | 
| 
      
 84 
     | 
    
         
            +
                  }
         
     | 
| 
      
 85 
     | 
    
         
            +
                }
         
     | 
| 
      
 86 
     | 
    
         
            +
                occurrences
         
     | 
| 
      
 87 
     | 
    
         
            +
              end
         
     | 
| 
      
 88 
     | 
    
         
            +
              
         
     | 
| 
       67 
89 
     | 
    
         | 
| 
       68 
90 
     | 
    
         | 
| 
       69 
91 
     | 
    
         
             
            end
         
     | 
    
        data/wc.gemspec
    CHANGED
    
    | 
         @@ -5,11 +5,11 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.name = %q{wc}
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = "0. 
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.94.0"
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.authors = ["Paolo Perego"]
         
     | 
| 
       12 
     | 
    
         
            -
              s.date = %q{2010-07- 
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = %q{2010-07-09}
         
     | 
| 
       13 
13 
     | 
    
         
             
              s.default_executable = %q{wc}
         
     | 
| 
       14 
14 
     | 
    
         
             
              s.description = %q{your ruby word counter experience}
         
     | 
| 
       15 
15 
     | 
    
         
             
              s.email = %q{thesp0nge@gmail.com}
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: wc
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 359
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
      
 8 
     | 
    
         
            +
              - 94
         
     | 
| 
       9 
9 
     | 
    
         
             
              - 0
         
     | 
| 
       10 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.94.0
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Paolo Perego
         
     | 
| 
         @@ -15,7 +15,7 @@ autorequire: 
     | 
|
| 
       15 
15 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
16 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            date: 2010-07- 
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2010-07-09 00:00:00 +02:00
         
     | 
| 
       19 
19 
     | 
    
         
             
            default_executable: wc
         
     | 
| 
       20 
20 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       21 
21 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     |