survey-gizmo-ruby 0.9.6 → 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.
- data/.document +5 -0
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/Gemfile +2 -21
- data/Gemfile.lock +53 -38
- data/README.md +15 -0
- data/Rakefile +3 -39
- data/lib/survey_gizmo/api/page.rb +3 -3
- data/lib/survey_gizmo/api/question.rb +1 -0
- data/lib/survey_gizmo/api/response.rb +5 -1
- data/lib/survey_gizmo/api/survey.rb +1 -0
- data/lib/survey_gizmo/api/survey_campaign.rb +3 -0
- data/lib/survey_gizmo/collection.rb +0 -1
- data/lib/survey_gizmo/resource.rb +57 -31
- data/lib/survey_gizmo/survey_gizmo.rb +3 -1
- data/spec/resource_spec.rb +21 -21
- data/spec/spec_helper.rb +4 -11
- data/spec/survey-gizmo-ruby_spec.rb +32 -32
- data/survey-gizmo-ruby.gemspec +29 -0
- metadata +97 -69
- data/VERSION +0 -1
- data/spec/support/model_cleanup.rb +0 -38
    
        data/.document
    ADDED
    
    
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            --color
         | 
    
        data/Gemfile
    CHANGED
    
    | @@ -1,22 +1,3 @@ | |
| 1 | 
            -
            source  | 
| 1 | 
            +
            source 'https://rubygems.org'
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
            gem 'i18n'
         | 
| 5 | 
            -
            gem 'virtus'
         | 
| 6 | 
            -
            gem 'httparty'
         | 
| 7 | 
            -
            gem 'addressable', :require => "addressable/uri"
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            group :development do
         | 
| 10 | 
            -
              gem 'bluecloth',    :require => nil
         | 
| 11 | 
            -
              gem "yard", "~> 0.7.0"
         | 
| 12 | 
            -
              gem "bundler", "~> 1.0"
         | 
| 13 | 
            -
              gem "jeweler", "~> 1.6.4"
         | 
| 14 | 
            -
              gem 'awesome_print', :require => 'ap'
         | 
| 15 | 
            -
            end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            group :test do
         | 
| 18 | 
            -
              gem "webmock", :require => 'webmock/rspec'
         | 
| 19 | 
            -
              gem "rspec", "~> 2.11.0"
         | 
| 20 | 
            -
              gem 'net-http-spy', :require => nil
         | 
| 21 | 
            -
              gem 'awesome_print', :require => nil
         | 
| 22 | 
            -
            end
         | 
| 3 | 
            +
            gemspec
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,28 +1,46 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: .
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                survey-gizmo-ruby (1.0.0)
         | 
| 5 | 
            +
                  activesupport (>= 3.0)
         | 
| 6 | 
            +
                  addressable
         | 
| 7 | 
            +
                  httparty
         | 
| 8 | 
            +
                  i18n
         | 
| 9 | 
            +
                  virtus (>= 1.0.0)
         | 
| 10 | 
            +
             | 
| 1 11 | 
             
            GEM
         | 
| 2 | 
            -
              remote:  | 
| 12 | 
            +
              remote: https://rubygems.org/
         | 
| 3 13 | 
             
              specs:
         | 
