tf_uploader 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.
- data/bin/tf +10 -0
- data/bin/tf_uploader +10 -0
- data/lib/models/file_system_file.rb +8 -0
- data/lib/models/tomb.rb +36 -0
- data/lib/tf_uploader.rb +17 -0
- data/lib/tf_uploader/command.rb +8 -0
- data/lib/tf_uploader/uploader.rb +54 -0
- metadata +132 -0
    
        data/bin/tf
    ADDED
    
    
    
        data/bin/tf_uploader
    ADDED
    
    
    
        data/lib/models/tomb.rb
    ADDED
    
    | @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            class Tomb < ActiveRecord::Base
         | 
| 2 | 
            +
              set_table_name "ZTOMB"
         | 
| 3 | 
            +
              set_primary_key "Z_PK"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              has_one :file_system_file, :foreign_key => "ZTOMB"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              def as_json(options={})
         | 
| 8 | 
            +
                {
         | 
| 9 | 
            +
                  :first_name => read_attribute("ZFIRSTNAME"),
         | 
| 10 | 
            +
                  :middle_name => read_attribute("ZMIDDLENAME"),
         | 
| 11 | 
            +
                  :surname => read_attribute("ZLASTNAME"),
         | 
| 12 | 
            +
                  :suffix => read_attribute("ZNAMESUFFIX"),
         | 
| 13 | 
            +
                  :gender => read_attribute("ZGENDER"),
         | 
| 14 | 
            +
                  :eulogy => read_attribute("ZEULOGY"),
         | 
| 15 | 
            +
                  :gravepic_latitude => read_attribute("ZLATITUDE"),
         | 
| 16 | 
            +
                  :gravepic_longitude => read_attribute("ZLONGITUDE"),
         | 
| 17 | 
            +
                  :gravepic_accuracy => read_attribute("ZCOORDINATEACCURACY"),
         | 
| 18 | 
            +
                  :input_at => read_attribute("ZINPUTAT"),
         | 
| 19 | 
            +
                  :account_id => read_attribute("ZSUBDOMAINURL"),
         | 
| 20 | 
            +
                  :guid => read_attribute("ZGUID"),
         | 
| 21 | 
            +
                  :birth_day => read_attribute("ZBIRTHDAY"),
         | 
| 22 | 
            +
                  :birth_month => read_attribute("ZBIRTHMONTH"),
         | 
| 23 | 
            +
                  :birth_year => read_attribute("ZBIRTHYEAR"),
         | 
| 24 | 
            +
                  :death_day => read_attribute("ZDEATHDAY"),
         | 
| 25 | 
            +
                  :death_month => read_attribute("ZDEATHMONTH"),
         | 
| 26 | 
            +
                  :death_year => read_attribute("ZDEATHYEAR"),
         | 
| 27 | 
            +
                  :photo_capture => read_attribute("ZPHOTOCAPTUREDATE"),
         | 
| 28 | 
            +
                  :compass => read_attribute("ZCOMPASS"),
         | 
| 29 | 
            +
                  :angle => read_attribute("ZANGLE"),
         | 
| 30 | 
            +
                  :row_count => read_attribute("ZROWCOUNT"),
         | 
| 31 | 
            +
                  :vet => read_attribute("ZVETERAN"),
         | 
| 32 | 
            +
                  :rotate => "None"
         | 
| 33 | 
            +
                }.merge(options)
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            end
         | 
    
        data/lib/tf_uploader.rb
    ADDED
    
    | @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            require 'thor'
         | 
| 3 | 
            +
            require 'active_record'
         | 
| 4 | 
            +
            require 'sqlite3'
         | 
| 5 | 
            +
            require 'rest_client'
         | 
| 6 | 
            +
            require 'mini_magick'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            module TfUploader
         | 
| 9 | 
            +
              #HOST = "http://www.tombfinder.com"
         | 
| 10 | 
            +
              HOST = "http://localhost:3000"
         | 
| 11 | 
            +
            end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            require 'tf_uploader/uploader'
         | 
| 14 | 
            +
            require 'tf_uploader/command'
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            require 'models/tomb'
         | 
| 17 | 
            +
            require 'models/file_system_file'
         | 
| @@ -0,0 +1,54 @@ | |
| 1 | 
            +
            class TfUploader::Uploader
         | 
| 2 | 
            +
              attr_accessor :base_path, :token
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              def initialize(directory, token)
         | 
