railsSignUp 0.0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
 - data/.gitignore +18 -0
 - data/Gemfile +4 -0
 - data/LICENSE.txt +22 -0
 - data/README.md +29 -0
 - data/Rakefile +4 -0
 - data/lib/railsSignUp.rb +12 -0
 - data/lib/railsSignUp/.DS_Store +0 -0
 - data/lib/railsSignUp/exceptions.rb +17 -0
 - data/lib/railsSignUp/model/.DS_Store +0 -0
 - data/lib/railsSignUp/model/event.rb +37 -0
 - data/lib/railsSignUp/model/race.rb +80 -0
 - data/lib/railsSignUp/model/registration_period.rb +14 -0
 - data/lib/railsSignUp/races.rb +99 -0
 - data/lib/railsSignUp/record.rb +14 -0
 - data/lib/railsSignUp/session.rb +26 -0
 - data/lib/railsSignUp/version.rb +3 -0
 - data/railsSignUp.gemspec +22 -0
 - data/spec/railsSignUp_helper.rb +7 -0
 - data/spec/railsSignUp_spec.rb +24 -0
 - data/spec/spec_helper.rb +11 -0
 - metadata +96 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            !binary "U0hBMQ==":
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 4 
     | 
    
         
            +
                ZWYxMmI5MTM4MjNkOGI5YTUyMjliOGM1ZDViNTk2YmJlNTI2ZmFkYg==
         
     | 
| 
      
 5 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 6 
     | 
    
         
            +
                MTRkOWNiZThlZTQ3NzNiOTFhM2QwNDI5YzViYTViYzczMjQ5MTc1Nw==
         
     | 
| 
      
 7 
     | 
    
         
            +
            !binary "U0hBNTEy":
         
     | 
| 
      
 8 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 9 
     | 
    
         
            +
                MDUyYzMzNWMwOWI5ZjliOTU0YzJmNGYwODI4YWIzMWViZDBhYjhlZmU1YmJh
         
     | 
| 
      
 10 
     | 
    
         
            +
                OWMyMjUyMGJlYTFhY2FkZTg2ZmE3MjI5MmM3NjNmNWE5YjQ2MzVkZGJhNDZm
         
     | 
| 
      
 11 
     | 
    
         
            +
                OGQwNmQ2NzQ0YjIxMmVmNDc3ZTc2MTk3ODUwNDIwOTYwODRlZTQ=
         
     | 
| 
      
 12 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 13 
     | 
    
         
            +
                YmE4M2JjNzY3MmIyNzBiYTljYmE5NjZlNGU2MWFlYTIyZDg3YTU3ZTg2ZTM0
         
     | 
| 
      
 14 
     | 
    
         
            +
                MDdlNzE2NWI2MjE0MjJiOGE3MTNhYzNmZThkN2ZhNDZlN2YxZDkyYjZjOTA0
         
     | 
| 
      
 15 
     | 
    
         
            +
                NzFmNzQ1MGNhMjg0MTY5ZmMxMjU2YmNmNWQ0ZGQ0M2U2OTYxMTI=
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2013 TODO: Write your name
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            MIT License
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 6 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 7 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 8 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 9 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 10 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 11 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 14 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 17 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 18 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 19 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 20 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 21 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 22 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # RailsSignUp
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            TODO: Write a gem description
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                gem 'railsSignUp'
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                $ gem install railsSignUp
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            TODO: Write usage instructions here
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            1. Fork it
         
     | 
| 
      
 26 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 27 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 28 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 29 
     | 
    
         
            +
            5. Create new Pull Request
         
     | 
    
        data/Rakefile
    ADDED
    
    
    
        data/lib/railsSignUp.rb
    ADDED
    
    | 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "RailsSignUp/version"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "RailsSignUp/session"
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "RailsSignUp/exceptions"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "RailsSignUp/record"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "RailsSignUp/model/race"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "RailsSignUp/model/event"
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "RailsSignUp/model/registration_period"
         
     | 
