autoexpreso 0.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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/.travis.yml +13 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +56 -0
- data/LICENSE +22 -0
- data/README.md +47 -0
- data/Rakefile +13 -0
- data/autoexpreso-cli.rb +53 -0
- data/autoexpreso.gemspec +28 -0
- data/bin/autoexpreso +9 -0
- data/lib/autoexpreso.rb +59 -0
- data/lib/autoexpreso/cli.rb +56 -0
- data/lib/autoexpreso/data_utils.rb +38 -0
- data/lib/autoexpreso/version.rb +3 -0
- data/spec/autoexpreso_spec.rb +23 -0
- data/spec/data_utils_spec.rb +31 -0
- data/spec/spec_helper.rb +8 -0
- metadata +152 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 36722af20e1bf636532c16cd946c92e1f2bb8512
         | 
| 4 | 
            +
              data.tar.gz: 516854d6d32b9f3175555f928b804c89d56cf457
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 2e3006a7cc105bd579ce460c609ae80758f21738a32b194add28ca6af620424bce9da9ff61a872a489e2d472af238a2ba0a44f8ce3183b3b1eb56b35640366f9
         | 
| 7 | 
            +
              data.tar.gz: 3ca4dba551003d2f4b71553a8c1d2bd580ba15927052892693ce09bc18f5737df6496d878520c03627b0247fd3cffe52bf632cc8ae7ecb262430bdc50e0428ea
         | 
    
        data/.gitignore
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            _*
         | 
    
        data/.rspec
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,56 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: .
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                autoexpreso (0.0.1)
         | 
| 5 | 
            +
                  awesome_print (~> 1.1.0)
         | 
| 6 | 
            +
                  highline (~> 1.6.19)
         | 
| 7 | 
            +
                  mechanize (~> 2.7.1)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            GEM
         | 
| 10 | 
            +
              remote: https://rubygems.org/
         | 
| 11 | 
            +
              specs:
         | 
| 12 | 
            +
                awesome_print (1.1.0)
         | 
| 13 | 
            +
                diff-lcs (1.2.4)
         | 
| 14 | 
            +
                domain_name (0.5.12)
         | 
| 15 | 
            +
                  unf (>= 0.0.5, < 1.0.0)
         | 
| 16 | 
            +
                highline (1.6.19)
         | 
| 17 | 
            +
                http-cookie (1.0.1)
         | 
| 18 | 
            +
                  domain_name (~> 0.5)
         | 
| 19 | 
            +
                mechanize (2.7.1)
         | 
| 20 | 
            +
                  domain_name (~> 0.5, >= 0.5.1)
         | 
| 21 | 
            +
                  http-cookie (~> 1.0.0)
         | 
| 22 | 
            +
                  mime-types (~> 1.17, >= 1.17.2)
         | 
| 23 | 
            +
                  net-http-digest_auth (~> 1.1, >= 1.1.1)
         | 
| 24 | 
            +
                  net-http-persistent (~> 2.5, >= 2.5.2)
         | 
| 25 | 
            +
                  nokogiri (~> 1.4)
         | 
| 26 | 
            +
                  ntlm-http (~> 0.1, >= 0.1.1)
         | 
| 27 | 
            +
                  webrobots (>= 0.0.9, < 0.2)
         | 
| 28 | 
            +
                mime-types (1.23)
         | 
| 29 | 
            +
                mini_portile (0.5.1)
         | 
| 30 | 
            +
                net-http-digest_auth (1.4)
         | 
| 31 | 
            +
                net-http-persistent (2.9)
         | 
| 32 | 
            +
                nokogiri (1.6.0)
         | 
| 33 | 
            +
                  mini_portile (~> 0.5.0)
         | 
| 34 | 
            +
                ntlm-http (0.1.1)
         | 
| 35 | 
            +
                rake (10.1.0)
         | 
| 36 | 
            +
                rspec (2.14.1)
         | 
| 37 | 
            +
                  rspec-core (~> 2.14.0)
         | 
| 38 | 
            +
                  rspec-expectations (~> 2.14.0)
         | 
| 39 | 
            +
                  rspec-mocks (~> 2.14.0)
         | 
