ccs_survey_gem 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
 - data/Gemfile +4 -0
 - data/Rakefile +2 -0
 - data/app/models/campaign_categories.rb +5 -0
 - data/app/models/instant_dollarz_campaign.rb +96 -0
 - data/app/models/instant_dollarz_category.rb +6 -0
 - data/app/models/survey_campaign.rb +37 -0
 - data/ccs_survey_gem.gemspec +21 -0
 - data/lib/ccs_survey_gem/engine.rb +6 -0
 - data/lib/ccs_survey_gem/version.rb +3 -0
 - data/lib/ccs_survey_gem.rb +3 -0
 - data/nbproject/private/config.properties +0 -0
 - data/nbproject/private/private.properties +3 -0
 - data/nbproject/private/rake-d.txt +3 -0
 - data/nbproject/project.properties +7 -0
 - data/nbproject/project.xml +13 -0
 - metadata +83 -0
 
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/Rakefile
    ADDED
    
    
| 
         @@ -0,0 +1,96 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # To change this template, choose Tools | Templates
         
     | 
| 
      
 2 
     | 
    
         
            +
            # and open the template in the editor.
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class InstantDollarzCampaign < SurveyCampaign
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              belongs_to :instant_dollarz_category, :foreign_key => 'campaign_category_id'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              def url_to_campaign(user_id)
         
     | 
| 
      
 9 
     | 
    
         
            +
                "#{self.offer_url}&subid=#{user_id}&sid=#{SiteDetail.get_site_id}&email=clicks@cloudcitysites.com"
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              def self.import
         
     | 
| 
      
 13 
     | 
    
         
            +
                InstantDollarzCategory.destroy_all
         
     | 
| 
      
 14 
     | 
    
         
            +
                response = download_instantdollarz_campaigns
         
     | 
| 
      
 15 
     | 
    
         
            +
                x = 0
         
     | 
| 
      
 16 
     | 
    
         
            +
                if response
         
     | 
| 
      
 17 
     | 
    
         
            +
            #      SurveyCampaign.destroy_all
         
     | 
| 
      
 18 
     | 
    
         
            +
                  response.body.each do |line|
         
     | 
| 
      
 19 
     | 
    
         
            +
                    x += 1
         
     | 
| 
      
 20 
     | 
    
         
            +
                    if x > 1
         
     | 
| 
      
 21 
     | 
    
         
            +
                      store_in_db(line)
         
     | 
| 
      
 22 
     | 
    
         
            +
            #          puts("@@@@@@@@@ Response line 1 = #{line}")
         
     | 
| 
      
 23 
     | 
    
         
            +
            #          puts("@@@@@@@@@ Response line count = #{response.body.size}")
         
     | 
| 
      
 24 
     | 
    
         
            +
                    end
         
     | 
| 
      
 25 
     | 
    
         
            +
                    #line
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
                disable_non_updated_campaigns
         
     | 
| 
      
 29 
     | 
    
         
            +
                return true
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              private
         
     | 
| 
      
 33 
     | 
    
         
            +
              def self.get_report_path
         
     | 
| 
      
 34 
     | 
    
         
            +
                '/subscription_data_generator/?username=ccslocal&key=cbb1d79dec9c850a4843b125f9c648fd&format=tab_bare'
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              def self.download_instantdollarz_campaigns
         
     | 
| 
      
 38 
     | 
    
         
            +
                response = ''
         
     | 
| 
      
 39 
     | 
    
         
            +
                end_point = 'api.instantdollarz.com'
         
     | 
| 
      
 40 
     | 
    
         
            +
                report_path = get_report_path
         
     | 
| 
      
 41 
     | 
    
         
            +
                unless report_path.blank?
         
     | 
| 
      
 42 
     | 
    
         
            +
                  site = Net::HTTP.new(end_point, 80)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  #site.use_ssl = true
         
     | 
| 
      
 44 
     | 
    
         
            +
                  response = site.get2(report_path)
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
                return response
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              def self.store_in_db(line)
         
     | 
| 
      
 50 
     | 
    
         
            +
                x = 1
         
     | 
| 
      
 51 
     | 
    
         
            +
                words = line.split(/\t/)
         
     | 
| 
      
 52 
     | 
    
         
            +
            #    words.each do |word|
         
     | 
| 
      
 53 
     | 
    
         
            +
            #      puts("@@@@@@ Word is #{word}, word_number is #{x}")
         
     | 
| 
      
 54 
     | 
    
         
            +
            #      x += 1
         
     | 
| 
      
 55 
     | 
    
         
            +
            #    end
         
     | 
| 
      
 56 
     | 
    
         
            +
            #    puts("@@@@@@ Line size is #{line.size}")
         
     | 
| 
      
 57 
     | 
    
         
            +
                sc = self.find_by_campaign_id(words[0].to_i)
         
     | 
| 
      
 58 
     | 
    
         
            +
                if sc.blank?
         
     | 