| 
      
 8 
     | 
    
         
            +
            require "RailsSignUp/races"
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            module RailsSignUp
         
     | 
| 
      
 11 
     | 
    
         
            +
              # Your code goes here...
         
     | 
| 
      
 12 
     | 
    
         
            +
            end
         
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         @@ -0,0 +1,37 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # @author Khang Le
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module RailsSignUp
         
     | 
| 
      
 4 
     | 
    
         
            +
              class Model
         
     | 
| 
      
 5 
     | 
    
         
            +
                class Event < RailsSignUp::Record
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # event id
         
     | 
| 
      
 7 
     | 
    
         
            +
                  attr_reader :id
         
     | 
| 
      
 8 
     | 
    
         
            +
                  # event name (usually the same as race name)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  attr_reader :name
         
     | 
| 
      
 10 
     | 
    
         
            +
                  # event details
         
     | 
| 
      
 11 
     | 
    
         
            +
                  attr_reader :details
         
     | 
| 
      
 12 
     | 
    
         
            +
                  # event start time
         
     | 
| 
      
 13 
     | 
    
         
            +
                  attr_reader :start_time
         
     | 
| 
      
 14 
     | 
    
         
            +
                  # event time when registration begins
         
     | 
| 
      
 15 
     | 
    
         
            +
                  attr_reader :registration_opens
         
     | 
| 
      
 16 
     | 
    
         
            +
                  # event type
         
     | 
| 
      
 17 
     | 
    
         
            +
                  attr_reader :event_type
         
     | 
| 
      
 18 
     | 
    
         
            +
                  # event distance of race
         
     | 
| 
      
 19 
     | 
    
         
            +
                  attr_reader :distance
         
     | 
| 
      
 20 
     | 
    
         
            +
                  # if event has volunteers
         
     | 
| 
      
 21 
     | 
    
         
            +
                  attr_reader :volunteer
         
     | 
| 
      
 22 
     | 
    
         
            +
                  # if event requires date of birth (for registration)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  attr_reader :require_dob
         
     | 
| 
      
 24 
     | 
    
         
            +
                  # if event requires phone number (for registration)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  attr_reader :require_phone
         
     | 
| 
      
 26 
     | 
    
         
            +
                  # what event gives away (T-Shirts etc.)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  attr_reader :give_away
         
     | 
| 
      
 28 
     | 
    
         
            +
                  # event registration periods (multiple for different price ranges)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  attr_accessor :registration_periods
         
     | 
| 
      
 30 
     | 
    
         
            +
                  
         
     | 
| 
      
 31 
     | 
    
         
            +
                  def add_registration_period period
         
     | 
| 
      
 32 
     | 
    
         
            +
                    self.registration_periods = []  if self.registration_periods.nil? 
         
     | 
| 
      
 33 
     | 
    
         
            +
                    self.registration_periods << period unless period.nil?
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,80 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module RailsSignUp
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Model
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Race < RailsSignUp::Record
         
     | 
| 
      
 4 
     | 
    
         
            +
                  # race id
         
     | 
| 
      
 5 
     | 
    
         
            +
                  attr_reader :id
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # name of race
         
     | 
| 
      
 7 
     | 
    
         
            +
                  attr_reader :name
         
     | 
| 
      
 8 
     | 
    
         
            +
                  # description
         
     | 
| 
      
 9 
     | 
    
         
            +
                  attr_reader :description
         
     | 
| 
      
 10 
     | 
    
         
            +
                  # runsignup url for race
         
     | 
| 
      
 11 
     | 
    
         
            +
                  attr_reader :url
         
     | 
| 
      
 12 
     | 
    
         
            +
                  # next date race takes place
         
     | 
| 
      
 13 
     | 
    
         
            +
                  attr_reader :next_date
         
     | 
| 
      
 14 
     | 
    
         
            +
                  # last date race took place
         
     | 
| 
      
 15 
     | 
    
         
            +
                  attr_reader :last_date
         
     | 
