swivel 0.0.96 → 0.0.102
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/swivel +1 -1
 - data/lib/benchmarking.rb +4 -0
 - data/lib/swivel.rb +17 -11
 - metadata +4 -2
 
    
        data/bin/swivel
    CHANGED
    
    | 
         @@ -74,7 +74,7 @@ class SwivelHelper 
     | 
|
| 
       74 
74 
     | 
    
         | 
| 
       75 
75 
     | 
    
         
             
              def upload name, options = Hash.new
         
     | 
| 
       76 
76 
     | 
    
         
             
                filename = options[:filename]
         
     | 
| 
       77 
     | 
    
         
            -
                data_set = @swivel.upload :original_asset_name => filename,
         
     | 
| 
      
 77 
     | 
    
         
            +
                data_set = @swivel.upload! :original_asset_name => filename,
         
     | 
| 
       78 
78 
     | 
    
         
             
                  :original_asset_path => filename,
         
     | 
| 
       79 
79 
     | 
    
         
             
                  :auto_estimate => true,
         
     | 
| 
       80 
80 
     | 
    
         
             
                  :data => read(filename),
         
     | 
    
        data/lib/benchmarking.rb
    ADDED
    
    
    
        data/lib/swivel.rb
    CHANGED
    
    | 
         @@ -10,7 +10,9 @@ require 'rexml/document' 
     | 
|
| 
       10 
10 
     | 
    
         
             
            require 'yaml'
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            class Time
         
     | 
| 
      
 13 
     | 
    
         
            +
              silence_warnings do
         
     | 
| 
       13 
14 
     | 
    
         
             
              RFC822_DATETIME_REGEX = /\w{3}, \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} [+-]\d{4}/
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
       14 
16 
     | 
    
         
             
            end
         
     | 
| 
       15 
17 
     | 
    
         | 
| 
       16 
18 
     | 
    
         
             
            class String
         
     | 
| 
         @@ -102,16 +104,16 @@ end 
     | 
|
| 
       102 
104 
     | 
    
         
             
            #
         
     | 
| 
       103 
105 
     | 
    
         
             
            # Upload data
         
     | 
| 
       104 
106 
     | 
    
         
             
            #
         
     | 
| 
       105 
     | 
    
         
            -
            #   See Swivel::Connection#upload for a detailed list of options
         
     | 
| 
      
 107 
     | 
    
         
            +
            #   See Swivel::Connection#upload! for a detailed list of options
         
     | 
| 
       106 
108 
     | 
    
         
             
            #
         
     | 
| 
       107 
109 
     | 
    
         
             
            #   # upload a new data_set
         
     | 
| 
       108 
     | 
    
         
            -
            #   data_set = swivel.upload {...}
         
     | 
| 
      
 110 
     | 
    
         
            +
            #   data_set = swivel.upload! {...}
         
     | 
| 
       109 
111 
     | 
    
         
             
            #
         
     | 
| 
       110 
112 
     | 
    
         
             
            #   # append to an existing data_set
         
     | 
| 
       111 
     | 
    
         
            -
            #   data_set = swivel.append {...}.merge(:id => orig_data_set_id)
         
     | 
| 
      
 113 
     | 
    
         
            +
            #   data_set = swivel.append! {...}.merge(:id => orig_data_set_id)
         
     | 
| 
       112 
114 
     | 
    
         
             
            #
         
     | 
| 
       113 
115 
     | 
    
         
             
            #   # replace data for an existing data_set
         
     | 
| 
       114 
     | 
    
         
            -
            #   data_set = swivel.replace {...}.merge(:id => orig_data_set_id)
         
     | 
| 
      
 116 
     | 
    
         
            +
            #   data_set = swivel.replace! {...}.merge(:id => orig_data_set_id)
         
     | 
| 
       115 
117 
     | 
    
         
             
            #
         
     | 
| 
       116 
118 
     | 
    
         
             
            # TODO: constructing URLs for csvs, html pages, etc
         
     | 
| 
       117 
119 
     | 
    
         
             
            #
         
     | 
| 
         @@ -348,7 +350,7 @@ module Swivel 
     | 
|
| 
       348 
350 
     | 
    
         
             
                def append! options = Hash.new
         
     | 
| 
       349 
351 
     | 
    
         
             
                  options.merge! :mode => 'append', :id => self.id
         
     | 
| 
       350 
352 
     | 
    
         
             
                  raise 'feed me data!' if options[:data].blank?
         
     | 