| 4 | 
            -
                activesupport ( | 
| 5 | 
            -
                  i18n (~> 0.6)
         | 
| 6 | 
            -
                   | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
                 | 
| 11 | 
            -
                 | 
| 14 | 
            +
                activesupport (4.0.1)
         | 
| 15 | 
            +
                  i18n (~> 0.6, >= 0.6.4)
         | 
| 16 | 
            +
                  minitest (~> 4.2)
         | 
| 17 | 
            +
                  multi_json (~> 1.3)
         | 
| 18 | 
            +
                  thread_safe (~> 0.1)
         | 
| 19 | 
            +
                  tzinfo (~> 0.3.37)
         | 
| 20 | 
            +
                addressable (2.3.5)
         | 
| 21 | 
            +
                atomic (1.1.14)
         | 
| 22 | 
            +
                axiom-types (0.0.5)
         | 
| 23 | 
            +
                  descendants_tracker (~> 0.0.1)
         | 
| 24 | 
            +
                  ice_nine (~> 0.9)
         | 
| 25 | 
            +
                backports (3.3.5)
         | 
| 26 | 
            +
                coercible (0.2.0)
         | 
| 27 | 
            +
                  backports (~> 3.0, >= 3.1.0)
         | 
| 28 | 
            +
                  descendants_tracker (~> 0.0.1)
         | 
| 29 | 
            +
                crack (0.4.1)
         | 
| 30 | 
            +
                  safe_yaml (~> 0.9.0)
         | 
| 31 | 
            +
                descendants_tracker (0.0.3)
         | 
| 12 32 | 
             
                diff-lcs (1.1.3)
         | 
| 13 | 
            -
                 | 
| 14 | 
            -
                httparty (0. | 
| 15 | 
            -
                   | 
| 16 | 
            -
                  multi_xml
         | 
| 17 | 
            -
                i18n (0.6. | 
| 18 | 
            -
                 | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
                 | 
| 23 | 
            -
                 | 
| 24 | 
            -
                net-http-spy (0.2.1)
         | 
| 25 | 
            -
                rake (0.9.2.2)
         | 
| 33 | 
            +
                equalizer (0.0.7)
         | 
| 34 | 
            +
                httparty (0.12.0)
         | 
| 35 | 
            +
                  json (~> 1.8)
         | 
| 36 | 
            +
                  multi_xml (>= 0.5.2)
         | 
| 37 | 
            +
                i18n (0.6.5)
         | 
| 38 | 
            +
                ice_nine (0.10.0)
         | 
| 39 | 
            +
                json (1.8.1)
         | 
| 40 | 
            +
                minitest (4.7.5)
         | 
| 41 | 
            +
                multi_json (1.8.2)
         | 
| 42 | 
            +
                multi_xml (0.5.5)
         | 
| 43 | 
            +
                rake (10.1.0)
         | 
| 26 44 | 
             
                rspec (2.11.0)
         | 
| 27 45 | 
             
                  rspec-core (~> 2.11.0)
         | 
| 28 46 | 
             
                  rspec-expectations (~> 2.11.0)
         | 
| @@ -31,27 +49,24 @@ GEM | |
| 31 49 | 
             
                rspec-expectations (2.11.3)
         | 
| 32 50 | 
             
                  diff-lcs (~> 1.1.3)
         | 
| 33 51 | 
             
                rspec-mocks (2.11.3)
         | 
| 34 | 
            -
                 | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 52 | 
            +
                safe_yaml (0.9.7)
         | 
| 53 | 
            +
                thread_safe (0.1.3)
         | 
| 54 | 
            +
                  atomic
         | 
| 55 | 
            +
                tzinfo (0.3.38)
         | 
| 56 | 
            +
                virtus (1.0.0)
         | 
| 57 | 
            +
                  axiom-types (~> 0.0.5)
         | 
| 58 | 
            +
                  coercible (~> 0.2)
         | 
| 59 | 
            +
                  descendants_tracker (~> 0.0.1)
         | 
| 60 | 
            +
                  equalizer (~> 0.0.7)
         | 
| 61 | 
            +
                webmock (1.15.2)
         | 
| 37 62 | 
             
                  addressable (>= 2.2.7)
         | 
| 38 | 
            -
                  crack (>= 0. | 
| 39 | 
            -
                yard (0.7.5)
         | 
| 63 | 
            +
                  crack (>= 0.3.2)
         | 
| 40 64 |  | 
| 41 65 | 
             
            PLATFORMS
         | 
| 42 66 | 
             
              ruby
         | 
| 43 67 |  | 
| 44 68 | 
             
            DEPENDENCIES
         | 
| 45 | 
            -
               | 
| 46 | 
            -
              addressable
         | 
| 47 | 
            -
              awesome_print
         | 
| 48 | 
            -
              bluecloth
         | 
| 49 | 
            -
              bundler (~> 1.0)
         | 
| 50 | 
            -
              httparty
         | 
| 51 | 
            -
              i18n
         | 
| 52 | 
            -
              jeweler (~> 1.6.4)
         | 
| 53 | 
            -
              net-http-spy
         | 
| 69 | 
            +
              rake
         | 
| 54 70 | 
             
              rspec (~> 2.11.0)
         | 
| 55 | 
            -
               | 
| 71 | 
            +
              survey-gizmo-ruby!
         | 
| 56 72 | 
             
              webmock
         | 
| 57 | 
            -
              yard (~> 0.7.0)
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,3 +1,18 @@ | |
| 1 | 
            +
            # WARNING:
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            SurveyGizmo doesn't test their REST API when they roll out changes.  They don't publish a list of active defects, and when you call/email for support it is unlikely you will geto a person that knows anything about programming or the REST API.  You can't talk to level 2 support, although they might offer you a discount on their paid consulting rates if the problem persists for more than a few weeks.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            You might be able to work around an active SurveyGizmo debacle by change which API version you use one of::
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            export GIZMO_URI="https://restapi.surveygizmo.com/v2"
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            export GIZMO_URI="https://restapi.surveygizmo.com/head"
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            ...and then your application might work again.
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            -chorn@chorn.com 2013-03-15
         | 
| 14 | 
            +
             | 
| 15 | 
            +
             | 
| 1 16 | 
             
            # Survey Gizmo (ruby)
         | 
| 2 17 |  | 
| 3 18 | 
             
            Integrate with the [Survey Gizmo API](http://developer.surveygizmo.com/resources/rest-api-documentation-version-1-01/) using an ActiveModel style interface. We currently support rest API **v3**. If you want to use version 1 of the API, please use gem version ~0.7.0
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -1,43 +1,7 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'rubygems'
         | 
| 4 | 
            -
            require 'bundler'
         | 
| 5 | 
            -
            begin
         | 
| 6 | 
            -
              Bundler.setup(:default, :development)
         | 
| 7 | 
            -
            rescue Bundler::BundlerError => e
         | 
| 8 | 
            -
              $stderr.puts e.message
         | 
| 9 | 
            -
              $stderr.puts "Run `bundle install` to install missing gems"
         | 
| 10 | 
            -
              exit e.status_code
         | 
| 11 | 
            -
            end
         | 
| 12 | 
            -
            require 'rake'
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            require 'jeweler'
         | 
| 15 | 
            -
            Jeweler::Tasks.new do |gem|
         | 
| 16 | 
            -
              # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
         | 
| 17 | 
            -
              gem.name        = "survey-gizmo-ruby"
         | 
| 18 | 
            -
              gem.homepage    = "http://github.com/RipTheJacker/survey-gizmo-ruby"
         | 
| 19 | 
            -
              gem.license     = "MIT"
         | 
| 20 | 
            -
              gem.summary     = %Q{gem to use the Survey Gizmo REST API}
         | 
| 21 | 
            -
              gem.description = %Q{gem to use the SurveyGizmo.com REST API, v3+}
         | 
| 22 | 
            -
              gem.email       = "self@ripthejacker.com"
         | 
| 23 | 
            -
              gem.authors     = ["Kabari Hendrick", "Chris Horn"]
         | 
| 24 | 
            -
              gem.files       = FileList['lib/**/*.rb', 'Gemfile*', '[A-Z]*', 'Rakefile', 'spec/**/*'].to_a
         | 
| 25 | 
            -
              # dependencies defined in Gemfile
         | 
| 26 | 
            -
            end
         | 
| 27 | 
            -
            Jeweler::RubygemsDotOrgTasks.new
         | 
| 28 | 
            -
             | 
| 29 | 
            -
            require 'rspec/core'
         | 
| 30 | 
            -
            require 'rspec/core/rake_task'
         | 
| 1 | 
            +
            require "bundler/gem_tasks"
         | 
| 2 | 
            +
            require "rspec/core/rake_task"
         | 
| 31 3 | 
             
            RSpec::Core::RakeTask.new(:spec) do |spec|
         | 
| 32 4 | 
             
              spec.pattern = FileList['spec/**/*_spec.rb']
         | 
| 33 5 | 
             
            end
         | 
| 34 6 |  | 
| 35 | 
            -
             | 
| 36 | 
            -
              spec.pattern = 'spec/**/*_spec.rb'
         | 
| 37 | 
            -
              spec.rcov = true
         | 
| 38 | 
            -
            end
         | 
| 39 | 
            -
             | 
| 40 | 
            -
            task :default => :spec
         | 
| 41 | 
            -
             | 
| 42 | 
            -
            require 'yard'
         | 
| 43 | 
            -
            YARD::Rake::YardocTask.new
         | 
| 7 | 
            +
            task :default => :spec
         | 
| @@ -6,7 +6,7 @@ module SurveyGizmo; module API | |
| 6 6 | 
             
                # @macro [attach] virtus_attribute
         | 
| 7 7 | 
             
                #   @return [$2]
         | 
| 8 8 | 
             
                attribute :id,            Integer
         | 
| 9 | 
            -
                attribute :title,          | 
| 9 | 
            +
                attribute :title,         Hash
         | 
| 10 10 | 
             
                attribute :description,   String
         | 
| 11 11 | 
             
                attribute :properties,    Hash
         | 
| 12 12 | 
             
                attribute :after,         Integer
         | 
| @@ -23,7 +23,7 @@ module SurveyGizmo; module API | |
| 23 23 | 
             
                # survey gizmo sends a hash back for :title
         | 
| 24 24 | 
             
                # @private
         | 
| 25 25 | 
             
                def title_with_multilingual=(val)
         | 
| 26 | 
            -
                  self.title_without_multilingual = val.is_a?(Hash) ? val | 
| 26 | 
            +
                  self.title_without_multilingual = val.is_a?(Hash) ? val : { "English" => val }
         | 
| 27 27 | 
             
                end
         | 
| 28 28 |  | 
| 29 29 | 
             
                alias_method_chain :title=, :multilingual
         | 
| @@ -33,4 +33,4 @@ module SurveyGizmo; module API | |
| 33 33 | 
             
                  {:id => self.id, :survey_id => self.survey_id}
         | 
| 34 34 | 
             
                end
         | 
| 35 35 | 
             
              end
         | 
| 36 | 
            -
            end; end
         | 
| 36 | 
            +
            end; end
         | 
| @@ -7,6 +7,7 @@ module SurveyGizmo; module API | |
| 7 7 | 
             
                #   @return [$2]
         | 
| 8 8 | 
             
                attribute :id,              Integer
         | 
| 9 9 | 
             
                attribute :name,            String
         | 
| 10 | 
            +
                attribute :type,            String
         | 
| 10 11 | 
             
                attribute :_type,           String
         | 
| 11 12 | 
             
                attribute :_subtype,        String
         | 
| 12 13 | 
             
                attribute :__subtype,       String
         | 
| @@ -21,6 +22,8 @@ module SurveyGizmo; module API | |
| 21 22 | 
             
                attribute :survey_id,       Integer
         | 
| 22 23 | 
             
                attribute :datecreated,     DateTime
         | 
| 23 24 | 
             
                attribute :datemodified,    DateTime
         | 
| 25 | 
            +
                attribute :surveycampaign,  Integer
         | 
| 26 | 
            +
                attribute :copy,            Boolean
         | 
| 24 27 |  | 
| 25 28 | 
             
                route '/survey/:survey_id/surveycampaign/:id', :via => [:get, :update, :delete]
         | 
| 26 29 | 
             
                route '/survey/:survey_id/surveycampaign', :via => :create
         | 
| @@ -6,7 +6,7 @@ module SurveyGizmo | |
| 6 6 | 
             
                extend ActiveSupport::Concern
         | 
| 7 7 |  | 
| 8 8 | 
             
                included do
         | 
| 9 | 
            -
                  include Virtus
         | 
| 9 | 
            +
                  include Virtus.model
         | 
| 10 10 | 
             
                  instance_variable_set('@paths', {})
         | 
| 11 11 | 
             
                  instance_variable_set('@collections', {})
         | 
| 12 12 | 
             
                  SurveyGizmo::Resource.descendants << self
         | 
| @@ -65,6 +65,18 @@ module SurveyGizmo | |
| 65 65 | 
             
                    resource
         | 
| 66 66 | 
             
                  end
         | 
| 67 67 |  | 
| 68 | 
            +
                  # Copy a resource
         | 
| 69 | 
            +
                  # @param [Integer] id
         | 
| 70 | 
            +
                  # @param [Hash] attributes
         | 
| 71 | 
            +
                  # @return [Resource]
         | 
| 72 | 
            +
                  #   The newly created resource instance
         | 
| 73 | 
            +
                  def copy(attributes = {})
         | 
| 74 | 
            +
                    attributes[:copy] = true
         | 
| 75 | 
            +
                    resource = new(attributes)
         | 
| 76 | 
            +
                    resource.__send__(:_copy)
         | 
| 77 | 
            +
                    resource
         | 
| 78 | 
            +
                  end
         | 
| 79 | 
            +
             | 
| 68 80 | 
             
                  # Deleted the Resource from Survey Gizmo
         | 
| 69 81 | 
             
                  # @param [Hash] conditions
         | 
| 70 82 | 
             
                  # @return [Boolean]
         | 
| @@ -150,7 +162,7 @@ module SurveyGizmo | |
| 150 162 | 
             
                  if new?
         | 
| 151 163 | 
             
                    _create
         | 
| 152 164 | 
             
                  else
         | 
| 153 | 
            -
                    handle_response SurveyGizmo.post(handle_route(:update), :query => self.attributes_without_blanks) do | 
| 165 | 
            +
                    handle_response SurveyGizmo.post(handle_route(:update), :query => self.attributes_without_blanks) do
         | 
| 154 166 | 
             
                      _response.ok? ? saved! : false
         | 
| 155 167 | 
             
                    end
         | 
| 156 168 | 
             
                  end
         | 
| @@ -217,18 +229,18 @@ module SurveyGizmo | |
| 217 229 | 
             
                def errors
         | 
| 218 230 | 
             
                  @errors ||= []
         | 
| 219 231 | 
             
                end
         | 
| 220 | 
            -
             | 
| 232 | 
            +
             | 
| 221 233 | 
             
                # @return [Hash] The raw JSON returned by Survey Gizmo
         | 
| 222 234 | 
             
                def raw_response
         | 
| 223 235 | 
             
                  _response.response if _response
         | 
| 224 236 | 
             
                end
         | 
| 225 | 
            -
             | 
| 237 | 
            +
             | 
| 226 238 | 
             
                # @visibility private
         | 
| 227 239 | 
             
                def inspect
         | 
| 228 | 
            -
                  attrs = self.class. | 
| 240 | 
            +
                  attrs = self.class.attribute_set.map do |attrib|
         | 
| 229 241 | 
             
                    value = attrib.get!(self).inspect
         | 
| 230 242 |  | 
| 231 | 
            -
                    " | 
| 243 | 
            +
                    "@#{attrib.name}=#{value}" if attrib.respond_to?(:name)
         | 
| 232 244 | 
             
                  end
         | 
| 233 245 |  | 
| 234 246 | 
             
                  "#<#{self.class.name}:#{self.object_id} #{attrs.join(' ')}>"
         | 
| @@ -237,7 +249,7 @@ module SurveyGizmo | |
| 237 249 | 
             
                # This class normalizes the response returned by Survey Gizmo
         | 
| 238 250 | 
             
                class Response
         | 
| 239 251 | 
             
                  def ok?
         | 
| 240 | 
            -
                    @response['result_ok']
         | 
| 252 | 
            +
                    @response && @response['result_ok']
         | 
| 241 253 | 
             
                  end
         | 
| 242 254 |  | 
| 243 255 | 
             
                  # The parsed JSON data of the response
         | 
| @@ -249,9 +261,9 @@ module SurveyGizmo | |
| 249 261 | 
             
                  def message
         | 
| 250 262 | 
             
                    @_message ||= @response['message']
         | 
| 251 263 | 
             
                  end
         | 
| 252 | 
            -
             | 
| 264 | 
            +
             | 
| 253 265 | 
             
                  attr_reader :response
         | 
| 254 | 
            -
             | 
| 266 | 
            +
             | 
| 255 267 | 
             
                  private
         | 
| 256 268 | 
             
                  def cleanup_attribute_name(attr)
         | 
| 257 269 | 
             
                    attr.downcase.gsub(/[^[:alnum:]]+/,'_').gsub(/(url|variable|standard|shown)/,'').gsub(/_+/,'_').gsub(/^_/,'').gsub(/_$/,'')
         | 
| @@ -274,33 +286,35 @@ module SurveyGizmo | |
| 274 286 |  | 
| 275 287 | 
             
                  def initialize(response)
         | 
| 276 288 | 
             
                    @response = response.parsed_response
         | 
| 277 | 
            -
                    return  | 
| 289 | 
            +
                    return if @response.nil? or not ok?
         | 
| 278 290 | 
             
                    @_data = @response['data']
         | 
| 279 291 |  | 
| 280 292 | 
             
                    # Handle really crappy [] notation in SG API, so far just in SurveyResponse
         | 
| 281 | 
            -
                    @_data. | 
| 282 | 
            -
                       | 
| 283 | 
            -
             | 
| 284 | 
            -
             | 
| 285 | 
            -
             | 
| 286 | 
            -
             | 
| 287 | 
            -
             | 
| 288 | 
            -
             | 
| 289 | 
            -
                         | 
| 290 | 
            -
             | 
| 291 | 
            -
                         | 
| 292 | 
            -
             | 
| 293 | 
            -
                         | 
| 294 | 
            -
             | 
| 295 | 
            -
                         | 
| 293 | 
            +
                    (@_data.is_a?(Array) ? @_data : [@_data]).each do |data_item|
         | 
| 294 | 
            +
                      data_item.keys.grep(/^\[/).each do |key|
         | 
| 295 | 
            +
                        next unless data_item[key].length > 0
         | 
| 296 | 
            +
             | 
| 297 | 
            +
                        parent = find_attribute_parent(key)
         | 
| 298 | 
            +
                        data_item[parent] = {} unless data_item[parent]
         | 
| 299 | 
            +
             | 
| 300 | 
            +
                        case key.downcase
         | 
| 301 | 
            +
                        when /(url|variable.*standard)/
         | 
| 302 | 
            +
                          data_item[parent][cleanup_attribute_name(key).to_sym] = data_item[key]
         | 
| 303 | 
            +
                        when /variable.*shown/
         | 
| 304 | 
            +
                          data_item[parent][cleanup_attribute_name(key).to_i] = data_item[key].include?("1")
         | 
| 305 | 
            +
                        when /variable/
         | 
| 306 | 
            +
                          data_item[parent][cleanup_attribute_name(key).to_i] = data_item[key].to_i
         | 
| 307 | 
            +
                        when /question/
         | 
| 308 | 
            +
                          data_item[parent][key] = data_item[key]
         | 
| 309 | 
            +
                        end
         | 
| 310 | 
            +
             | 
| 311 | 
            +
                        data_item.delete(key)
         | 
| 296 312 | 
             
                      end
         | 
| 297 | 
            -
             | 
| 298 | 
            -
                      @_data.delete(key)
         | 
| 299 | 
            -
                    end
         | 
| 313 | 
            +
                    end unless @_data.nil?
         | 
| 300 314 | 
             
                  end
         | 
| 301 315 | 
             
                end
         | 
| 302 | 
            -
             | 
| 303 | 
            -
             | 
| 316 | 
            +
             | 
| 317 | 
            +
             | 
| 304 318 | 
             
                protected
         | 
| 305 319 |  | 
| 306 320 | 
             
                def attributes_without_blanks
         | 
| @@ -338,5 +352,17 @@ module SurveyGizmo | |
| 338 352 | 
             
                  end
         | 
| 339 353 | 
             
                end
         | 
| 340 354 |  | 
| 355 | 
            +
                def _copy(attributes = {})
         | 
| 356 | 
            +
                  http = SurveyGizmo.post(handle_route(:update), :query => self.attributes_without_blanks)
         | 
| 357 | 
            +
                  handle_response http do
         | 
| 358 | 
            +
                    if _response.ok?
         | 
| 359 | 
            +
                      self.attributes = _response.data
         | 
| 360 | 
            +
                      saved!
         | 
| 361 | 
            +
                    else
         | 
| 362 | 
            +
                      false
         | 
| 363 | 
            +
                    end
         | 
| 364 | 
            +
                  end
         | 
| 365 | 
            +
                end
         | 
| 366 | 
            +
             | 
| 341 367 | 
             
              end
         | 
| 342 | 
            -
            end
         | 
| 368 | 
            +
            end
         | 
| @@ -5,6 +5,7 @@ require "active_support/core_ext/object/blank" | |
| 5 5 | 
             
            require "active_support/concern"
         | 
| 6 6 | 
             
            require "virtus"
         | 
| 7 7 | 
             
            require "httparty"
         | 
| 8 | 
            +
            require "digest/md5"
         | 
| 8 9 |  | 
| 9 10 | 
             
            require "survey_gizmo/resource"
         | 
| 10 11 | 
             
            require "survey_gizmo/collection"
         | 
| @@ -21,6 +22,7 @@ require "survey_gizmo/api/email_message" | |
| 21 22 | 
             
            module SurveyGizmo
         | 
| 22 23 | 
             
              include HTTParty
         | 
| 23 24 | 
             
              debug_output $stderr if ENV['GIZMO_DEBUG']
         | 
| 25 | 
            +
              default_timeout 600  # 10 minutes, SurveyGizmo has serious problems.
         | 
| 24 26 |  | 
| 25 27 | 
             
              format :json
         | 
| 26 28 |  | 
| @@ -40,7 +42,7 @@ module SurveyGizmo | |
| 40 42 | 
             
              #   The account password
         | 
| 41 43 | 
             
              def self.setup(opts = {})
         | 
| 42 44 | 
             
                self.options = opts
         | 
| 43 | 
            -
                default_params({"user: | 
| 45 | 
            +
                default_params({ "user:md5" => "#{opts[:user]}:#{Digest::MD5.hexdigest(opts[:password])}" })
         | 
| 44 46 | 
             
              end
         | 
| 45 47 |  | 
| 46 48 | 
             
            end
         | 
    
        data/spec/resource_spec.rb
    CHANGED
    
    | @@ -1,26 +1,26 @@ | |
| 1 1 | 
             
            require "spec_helper"
         | 
| 2 2 | 
             
            describe "Survey Gizmo Resource" do
         | 
| 3 | 
            -
             | 
| 3 | 
            +
             | 
| 4 4 | 
             
              describe SurveyGizmo::Resource do
         | 
| 5 5 | 
             
                before(:each) do
         | 
| 6 6 | 
             
                  SurveyGizmo.setup(:user => 'test@test.com', :password => 'password')
         | 
| 7 7 | 
             
                end
         | 
| 8 | 
            -
             | 
| 8 | 
            +
             | 
| 9 9 | 
             
                let(:described_class) { SurveyGizmoSpec::ResourceTest }
         | 
| 10 | 
            -
             | 
| 10 | 
            +
             | 
| 11 11 | 
             
                let(:create_attributes){ {:title => 'Spec', :test_id => 5} }
         | 
| 12 12 | 
             
                let(:get_attributes)   { create_attributes.merge(:id => 1) }
         | 
| 13 13 | 
             
                let(:update_attributes){ {:title => 'Updated'} }
         | 
| 14 14 | 
             
                let(:first_params){ {:id => 1, :test_id => 5} }
         | 
| 15 | 
            -
                let(:uri_paths){ | 
| 16 | 
            -
                  { | 
| 15 | 
            +
                let(:uri_paths){
         | 
| 16 | 
            +
                  {
         | 
| 17 17 | 
             
                    :get => '/test/1',
         | 
| 18 18 | 
             
                    :create => '/test/5/resource',
         | 
| 19 19 | 
             
                    :update => '/test/5/resource/1',
         | 
| 20 20 | 
             
                    :delete => '/test/5/resource/1'
         | 
| 21 21 | 
             
                  }
         | 
| 22 22 | 
             
                }
         | 
| 23 | 
            -
             | 
| 23 | 
            +
             | 
| 24 24 | 
             
                it "#new?" do
         | 
| 25 25 | 
             
                  described_class.new.should be_new
         | 
| 26 26 | 
             
                end
         | 
| @@ -35,13 +35,13 @@ describe "Survey Gizmo Resource" do | |
| 35 35 | 
             
                end
         | 
| 36 36 |  | 
| 37 37 | 
             
                it '#valid?'
         | 
| 38 | 
            -
             | 
| 38 | 
            +
             | 
| 39 39 | 
             
                it "should raise an error if params are missing" do
         | 
| 40 40 | 
             
                  lambda {
         | 
| 41 41 | 
             
                    SurveyGizmoSpec::ResourceTest.destroy(:test_id => 5)
         | 
| 42 42 | 
             
                  }.should raise_error(SurveyGizmo::URLError, 'Missing parameters in request: `:id`')
         | 
| 43 43 | 
             
                end
         | 
| 44 | 
            -
             | 
| 44 | 
            +
             | 
| 45 45 | 
             
                it_should_behave_like 'an API object'
         | 
| 46 46 | 
             
                it_should_behave_like 'an object with errors'
         | 
| 47 47 | 
             
              end
         | 
| @@ -51,39 +51,39 @@ describe "Survey Gizmo Resource" do | |
| 51 51 | 
             
                let(:get_attributes)   { create_attributes.merge(:id => 1234) }
         | 
| 52 52 | 
             
                let(:update_attributes){ {:title => 'Updated'} }
         | 
| 53 53 | 
             
                let(:first_params){ {:id => 1234} }
         | 
| 54 | 
            -
                let(:uri_paths){ | 
| 54 | 
            +
                let(:uri_paths){
         | 
| 55 55 | 
             
                  h = { :create => '/survey' }
         | 
| 56 56 | 
             
                  h.default = '/survey/1234'
         | 
| 57 57 | 
             
                  h
         | 
| 58 58 | 
             
                }
         | 
| 59 | 
            -
             | 
| 59 | 
            +
             | 
| 60 60 | 
             
                it_should_behave_like 'an API object'
         | 
| 61 61 | 
             
                it_should_behave_like 'an object with errors'
         | 
| 62 62 | 
             
              end
         | 
| 63 63 |  | 
| 64 64 | 
             
              describe SurveyGizmo::API::Question do
         | 
| 65 65 | 
             
                let(:create_attributes){ {:survey_id => 1234, :page_id => 1, :title => 'Spec Question', :type => 'radio', :properties => {"required" => true, "option_sort" => false} } }
         | 
| 66 | 
            -
                let(:get_attributes)   { | 
| 66 | 
            +
                let(:get_attributes)   {
         | 
| 67 67 | 
             
                  create_attributes.merge(:id => 1)
         | 
| 68 68 | 
             
                }
         | 
| 69 69 | 
             
                let(:update_attributes){ {:survey_id => 1234, :page_id => 1, :title => 'Updated'} }
         | 
| 70 70 | 
             
                let(:first_params){ {:id => 1, :survey_id => 1234, :page_id => 1} }
         | 
| 71 | 
            -
                let(:uri_paths){ | 
| 71 | 
            +
                let(:uri_paths){
         | 
| 72 72 | 
             
                  { :get =>    '/survey/1234/surveyquestion/1',
         | 
| 73 73 | 
             
                    :create => '/survey/1234/surveypage/1/surveyquestion',
         | 
| 74 74 | 
             
                    :update => '/survey/1234/surveypage/1/surveyquestion/1',
         | 
| 75 | 
            -
                    :delete => '/survey/1234/surveypage/1/surveyquestion/1' | 
| 75 | 
            +
                    :delete => '/survey/1234/surveypage/1/surveyquestion/1'
         | 
| 76 76 | 
             
                  }
         | 
| 77 77 | 
             
                }
         | 
| 78 | 
            -
             | 
| 78 | 
            +
             | 
| 79 79 | 
             
                it_should_behave_like 'an API object'
         | 
| 80 80 | 
             
                it_should_behave_like 'an object with errors'
         | 
| 81 | 
            -
             | 
| 81 | 
            +
             | 
| 82 82 | 
             
                it "should handle the title hash returned from the API" do
         | 
| 83 83 | 
             
                  @question = described_class.new('title' => {'English' => 'Some title'})
         | 
| 84 84 | 
             
                  @question.title.should == 'Some title'
         | 
| 85 85 | 
             
                end
         | 
| 86 | 
            -
             | 
| 86 | 
            +
             | 
| 87 87 | 
             
                it "should handle the _subtype key" do
         | 
| 88 88 | 
             
                  @question = described_class.new(:_subtype => 'radio')
         | 
| 89 89 | 
             
                  @question.type.should == 'radio'
         | 
| @@ -97,29 +97,29 @@ describe "Survey Gizmo Resource" do | |
| 97 97 | 
             
                }
         | 
| 98 98 | 
             
                let(:update_attributes){ {:survey_id => 1234, :page_id => 1, :question_id => 1, :title => 'Updated'} }
         | 
| 99 99 | 
             
                let(:first_params){ {:id => 1, :survey_id => 1234, :page_id => 1, :question_id => 1} }
         | 
| 100 | 
            -
                let(:uri_paths){ | 
| 100 | 
            +
                let(:uri_paths){
         | 
| 101 101 | 
             
                  h = { :create => '/survey/1234/surveypage/1/surveyquestion/1/surveyoption' }
         | 
| 102 102 | 
             
                  h.default = '/survey/1234/surveypage/1/surveyquestion/1/surveyoption/1'
         | 
| 103 103 | 
             
                  h
         | 
| 104 104 | 
             
                }
         | 
| 105 | 
            -
             | 
| 105 | 
            +
             | 
| 106 106 | 
             
                it_should_behave_like 'an API object'
         | 
| 107 107 | 
             
                it_should_behave_like 'an object with errors'
         | 
| 108 108 | 
             
              end
         | 
| 109 109 |  | 
| 110 110 | 
             
              describe SurveyGizmo::API::Page do
         | 
| 111 | 
            -
                let(:create_attributes){ {:survey_id => 1234, :title => 'Spec Page'} }
         | 
| 111 | 
            +
                let(:create_attributes){ {:survey_id => 1234, :title => {'English' => 'Spec Page'}} }
         | 
| 112 112 | 
             
                let(:get_attributes)   {
         | 
| 113 113 | 
             
                  create_attributes.merge(:id => 1)
         | 
| 114 114 | 
             
                }
         | 
| 115 115 | 
             
                let(:update_attributes){ {:survey_id => 1234, :title => 'Updated'} }
         | 
| 116 116 | 
             
                let(:first_params){ {:id => 1, :survey_id => 1234 } }
         | 
| 117 | 
            -
                let(:uri_paths){ | 
| 117 | 
            +
                let(:uri_paths){
         | 
| 118 118 | 
             
                  h = { :create => '/survey/1234/surveypage' }
         | 
| 119 119 | 
             
                  h.default = '/survey/1234/surveypage/1'
         | 
| 120 120 | 
             
                  h
         | 
| 121 121 | 
             
                }
         | 
| 122 | 
            -
             | 
| 122 | 
            +
             | 
| 123 123 | 
             
                it_should_behave_like 'an API object'
         | 
| 124 124 | 
             
                it_should_behave_like 'an object with errors'
         | 
| 125 125 | 
             
              end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -1,10 +1,7 @@ | |
| 1 | 
            -
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         | 
| 2 | 
            -
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         | 
| 3 | 
            -
            require "bundler/setup"
         | 
| 4 | 
            -
            Bundler.require(:test)
         | 
| 5 1 | 
             
            require 'survey-gizmo-ruby'
         | 
| 6 | 
            -
            require  | 
| 7 | 
            -
            require  | 
| 2 | 
            +
            require 'active_support/json'
         | 
| 3 | 
            +
            require 'active_support/ordered_hash'
         | 
| 4 | 
            +
            require 'webmock/rspec'
         | 
| 8 5 |  | 
| 9 6 | 
             
            # Requires supporting files with custom matchers and macros, etc,
         | 
| 10 7 | 
             
            # in ./support/ and its subdirectories.
         | 
| @@ -12,12 +9,8 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f } | |
| 12 9 |  | 
| 13 10 | 
             
            RSpec.configure do |config|
         | 
| 14 11 | 
             
              config.include SurveyGizmoSpec::Methods
         | 
| 15 | 
            -
             | 
| 12 | 
            +
             | 
| 16 13 | 
             
              config.before(:each) do
         | 
| 17 14 | 
             
                @base = 'https://restapi.surveygizmo.com/v3'
         | 
| 18 15 | 
             
              end
         | 
| 19 | 
            -
              
         | 
| 20 | 
            -
              config.after(:suite) do
         | 
| 21 | 
            -
                SurveyGizmoSpec.cleanup_models
         | 
| 22 | 
            -
              end
         | 
| 23 16 | 
             
            end
         | 
| @@ -1,17 +1,17 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            describe "SurveyGizmo" do | 
| 3 | 
            +
            describe "SurveyGizmo" do
         | 
| 4 4 | 
             
              it "should have a base uri" do
         | 
| 5 5 | 
             
                SurveyGizmo.base_uri.should == 'https://restapi.surveygizmo.com/v3'
         | 
| 6 6 | 
             
              end
         | 
| 7 | 
            -
             | 
| 7 | 
            +
             | 
| 8 8 | 
             
              it "should allow basic authentication configuration" do
         | 
| 9 9 | 
             
                SurveyGizmo.setup(:user => 'test@test.com', :password => 'password')
         | 
| 10 | 
            -
                SurveyGizmo.default_options[:default_params].should == {'user: | 
| 10 | 
            +
                SurveyGizmo.default_options[:default_params].should == {'user:md5' => 'test@test.com:5f4dcc3b5aa765d61d8327deb882cf99'}
         | 
| 11 11 | 
             
              end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              it "should raise an error if auth isn't configured" | 
| 14 | 
            -
             | 
| 12 | 
            +
             | 
| 13 | 
            +
              it "should raise an error if auth isn't configured"
         | 
| 14 | 
            +
             | 
| 15 15 | 
             
              describe "Collection" do
         | 
| 16 16 | 
             
                before(:each) do
         | 
| 17 17 | 
             
                  @array = [
         | 
| @@ -19,55 +19,55 @@ describe "SurveyGizmo" do | |
| 19 19 | 
             
                    {:id => 2, :title => 'Test 2'},
         | 
| 20 20 | 
             
                    {:id => 3, :title => 'Test 3'},
         | 
| 21 21 | 
             
                    {:id => 4, :title => 'Test 4'}
         | 
| 22 | 
            -
                  ] | 
| 23 | 
            -
             | 
| 22 | 
            +
                  ]
         | 
| 23 | 
            +
             | 
| 24 24 | 
             
                  SurveyGizmo::Collection.send :public, *SurveyGizmo::Collection.private_instance_methods
         | 
| 25 25 | 
             
                end
         | 
| 26 | 
            -
             | 
| 26 | 
            +
             | 
| 27 27 | 
             
                let(:described_class) { SurveyGizmoSpec::CollectionTest }
         | 
| 28 | 
            -
             | 
| 28 | 
            +
             | 
| 29 29 | 
             
                context "class" do
         | 
| 30 30 | 
             
                  before(:each) do
         | 
| 31 31 | 
             
                    described_class.collection :generic_resources
         | 
| 32 32 | 
             
                  end
         | 
| 33 | 
            -
             | 
| 33 | 
            +
             | 
| 34 34 | 
             
                  subject { SurveyGizmo::Collection.new(described_class, :generic_resources, @array) }
         | 
| 35 | 
            -
             | 
| 35 | 
            +
             | 
| 36 36 | 
             
                  it { should_not be_loaded }
         | 
| 37 | 
            -
             | 
| 37 | 
            +
             | 
| 38 38 | 
             
                  it "should set the options in the collections property" do
         | 
| 39 39 | 
             
                    described_class.collections.should == {:generic_resources => {:parent => described_class, :target => :generic_resources}}
         | 
| 40 40 | 
             
                  end
         | 
| 41 | 
            -
             | 
| 41 | 
            +
             | 
| 42 42 | 
             
                  it "should load objects using the given class" do
         | 
| 43 | 
            -
                    subject.first.should be_instance_of(SurveyGizmoSpec::GenericResource) | 
| 43 | 
            +
                    subject.first.should be_instance_of(SurveyGizmoSpec::GenericResource)
         | 
| 44 44 | 
             
                  end
         | 
| 45 | 
            -
             | 
| 45 | 
            +
             | 
| 46 46 | 
             
                  it "should be loaded before iteration" do
         | 
| 47 47 | 
             
                    subject.should_not be_loaded
         | 
| 48 48 | 
             
                    subject.each
         | 
| 49 49 | 
             
                    subject.should be_loaded
         | 
| 50 | 
            -
                  end | 
| 50 | 
            +
                  end
         | 
| 51 51 | 
             
                end
         | 
| 52 | 
            -
             | 
| 52 | 
            +
             | 
| 53 53 | 
             
                context '#collection' do
         | 
| 54 54 | 
             
                  before(:each) do
         | 
| 55 55 | 
             
                    described_class.collection(:resources, 'ResourceTest')
         | 
| 56 56 | 
             
                  end
         | 
| 57 | 
            -
             | 
| 57 | 
            +
             | 
| 58 58 | 
             
                  it { lambda{ described_class.collection :resources, 'ResourceTest'}.should_not raise_error }
         | 
| 59 | 
            -
             | 
| 59 | 
            +
             | 
| 60 60 | 
             
                  it "should have an accessor for the collection" do
         | 
| 61 | 
            -
                    described_class. | 
| 62 | 
            -
                    described_class. | 
| 61 | 
            +
                    described_class.new.should respond_to('resources')
         | 
| 62 | 
            +
                    described_class.new.should respond_to('resources=')
         | 
| 63 63 | 
             
                  end
         | 
| 64 | 
            -
             | 
| 64 | 
            +
             | 
| 65 65 | 
             
                  it "should set an empty collection" do
         | 
| 66 66 | 
             
                    described_class.collection(:resources, 'ResourceTest')
         | 
| 67 67 | 
             
                    obj = described_class.new()
         | 
| 68 68 | 
             
                    obj.resources.should be_empty
         | 
| 69 69 | 
             
                  end
         | 
| 70 | 
            -
             | 
| 70 | 
            +
             | 
| 71 71 | 
             
                  it "should set a collection" do
         | 
| 72 72 | 
             
                    described_class.collection(:resources, 'ResourceTest')
         | 
| 73 73 | 
             
                    obj = described_class.new()
         | 
| @@ -75,19 +75,19 @@ describe "SurveyGizmo" do | |
| 75 75 | 
             
                    obj.resources.should be_instance_of(SurveyGizmo::Collection)
         | 
| 76 76 | 
             
                    obj.resources.length.should == @array.length
         | 
| 77 77 | 
             
                  end
         | 
| 78 | 
            -
             | 
| 78 | 
            +
             | 
| 79 79 | 
             
                  it "should set a collection from a hash" do
         | 
| 80 80 | 
             
                    obj = described_class.new(:id => 1, :resources => @array)
         | 
| 81 81 | 
             
                    obj.resources.should be_instance_of(SurveyGizmo::Collection)
         | 
| 82 82 | 
             
                    obj.resources.length.should == @array.length
         | 
| 83 83 | 
             
                  end
         | 
| 84 | 
            -
             | 
| 84 | 
            +
             | 
| 85 85 | 
             
                  it "can handle multiple collections" do
         | 
| 86 86 | 
             
                    described_class.collection(:generic_resources)
         | 
| 87 | 
            -
                    described_class. | 
| 88 | 
            -
                    described_class. | 
| 87 | 
            +
                    described_class.new.should respond_to('resources')
         | 
| 88 | 
            +
                    described_class.new.should respond_to('generic_resources')
         | 
| 89 89 | 
             
                  end
         | 
| 90 | 
            -
             | 
| 90 | 
            +
             | 
| 91 91 | 
             
                  it "can handle nested collections" do
         | 
| 92 92 | 
             
                    pending("Needs to be changed to work with suite. Right now it only passes in isolation.")
         | 
| 93 93 | 
             
                    SurveyGizmoSpec::ResourceTest.collection :generic_resources
         | 
| @@ -95,13 +95,13 @@ describe "SurveyGizmo" do | |
| 95 95 | 
             
                      {:id => 1, :title => 'Generic Test 5'},
         | 
| 96 96 | 
             
                      {:id => 2, :title => 'Generic Test 6'},
         | 
| 97 97 | 
             
                      {:id => 3, :title => 'Generic Test 7'}
         | 
| 98 | 
            -
                    ] | 
| 99 | 
            -
             | 
| 98 | 
            +
                    ]
         | 
| 99 | 
            +
             | 
| 100 100 | 
             
                    @array << {:id => 99, :generic_resources => @generic_resource_list}
         | 
| 101 101 | 
             
                    obj = described_class.new(:id => 1, :resources => @array)
         | 
| 102 102 | 
             
                    obj.resources.first.should be_instance_of(SurveyGizmoSpec::ResourceTest)
         | 
| 103 103 | 
             
                    obj.resources.detect{|r| r.id == 99 }.generic_resources.first.should be_instance_of(SurveyGizmoSpec::GenericResource)
         | 
| 104 104 | 
             
                  end
         | 
| 105 105 | 
             
                end
         | 
| 106 | 
            -
              end | 
| 106 | 
            +
              end
         | 
| 107 107 | 
             
            end
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |gem|
         | 
| 6 | 
            +
              gem.name = "survey-gizmo-ruby"
         | 
| 7 | 
            +
              gem.version = "1.0.1"
         | 
| 8 | 
            +
              gem.authors = ["Kabari Hendrick", "Chris Horn", "Adrien Jarthon"]
         | 
| 9 | 
            +
              gem.email = ["adrien.jarthon@dimelo.com"]
         | 
| 10 | 
            +
              gem.description = "Gem to use the SurveyGizmo.com REST API, v3+"
         | 
| 11 | 
            +
              gem.summary = "Gem to use the SurveyGizmo.com REST API, v3+"
         | 
| 12 | 
            +
              gem.homepage = "http://github.com/RipTheJacker/survey-gizmo-ruby"
         | 
| 13 | 
            +
              gem.licenses = ["MIT"]
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              gem.add_dependency 'activesupport', ">= 3.0"
         | 
| 16 | 
            +
              gem.add_dependency 'i18n'
         | 
| 17 | 
            +
              gem.add_dependency 'virtus', ">= 1.0.0"
         | 
| 18 | 
            +
              gem.add_dependency 'httparty'
         | 
| 19 | 
            +
              gem.add_dependency 'addressable'
         | 
| 20 | 
            +
              gem.add_development_dependency 'webmock'
         | 
| 21 | 
            +
              gem.add_development_dependency 'rspec', "~> 2.11.0"
         | 
| 22 | 
            +
              gem.add_development_dependency 'rake'
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              gem.files = `git ls-files`.split($/)
         | 
| 25 | 
            +
              gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
         | 
| 26 | 
            +
              gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
         | 
| 27 | 
            +
              gem.require_paths = ["lib"]
         | 
| 28 | 
            +
            end
         | 
| 29 | 
            +
             | 
    
        metadata
    CHANGED
    
    | @@ -1,141 +1,161 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: survey-gizmo-ruby
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.9.6
         | 
| 5 4 | 
             
              prerelease: 
         | 
| 5 | 
            +
              version: 1.0.1
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| 8 8 | 
             
            - Kabari Hendrick
         | 
| 9 9 | 
             
            - Chris Horn
         | 
| 10 | 
            +
            - Adrien Jarthon
         | 
| 10 11 | 
             
            autorequire: 
         | 
| 11 12 | 
             
            bindir: bin
         | 
| 12 13 | 
             
            cert_chain: []
         | 
| 13 | 
            -
            date:  | 
| 14 | 
            +
            date: 2013-11-12 00:00:00.000000000 Z
         | 
| 14 15 | 
             
            dependencies:
         | 
| 15 16 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 | 
            -
               | 
| 17 | 
            -
              requirement: &70327435758280 !ruby/object:Gem::Requirement
         | 
| 18 | 
            -
                none: false
         | 
| 17 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 19 18 | 
             
                requirements:
         | 
| 20 | 
            -
                - -  | 
| 19 | 
            +
                - - ! '>='
         | 
| 21 20 | 
             
                  - !ruby/object:Gem::Version
         | 
| 22 21 | 
             
                    version: '3.0'
         | 
| 22 | 
            +
                none: false
         | 
| 23 | 
            +
              name: activesupport
         | 
| 23 24 | 
             
              type: :runtime
         | 
| 24 25 | 
             
              prerelease: false
         | 
| 25 | 
            -
               | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 26 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 27 | 
            +
                requirements:
         | 
| 28 | 
            +
                - - ! '>='
         | 
| 29 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 30 | 
            +
                    version: '3.0'
         | 
| 29 31 | 
             
                none: false
         | 
| 32 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 33 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 30 34 | 
             
                requirements:
         | 
| 31 35 | 
             
                - - ! '>='
         | 
| 32 36 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 37 | 
             
                    version: '0'
         | 
| 38 | 
            +
                none: false
         | 
| 39 | 
            +
              name: i18n
         | 
| 34 40 | 
             
              type: :runtime
         | 
| 35 41 | 
             
              prerelease: false
         | 
| 36 | 
            -
               | 
| 37 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 38 | 
            -
              name: virtus
         | 
| 39 | 
            -
              requirement: &70327435748540 !ruby/object:Gem::Requirement
         | 
| 40 | 
            -
                none: false
         | 
| 42 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 41 43 | 
             
                requirements:
         | 
| 42 44 | 
             
                - - ! '>='
         | 
| 43 45 | 
             
                  - !ruby/object:Gem::Version
         | 
| 44 46 | 
             
                    version: '0'
         | 
| 47 | 
            +
                none: false
         | 
| 48 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 49 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - ! '>='
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            +
                    version: 1.0.0
         | 
| 54 | 
            +
                none: false
         | 
| 55 | 
            +
              name: virtus
         | 
| 45 56 | 
             
              type: :runtime
         | 
| 46 57 | 
             
              prerelease: false
         | 
| 47 | 
            -
               | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 58 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 59 | 
            +
                requirements:
         | 
| 60 | 
            +
                - - ! '>='
         | 
| 61 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 62 | 
            +
                    version: 1.0.0
         | 
| 51 63 | 
             
                none: false
         | 
| 64 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 65 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 52 66 | 
             
                requirements:
         | 
| 53 67 | 
             
                - - ! '>='
         | 
| 54 68 | 
             
                  - !ruby/object:Gem::Version
         | 
| 55 69 | 
             
                    version: '0'
         | 
| 70 | 
            +
                none: false
         | 
| 71 | 
            +
              name: httparty
         | 
| 56 72 | 
             
              type: :runtime
         | 
| 57 73 | 
             
              prerelease: false
         | 
| 58 | 
            -
               | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 74 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 75 | 
            +
                requirements:
         | 
| 76 | 
            +
                - - ! '>='
         | 
| 77 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 78 | 
            +
                    version: '0'
         | 
| 62 79 | 
             
                none: false
         | 
| 80 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 81 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 63 82 | 
             
                requirements:
         | 
| 64 83 | 
             
                - - ! '>='
         | 
| 65 84 | 
             
                  - !ruby/object:Gem::Version
         | 
| 66 85 | 
             
                    version: '0'
         | 
| 86 | 
            +
                none: false
         | 
| 87 | 
            +
              name: addressable
         | 
| 67 88 | 
             
              type: :runtime
         | 
| 68 89 | 
             
              prerelease: false
         | 
| 69 | 
            -
               | 
| 70 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 71 | 
            -
              name: bluecloth
         | 
| 72 | 
            -
              requirement: &70327435742600 !ruby/object:Gem::Requirement
         | 
| 73 | 
            -
                none: false
         | 
| 90 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 74 91 | 
             
                requirements:
         | 
| 75 92 | 
             
                - - ! '>='
         | 
| 76 93 | 
             
                  - !ruby/object:Gem::Version
         | 
| 77 94 | 
             
                    version: '0'
         | 
| 78 | 
            -
              type: :development
         | 
| 79 | 
            -
              prerelease: false
         | 
| 80 | 
            -
              version_requirements: *70327435742600
         | 
| 81 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 82 | 
            -
              name: yard
         | 
| 83 | 
            -
              requirement: &70327435741380 !ruby/object:Gem::Requirement
         | 
| 84 95 | 
             
                none: false
         | 
| 96 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 97 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 85 98 | 
             
                requirements:
         | 
| 86 | 
            -
                - -  | 
| 99 | 
            +
                - - ! '>='
         | 
| 87 100 | 
             
                  - !ruby/object:Gem::Version
         | 
| 88 | 
            -
                    version: 0 | 
| 101 | 
            +
                    version: '0'
         | 
| 102 | 
            +
                none: false
         | 
| 103 | 
            +
              name: webmock
         | 
| 89 104 | 
             
              type: :development
         | 
| 90 105 | 
             
              prerelease: false
         | 
| 91 | 
            -
               | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 106 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - ! '>='
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '0'
         | 
| 95 111 | 
             
                none: false
         | 
| 112 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 113 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 96 114 | 
             
                requirements:
         | 
| 97 115 | 
             
                - - ~>
         | 
| 98 116 | 
             
                  - !ruby/object:Gem::Version
         | 
| 99 | 
            -
                    version:  | 
| 117 | 
            +
                    version: 2.11.0
         | 
| 118 | 
            +
                none: false
         | 
| 119 | 
            +
              name: rspec
         | 
| 100 120 | 
             
              type: :development
         | 
| 101 121 | 
             
              prerelease: false
         | 
| 102 | 
            -
               | 
| 103 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 104 | 
            -
              name: jeweler
         | 
| 105 | 
            -
              requirement: &70327435724260 !ruby/object:Gem::Requirement
         | 
| 106 | 
            -
                none: false
         | 
| 122 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 107 123 | 
             
                requirements:
         | 
| 108 124 | 
             
                - - ~>
         | 
| 109 125 | 
             
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            -
                    version:  | 
| 111 | 
            -
              type: :development
         | 
| 112 | 
            -
              prerelease: false
         | 
| 113 | 
            -
              version_requirements: *70327435724260
         | 
| 114 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 115 | 
            -
              name: awesome_print
         | 
| 116 | 
            -
              requirement: &70327435712160 !ruby/object:Gem::Requirement
         | 
| 126 | 
            +
                    version: 2.11.0
         | 
| 117 127 | 
             
                none: false
         | 
| 128 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 129 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 118 130 | 
             
                requirements:
         | 
| 119 131 | 
             
                - - ! '>='
         | 
| 120 132 | 
             
                  - !ruby/object:Gem::Version
         | 
| 121 133 | 
             
                    version: '0'
         | 
| 134 | 
            +
                none: false
         | 
| 135 | 
            +
              name: rake
         | 
| 122 136 | 
             
              type: :development
         | 
| 123 137 | 
             
              prerelease: false
         | 
| 124 | 
            -
               | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 138 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 139 | 
            +
                requirements:
         | 
| 140 | 
            +
                - - ! '>='
         | 
| 141 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 142 | 
            +
                    version: '0'
         | 
| 143 | 
            +
                none: false
         | 
| 144 | 
            +
            description: Gem to use the SurveyGizmo.com REST API, v3+
         | 
| 145 | 
            +
            email:
         | 
| 146 | 
            +
            - adrien.jarthon@dimelo.com
         | 
| 127 147 | 
             
            executables: []
         | 
| 128 148 | 
             
            extensions: []
         | 
| 129 | 
            -
            extra_rdoc_files:
         | 
| 130 | 
            -
            - LICENSE.txt
         | 
| 131 | 
            -
            - README.md
         | 
| 149 | 
            +
            extra_rdoc_files: []
         | 
| 132 150 | 
             
            files:
         | 
| 151 | 
            +
            - .document
         | 
| 152 | 
            +
            - .gitignore
         | 
| 153 | 
            +
            - .rspec
         | 
| 133 154 | 
             
            - Gemfile
         | 
| 134 155 | 
             
            - Gemfile.lock
         | 
| 135 156 | 
             
            - LICENSE.txt
         | 
| 136 157 | 
             
            - README.md
         | 
| 137 158 | 
             
            - Rakefile
         | 
| 138 | 
            -
            - VERSION
         | 
| 139 159 | 
             
            - lib/survey-gizmo-ruby.rb
         | 
| 140 160 | 
             
            - lib/survey_gizmo/api/contact.rb
         | 
| 141 161 | 
             
            - lib/survey_gizmo/api/email_message.rb
         | 
| @@ -151,7 +171,6 @@ files: | |
| 151 171 | 
             
            - spec/resource_spec.rb
         | 
| 152 172 | 
             
            - spec/spec_helper.rb
         | 
| 153 173 | 
             
            - spec/support/methods.rb
         | 
| 154 | 
            -
            - spec/support/model_cleanup.rb
         | 
| 155 174 | 
             
            - spec/support/spec_shared_api_object.rb
         | 
| 156 175 | 
             
            - spec/support/spec_shared_object_with_errors.rb
         | 
| 157 176 | 
             
            - spec/support/test_resource_classes.rb
         | 
| @@ -159,6 +178,7 @@ files: | |
| 159 178 | 
             
            - spec/test_json/page.json
         | 
| 160 179 | 
             
            - spec/test_json/question.json
         | 
| 161 180 | 
             
            - spec/test_json/survey.json
         | 
| 181 | 
            +
            - survey-gizmo-ruby.gemspec
         | 
| 162 182 | 
             
            homepage: http://github.com/RipTheJacker/survey-gizmo-ruby
         | 
| 163 183 | 
             
            licenses:
         | 
| 164 184 | 
             
            - MIT
         | 
| @@ -167,24 +187,32 @@ rdoc_options: [] | |
| 167 187 | 
             
            require_paths:
         | 
| 168 188 | 
             
            - lib
         | 
| 169 189 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 170 | 
            -
              none: false
         | 
| 171 190 | 
             
              requirements:
         | 
| 172 191 | 
             
              - - ! '>='
         | 
| 173 192 | 
             
                - !ruby/object:Gem::Version
         | 
| 174 193 | 
             
                  version: '0'
         | 
| 175 | 
            -
                  segments:
         | 
| 176 | 
            -
                  - 0
         | 
| 177 | 
            -
                  hash: 1680038984146331974
         | 
| 178 | 
            -
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 179 194 | 
             
              none: false
         | 
| 195 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 180 196 | 
             
              requirements:
         | 
| 181 197 | 
             
              - - ! '>='
         | 
| 182 198 | 
             
                - !ruby/object:Gem::Version
         | 
| 183 199 | 
             
                  version: '0'
         | 
| 200 | 
            +
              none: false
         | 
| 184 201 | 
             
            requirements: []
         | 
| 185 202 | 
             
            rubyforge_project: 
         | 
| 186 | 
            -
            rubygems_version: 1.8. | 
| 203 | 
            +
            rubygems_version: 1.8.23
         | 
| 187 204 | 
             
            signing_key: 
         | 
| 188 205 | 
             
            specification_version: 3
         | 
| 189 | 
            -
            summary:  | 
| 190 | 
            -
            test_files: | 
| 206 | 
            +
            summary: Gem to use the SurveyGizmo.com REST API, v3+
         | 
| 207 | 
            +
            test_files:
         | 
| 208 | 
            +
            - spec/resource_spec.rb
         | 
| 209 | 
            +
            - spec/spec_helper.rb
         | 
| 210 | 
            +
            - spec/support/methods.rb
         | 
| 211 | 
            +
            - spec/support/spec_shared_api_object.rb
         | 
| 212 | 
            +
            - spec/support/spec_shared_object_with_errors.rb
         | 
| 213 | 
            +
            - spec/support/test_resource_classes.rb
         | 
| 214 | 
            +
            - spec/survey-gizmo-ruby_spec.rb
         | 
| 215 | 
            +
            - spec/test_json/page.json
         | 
| 216 | 
            +
            - spec/test_json/question.json
         | 
| 217 | 
            +
            - spec/test_json/survey.json
         | 
| 218 | 
            +
            has_rdoc: 
         | 
    
        data/VERSION
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            0.9.6
         | 
| @@ -1,38 +0,0 @@ | |
| 1 | 
            -
            module SurveyGizmoSpec
         | 
| 2 | 
            -
              # global model cleanup. Mostly stolen from DataMapper.
         | 
| 3 | 
            -
              def self.cleanup_models
         | 
| 4 | 
            -
               descendants = SurveyGizmo::Resource.descendants.to_a
         | 
| 5 | 
            -
             | 
| 6 | 
            -
               while model = descendants.shift
         | 
| 7 | 
            -
                 model_name = model.name.to_s.strip
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                 unless model_name.empty? || model_name[0] == ?#
         | 
| 10 | 
            -
                   parts         = model_name.split('::')
         | 
| 11 | 
            -
                   constant_name = parts.pop.to_sym
         | 
| 12 | 
            -
                   base          = parts.empty? ? Object : SurveyGizmoSpec.full_const_get(parts.join('::'))
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                   base.class_eval { remove_const(constant_name) if const_defined?(constant_name) }
         | 
| 15 | 
            -
                 end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                 model.instance_methods(false).each { |method| model.send(:undef_method, method) }
         | 
| 18 | 
            -
             | 
| 19 | 
            -
               end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
               SurveyGizmo::Resource.descendants.clear
         | 
| 22 | 
            -
              end
         | 
| 23 | 
            -
              
         | 
| 24 | 
            -
            end
         | 
| 25 | 
            -
             | 
| 26 | 
            -
            class Object
         | 
| 27 | 
            -
              def full_const_get(name)
         | 
| 28 | 
            -
                list = name.split("::")
         | 
| 29 | 
            -
                list.shift if list.first.blank?
         | 
| 30 | 
            -
                obj = self
         | 
| 31 | 
            -
                list.each do |x|
         | 
| 32 | 
            -
                  # This is required because const_get tries to look for constants in the
         | 
| 33 | 
            -
                  # ancestor chain, but we only want constants that are HERE
         | 
| 34 | 
            -
                  obj = obj.const_defined?(x) ? obj.const_get(x) : obj.const_missing(x)
         | 
| 35 | 
            -
                end
         | 
| 36 | 
            -
                obj
         | 
| 37 | 
            -
              end  
         | 
| 38 | 
            -
            end
         |