| 
      
 59 
     | 
    
         
            +
                  sc = self.new
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
                category = InstantDollarzCategory.find_by_name(words[8])
         
     | 
| 
      
 62 
     | 
    
         
            +
                if category.blank?
         
     | 
| 
      
 63 
     | 
    
         
            +
                  category = InstantDollarzCategory.new
         
     | 
| 
      
 64 
     | 
    
         
            +
                  category.name = words[8]
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
                sc.instant_dollarz_category = category
         
     | 
| 
      
 67 
     | 
    
         
            +
                if words[0].to_i == 4233
         
     | 
| 
      
 68 
     | 
    
         
            +
                  puts("@@@@ Category is #{words[8]} - should be - Adult - ac.category is #{sc.instant_dollarz_category.name}")
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
                if sc.instant_dollarz_category.blank?
         
     | 
| 
      
 71 
     | 
    
         
            +
                  puts("@@@@ Category is blank!")
         
     | 
| 
      
 72 
     | 
    
         
            +
                end
         
     | 
| 
      
 73 
     | 
    
         
            +
                sc.campaign_id = words[0].to_i
         
     | 
| 
      
 74 
     | 
    
         
            +
                sc.offer_name = words[1]
         
     | 
| 
      
 75 
     | 
    
         
            +
                sc.commission = words[2]
         
     | 
| 
      
 76 
     | 
    
         
            +
                sc.banner_size = words[3]
         
     | 
| 
      
 77 
     | 
    
         
            +
                sc.offer_url = words[4]
         
     | 
| 
      
 78 
     | 
    
         
            +
                sc.banner_url = words[5]
         
     | 
| 
      
 79 
     | 
    
         
            +
                sc.description = words[6]
         
     | 
| 
      
 80 
     | 
    
         
            +
                sc.reporting = words[7]
         
     | 
| 
      
 81 
     | 
    
         
            +
                sc.countries = words[9]
         
     | 
| 
      
 82 
     | 
    
         
            +
                sc.updated = true
         
     | 
| 
      
 83 
     | 
    
         
            +
                sc.save
         
     | 
| 
      
 84 
     | 
    
         
            +
              end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
              def self.disable_non_updated_campaigns
         
     | 
| 
      
 87 
     | 
    
         
            +
                #Set current to false on campaigns that were not updated
         
     | 
| 
      
 88 
     | 
    
         
            +
            #    logger.debug("@@@@ 1")
         
     | 
| 
      
 89 
     | 
    
         
            +
                InstantDollarzCampaign.update_all({:current => false}, {:updated => false})
         
     | 
| 
      
 90 
     | 
    
         
            +
            #                     ['updated IS ?', false])
         
     | 
| 
      
 91 
     | 
    
         
            +
                #now set updated flag back to false on all campaigns ready for the next import run
         
     | 
| 
      
 92 
     | 
    
         
            +
            #    logger.debug("@@@@ 2")
         
     | 
| 
      
 93 
     | 
    
         
            +
                InstantDollarzCampaign.update_all({:updated => false}, {:updated => true})
         
     | 
| 
      
 94 
     | 
    
         
            +
            #                     ['updated IS ?', true])
         
     | 
| 
      
 95 
     | 
    
         
            +
              end
         
     | 
| 
      
 96 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,37 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class SurveyCampaign < ActiveRecord::Base
         
     | 
| 
      
 2 
     | 
    
         
            +
              establish_connection "ccs_central_#{Rails.env}"
         
     | 
| 
      
 3 
     | 
    
         
            +
              belongs_to :campaign_category
         
     | 
| 
      
 4 
     | 
    
         
            +
              acts_as_list
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              def url_to_campaign(user_id)
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              def positive_vote
         
     | 
| 
      
 10 
     | 
    
         
            +
               if self.positive_vote_count
         
     | 
| 
      
 11 
     | 
    
         
            +
                  self.positive_vote_count += 1
         
     | 
| 
      
 12 
     | 
    
         
            +
                else
         
     | 
| 
      
 13 
     | 
    
         
            +
                  self.positive_vote_count = 1
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
                if self.position
         
     | 
| 
      
 16 
     | 
    
         
            +
                  self.position += 1
         
     | 
| 
      
 17 
     | 
    
         
            +
                else
         
     | 
| 
      
 18 
     | 
    
         
            +
                  self.position = 1
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
                self.save
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              def negative_vote
         
     | 
| 
      
 24 
     | 
    
         
            +
               if self.negative_vote_count
         
     | 
| 
      
 25 
     | 
    
         
            +
                  self.negative_vote_count += 1
         
     | 
| 
      
 26 
     | 
    
         
            +
                else
         
     | 
| 
      
 27 
     | 
    
         
            +
                  self.negative_vote_count = 1
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
                if self.position
         
     | 
| 
      
 30 
     | 
    
         
            +
                  self.position -= 1
         
     | 
| 
      
 31 
     | 
    
         
            +
                else
         
     | 