| 40 | 
            +
                rspec-core (2.14.4)
         | 
| 41 | 
            +
                rspec-expectations (2.14.0)
         | 
| 42 | 
            +
                  diff-lcs (>= 1.1.3, < 2.0)
         | 
| 43 | 
            +
                rspec-mocks (2.14.2)
         | 
| 44 | 
            +
                unf (0.1.1)
         | 
| 45 | 
            +
                  unf_ext
         | 
| 46 | 
            +
                unf_ext (0.0.6)
         | 
| 47 | 
            +
                webrobots (0.1.1)
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            PLATFORMS
         | 
| 50 | 
            +
              ruby
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            DEPENDENCIES
         | 
| 53 | 
            +
              autoexpreso!
         | 
| 54 | 
            +
              bundler (~> 1.3)
         | 
| 55 | 
            +
              rake
         | 
| 56 | 
            +
              rspec (~> 2.14.0)
         | 
    
        data/LICENSE
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Copyright (c) 2013 Axel Rivera, Jonah Ruiz
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
            the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,47 @@ | |
| 1 | 
            +
            ## Autoexpreso [](https://travis-ci.org/jonahoffline/autoexpreso-cli)
         | 
| 2 | 
            +
            A Ruby Gem and Command-Line App for getting your account status from autoexpreso.com
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            ### Features
         | 
| 5 | 
            +
            * Gets your basic account info
         | 
| 6 | 
            +
            * Gets the latest 20 transactions
         | 
| 7 | 
            +
             | 
| 8 | 
            +
             | 
| 9 | 
            +
            ### Installation
         | 
| 10 | 
            +
            	$ gem install autoexpreso
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            ## Usage
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            Ruby:
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            ```ruby
         | 
| 17 | 
            +
            require 'autoexpreso'
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ae = AutoExpreso::Client.new
         | 
| 20 | 
            +
            ae.login('username', 'password')
         | 
| 21 | 
            +
            ```
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            Commandline-Application:
         | 