| 5 | 
            +
                @base_path = File.expand_path(directory)
         | 
| 6 | 
            +
                @token = token
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                @connection = ActiveRecord::Base.establish_connection(
         | 
| 9 | 
            +
                  :adapter => "sqlite3",
         | 
| 10 | 
            +
                  :database  => File.join(@base_path, "TombfinderNew.sqlite"))
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              def upload!
         | 
| 14 | 
            +
                tombs = Tomb.all
         | 
| 15 | 
            +
                puts "Posting #{tombs.count} records"
         | 
| 16 | 
            +
                Tomb.all.each do |tomb|
         | 
| 17 | 
            +
                  post(tomb)
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
                puts ""
         | 
| 20 | 
            +
                puts "Done!"
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              def post(tomb)
         | 
| 24 | 
            +
                picture = square_pic(tomb)
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                RestClient.post(
         | 
| 27 | 
            +
                  "#{TfUploader::HOST}/api/records.json?auth_token=#{token}",
         | 
| 28 | 
            +
                  :record => tomb.as_json(:gravepic => picture),
         | 
| 29 | 
            +
                  :favorite => "false",
         | 
| 30 | 
            +
                  :name => "record",
         | 
| 31 | 
            +
                  :secret => "U8BsP0TZF"
         | 
| 32 | 
            +
                )
         | 
| 33 | 
            +
                print "."
         | 
| 34 | 
            +
              rescue RestClient::UnprocessableEntity => e
         | 
| 35 | 
            +
                puts ""
         | 
| 36 | 
            +
                puts "Failed to upload record #{tomb.read_attribute("ZGUID")}"
         | 
| 37 | 
            +
              ensure
         | 
| 38 | 
            +
                STDOUT.flush
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
              def square_pic(tomb)
         | 
| 42 | 
            +
                image = MiniMagick::Image.open(File.join(base_path, tomb.file_system_file.path))
         | 
| 43 | 
            +
                if image['width'] > image['height']
         | 
| 44 | 
            +
                  geometry = "#{image['height']}x#{image['height']}+#{image['height']/2}+0"
         | 
| 45 | 
            +
                else
         | 
| 46 | 
            +
                  geometry = "#{image['width']}x#{image['width']}+0+#{image['width']/2}"
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                image.crop geometry
         | 
| 50 | 
            +
                cropped_path = File.join(base_path, "cropped_" + tomb.file_system_file.path)
         | 
| 51 | 
            +
                image.write cropped_path
         | 
| 52 | 
            +
                File.new(cropped_path, 'rb')
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,132 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: tf_uploader
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
              prerelease: 
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - Ross Hale
         | 
| 9 | 
            +
            - Tony Spore
         | 
| 10 | 
            +
            autorequire: 
         | 
| 11 | 
            +
            bindir: bin
         | 
| 12 | 
            +
            cert_chain: []
         | 
| 13 | 
            +
            date: 2012-05-08 00:00:00.000000000 Z
         | 
| 14 | 
            +
            dependencies:
         | 
| 15 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 16 | 
            +
              name: term-ansicolor
         | 
| 17 | 
            +
              requirement: &2164531120 !ruby/object:Gem::Requirement
         | 
| 18 | 
            +
                none: false
         | 
| 19 | 
            +
                requirements:
         | 
| 20 | 
            +
                - - ~>
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: 1.0.7
         | 
| 23 | 
            +
              type: :runtime
         | 
| 24 | 
            +
              prerelease: false
         | 
| 25 | 
            +
              version_requirements: *2164531120
         | 
| 26 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 27 | 
            +
              name: rest-client
         | 
| 28 | 
            +
              requirement: &2164530520 !ruby/object:Gem::Requirement
         | 
| 29 | 
            +
                none: false
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ~>
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: 1.6.7
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: *2164530520
         | 
| 37 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 38 | 
            +
              name: thor
         | 
| 39 | 
            +
              requirement: &2164529900 !ruby/object:Gem::Requirement
         | 
| 40 | 
            +
                none: false
         | 
| 41 | 
            +
                requirements:
         | 
| 42 | 
            +
                - - ~>
         | 
| 43 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 44 | 
            +
                    version: 0.14.6
         | 
| 45 | 
            +
              type: :runtime
         | 
| 46 | 
            +
              prerelease: false
         | 
| 47 | 
            +
              version_requirements: *2164529900
         | 