| 
      
 16 
     | 
    
         
            +
                  # (BOOL) if registration is open
         
     | 
| 
      
 17 
     | 
    
         
            +
                  attr_reader :is_registration_open
         
     | 
| 
      
 18 
     | 
    
         
            +
                  # if is a draft race
         
     | 
| 
      
 19 
     | 
    
         
            +
                  attr_reader :is_draft_race
         
     | 
| 
      
 20 
     | 
    
         
            +
                  # street of race
         
     | 
| 
      
 21 
     | 
    
         
            +
                  attr_reader :street
         
     | 
| 
      
 22 
     | 
    
         
            +
                  # city of race
         
     | 
| 
      
 23 
     | 
    
         
            +
                  attr_reader :city
         
     | 
| 
      
 24 
     | 
    
         
            +
                  # state of race
         
     | 
| 
      
 25 
     | 
    
         
            +
                  attr_reader :state
         
     | 
| 
      
 26 
     | 
    
         
            +
                  # zip code of race
         
     | 
| 
      
 27 
     | 
    
         
            +
                  attr_reader :zip_code
         
     | 
| 
      
 28 
     | 
    
         
            +
                  # country of race
         
     | 
| 
      
 29 
     | 
    
         
            +
                  attr_reader :country_code
         
     | 
| 
      
 30 
     | 
    
         
            +
                  # list of events of races
         
     | 
| 
      
 31 
     | 
    
         
            +
                  attr_accessor :events
         
     | 
| 
      
 32 
     | 
    
         
            +
                  # access token for oauth
         
     | 
| 
      
 33 
     | 
    
         
            +
                  attr_accessor :access_token
         
     | 
| 
      
 34 
     | 
    
         
            +
                  # api_key
         
     | 
| 
      
 35 
     | 
    
         
            +
                  attr :api_key
         
     | 
| 
      
 36 
     | 
    
         
            +
                  # api_secret
         
     | 
| 
      
 37 
     | 
    
         
            +
                  attr :api_secret
         
     | 
| 
      
 38 
     | 
    
         
            +
                  
         
     | 
| 
      
 39 
     | 
    
         
            +
                  # Retrieve all events for a race
         
     | 
| 
      
 40 
     | 
    
         
            +
                  #
         
     | 
| 
      
 41 
     | 
    
         
            +
                  # @author Khang Le
         
     | 
| 
      
 42 
     | 
    
         
            +
                  def get_events
         
     | 
| 
      
 43 
     | 
    
         
            +
                    response = self.access_token.get("/rest/race/#{self.id}/?format=json&race_id=#{self.id}&api_key=#{self.api_key}&api_secret=#{self.api_secret}")
         
     | 
| 
      
 44 
     | 
    
         
            +
                    json_response = JSON.parse(response.body)
         
     | 
| 
      
 45 
     | 
    
         
            +
                    
         
     | 
| 
      
 46 
     | 
    
         
            +
            				raise RailsSignUp::RaceError, "RailsSignUp race.get Error: #{json_response['error']['error_code']} - #{json_response['error']['error_msg']}" unless json_response['error'].nil?
         
     | 
| 
      
 47 
     | 
    
         
            +
                    
         
     | 
| 
      
 48 
     | 
    
         
            +
                    json_response['race']['events'].each do |event|
         
     | 
| 
      
 49 
     | 
    
         
            +
                      _event = RailsSignUp::Model::Event.new(
         
     | 
| 
      
 50 
     | 
    
         
            +
                        :id => event['id'],
         
     | 
| 
      
 51 
     | 
    
         
            +
                        :name => event['name'],
         
     | 
| 
      
 52 
     | 
    
         
            +
                        :details => event['details'],
         
     | 
| 
      
 53 
     | 
    
         
            +
                        :start_time =>  event['start_time'],
         
     | 
| 
      
 54 
     | 
    
         
            +
                        :registration_opens => event['registration_opens'],
         
     | 
| 
      
 55 
     | 
    
         
            +
                        :event_type => event['event_type'],
         
     | 
| 
      
 56 
     | 
    
         
            +
                        :distance => event['distance'],
         
     | 
| 
      
 57 
     | 
    
         
            +
                        :volunteer => event['volunteer'],
         
     | 
| 
      
 58 
     | 
    
         
            +
                        :require_dob => event['require_dob'],
         
     | 
| 
      
 59 
     | 
    
         
            +
                        :require_phone => event['require_phone'],
         
     | 
| 
      
 60 
     | 
    
         
            +
                        :give_away => event['give_away']
         
     | 
| 
      
 61 
     | 
    
         
            +
                      )
         
     | 
