simple-ynab 0.0.2
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/bin/simple-ynab.rb +48 -0
- metadata +45 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: ae61c3a17426da59d0c8496715356fee48d789da
         | 
| 4 | 
            +
              data.tar.gz: 5e52d1792bacc8ed4fc6eec0e28dc2fe186eecd6
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: df75ec306cde43a4a54e3c16d511ac6f8956ca28f14534b37d803a603ee056a56a25306eb9e242a34d5a50af54179852d8d2afec2d6968e25d944e74b3e4f871
         | 
| 7 | 
            +
              data.tar.gz: 50e28de0ba1da5835b9650eba0942507ab16b211bb9bc1a7a4a27a38eec074505154cf486316bdf68d0c70edcb85d0f2970221d5ea8a6f066005fe799d5b4820
         | 
    
        data/bin/simple-ynab.rb
    ADDED
    
    | @@ -0,0 +1,48 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'csv'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
             | 
| 6 | 
            +
            @simple_keywords = ["Date", "Description", "Category", "Memo", "Amount"]
         | 
| 7 | 
            +
            @ynab_keywords        = ["Date", "Payee", "Category", "Memo", "Amount"]
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            @newcsv = []
         | 
| 10 | 
            +
            puts ""
         | 
| 11 | 
            +
             | 
| 12 | 
            +
             | 
| 13 | 
            +
            # Get the csv file from args or prompt user
         | 
| 14 | 
            +
            ARGV.each do |argument|
         | 
| 15 | 
            +
            	@csvfile = ARGV[0]
         | 
| 16 | 
            +
            end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            if ARGV.empty?
         | 
| 19 | 
            +
            	print "No file detected, enter file name: "
         | 
| 20 | 
            +
            	@csvfile = gets
         | 
| 21 | 
            +
            end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            # Import csv
         | 
| 24 | 
            +
            csv = CSV.read(@csvfile, headers: true) #http://bit.ly/1mSlqfA
         | 
| 25 | 
            +
            # @headers = CSV.open('foo.csv','r', :headers => true).read.headers
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            # puts "csv is #{csv}"
         | 
| 28 | 
            +
            indicies = @simple_keywords.map{ |column| csv.headers.index(column)}
         | 
| 29 | 
            +
             | 
| 30 | 
            +
             | 
| 31 | 
            +
            @newcsv = csv.map { |row| row.values_at(*indicies) }
         | 
| 32 | 
            +
             | 
| 33 | 
            +
             | 
| 34 | 
            +
            filename  = File.basename(@csvfile,".*")
         | 
| 35 | 
            +
            pathname = File.join( File.dirname(@csvfile), "#{filename}.simple.csv" )
         | 
| 36 | 
            +
             | 
| 37 | 
            +
             | 
| 38 | 
            +
            # Save headers to file
         | 
| 39 | 
            +
            puts "Saving new file to #{pathname}"
         | 
| 40 | 
            +
            CSV.open(pathname, 'w') do |the_csv|
         | 
| 41 | 
            +
            	the_csv << @ynab_keywords
         | 
| 42 | 
            +
            end
         | 
| 43 | 
            +
            # Save map to file
         | 
| 44 | 
            +
            CSV.open(pathname, 'a+') do |the_csv|
         | 
| 45 | 
            +
            	@newcsv.each do |row|
         | 
| 46 | 
            +
            		the_csv << row
         | 
| 47 | 
            +
            	end
         | 
| 48 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: simple-ynab
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.2
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Spencer Owen
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2014-04-06 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies: []
         | 
| 13 | 
            +
            description: Converts simple bank csv to ynab csv
         | 
| 14 | 
            +
            email: owenspencer@gmail.com
         | 
| 15 | 
            +
            executables:
         | 
| 16 | 
            +
            - simple-ynab.rb
         | 
| 17 | 
            +
            extensions: []
         | 
| 18 | 
            +
            extra_rdoc_files: []
         | 
| 19 | 
            +
            files:
         | 
| 20 | 
            +
            - bin/simple-ynab.rb
         | 
| 21 | 
            +
            homepage: 
         | 
| 22 | 
            +
            licenses:
         | 
| 23 | 
            +
            - MIT
         | 
| 24 | 
            +
            metadata: {}
         | 
| 25 | 
            +
            post_install_message: 
         | 
| 26 | 
            +
            rdoc_options: []
         | 
| 27 | 
            +
            require_paths:
         | 
| 28 | 
            +
            - lib
         | 
| 29 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
              requirements:
         | 
| 31 | 
            +
              - - '>='
         | 
| 32 | 
            +
                - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                  version: '0'
         | 
| 34 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 35 | 
            +
              requirements:
         | 
| 36 | 
            +
              - - '>='
         | 
| 37 | 
            +
                - !ruby/object:Gem::Version
         | 
| 38 | 
            +
                  version: '0'
         | 
| 39 | 
            +
            requirements: []
         | 
| 40 | 
            +
            rubyforge_project: 
         | 
| 41 | 
            +
            rubygems_version: 2.0.3
         | 
| 42 | 
            +
            signing_key: 
         | 
| 43 | 
            +
            specification_version: 4
         | 
| 44 | 
            +
            summary: Converts csv from simple format to ynab format
         | 
| 45 | 
            +
            test_files: []
         |