| 24 | 
            +
            ```
         | 
| 25 | 
            +
            console
         | 
| 26 | 
            +
            autoexpreso --login
         | 
| 27 | 
            +
            Username:  tavin_pumarejo
         | 
| 28 | 
            +
            Password:  **************
         | 
| 29 | 
            +
             | 
| 30 | 
            +
             | 
| 31 | 
            +
            ## Authors
         | 
| 32 | 
            +
            * [Axel Rivera](http://riveralabs.com)
         | 
| 33 | 
            +
            * [Jonah Ruiz](http://www.pixelhipsters.com)
         | 
| 34 | 
            +
             | 
| 35 | 
            +
             | 
| 36 | 
            +
            ### TODO
         | 
| 37 | 
            +
            * Persistence
         | 
| 38 | 
            +
            * Examples for integrating with Ruby On Rails / Sinatra
         | 
| 39 | 
            +
            * JSON Formatter
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            ## Contributing
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            1. Fork it
         | 
| 44 | 
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         | 
| 45 | 
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 46 | 
            +
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 47 | 
            +
            5. Create new Pull Request
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            require 'bundler/gem_tasks'
         | 
| 2 | 
            +
            require 'rspec/core/rake_task'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            RSpec::Core::RakeTask.new
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            task :default => :spec
         | 
| 7 | 
            +
            task :test => :spec
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            desc 'Run all specs and open browser'
         | 
| 10 | 
            +
            task :lazy do |t|
         | 
| 11 | 
            +
              Rake::Task['spec'].execute
         | 
| 12 | 
            +
              `open coverage/index.html`
         | 
| 13 | 
            +
            end
         | 
    
        data/autoexpreso-cli.rb
    ADDED
    
    | @@ -0,0 +1,53 @@ | |
| 1 | 
            +
            require 'mechanize'
         | 
| 2 | 
            +
            require 'awesome_print'
         | 
| 3 | 
            +
            require "highline/import"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            AE_URL = 'https://www.autoexpreso.com/Login.aspx'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            username = ask('Username:  ')
         | 
| 8 | 
            +
            password = ask('Password:  ') { |q| q.echo = "*" }
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            login_form_id = 'aspnetForm'
         | 
| 11 | 
            +
            login_form_username_name = 'ctl00$ContentPlaceHolder1$Login1$uxUserNameField'
         | 
| 12 | 
            +
            login_form_password_name = 'ctl00$ContentPlaceHolder1$Login1$uxPasswordField'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            account_name_id = '#ctl00_Content_uxLogonAccountName'
         | 
| 15 | 
            +
            account_balance_id = '#ctl00_Content_uxLogonBalanceAmount'
         | 
| 16 | 
            +
            account_status_id = '#ctl00_Content_uxLogonAccountStatus'
         | 
| 17 | 
            +
            account_last_payment_id = '#ctl00_Content_uxLogonAmountLastPayment'
         | 
| 18 | 
            +
            account_last_payment_date_id = '#ctl00_Content_uxLogonDateLastPayment'
         | 
| 19 | 
            +
            account_transaction_table_id = '#ctl00_Content_uxLast20TransactionsGrid'
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            client = Mechanize.new
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            account = Hash.new
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            client.get(AE_URL) do |page|
         | 
| 26 | 
            +
              account_page = page.form_with(id: login_form_id) do |f|
         | 
| 27 | 
            +
                f[login_form_username_name] = username
         | 
| 28 | 
            +
                f[login_form_password_name] = password
         | 
| 29 | 
            +
              end.click_button
         | 
| 30 | 
            +
              
         | 
| 31 | 
            +
              account[:name] = account_page.search(account_name_id).text.strip
         | 
| 32 | 
            +
              account[:balance] = account_page.search(account_balance_id).text.strip
         | 
| 33 | 
            +
              account[:status] = account_page.search(account_status_id).text.strip
         | 
| 34 | 
            +
              account[:last_payment] = account_page.search(account_last_payment_id).text.strip
         | 
| 35 | 
            +
              account[:last_payment_date] = account_page.search(account_last_payment_date_id).text.strip
         | 
| 36 | 
            +
              
         | 
| 37 | 
            +
              transactions = []
         | 
| 38 | 
            +
              table = account_page.search("#{account_transaction_table_id} tbody tr")
         | 
| 39 | 
            +
              table.each do |tr|
         | 
| 40 | 
            +
                tds = tr.search('td')
         | 
| 41 | 
            +
                next unless tds.count == 4
         | 
| 42 | 
            +
                transactions << {
         | 
| 43 | 
            +
                  date: tds[0].text.strip,
         | 
| 44 | 
            +
                  location: tds[1].text.strip,
         | 
| 45 | 
            +
                  amount: tds[2].text.strip,
         | 
| 46 | 
            +
                  tag_number: tds[3].text.strip
         | 
| 47 | 
            +
                }
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
              
         | 
| 50 | 
            +
              account[:transactions] = transactions
         | 
| 51 | 
            +
            end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            ap account
         | 
    
        data/autoexpreso.gemspec
    ADDED
    
    | @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'autoexpreso/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = 'autoexpreso'
         | 
| 8 | 
            +
              spec.version       = AutoExpreso::VERSION
         | 
| 9 | 
            +
              spec.authors       = ['Axel Rivera','Jonah Ruiz']
         | 
| 10 | 
            +
              spec.email         = ['jonah@pixelhipsters.com']
         | 
| 11 | 
            +
              spec.description   = %q{Scrapes autoexpreso.com}
         | 
| 12 | 
            +
              spec.summary       = %q{Scrapes autoexpreso.com for your account status}
         | 
| 13 | 
            +
              spec.homepage      = 'https://www.github.com/jonahoffline/autoexpreso-cli'
         | 
| 14 | 
            +
              spec.license       = 'MIT'
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              spec.files         = `git ls-files`.split($/)
         | 
| 17 | 
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 18 | 
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 19 | 
            +
              spec.require_paths = ['lib']
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              spec.add_dependency 'awesome_print', '~> 1.1.0'
         | 
| 22 | 
            +
              spec.add_dependency 'highline', '~> 1.6.19'
         | 
| 23 | 
            +
              spec.add_dependency 'mechanize', '~> 2.7.1'
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              spec.add_development_dependency 'bundler', '~> 1.3'
         | 
| 26 | 
            +
              spec.add_development_dependency 'rake'
         | 
| 27 | 
            +
              spec.add_development_dependency 'rspec', '~> 2.14.0'
         | 
| 28 | 
            +
            end
         | 
    
        data/bin/autoexpreso
    ADDED
    
    
    
        data/lib/autoexpreso.rb
    ADDED
    
    | @@ -0,0 +1,59 @@ | |
| 1 | 
            +
            require 'autoexpreso/version'
         | 
| 2 | 
            +
            require 'autoexpreso/data_utils'
         | 
| 3 | 
            +
            require 'mechanize'
         | 
| 4 | 
            +
            require 'awesome_print'
         | 
| 5 | 
            +
            require 'ostruct'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module AutoExpreso
         | 
| 8 | 
            +
              class Client
         | 
| 9 | 
            +
                include AutoExpreso::DataUtils
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                AE_URL = 'https://www.autoexpreso.com/Login.aspx'
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                attr_reader :client, :account, :transactions, :account_page
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                def initialize(*args)
         | 
| 16 | 
            +
                  @client       = Mechanize.new
         | 
| 17 | 
            +
                  @account      = Hash.new
         | 
| 18 | 
            +
                  @transactions = []
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                def login(username, password)
         | 
| 22 | 
            +
                  process_request(username, password)
         | 
| 23 | 
            +
                  ap @account
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                def process_request(username, password)
         | 
| 27 | 
            +
                  @client.get(AE_URL) do |page|
         | 
| 28 | 
            +
                    @account_page = page.form_with(id: form_data.login_form_id) do |form|
         | 
| 29 | 
            +
                      form[form_data.login_form_username_name] = username
         | 
| 30 | 
            +
                      form[form_data.login_form_password_name] = password
         | 
| 31 | 
            +
                    end.click_button
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                  save_account
         | 
| 34 | 
            +
                  table_strip
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                def save_account
         | 
| 38 | 
            +
                  attributes.map { |attribute| @account[attribute] = text_strip(form_data.send(attribute)) }
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                def text_strip(field_name)
         | 
| 42 | 
            +
                  @account_page.search(field_name).text.strip
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                def table_data
         | 
| 46 | 
            +
                  @account_page.search("#{form_data.account_transaction_table_id} tbody tr")
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                def table_strip
         | 
| 50 | 
            +
                  table_data.each do |tr|
         | 
| 51 | 
            +
                    tds = tr.search('td')
         | 
| 52 | 
            +
                    next unless tds.count == 4
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                    save_transactions(tds, @transactions)
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                  @account[:transactions] = @transactions
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
            end
         | 
| @@ -0,0 +1,56 @@ | |
| 1 | 
            +
            require 'optparse'
         | 
| 2 | 
            +
            require 'highline/import'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module AutoExpreso
         | 
| 5 | 
            +
              # @author Jonah Ruiz <jonah@pixelhipsters.com>
         | 
| 6 | 
            +
              # A Simple class for the executable version of the gem
         | 
| 7 | 
            +
              class CLI
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                # @param args [Array<String>] The command-line arguments
         | 
| 10 | 
            +
                def initialize(args)
         | 
| 11 | 
            +
                  @args = args
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                # Configures the arguments for the command
         | 
| 15 | 
            +
                # @param opts [OptionParser]
         | 
| 16 | 
            +
                def set_options(opts)
         | 
| 17 | 
            +
                  opts.version = AutoExpreso::VERSION
         | 
| 18 | 
            +
                  opts.banner  = <<MSG
         | 
| 19 | 
            +
            Usage: link_shrink [OPTION]
         | 
| 20 | 
            +
            Description:
         | 
| 21 | 
            +
              Autoexpreso, Scrapes autoexpreso.com for your account status.
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            Options:
         | 
| 24 | 
            +
            MSG
         | 
| 25 | 
            +
                  opts.set_program_name 'AutoExpreso'
         | 
| 26 | 
            +
                  opts.on_head('-l', '--login', 'Log into AutoExpreso') do
         | 
| 27 | 
            +
                    @login = :true
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  opts.on_tail('-v', '--version', 'display the version of AutoExpreso and exit') do
         | 
| 31 | 
            +
                    puts opts.version
         | 
| 32 | 
            +
                    exit
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  opts.on_tail('-h', '--help', 'print this help') do
         | 
| 36 | 
            +
                    puts opts.help
         | 
| 37 | 
            +
                    exit
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                # Parses the command-line arguments and runs the executable
         | 
| 42 | 
            +
                # @return [String] The short url or argument passed
         | 
| 43 | 
            +
                def parse
         | 
| 44 | 
            +
                  opts = OptionParser.new(&method(:set_options))
         | 
| 45 | 
            +
                  opts.parse!(@args)
         | 
| 46 | 
            +
                  return login if @login
         | 
| 47 | 
            +
                  opts.help
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                def login
         | 
| 51 | 
            +
                  username = ask('Username:  ')
         | 
| 52 | 
            +
                  password = ask('Password:  ') { |q| q.echo = '*' }
         | 
| 53 | 
            +
                  AutoExpreso::Client.new.login(username, password)
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
            end
         | 
| @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            module AutoExpreso
         | 
| 2 | 
            +
              module DataUtils
         | 
| 3 | 
            +
                def self.included(base)
         | 
| 4 | 
            +
                  base.extend self
         | 
| 5 | 
            +
                end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                module_function
         | 
| 8 | 
            +
                def form_data
         | 
| 9 | 
            +
                  OpenStruct.new({
         | 
| 10 | 
            +
                    login_form_id:                'aspnetForm',
         | 
| 11 | 
            +
                    login_form_username_name:     'ctl00$ContentPlaceHolder1$Login1$uxUserNameField',
         | 
| 12 | 
            +
                    login_form_password_name:     'ctl00$ContentPlaceHolder1$Login1$uxPasswordField',
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                    account_name_id:              '#ctl00_Content_uxLogonAccountName',
         | 
| 15 | 
            +
                    account_balance_id:           '#ctl00_Content_uxLogonBalanceAmount',
         | 
| 16 | 
            +
                    account_status_id:            '#ctl00_Content_uxLogonAccountStatus',
         | 
| 17 | 
            +
                    account_last_payment_id:      '#ctl00_Content_uxLogonAmountLastPayment',
         | 
| 18 | 
            +
                    account_last_payment_date_id: '#ctl00_Content_uxLogonDateLastPayment',
         | 
| 19 | 
            +
                    account_transaction_table_id: '#ctl00_Content_uxLast20TransactionsGrid'
         | 
| 20 | 
            +
                 })
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                def attributes
         | 
| 24 | 
            +
                  %w(name_id balance_id status_id last_payment_id last_payment_date_id).map do |field_name|
         | 
| 25 | 
            +
                    "account_#{field_name}".to_sym
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                def save_transactions(tds, transactions)
         | 
| 30 | 
            +
                  transactions << {
         | 
| 31 | 
            +
                    date:       tds[0].text.strip,
         | 
| 32 | 
            +
                    location:   tds[1].text.strip,
         | 
| 33 | 
            +
                    amount:     tds[2].text.strip,
         | 
| 34 | 
            +
                    tag_number: tds[3].text.strip
         | 
| 35 | 
            +
                  }
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe AutoExpreso::Client do
         | 
| 4 | 
            +
              let(:auto) { AutoExpreso::Client.new }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              describe '#client' do
         | 
| 7 | 
            +
                it 'returns a new Mechanize instance' do
         | 
| 8 | 
            +
                  expect(auto.client).to be_kind_of(Mechanize)
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              describe '#account' do
         | 
| 13 | 
            +
                it 'returns a Hash' do
         | 
| 14 | 
            +
                  expect(auto.account).to be_a(Hash)
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              describe '#transactions' do
         | 
| 19 | 
            +
                it 'returns an array' do
         | 
| 20 | 
            +
                  expect(auto.transactions).to be_a(Array)
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe AutoExpreso::DataUtils do
         | 
| 4 | 
            +
              let(:data_utils) { AutoExpreso::DataUtils }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              describe '#attributes' do
         | 
| 7 | 
            +
                it 'returns an array of symbols' do
         | 
| 8 | 
            +
                  expect(data_utils.attributes)
         | 
| 9 | 
            +
                  .to match_array [:account_name_id, :account_balance_id, :account_status_id,:account_last_payment_id, :account_last_payment_date_id]
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              describe '#form_data' do
         | 
| 14 | 
            +
                it 'returns an OpenStruct instance' do
         | 
| 15 | 
            +
                  expect(data_utils.form_data).to be_a(OpenStruct)
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                it 'contains methods' do
         | 
| 19 | 
            +
                  expect(data_utils.form_data.methods(false))
         | 
| 20 | 
            +
                  .to match_array [:login_form_id, :login_form_id=, :login_form_username_name, :login_form_username_name=, :login_form_password_name, :login_form_password_name=, :account_name_id, :account_name_id=, :account_balance_id, :account_balance_id=, :account_status_id, :account_status_id=, :account_last_payment_id, :account_last_payment_id=, :account_last_payment_date_id, :account_last_payment_date_id=, :account_transaction_table_id, :account_transaction_table_id=]
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                it 'returns html attributes correctly' do
         | 
| 24 | 
            +
                  expect(data_utils.form_data.login_form_id).to eq('aspnetForm')
         | 
| 25 | 
            +
                  expect(data_utils.form_data.login_form_username_name).to eq('ctl00$ContentPlaceHolder1$Login1$uxUserNameField')
         | 
| 26 | 
            +
                  expect(data_utils.form_data.login_form_password_name).to eq('ctl00$ContentPlaceHolder1$Login1$uxPasswordField')
         | 
| 27 | 
            +
                  expect(data_utils.form_data.account_name_id).to eq('#ctl00_Content_uxLogonAccountName')
         | 
| 28 | 
            +
                  expect(data_utils.form_data.account_balance_id).to eq('#ctl00_Content_uxLogonBalanceAmount')
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | @@ -0,0 +1,152 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: autoexpreso
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Axel Rivera
         | 
| 8 | 
            +
            - Jonah Ruiz
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2013-08-08 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              name: awesome_print
         | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                requirements:
         | 
| 18 | 
            +
                - - ~>
         | 
| 19 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 20 | 
            +
                    version: 1.1.0
         | 
| 21 | 
            +
              type: :runtime
         | 
| 22 | 
            +
              prerelease: false
         | 
| 23 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 24 | 
            +
                requirements:
         | 
| 25 | 
            +
                - - ~>
         | 
| 26 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 27 | 
            +
                    version: 1.1.0
         | 
| 28 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 29 | 
            +
              name: highline
         | 
| 30 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 31 | 
            +
                requirements:
         | 
| 32 | 
            +
                - - ~>
         | 
| 33 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 34 | 
            +
                    version: 1.6.19
         | 
| 35 | 
            +
              type: :runtime
         | 
| 36 | 
            +
              prerelease: false
         | 
| 37 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 38 | 
            +
                requirements:
         | 
| 39 | 
            +
                - - ~>
         | 
| 40 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 41 | 
            +
                    version: 1.6.19
         | 
| 42 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 43 | 
            +
              name: mechanize
         | 
| 44 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 45 | 
            +
                requirements:
         | 
| 46 | 
            +
                - - ~>
         | 
| 47 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 48 | 
            +
                    version: 2.7.1
         | 
| 49 | 
            +
              type: :runtime
         | 
| 50 | 
            +
              prerelease: false
         | 
| 51 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 52 | 
            +
                requirements:
         | 
| 53 | 
            +
                - - ~>
         | 
| 54 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 55 | 
            +
                    version: 2.7.1
         | 
| 56 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 57 | 
            +
              name: bundler
         | 
| 58 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 59 | 
            +
                requirements:
         | 
| 60 | 
            +
                - - ~>
         | 
| 61 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 62 | 
            +
                    version: '1.3'
         | 
| 63 | 
            +
              type: :development
         | 
| 64 | 
            +
              prerelease: false
         | 
| 65 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 66 | 
            +
                requirements:
         | 
| 67 | 
            +
                - - ~>
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                    version: '1.3'
         | 
| 70 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 71 | 
            +
              name: rake
         | 
| 72 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                requirements:
         | 
| 74 | 
            +
                - - '>='
         | 
| 75 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 76 | 
            +
                    version: '0'
         | 
| 77 | 
            +
              type: :development
         | 
| 78 | 
            +
              prerelease: false
         | 
| 79 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 80 | 
            +
                requirements:
         | 
| 81 | 
            +
                - - '>='
         | 
| 82 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 83 | 
            +
                    version: '0'
         | 
| 84 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 85 | 
            +
              name: rspec
         | 
| 86 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 87 | 
            +
                requirements:
         | 
| 88 | 
            +
                - - ~>
         | 
| 89 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 90 | 
            +
                    version: 2.14.0
         | 
| 91 | 
            +
              type: :development
         | 
| 92 | 
            +
              prerelease: false
         | 
| 93 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 94 | 
            +
                requirements:
         | 
| 95 | 
            +
                - - ~>
         | 
| 96 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 97 | 
            +
                    version: 2.14.0
         | 
| 98 | 
            +
            description: Scrapes autoexpreso.com
         | 
| 99 | 
            +
            email:
         | 
| 100 | 
            +
            - jonah@pixelhipsters.com
         | 
| 101 | 
            +
            executables:
         | 
| 102 | 
            +
            - autoexpreso
         | 
| 103 | 
            +
            extensions: []
         | 
| 104 | 
            +
            extra_rdoc_files: []
         | 
| 105 | 
            +
            files:
         | 
| 106 | 
            +
            - .gitignore
         | 
| 107 | 
            +
            - .rspec
         | 
| 108 | 
            +
            - .travis.yml
         | 
| 109 | 
            +
            - Gemfile
         | 
| 110 | 
            +
            - Gemfile.lock
         | 
| 111 | 
            +
            - LICENSE
         | 
| 112 | 
            +
            - README.md
         | 
| 113 | 
            +
            - Rakefile
         | 
| 114 | 
            +
            - autoexpreso-cli.rb
         | 
| 115 | 
            +
            - autoexpreso.gemspec
         | 
| 116 | 
            +
            - bin/autoexpreso
         | 
| 117 | 
            +
            - lib/autoexpreso.rb
         | 
| 118 | 
            +
            - lib/autoexpreso/cli.rb
         | 
| 119 | 
            +
            - lib/autoexpreso/data_utils.rb
         | 
| 120 | 
            +
            - lib/autoexpreso/version.rb
         | 
| 121 | 
            +
            - spec/autoexpreso_spec.rb
         | 
| 122 | 
            +
            - spec/data_utils_spec.rb
         | 
| 123 | 
            +
            - spec/spec_helper.rb
         | 
| 124 | 
            +
            homepage: https://www.github.com/jonahoffline/autoexpreso-cli
         | 
| 125 | 
            +
            licenses:
         | 
| 126 | 
            +
            - MIT
         | 
| 127 | 
            +
            metadata: {}
         | 
| 128 | 
            +
            post_install_message: 
         | 
| 129 | 
            +
            rdoc_options: []
         | 
| 130 | 
            +
            require_paths:
         | 
| 131 | 
            +
            - lib
         | 
| 132 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 133 | 
            +
              requirements:
         | 
| 134 | 
            +
              - - '>='
         | 
| 135 | 
            +
                - !ruby/object:Gem::Version
         | 
| 136 | 
            +
                  version: '0'
         | 
| 137 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 138 | 
            +
              requirements:
         | 
| 139 | 
            +
              - - '>='
         | 
| 140 | 
            +
                - !ruby/object:Gem::Version
         | 
| 141 | 
            +
                  version: '0'
         | 
| 142 | 
            +
            requirements: []
         | 
| 143 | 
            +
            rubyforge_project: 
         | 
| 144 | 
            +
            rubygems_version: 2.0.3
         | 
| 145 | 
            +
            signing_key: 
         | 
| 146 | 
            +
            specification_version: 4
         | 
| 147 | 
            +
            summary: Scrapes autoexpreso.com for your account status
         | 
| 148 | 
            +
            test_files:
         | 
| 149 | 
            +
            - spec/autoexpreso_spec.rb
         | 
| 150 | 
            +
            - spec/data_utils_spec.rb
         | 
| 151 | 
            +
            - spec/spec_helper.rb
         | 
| 152 | 
            +
            has_rdoc: 
         |