Sha256: 0552935a5acd965c12c959400e4a1641c9e4ec7190d5fea80bc13b676c6d028c

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 KB

Contents

module Datapimp
  module Clients
    class Keen
      include Singleton

      def self.method_missing(meth, *args, &block)
        if client.respond_to?(meth)
          return client.send(meth, *args, &block)
        end

        super
      end

      def self.client(options={})
        Keen
      end

      def options
        @options ||= {}
      end

      def with_options(opts={})
        options.merge!(opts)
        self
      end

      def setup(options={})
        access_token = options[:keen_read_key] || Datapimp.config.keen_read_key
        project_id = options[:keen_project_id] || Datapimp.config.keen_project_id

        unless access_token.to_s.length > 1
          if respond_to?(:ask)
            access_token = ask("Enter a keen read key when  you have one", String)
          end
        end

        unless project_id.to_s.length > 1
          if respond_to?(:ask)
            project_id = ask("Enter a keen read key when  you have one", String)
          end
        end

        Datapimp.config.set(:keen_read_key, access_token) if access_token.to_s.length > 1
        Datapimp.config.set(:keen_project_id, project_id) if project_id.to_s.length > 1
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
datapimp-1.2.11 lib/datapimp/clients/keen.rb
datapimp-1.2.10 lib/datapimp/clients/keen.rb
datapimp-1.2.9 lib/datapimp/clients/keen.rb
datapimp-1.2.8 lib/datapimp/clients/keen.rb
datapimp-1.2.7 lib/datapimp/clients/keen.rb
datapimp-1.2.6 lib/datapimp/clients/keen.rb
datapimp-1.2.5 lib/datapimp/clients/keen.rb
datapimp-1.2.4 lib/datapimp/clients/keen.rb
datapimp-1.2.3 lib/datapimp/clients/keen.rb
datapimp-1.2.2 lib/datapimp/clients/keen.rb