| 
       351 
     | 
    
         
            -
                  appended_data_set = @connection.upload options
         
     | 
| 
      
 353 
     | 
    
         
            +
                  appended_data_set = @connection.upload! options
         
     | 
| 
       352 
354 
     | 
    
         
             
                  @refreshed_at = nil
         
     | 
| 
       353 
355 
     | 
    
         
             
                  @retried = false
         
     | 
| 
       354 
356 
     | 
    
         
             
                  @doc = appended_data_set.instance_variable_get :@doc
         
     | 
| 
         @@ -365,7 +367,7 @@ module Swivel 
     | 
|
| 
       365 
367 
     | 
    
         
             
                def replace! options = Hash.new
         
     | 
| 
       366 
368 
     | 
    
         
             
                  options.merge! :mode => 'replace', :id => self.id
         
     | 
| 
       367 
369 
     | 
    
         
             
                  raise 'feed me data!' if options[:data].blank?
         
     | 
| 
       368 
     | 
    
         
            -
                  replaced_data_set = @connection.upload options
         
     | 
| 
      
 370 
     | 
    
         
            +
                  replaced_data_set = @connection.upload! options
         
     | 
| 
       369 
371 
     | 
    
         
             
                  @refreshed_at = nil
         
     | 
| 
       370 
372 
     | 
    
         
             
                  @retried = false
         
     | 
| 
       371 
373 
     | 
    
         
             
                  @doc = replaced_data_set.instance_variable_get :@doc
         
     | 
| 
         @@ -540,13 +542,15 @@ module Swivel 
     | 
|
| 
       540 
542 
     | 
    
         
             
                #
         
     | 
| 
       541 
543 
     | 
    
         | 
| 
       542 
544 
     | 
    
         
             
                class Config
         
     | 
| 
      
 545 
     | 
    
         
            +
                  silence_warnings do
         
     | 
| 
       543 
546 
     | 
    
         
             
                  CONFIG_DIR = ENV['HOME']
         
     | 
| 
       544 
547 
     | 
    
         
             
                  CONFIG_DIR = RAILS_ROOT if PLATFORM.include?('win32')
         
     | 
| 
       545 
548 
     | 
    
         
             
                  CONFIG_FILE = '.swivelrc'
         
     | 
| 
       546 
549 
     | 
    
         
             
                  DEFAULT_HOST = 'api.swivel.com'
         
     | 
| 
       547 
550 
     | 
    
         
             
                  DEFAULT_CONFIG = { :api_key => '', :protocol => 'http://',
         
     | 
| 
       548 
551 
     | 
    
         
             
                    :host => DEFAULT_HOST, :port => 80,
         
     | 
| 
       549 
     | 
    
         
            -
                    :timeout_up =>  
     | 
| 
      
 552 
     | 
    
         
            +
                    :timeout_up => 1000, :timeout_down => 1000, :path_prefix => '', :logfile => nil }
         
     | 
| 
      
 553 
     | 
    
         
            +
                  end
         
     | 
| 
       550 
554 
     | 
    
         | 
| 
       551 
555 
     | 
    
         
             
                  attr_accessor :config
         
     | 
| 
       552 
556 
     | 
    
         | 
| 
         @@ -717,6 +721,7 @@ module Swivel 
     | 
|
| 
       717 
721 
     | 
    
         
             
                  LAZY
         
     | 
| 
       718 
722 
     | 
    
         
             
                end
         
     | 
| 
       719 
723 
     | 
    
         | 
| 
      
 724 
     | 
    
         
            +
                silence_warnings do
         
     | 
| 
       720 
725 
     | 
    
         
             
                DEFAULT_UPLOAD_OPTIONS = {
         
     | 
| 
       721 
726 
     | 
    
         
             
                  :citation => 'swivel.rb',
         
     | 
| 
       722 
727 
     | 
    
         
             
                  :citation_url => 'www.swivel.com/developer',
         
     | 
| 
         @@ -724,6 +729,7 @@ module Swivel 
     | 
|
| 
       724 
729 
     | 
    
         
             
                  :image_source_url => 'http://www.swivel.com',
         
     | 
| 
       725 
730 
     | 
    
         
             
                  :display_tags => 'swivel api swivel.rb'
         
     | 
| 
       726 
731 
     | 
    
         
             
                }
         
     | 
| 
      
 732 
     | 
    
         
            +
                end
         
     | 