| 
      
 62 
     | 
    
         
            +
                      event['registration_periods'].each do |period|
         
     | 
| 
      
 63 
     | 
    
         
            +
                        _period = RailsSignUp::Model::RegistrationPeriod.new(
         
     | 
| 
      
 64 
     | 
    
         
            +
                          :registration_opens => period['registration_opens'],
         
     | 
| 
      
 65 
     | 
    
         
            +
                          :registration_closes => period['registration_closes'],
         
     | 
| 
      
 66 
     | 
    
         
            +
                          :race_fee => period['race_fee']
         
     | 
| 
      
 67 
     | 
    
         
            +
                        )
         
     | 
| 
      
 68 
     | 
    
         
            +
                        _event.add_registration_period _period
         
     | 
| 
      
 69 
     | 
    
         
            +
                      end
         
     | 
| 
      
 70 
     | 
    
         
            +
                      self.add_event _event
         
     | 
| 
      
 71 
     | 
    
         
            +
                    end
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
                  
         
     | 
| 
      
 74 
     | 
    
         
            +
                  def add_event event
         
     | 
| 
      
 75 
     | 
    
         
            +
                    self.events = [] if self.events.nil?
         
     | 
| 
      
 76 
     | 
    
         
            +
                    self.events << event
         
     | 
| 
      
 77 
     | 
    
         
            +
                  end
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
      
 79 
     | 
    
         
            +
              end
         
     | 
| 
      
 80 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # @author Khang Le
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module RailsSignUp
         
     | 
| 
      
 4 
     | 
    
         
            +
              class Model
         
     | 
| 
      
 5 
     | 
    
         
            +
                class RegistrationPeriod < RailsSignUp::Record
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # time when registration period opens
         
     | 
| 
      
 7 
     | 
    
         
            +
                  attr_reader :registration_opens
         
     | 
| 
      
 8 
     | 
    
         
            +
                  # time when registration period closes
         
     | 
| 
      
 9 
     | 
    
         
            +
                  attr_reader :registration_closes
         
     | 
| 
      
 10 
     | 
    
         
            +
                  # race fee for registration period
         
     | 
| 
      
 11 
     | 
    
         
            +
                  attr_reader :race_fee
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,99 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # @author Khang Le
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module RailsSignUp
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              class Races
         
     | 
| 
      
 6 
     | 
    
         
            +
                attr_accessor :races
         
     | 
| 
      
 7 
     | 
    
         
            +
                
         
     | 
| 
      
 8 
     | 
    
         
            +
                def initialize session
         
     | 
| 
      
 9 
     | 
    
         
            +
                  raise RailsSignUp::SessionError, "Invalid session (session cannot be nil)" if session.nil?
         
     | 
| 
      
 10 
     | 
    
         
            +
                  
         
     | 
| 
      
 11 
     | 
    
         
            +
                  @races = []
         
     | 
| 
      
 12 
     | 
    
         
            +
                  @access_token = session.access_token
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @api_key = session.api_key
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @api_secret = session.api_secret
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
                
         
     | 
| 
      
 17 
     | 
    
         
            +
                # get races from runsignup
         
     | 
| 
      
 18 
     | 
    
         
            +
                #
         
     | 
| 
      
 19 
     | 
    
         
            +
                # @author Khang Le
         
     | 
