securities 2.0.0 → 2.0.1
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/lib/securities/lookup.rb +2 -2
 - data/lib/securities/stock.rb +0 -4
 - data/lib/securities/version.rb +1 -1
 - data/spec/lookup_spec.rb +1 -0
 - data/spec/stock_spec.rb +4 -1
 - metadata +4 -4
 
    
        data/lib/securities/lookup.rb
    CHANGED
    
    | 
         @@ -9,8 +9,8 @@ module Securities 
     | 
|
| 
       9 
9 
     | 
    
         
             
                class LookupException < StandardError ; end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
                def initialize parameters
         
     | 
| 
       12 
     | 
    
         
            -
                	@input = parameters 
     | 
| 
       13 
     | 
    
         
            -
                	if @input.empty?
         
     | 
| 
      
 12 
     | 
    
         
            +
                	@input = parameters
         
     | 
| 
      
 13 
     | 
    
         
            +
                	if @input.delete(' ').empty?
         
     | 
| 
       14 
14 
     | 
    
         
             
                		raise LookupException, 'The lookup input was empty.'
         
     | 
| 
       15 
15 
     | 
    
         
             
                	end
         
     | 
| 
       16 
16 
     | 
    
         
             
                	url = generate_lookup_url
         
     | 
    
        data/lib/securities/stock.rb
    CHANGED
    
    | 
         @@ -78,10 +78,6 @@ module Securities 
     | 
|
| 
       78 
78 
     | 
    
         
             
            				unless parameters[:symbol].is_a?(String)
         
     | 
| 
       79 
79 
     | 
    
         
             
            					raise StockException, 'Stock symbol must be a string.'
         
     | 
| 
       80 
80 
     | 
    
         
             
            				end
         
     | 
| 
       81 
     | 
    
         
            -
            				# Check if stock symbol is valid.
         
     | 
| 
       82 
     | 
    
         
            -
            				unless parameters[:symbol].match('^[a-zA-Z0-9]+$')
         
     | 
| 
       83 
     | 
    
         
            -
            					raise StockException, 'Invalid stock symbol specified.'
         
     | 
| 
       84 
     | 
    
         
            -
            				end
         
     | 
| 
       85 
81 
     | 
    
         | 
| 
       86 
82 
     | 
    
         
             
            				# Use today date if :end_date is not specified.
         
     | 
| 
       87 
83 
     | 
    
         
             
            				unless parameters.has_key?(:end_date)
         
     | 
    
        data/lib/securities/version.rb
    CHANGED
    
    
    
        data/spec/lookup_spec.rb
    CHANGED
    
    | 
         @@ -6,6 +6,7 @@ describe Securities::Lookup do 
     | 
|
| 
       6 
6 
     | 
    
         
             
            		context "should raise an exception if parameter" do
         
     | 
| 
       7 
7 
     | 
    
         
             
            			it "is empty" do
         
     | 
| 
       8 
8 
     | 
    
         
             
            				expect { Securities::Lookup.new(' ') }.to raise_error('The lookup input was empty.')
         
     | 
| 
      
 9 
     | 
    
         
            +
            				expect { Securities::Lookup.new('') }.to raise_error('The lookup input was empty.')
         
     | 
| 
       9 
10 
     | 
    
         
             
            			end
         
     | 
| 
       10 
11 
     | 
    
         
             
            			it "got no results" do
         
     | 
| 
       11 
12 
     | 
    
         
             
            				expect { Securities::Lookup.new('some invalid lookup string') }.to raise_error('There were no results for this lookup.')
         
     | 
    
        data/spec/stock_spec.rb
    CHANGED
    
    | 
         @@ -16,7 +16,7 @@ describe Securities::Stock do 
     | 
|
| 
       16 
16 
     | 
    
         
             
            		      expect { Securities::Stock.new(:symbol => ["AAPL", "GOOG"], :start_date => '2012-01-01', :end_date => '2012-01-04') }.to raise_error('Stock symbol must be a string.')
         
     | 
| 
       17 
17 
     | 
    
         
             
            		    end
         
     | 
| 
       18 
18 
     | 
    
         
             
            		    it "is an invalid string" do
         
     | 
| 
       19 
     | 
    
         
            -
            		      expect { Securities::Stock.new(:symbol => 'AAPL company', :start_date => '2012-01-01', :end_date => '2012-01-04') }.to raise_error(' 
     | 
| 
      
 19 
     | 
    
         
            +
            		      expect { Securities::Stock.new(:symbol => 'AAPL company', :start_date => '2012-01-01', :end_date => '2012-01-04') }.to raise_error('Stock symbol does not exist.')
         
     | 
| 
       20 
20 
     | 
    
         
             
            		    end
         
     | 
| 
       21 
21 
     | 
    
         
             
            		  end
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
         @@ -55,6 +55,9 @@ describe Securities::Stock do 
     | 
|
| 
       55 
55 
     | 
    
         
             
            	    	expect { @my_stocks = Securities::Stock.new(:symbol => 'AAPL', :start_date => (Date.today-8).strftime("%Y-%m-%d")) }.not_to raise_error
         
     | 
| 
       56 
56 
     | 
    
         
             
            	    	@my_stocks.type.should eq(:daily)
         
     | 
| 
       57 
57 
     | 
    
         
             
            	    end
         
     | 
| 
      
 58 
     | 
    
         
            +
            	    it ":symbol is an Index" do
         
     | 
| 
      
 59 
     | 
    
         
            +
            	    	expect { Securities::Stock.new(:symbol => '^GSPC', :start_date => '2012-01-01', :end_date => '2012-01-04') }.not_to raise_error
         
     | 
| 
      
 60 
     | 
    
         
            +
            	    end
         
     | 
| 
       58 
61 
     | 
    
         | 
| 
       59 
62 
     | 
    
         
             
            	  end
         
     | 
| 
       60 
63 
     | 
    
         
             
            	end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: securities
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.0.1
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2012-09- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-09-20 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: rails
         
     | 
| 
         @@ -99,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       99 
99 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       100 
100 
     | 
    
         
             
                  segments:
         
     | 
| 
       101 
101 
     | 
    
         
             
                  - 0
         
     | 
| 
       102 
     | 
    
         
            -
                  hash: - 
     | 
| 
      
 102 
     | 
    
         
            +
                  hash: -3313097270071002997
         
     | 
| 
       103 
103 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       104 
104 
     | 
    
         
             
              none: false
         
     | 
| 
       105 
105 
     | 
    
         
             
              requirements:
         
     | 
| 
         @@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       108 
108 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       109 
109 
     | 
    
         
             
                  segments:
         
     | 
| 
       110 
110 
     | 
    
         
             
                  - 0
         
     | 
| 
       111 
     | 
    
         
            -
                  hash: - 
     | 
| 
      
 111 
     | 
    
         
            +
                  hash: -3313097270071002997
         
     | 
| 
       112 
112 
     | 
    
         
             
            requirements: []
         
     | 
| 
       113 
113 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       114 
114 
     | 
    
         
             
            rubygems_version: 1.8.24
         
     |