| 
      
 32 
     | 
    
         
            +
                  self.position = -1
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
                self.save
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            $:.push File.expand_path("../lib", __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "ccs_survey_gem/version"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.name        = "ccs_survey_gem"
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.version     = CcsSurveyGem::VERSION
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.platform    = Gem::Platform::RUBY
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.authors     = ["James West"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.email       = ["jamesw@cloudcitysites.com"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.homepage    = "http://www.cloudcitysites.com"
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.summary     = %q{A private gem specific for use with Cloud City Sites projects}
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.description = %q{Provides survey functionality for ccs_local and cloud city sites websites}
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              s.rubyforge_project = "ccs_survey_gem"
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              s.files         = `git ls-files`.split("\n")
         
     | 
| 
      
 18 
     | 
    
         
            +
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         
     | 
| 
      
 20 
     | 
    
         
            +
              s.require_paths = ["lib"]
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         
            File without changes
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <?xml version="1.0" encoding="UTF-8"?>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <project xmlns="http://www.netbeans.org/ns/project/1">
         
     | 
| 
      
 3 
     | 
    
         
            +
                <type>org.netbeans.modules.ruby.rubyproject</type>
         
     | 
| 
      
 4 
     | 
    
         
            +
                <configuration>
         
     | 
| 
      
 5 
     | 
    
         
            +
                    <data xmlns="http://www.netbeans.org/ns/ruby-project/1">
         
     | 
| 
      
 6 
     | 
    
         
            +
                        <name>ccs_survey_gem</name>
         
     | 
| 
      
 7 
     | 
    
         
            +
                        <source-roots>
         
     | 
| 
      
 8 
     | 
    
         
            +
                            <root id="src.dir"/>
         
     | 
| 
      
 9 
     | 
    
         
            +
                        </source-roots>
         
     | 
| 
      
 10 
     | 
    
         
            +
                        <test-roots/>
         
     | 
| 
      
 11 
     | 
    
         
            +
                    </data>
         
     | 
| 
      
 12 
     | 
    
         
            +
                </configuration>
         
     | 
| 
      
 13 
     | 
    
         
            +
            </project>
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,83 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: ccs_survey_gem
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 29
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 6 
     | 
    
         
            +
              segments: 
         
     | 
| 
      
 7 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 9 
     | 
    
         
            +
              - 1
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 11 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 12 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 13 
     | 
    
         
            +
            - James West
         
     | 
| 
      
 14 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 16 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2011-01-06 00:00:00 +00:00
         
     | 
| 
      
 19 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 20 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            description: Provides survey functionality for ccs_local and cloud city sites websites
         
     | 
| 
      
 23 
     | 
    
         
            +
            email: 
         
     | 
| 
      
 24 
     | 
    
         
            +
            - jamesw@cloudcitysites.com
         
     | 
| 
      
 25 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 32 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 33 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 34 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 35 
     | 
    
         
            +
            - app/models/campaign_categories.rb
         
     | 
| 
      
 36 
     | 
    
         
            +
            - app/models/instant_dollarz_campaign.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            - app/models/instant_dollarz_category.rb
         
     | 
| 
      
 38 
     | 
    
         
            +
            - app/models/survey_campaign.rb
         
     | 
| 
      
 39 
     | 
    
         
            +
            - ccs_survey_gem.gemspec
         
     | 
| 
      
 40 
     | 
    
         
            +
            - lib/ccs_survey_gem.rb
         
     | 
| 
      
 41 
     | 
    
         
            +
            - lib/ccs_survey_gem/engine.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
            - lib/ccs_survey_gem/version.rb
         
     | 
| 
      
 43 
     | 
    
         
            +
            - nbproject/private/config.properties
         
     | 
| 
      
 44 
     | 
    
         
            +
            - nbproject/private/private.properties
         
     | 
| 
      
 45 
     | 
    
         
            +
            - nbproject/private/rake-d.txt
         
     | 
| 
      
 46 
     | 
    
         
            +
            - nbproject/project.properties
         
     | 
| 
      
 47 
     | 
    
         
            +
            - nbproject/project.xml
         
     | 
| 
      
 48 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 49 
     | 
    
         
            +
            homepage: http://www.cloudcitysites.com
         
     | 
| 
      
 50 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 53 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 56 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 57 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 58 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 59 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 60 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 61 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 62 
     | 
    
         
            +
                  hash: 3
         
     | 
| 
      
 63 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 64 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 65 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 66 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 67 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 68 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 69 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 70 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 71 
     | 
    
         
            +
                  hash: 3
         
     | 
| 
      
 72 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 73 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 74 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 75 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
            rubyforge_project: ccs_survey_gem
         
     | 
| 
      
 78 
     | 
    
         
            +
            rubygems_version: 1.3.7
         
     | 
| 
      
 79 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 80 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 81 
     | 
    
         
            +
            summary: A private gem specific for use with Cloud City Sites projects
         
     | 
| 
      
 82 
     | 
    
         
            +
            test_files: []
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     |