| 
      
 20 
     | 
    
         
            +
                # param[aflt_token] T/F appends affiliate token to end of string, default T
         
     | 
| 
      
 21 
     | 
    
         
            +
                # param[events] T/F shows events with each race, default F
         
     | 
| 
      
 22 
     | 
    
         
            +
                # param[race_headings] T/F shows heading with each race, default F
         
     | 
| 
      
 23 
     | 
    
         
            +
                # param[race_links] T/F shows links of each race, default F
         
     | 
| 
      
 24 
     | 
    
         
            +
                # param[page] int specifies which page to return, default 1
         
     | 
| 
      
 25 
     | 
    
         
            +
                # param[results_per_page] int specifies how many results to return per page, default 10
         
     | 
| 
      
 26 
     | 
    
         
            +
                # param[sort] specifies how to sort results (name or date, descending or ascending), default name+ASC
         
     | 
| 
      
 27 
     | 
    
         
            +
                # param[name] search race by name
         
     | 
| 
      
 28 
     | 
    
         
            +
                # see runsignup api documentation for extra parameters
         
     | 
| 
      
 29 
     | 
    
         
            +
                def get_races opts = {}
         
     | 
| 
      
 30 
     | 
    
         
            +
                  response = @access_token.get("/rest/races/?format=json&api_key=#{@api_key}&api_secret=#{@api_secret}&#{opts.map{|k, v| "#{k}=#{v}"}.join('&')}")
         
     | 
| 
      
 31 
     | 
    
         
            +
                  json_response = JSON.parse(response.body)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  
         
     | 
| 
      
 33 
     | 
    
         
            +
                  raise RailsSignUp::RaceError, "RunSignUp races.get Error: #{json_response['error']['error_code']} - #{json_response['error']['error_msg']}" unless json_response['error'].nil?
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  self.races = parse_json json_response, opts unless json_response.nil?
         
     | 
| 
      
 36 
     | 
    
         
            +
                  self.races
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
                
         
     | 
| 
      
 39 
     | 
    
         
            +
                def parse_json json_response, opts
         
     | 
| 
      
 40 
     | 
    
         
            +
                  races = []
         
     | 
| 
      
 41 
     | 
    
         
            +
                  count = 0
         
     | 
| 
      
 42 
     | 
    
         
            +
                  
         
     | 
| 
      
 43 
     | 
    
         
            +
                  return if json_response['races'].nil?
         
     | 
| 
      
 44 
     | 
    
         
            +
                  
         
     | 
| 
      
 45 
     | 
    
         
            +
                  json_response['races'].each do |race|
         
     | 
| 
      
 46 
     | 
    
         
            +
                    _race = RailsSignUp::Model::Race.new(
         
     | 
| 
      
 47 
     | 
    
         
            +
                      :access_token => @access_token,
         
     | 
| 
      
 48 
     | 
    
         
            +
                      :api_key => @api_key,
         
     | 
| 
      
 49 
     | 
    
         
            +
                      :api_secret => @api_secret,
         
     | 
| 
      
 50 
     | 
    
         
            +
                  	  :id => race['race']['race_id'],
         
     | 
| 
      
 51 
     | 
    
         
            +
                      :name => race['race']['name'],
         
     | 
| 
      
 52 
     | 
    
         
            +
                      :description => race['race']['description'],
         
     | 
| 
      
 53 
     | 
    
         
            +
                      :url => race['race']['url'],
         
     | 
| 
      
 54 
     | 
    
         
            +
                      :next_date => race['race']['next_date'],
         
     | 
| 
      
 55 
     | 
    
         
            +
                      :last_date => race['race']['last_date'],
         
     | 
| 
      
 56 
     | 
    
         
            +
                      :is_registration_open => race['race']['is_registration_open'],
         
     | 
| 
      
 57 
     | 
    
         
            +
                      :is_draft_race => race['race']['is_draft_race'],
         
     | 
| 
      
 58 
     | 
    
         
            +
                      :street => race['race']['address']['street'],
         
     | 
| 
      
 59 
     | 
    
         
            +
                      :city => race['race']['address']['city'],
         
     | 
| 
      
 60 
     | 
    
         
            +
                      :state => race['race']['address']['state'],
         
     | 
| 
      
 61 
     | 
    
         
            +
                      :zip_code => race['race']['address']['zip_code'],
         
     | 
| 
      
 62 
     | 
    
         
            +
                      :country_code => race['race']['address']['country_code']
         
     | 
| 
      
 63 
     | 
    
         
            +
                  	)
         
     | 
| 
      
 64 
     | 
    
         
            +
                    
         
     | 
| 
      
 65 
     | 
    
         
            +
                    if !opts[:events].nil? && opts[:events] === "T"
         
     | 
| 
      
 66 
     | 
    
         
            +
                      race['race']['events'].each do |event|
         
     | 
| 
      
 67 
     | 
    
         
            +
                        _event = RailsSignUp::Model::Event.new(
         
     | 
| 
      
 68 
     | 
    
         
            +
                          :id => event['id'],
         
     | 
| 
      
 69 
     | 
    
         
            +
                          :name => event['name'],
         
     | 
| 
      
 70 
     | 
    
         
            +
                          :details => event['details'],
         
     | 
| 
      
 71 
     | 
    
         
            +
                          :start_time =>  event['start_time'],
         
     | 
| 
      
 72 
     | 
    
         
            +
                          :registration_opens => event['registration_opens'],
         
     | 
| 
      
 73 
     | 
    
         
            +
                          :event_type => event['event_type'],
         
     | 
| 
      
 74 
     | 
    
         
            +
                          :distance => event['distance'],
         
     | 
| 
      
 75 
     | 
    
         
            +
                          :volunteer => event['volunteer'],
         
     | 
| 
      
 76 
     | 
    
         
            +
                          :require_dob => event['require_dob'],
         
     | 
| 
      
 77 
     | 
    
         
            +
                          :require_phone => event['require_phone'],
         
     | 
| 
      
 78 
     | 
    
         
            +
                          :give_away => event['give_away']
         
     | 
| 
      
 79 
     | 
    
         
            +
                        )
         
     | 
| 
      
 80 
     | 
    
         
            +
                      
         
     | 
| 
      
 81 
     | 
    
         
            +
                        event['registration_periods'].each do |period|
         
     | 
| 
      
 82 
     | 
    
         
            +
                          _period = RailsSignUp::Model::RegistrationPeriod.new(
         
     | 
| 
      
 83 
     | 
    
         
            +
                            :registration_opens => period['registration_opens'],
         
     | 
| 
      
 84 
     | 
    
         
            +
                            :registration_closes => period['registration_closes'],
         
     | 
| 
      
 85 
     | 
    
         
            +
                            :race_fee => period['race_fee']
         
     | 
| 
      
 86 
     | 
    
         
            +
                          )
         
     | 
| 
      
 87 
     | 
    
         
            +
                          _event.add_registration_period _period
         
     | 
| 
      
 88 
     | 
    
         
            +
                        end
         
     | 
| 
      
 89 
     | 
    
         
            +
                        _race.add_event _event 
         
     | 
| 
      
 90 
     | 
    
         
            +
                      end
         
     | 
| 
      
 91 
     | 
    
         
            +
                    end
         
     | 
| 
      
 92 
     | 
    
         
            +
                  	races << _race
         
     | 
| 
      
 93 
     | 
    
         
            +
                  	count = count + 1
         
     | 
| 
      
 94 
     | 
    
         
            +
                  	break if !opts[:limit].nil? && count >= opts[:limit].to_i
         
     | 
| 
      
 95 
     | 
    
         
            +
                  end
         
     | 
| 
      
 96 
     | 
    
         
            +
                  races
         
     | 
| 
      
 97 
     | 
    
         
            +
                end
         
     | 
| 
      
 98 
     | 
    
         
            +
              end
         
     | 
| 
      
 99 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # @author Khang Le
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'oauth'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module RailsSignUp
         
     | 
| 
      
 6 
     | 
    
         
            +
              
         
     | 
| 
      
 7 
     | 
    
         
            +
              class Session
         
     | 
| 
      
 8 
     | 
    
         
            +
                attr :session
         
     | 
| 
      
 9 
     | 
    
         
            +
                attr :access_token
         
     | 
| 
      
 10 
     | 
    
         
            +
                attr :api_key
         
     | 
| 
      
 11 
     | 
    
         
            +
                attr :api_secret
         
     | 
| 
      
 12 
     | 
    
         
            +
                
         
     | 
| 
      
 13 
     | 
    
         
            +
                def initialize api_key, api_secret, access_token, access_token_secret, oauth_key, oauth_secret
         
     | 
| 
      
 14 
     | 
    
         
            +
                  raise RailsSignUp::RailsSignUpError, "Missing parameter(api_key)" if api_key.nil? || api_key.length == 0
         
     | 
| 
      
 15 
     | 
    
         
            +
            			raise RailsSignUp::RailsSignUpError, "Missing parameter(api_secret)" if api_secret.nil? || api_secret.length == 0
         
     | 
| 
      
 16 
     | 
    
         
            +
                	raise RailsSignUp::RailsSignUpError, "Missing parameter(access_token)" if access_token.nil? || access_token.length == 0
         
     | 
| 
      
 17 
     | 
    
         
            +
            			raise RailsSignUp::RailsSignUpError, "Missing parameter(access_token_secret)" if access_token_secret.nil? || access_token_secret.length == 0
         
     | 
| 
      
 18 
     | 
    
         
            +
                  
         
     | 
| 
      
 19 
     | 
    
         
            +
                  @consumer = OAuth::Consumer.new(oauth_key, oauth_secret, :site => "https://runsignup.com", :request_token_path => "/oauth/requestToken.php", 
         
     | 
| 
      
 20 
     | 
    
         
            +
                    :authorize_path => "/OAuth/Verify", :access_token_path => "/oauth/accessToken.php")
         
     | 
| 
      
 21 
     | 
    
         
            +
                  @access_token = OAuth::AccessToken.new(@consumer, access_token, access_token_secret)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  @api_key = api_key
         
     | 
| 
      
 23 
     | 
    
         
            +
                  @api_secret = api_secret
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
    
        data/railsSignUp.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'RailsSignUp/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |gem|
         
     | 
| 
      
 7 
     | 
    
         
            +
              gem.name          = "railsSignUp"
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem.version       = RailsSignUp::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem.authors       = ["Khang Le"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem.email         = ["khangsile@gmail.com"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              gem.description   = %q{Retrieve races from RunSignUp}
         
     | 
| 
      
 12 
     | 
    
         
            +
              gem.summary       = %q{This is a gem to allow an authenticated user to get races/race info from RunSignUp}
         
     | 
| 
      
 13 
     | 
    
         
            +
              gem.homepage      = ""
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              gem.files         = `git ls-files`.split($/)
         
     | 
| 
      
 16 
     | 
    
         
            +
              gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
         
     | 
| 
      
 17 
     | 
    
         
            +
              gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 18 
     | 
    
         
            +
              gem.require_paths = ["lib"]
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              gem.add_development_dependency "rspec", "~> 2.6"
         
     | 
| 
      
 21 
     | 
    
         
            +
              gem.add_development_dependency "oauth"
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # @author Khang Le
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe RailsSignUp do
         
     | 
| 
      
 6 
     | 
    
         
            +
              session = RailsSignUp::Session.new('<YOUR API KEY>','<YOUR API SECERET','<YOUR ACCESS TOKEN>','<YOUR ACCESS TOKEN SECRET>', '<YOUR OAUTH TOKEN>', '<YOUR OAUTH SECRET>')
         
     | 
| 
      
 7 
     | 
    
         
            +
              
         
     | 
| 
      
 8 
     | 
    
         
            +
              it "should create oauth session" do
         
     | 
| 
      
 9 
     | 
    
         
            +
                session.should_not be_nil
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
              
         
     | 
| 
      
 12 
     | 
    
         
            +
              it "should retrieve race list" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                rails_sign_up = RailsSignUp::Races.new(session)
         
     | 
| 
      
 14 
     | 
    
         
            +
                races = rails_sign_up.get_races 
         
     | 
| 
      
 15 
     | 
    
         
            +
                races.should_not be_nil
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
              
         
     | 
| 
      
 18 
     | 
    
         
            +
              it "should retrieve race list from search" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                rails_sign_up = RailsSignUp::Races.new(session)
         
     | 
| 
      
 20 
     | 
    
         
            +
                opts = { :events => "T", :name => "Run+Til" }
         
     | 
| 
      
 21 
     | 
    
         
            +
                races = rails_sign_up.get_races opts
         
     | 
| 
      
 22 
     | 
    
         
            +
                races.should_not be_nil
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,96 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: railsSignUp
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1.1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Khang Le
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-07-23 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '2.6'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '2.6'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: oauth
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            description: Retrieve races from RunSignUp
         
     | 
| 
      
 42 
     | 
    
         
            +
            email:
         
     | 
| 
      
 43 
     | 
    
         
            +
            - khangsile@gmail.com
         
     | 
| 
      
 44 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 45 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 46 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 47 
     | 
    
         
            +
            files:
         
     | 
| 
      
 48 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 49 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 50 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 51 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 52 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 53 
     | 
    
         
            +
            - lib/railsSignUp.rb
         
     | 
| 
      
 54 
     | 
    
         
            +
            - lib/railsSignUp/.DS_Store
         
     | 
| 
      
 55 
     | 
    
         
            +
            - lib/railsSignUp/exceptions.rb
         
     | 
| 
      
 56 
     | 
    
         
            +
            - lib/railsSignUp/model/.DS_Store
         
     | 
| 
      
 57 
     | 
    
         
            +
            - lib/railsSignUp/model/event.rb
         
     | 
| 
      
 58 
     | 
    
         
            +
            - lib/railsSignUp/model/race.rb
         
     | 
| 
      
 59 
     | 
    
         
            +
            - lib/railsSignUp/model/registration_period.rb
         
     | 
| 
      
 60 
     | 
    
         
            +
            - lib/railsSignUp/races.rb
         
     | 
| 
      
 61 
     | 
    
         
            +
            - lib/railsSignUp/record.rb
         
     | 
| 
      
 62 
     | 
    
         
            +
            - lib/railsSignUp/session.rb
         
     | 
| 
      
 63 
     | 
    
         
            +
            - lib/railsSignUp/version.rb
         
     | 
| 
      
 64 
     | 
    
         
            +
            - railsSignUp.gemspec
         
     | 
| 
      
 65 
     | 
    
         
            +
            - spec/railsSignUp_helper.rb
         
     | 
| 
      
 66 
     | 
    
         
            +
            - spec/railsSignUp_spec.rb
         
     | 
| 
      
 67 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 68 
     | 
    
         
            +
            homepage: ''
         
     | 
| 
      
 69 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 70 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 71 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 72 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 73 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 74 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 75 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 76 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 77 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 78 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 79 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 80 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 81 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 82 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 83 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 84 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 85 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 86 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 87 
     | 
    
         
            +
            rubygems_version: 2.0.5
         
     | 
| 
      
 88 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 89 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 90 
     | 
    
         
            +
            summary: This is a gem to allow an authenticated user to get races/race info from
         
     | 
| 
      
 91 
     | 
    
         
            +
              RunSignUp
         
     | 
| 
      
 92 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 93 
     | 
    
         
            +
            - spec/railsSignUp_helper.rb
         
     | 
| 
      
 94 
     | 
    
         
            +
            - spec/railsSignUp_spec.rb
         
     | 
| 
      
 95 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 96 
     | 
    
         
            +
            has_rdoc: 
         
     |