| 48 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 49 | 
            +
              name: activerecord
         | 
| 50 | 
            +
              requirement: &2164529320 !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                none: false
         | 
| 52 | 
            +
                requirements:
         | 
| 53 | 
            +
                - - ~>
         | 
| 54 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 55 | 
            +
                    version: 3.1.3
         | 
| 56 | 
            +
              type: :runtime
         | 
| 57 | 
            +
              prerelease: false
         | 
| 58 | 
            +
              version_requirements: *2164529320
         | 
| 59 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 60 | 
            +
              name: sqlite3
         | 
| 61 | 
            +
              requirement: &2164528840 !ruby/object:Gem::Requirement
         | 
| 62 | 
            +
                none: false
         | 
| 63 | 
            +
                requirements:
         | 
| 64 | 
            +
                - - ~>
         | 
| 65 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 66 | 
            +
                    version: 1.3.5
         | 
| 67 | 
            +
              type: :runtime
         | 
| 68 | 
            +
              prerelease: false
         | 
| 69 | 
            +
              version_requirements: *2164528840
         | 
| 70 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 71 | 
            +
              name: sqlite3-ruby
         | 
| 72 | 
            +
              requirement: &2164528360 !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                none: false
         | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - ~>
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: 1.3.3
         | 
| 78 | 
            +
              type: :runtime
         | 
| 79 | 
            +
              prerelease: false
         | 
| 80 | 
            +
              version_requirements: *2164528360
         | 
| 81 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 82 | 
            +
              name: mini_magick
         | 
| 83 | 
            +
              requirement: &2164527860 !ruby/object:Gem::Requirement
         | 
| 84 | 
            +
                none: false
         | 
| 85 | 
            +
                requirements:
         | 
| 86 | 
            +
                - - ~>
         | 
| 87 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 88 | 
            +
                    version: '3.4'
         | 
| 89 | 
            +
              type: :runtime
         | 
| 90 | 
            +
              prerelease: false
         | 
| 91 | 
            +
              version_requirements: *2164527860
         | 
| 92 | 
            +
            description: A ruby command line interface for uploading large numbers of tombs to
         | 
| 93 | 
            +
              TombFinder
         | 
| 94 | 
            +
            email: rosshale@gmail.com
         | 
| 95 | 
            +
            executables:
         | 
| 96 | 
            +
            - tf
         | 
| 97 | 
            +
            - tf_uploader
         | 
| 98 | 
            +
            extensions: []
         | 
| 99 | 
            +
            extra_rdoc_files: []
         | 
| 100 | 
            +
            files:
         | 
| 101 | 
            +
            - lib/models/file_system_file.rb
         | 
| 102 | 
            +
            - lib/models/tomb.rb
         | 
| 103 | 
            +
            - lib/tf_uploader/command.rb
         | 
| 104 | 
            +
            - lib/tf_uploader/uploader.rb
         | 
| 105 | 
            +
            - lib/tf_uploader.rb
         | 
| 106 | 
            +
            - bin/tf
         | 
| 107 | 
            +
            - bin/tf_uploader
         | 
| 108 | 
            +
            homepage: http://www.tombfinder.com
         | 
| 109 | 
            +
            licenses: []
         | 
| 110 | 
            +
            post_install_message: 
         | 
| 111 | 
            +
            rdoc_options: []
         | 
| 112 | 
            +
            require_paths:
         | 
| 113 | 
            +
            - lib
         | 
| 114 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 115 | 
            +
              none: false
         | 
| 116 | 
            +
              requirements:
         | 
| 117 | 
            +
              - - ! '>='
         | 
| 118 | 
            +
                - !ruby/object:Gem::Version
         | 
| 119 | 
            +
                  version: '0'
         | 
| 120 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
              none: false
         | 
| 122 | 
            +
              requirements:
         | 
| 123 | 
            +
              - - ! '>='
         | 
| 124 | 
            +
                - !ruby/object:Gem::Version
         | 
| 125 | 
            +
                  version: 1.3.6
         | 
| 126 | 
            +
            requirements: []
         | 
| 127 | 
            +
            rubyforge_project: 
         | 
| 128 | 
            +
            rubygems_version: 1.8.6
         | 
| 129 | 
            +
            signing_key: 
         | 
| 130 | 
            +
            specification_version: 3
         | 
| 131 | 
            +
            summary: TombFinder Uploader
         | 
| 132 | 
            +
            test_files: []
         |