tesults 1.0.0 → 1.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 +4 -4
- data/lib/tesults.rb +27 -0
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 7fa9be7865cbdeda9f2eccd4dd11c4810788b279
         | 
| 4 | 
            +
              data.tar.gz: 3aebfd30793e3d4ccb90ebce82215b9611e6d846
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2a43aa758c8d5284900d819fd954dac879baffa35c1b28d720115b3d4b9974542648f9ff8d4eb23ea7e4d63154d38899c091f684ebc02c1eadbc4b0aca894f7d
         | 
| 7 | 
            +
              data.tar.gz: cece65ac6296ca768f93c1862b24295c020923a9327965e7bee21433cf71ac84b2990e8d14ed2a67945aa5eddf9dc4faaf44cd1e84436d690acd4c324c4d9dde
         | 
    
        data/lib/tesults.rb
    ADDED
    
    | @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            require 'json'
         | 
| 2 | 
            +
            require 'uri'
         | 
| 3 | 
            +
            require 'net/https'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Tesults
         | 
| 6 | 
            +
                def self.upload(data)
         | 
| 7 | 
            +
                    uri = URI("https://www.tesults.com/results")
         | 
| 8 | 
            +
                    http = Net::HTTP.new(uri.host, uri.port)
         | 
| 9 | 
            +
                    http.use_ssl = true
         | 
| 10 | 
            +
                    req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
         | 
| 11 | 
            +
                    req.body = data.to_json
         | 
| 12 | 
            +
                    res = http.request(req)
         | 
| 13 | 
            +
                    jsonData = JSON.parse(res.body)
         | 
| 14 | 
            +
                    success = false
         | 
| 15 | 
            +
                    message = ""
         | 
| 16 | 
            +
                    if jsonData['error'] == nil
         | 
| 17 | 
            +
                        success = true
         | 
| 18 | 
            +
                        message = (jsonData['data'])['message']
         | 
| 19 | 
            +
                    else
         | 
| 20 | 
            +
                        success = false
         | 
| 21 | 
            +
                        message = (jsonData['error'])['message']
         | 
| 22 | 
            +
                    end
         | 
| 23 | 
            +
                    val = {:success => success, :message => message}
         | 
| 24 | 
            +
                rescue => e
         | 
| 25 | 
            +
                    val = {:success => false, :message => e}
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: tesults
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Tesults
         | 
| @@ -17,7 +17,8 @@ email: | |
| 17 17 | 
             
            executables: []
         | 
| 18 18 | 
             
            extensions: []
         | 
| 19 19 | 
             
            extra_rdoc_files: []
         | 
| 20 | 
            -
            files: | 
| 20 | 
            +
            files:
         | 
| 21 | 
            +
            - lib/tesults.rb
         | 
| 21 22 | 
             
            homepage: https://www.tesults.com
         | 
| 22 23 | 
             
            licenses:
         | 
| 23 24 | 
             
            - MIT
         |