| 
       727 
733 
     | 
    
         | 
| 
       728 
734 
     | 
    
         
             
                # Performs an upload, append, or replace to a data_set in Swivel.
         
     | 
| 
       729 
735 
     | 
    
         
             
                #   # upload a file to swivel
         
     | 
| 
         @@ -767,7 +773,7 @@ module Swivel 
     | 
|
| 
       767 
773 
     | 
    
         
             
                # * You must post data as a string of text.
         
     | 
| 
       768 
774 
     | 
    
         
             
                # * Actually, that's it, I think.
         
     | 
| 
       769 
775 
     | 
    
         | 
| 
       770 
     | 
    
         
            -
                def upload options = Hash.new
         
     | 
| 
      
 776 
     | 
    
         
            +
                def upload! options = Hash.new
         
     | 
| 
       771 
777 
     | 
    
         
             
                  opts = options.clone
         
     | 
| 
       772 
778 
     | 
    
         
             
                  opts[:mode] ||= 'initial'
         
     | 
| 
       773 
779 
     | 
    
         | 
| 
         @@ -783,16 +789,16 @@ module Swivel 
     | 
|
| 
       783 
789 
     | 
    
         
             
                      opts.reverse_merge! DEFAULT_UPLOAD_OPTIONS
         
     | 
| 
       784 
790 
     | 
    
         
             
                      ['/data_sets', :post]
         
     | 
| 
       785 
791 
     | 
    
         
             
                    end
         
     | 
| 
       786 
     | 
    
         
            -
                  call uri, opts, method
         
     | 
| 
      
 792 
     | 
    
         
            +
                  call! uri, opts, method
         
     | 
| 
       787 
793 
     | 
    
         
             
                end
         
     | 
| 
       788 
     | 
    
         
            -
                alias_method :create_data_set, :upload
         
     | 
| 
      
 794 
     | 
    
         
            +
                alias_method :create_data_set, :upload!
         
     | 
| 
       789 
795 
     | 
    
         | 
| 
       790 
796 
     | 
    
         
             
                %w/append replace/.each do |mode|
         
     | 
| 
       791 
797 
     | 
    
         
             
                  class_eval <<-LAZY
         
     | 
| 
       792 
798 
     | 
    
         
             
                    def #{mode} options = Hash.new
         
     | 
| 
       793 
799 
     | 
    
         
             
                      opts = options.clone
         
     | 
| 
       794 
800 
     | 
    
         
             
                      opts[:mode] = "#{mode}"
         
     | 
| 
       795 
     | 
    
         
            -
                      upload opts
         
     | 
| 
      
 801 
     | 
    
         
            +
                      upload! opts
         
     | 
| 
       796 
802 
     | 
    
         
             
                    end
         
     | 
| 
       797 
803 
     | 
    
         
             
                  LAZY
         
     | 
| 
       798 
804 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -3,8 +3,8 @@ rubygems_version: 0.9.4 
     | 
|
| 
       3 
3 
     | 
    
         
             
            specification_version: 1
         
     | 
| 
       4 
4 
     | 
    
         
             
            name: swivel
         
     | 
| 
       5 
5 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       6 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
       7 
     | 
    
         
            -
            date: 2007-10- 
     | 
| 
      
 6 
     | 
    
         
            +
              version: 0.0.102
         
     | 
| 
      
 7 
     | 
    
         
            +
            date: 2007-10-18 00:00:00 -07:00
         
     | 
| 
       8 
8 
     | 
    
         
             
            summary: Ruby interface to the Swivel API.
         
     | 
| 
       9 
9 
     | 
    
         
             
            require_paths: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -32,7 +32,9 @@ files: 
     | 
|
| 
       32 
32 
     | 
    
         
             
            - COPYING
         
     | 
| 
       33 
33 
     | 
    
         
             
            - README
         
     | 
| 
       34 
34 
     | 
    
         
             
            - Rakefile
         
     | 
| 
      
 35 
     | 
    
         
            +
            - lib/benchmarking.rb
         
     | 
| 
       35 
36 
     | 
    
         
             
            - lib/swivel.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            - lib/test
         
     | 
| 
       36 
38 
     | 
    
         
             
            - bin/swivel
         
     | 
| 
       37 
39 
     | 
    
         
             
            - CHANGELOG
         
     | 
| 
       38 
40 
     | 
    
         
             
            test_files: []
         
     |