cloudmine 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.
- checksums.yaml +7 -0
 - data/.gitignore +17 -0
 - data/.rspec +2 -0
 - data/Gemfile +9 -0
 - data/LICENSE.txt +22 -0
 - data/README.md +56 -0
 - data/Rakefile +1 -0
 - data/cloudmine.gemspec +22 -0
 - data/lib/cloudmine.rb +5 -0
 - data/lib/cloudmine/base.rb +65 -0
 - data/lib/cloudmine/object.rb +19 -0
 - data/lib/cloudmine/version.rb +3 -0
 - data/spec/integration/object_spec.rb +89 -0
 - data/spec/lib/base_spec.rb +25 -0
 - data/spec/spec_helper.rb +23 -0
 - metadata +88 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b19a1c9558bbb1e1d573e0069033826b83ea5c28
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 8f9e049c46aaa1fdfa1dd3d177d3be489547b578
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8e49461106d8455a8a032127913a0b57d3cf24dab3a01d20931e3f01bc6df8e02fde293b98d9fc52eb3841b013c2980984c762d10f7fecde5b4eeace9a2f7a03
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e06b76b7b528cc17e6e4810c9d2498daf26cdcc1fa9386fb31acb581f28958123435f09e05090c829f6bb07d2b634d4949cc23559cca872a4902d97acb8d67ca
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2013 Nicholas Hance
         
     | 
| 
      
 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,56 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            cloudmine
         
     | 
| 
      
 2 
     | 
    
         
            +
            ==============
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            [CloudMine](https://cloudmine.me) is a backend-as-a-service platform for
         
     | 
| 
      
 5 
     | 
    
         
            +
            mobile and web developers to rapidly build and quickly scale their apps.
         
     | 
| 
      
 6 
     | 
    
         
            +
            Build and scale iOS, Android, Windows Phone, and web apps on our secure
         
     | 
| 
      
 7 
     | 
    
         
            +
            and managed backend.
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            This is a Ruby gem for interacting with the CloudMine API.
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                gem 'cloudmine'
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                $ gem install cloudmine
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            Assign your credentials:
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                Cloudmine.api_key = "my api key"
         
     | 
| 
      
 30 
     | 
    
         
            +
                Cloudmine.app_id  = "my app id"
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            # Objects
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            Create an object:
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                Cloudmine::Object.create('key', { "field" => 'value' })
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            Fetch an object:
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                object = Cloudmine::Object.fetch('key')
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            Update an object:
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                Cloudmine::Object.update('key', 'new value')
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            Destroy an object:
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                Cloudmine::Object.destroy('key')
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            1. Fork it
         
     | 
| 
      
 53 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 54 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 55 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 56 
     | 
    
         
            +
            5. Create new Pull Request
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "bundler/gem_tasks"
         
     | 
    
        data/cloudmine.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 'cloudmine/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |gem|
         
     | 
| 
      
 7 
     | 
    
         
            +
              gem.name          = "cloudmine"
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem.version       = Cloudmine::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem.authors       = ["Nicholas Hance"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem.email         = ["nhance@reenhanced.com"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              gem.description   = %q{Cloudmine API wrapper}
         
     | 
| 
      
 12 
     | 
    
         
            +
              gem.summary       = %q{Cloudmine API wrapper}
         
     | 
| 
      
 13 
     | 
    
         
            +
              gem.homepage      = "http://github.com/reenhanced/cloudmine"
         
     | 
| 
      
 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_dependency('httparty')
         
     | 
| 
      
 21 
     | 
    
         
            +
              gem.add_dependency('json')
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/cloudmine.rb
    ADDED
    
    
| 
         @@ -0,0 +1,65 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Cloudmine
         
     | 
| 
      
 2 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 3 
     | 
    
         
            +
                def app_id
         
     | 
| 
      
 4 
     | 
    
         
            +
                  Base.app_id
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                def app_id=(app_id)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  Base.app_id = app_id
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                def api_key
         
     | 
| 
      
 12 
     | 
    
         
            +
                  Base.api_key
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
                
         
     | 
| 
      
 15 
     | 
    
         
            +
                def api_key=(api_key)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  Base.api_key = api_key
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              class Base
         
     | 
| 
      
 21 
     | 
    
         
            +
                include HTTParty
         
     | 
| 
      
 22 
     | 
    
         
            +
                default_timeout 30
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                attr_accessor :api_key, :app_id
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                def initialize(api_key, app_id)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  self.api_key = api_key
         
     | 
| 
      
 28 
     | 
    
         
            +
                  self.app_id  = app_id
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 32 
     | 
    
         
            +
                  attr_accessor :api_key, :app_id
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  def method_missing(sym, *args, &block)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    new(Cloudmine.api_key, Cloudmine.app_id).send(sym, *args, &block)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
                
         
     | 
| 
      
 39 
     | 
    
         
            +
                protected
         
     | 
| 
      
 40 
     | 
    
         
            +
                  def api_call(method, endpoint, options={})
         
     | 
| 
      
 41 
     | 
    
         
            +
                    options[:headers] ||= {}
         
     | 
| 
      
 42 
     | 
    
         
            +
                    options[:headers]["X-CloudMine-ApiKey"] = api_key
         
     | 
| 
      
 43 
     | 
    
         
            +
                    options[:headers]["Content-Type"]       = "application/json"
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                    options[:body] = options[:body].to_json if options[:body]
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                    response = self.class.send(method, api_url(endpoint), options)
         
     | 
| 
      
 48 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 49 
     | 
    
         
            +
                      response_body = JSON.parse(response.body)
         
     | 
| 
      
 50 
     | 
    
         
            +
                    rescue JSON::ParserError
         
     | 
| 
      
 51 
     | 
    
         
            +
                      response_body = response.body
         
     | 
| 
      
 52 
     | 
    
         
            +
                    end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                    unless (200..299).include? response.code
         
     | 
| 
      
 55 
     | 
    
         
            +
                      raise "Error from Cloudmine API: #{response_body["errors"].join(", ")} (code #{response.code})"
         
     | 
| 
      
 56 
     | 
    
         
            +
                    end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                    response_body
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
                  
         
     | 
| 
      
 61 
     | 
    
         
            +
                  def api_url(endpoint)
         
     | 
| 
      
 62 
     | 
    
         
            +
                    "https://api.cloudmine.me/v1/app/#{app_id}/#{endpoint}"
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
              end
         
     | 
| 
      
 65 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Cloudmine
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Object < Base
         
     | 
| 
      
 3 
     | 
    
         
            +
                def fetch(*keys)
         
     | 
| 
      
 4 
     | 
    
         
            +
                  api_call(:get, 'text', :query => { :keys => keys.flatten.join(',') })["success"]
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                def update(key, value, options = {})
         
     | 
| 
      
 8 
     | 
    
         
            +
                  api_call(:post, 'text', :body => { key => value })
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                def create(key, value)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  api_call(:put, 'text', :body => { key => value })
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                def destroy(*keys)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  api_call(:delete, 'data', :query => { :keys => keys.flatten.join(',') })
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,89 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Cloudmine::Object do
         
     | 
| 
      
 4 
     | 
    
         
            +
              let(:app_id)  { "appid" }
         
     | 
| 
      
 5 
     | 
    
         
            +
              let(:api_key) { "apikey" }
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              before do
         
     | 
| 
      
 8 
     | 
    
         
            +
                Cloudmine.app_id  = app_id
         
     | 
| 
      
 9 
     | 
    
         
            +
                Cloudmine.api_key = api_key
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              describe "#create" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                let(:request_body)  { { "key1" => "value" }.to_json }
         
     | 
| 
      
 14 
     | 
    
         
            +
                let(:response_body) { { "success" => { "key1" => "created" } }.to_json }
         
     | 
| 
      
 15 
     | 
    
         
            +
                let!(:request) {
         
     | 
| 
      
 16 
     | 
    
         
            +
                  WebMock.stub_request(:put, "https://api.cloudmine.me/v1/app/#{app_id}/text").with(headers: { "X-CloudMine-ApiKey" => api_key,
         
     | 
| 
      
 17 
     | 
    
         
            +
                                                                                                               "Content-Type" => "application/json" },
         
     | 
| 
      
 18 
     | 
    
         
            +
                                                                                                    body:     request_body)
         
     | 
| 
      
 19 
     | 
    
         
            +
                                                                                              .to_return(body:    response_body,
         
     | 
| 
      
 20 
     | 
    
         
            +
                                                                                                         status:  200,
         
     | 
| 
      
 21 
     | 
    
         
            +
                                                                                                         headers: { "Content-Type" => "application/json" })
         
     | 
| 
      
 22 
     | 
    
         
            +
                }
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                it "issues a create request to Cloudmine" do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  Cloudmine::Object.create("key1", "value")
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                  request.should have_been_requested
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              describe "#destroy" do
         
     | 
| 
      
 32 
     | 
    
         
            +
                let(:response_body) { { "success" => { "key1" => "deleted", "key2" => "deleted" } }.to_json }
         
     | 
| 
      
 33 
     | 
    
         
            +
                let!(:request) {
         
     | 
| 
      
 34 
     | 
    
         
            +
                  WebMock.stub_request(:delete, "https://api.cloudmine.me/v1/app/#{app_id}/data?keys=key1,key2").with(headers: { "X-CloudMine-ApiKey" => api_key,
         
     | 
| 
      
 35 
     | 
    
         
            +
                                                                                                               "Content-Type" => "application/json" })
         
     | 
| 
      
 36 
     | 
    
         
            +
                                                                                              .to_return(body:    response_body,
         
     | 
| 
      
 37 
     | 
    
         
            +
                                                                                                         status:  200,
         
     | 
| 
      
 38 
     | 
    
         
            +
                                                                                                         headers: { "Content-Type" => "application/json" })
         
     | 
| 
      
 39 
     | 
    
         
            +
                }
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                it "issues a delete request to Cloudmine" do
         
     | 
| 
      
 42 
     | 
    
         
            +
                  Cloudmine::Object.destroy(["key1", "key2"])
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                  request.should have_been_requested
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              describe "#fetch" do
         
     | 
| 
      
 49 
     | 
    
         
            +
                let(:response_body) { { "success" => { "key1" => "value", "key2" => "value" } }.to_json }
         
     | 
| 
      
 50 
     | 
    
         
            +
                let!(:request) {
         
     | 
| 
      
 51 
     | 
    
         
            +
                  WebMock.stub_request(:get, "https://api.cloudmine.me/v1/app/#{app_id}/text?keys=key1,key2").with(headers: { "X-CloudMine-ApiKey" => api_key,
         
     | 
| 
      
 52 
     | 
    
         
            +
                                                                                                               "Content-Type" => "application/json" })
         
     | 
| 
      
 53 
     | 
    
         
            +
                                                                                              .to_return(body:    response_body,
         
     | 
| 
      
 54 
     | 
    
         
            +
                                                                                                         status:  200,
         
     | 
| 
      
 55 
     | 
    
         
            +
                                                                                                         headers: { "Content-Type" => "application/json" })
         
     | 
| 
      
 56 
     | 
    
         
            +
                }
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                it "issues a fetch request to Cloudmine" do
         
     | 
| 
      
 59 
     | 
    
         
            +
                  Cloudmine::Object.fetch(["key1", "key2"])
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  request.should have_been_requested
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                it "returns a JSON representation of the data stored in cloudmine" do
         
     | 
| 
      
 65 
     | 
    
         
            +
                  fetched = Cloudmine::Object.fetch(["key1", "key2"])
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                  fetched.should == { "key1" => "value", "key2" => "value" }
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
              describe "#update" do
         
     | 
| 
      
 72 
     | 
    
         
            +
                let(:request_body)  { { "key1" => "value" }.to_json }
         
     | 
| 
      
 73 
     | 
    
         
            +
                let(:response_body) { { "success" => { "key1" => "updated" } }.to_json }
         
     | 
| 
      
 74 
     | 
    
         
            +
                let!(:request) {
         
     | 
| 
      
 75 
     | 
    
         
            +
                  WebMock.stub_request(:post, "https://api.cloudmine.me/v1/app/#{app_id}/text").with(headers: { "X-CloudMine-ApiKey" => api_key,
         
     | 
| 
      
 76 
     | 
    
         
            +
                                                                                                               "Content-Type" => "application/json" },
         
     | 
| 
      
 77 
     | 
    
         
            +
                                                                                                    body:     request_body)
         
     | 
| 
      
 78 
     | 
    
         
            +
                                                                                              .to_return(body:    response_body,
         
     | 
| 
      
 79 
     | 
    
         
            +
                                                                                                         status:  200,
         
     | 
| 
      
 80 
     | 
    
         
            +
                                                                                                         headers: { "Content-Type" => "application/json" })
         
     | 
| 
      
 81 
     | 
    
         
            +
                }
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                it "issues a request to Cloudmine" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                  Cloudmine::Object.update("key1", "value")
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                  request.should have_been_requested
         
     | 
| 
      
 87 
     | 
    
         
            +
                end
         
     | 
| 
      
 88 
     | 
    
         
            +
              end
         
     | 
| 
      
 89 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Cloudmine::Base do
         
     | 
| 
      
 4 
     | 
    
         
            +
              let(:api_key) { "api_key_for_me" }
         
     | 
| 
      
 5 
     | 
    
         
            +
              let(:app_id)  { "myappid" }
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              context "initialization" do
         
     | 
| 
      
 8 
     | 
    
         
            +
                subject       { Cloudmine::Base.new(api_key, app_id) }
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                its(:api_key) { should == api_key }
         
     | 
| 
      
 11 
     | 
    
         
            +
                its(:app_id)  { should == app_id }
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              context "top level accessors" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                before do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  Cloudmine.api_key = "apikey"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  Cloudmine.app_id  = "app_id"
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                subject { Cloudmine }
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                its(:api_key) { should == "apikey" }
         
     | 
| 
      
 23 
     | 
    
         
            +
                its(:app_id)  { should == "app_id" }
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'cloudmine'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'webmock/rspec'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'json'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            # This file was generated by the `rspec --init` command. Conventionally, all
         
     | 
| 
      
 6 
     | 
    
         
            +
            # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
         
     | 
| 
      
 7 
     | 
    
         
            +
            # Require this file using `require "spec_helper"` to ensure that it is only
         
     | 
| 
      
 8 
     | 
    
         
            +
            # loaded once.
         
     | 
| 
      
 9 
     | 
    
         
            +
            #
         
     | 
| 
      
 10 
     | 
    
         
            +
            # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
         
     | 
| 
      
 11 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 12 
     | 
    
         
            +
              config.treat_symbols_as_metadata_keys_with_true_values = true
         
     | 
| 
      
 13 
     | 
    
         
            +
              config.run_all_when_everything_filtered = true
         
     | 
| 
      
 14 
     | 
    
         
            +
              config.filter_run :focus
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              # Run specs in random order to surface order dependencies. If you find an
         
     | 
| 
      
 17 
     | 
    
         
            +
              # order dependency and want to debug it, you can fix the order by providing
         
     | 
| 
      
 18 
     | 
    
         
            +
              # the seed, which is printed after each run.
         
     | 
| 
      
 19 
     | 
    
         
            +
              #     --seed 1234
         
     | 
| 
      
 20 
     | 
    
         
            +
              config.order = 'random'
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            WebMock.disable_net_connect!(allow_localhost: true)
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,88 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: cloudmine
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Nicholas Hance
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-06-26 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: httparty
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - '>='
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - '>='
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: json
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - '>='
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - '>='
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            description: Cloudmine API wrapper
         
     | 
| 
      
 42 
     | 
    
         
            +
            email:
         
     | 
| 
      
 43 
     | 
    
         
            +
            - nhance@reenhanced.com
         
     | 
| 
      
 44 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 45 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 46 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 47 
     | 
    
         
            +
            files:
         
     | 
| 
      
 48 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 49 
     | 
    
         
            +
            - .rspec
         
     | 
| 
      
 50 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 51 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 52 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 53 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 54 
     | 
    
         
            +
            - cloudmine.gemspec
         
     | 
| 
      
 55 
     | 
    
         
            +
            - lib/cloudmine.rb
         
     | 
| 
      
 56 
     | 
    
         
            +
            - lib/cloudmine/base.rb
         
     | 
| 
      
 57 
     | 
    
         
            +
            - lib/cloudmine/object.rb
         
     | 
| 
      
 58 
     | 
    
         
            +
            - lib/cloudmine/version.rb
         
     | 
| 
      
 59 
     | 
    
         
            +
            - spec/integration/object_spec.rb
         
     | 
| 
      
 60 
     | 
    
         
            +
            - spec/lib/base_spec.rb
         
     | 
| 
      
 61 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 62 
     | 
    
         
            +
            homepage: http://github.com/reenhanced/cloudmine
         
     | 
| 
      
 63 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 64 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 65 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 66 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 67 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 68 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 69 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 70 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 71 
     | 
    
         
            +
              - - '>='
         
     | 
| 
      
 72 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 73 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 74 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 75 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 76 
     | 
    
         
            +
              - - '>='
         
     | 
| 
      
 77 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 78 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 79 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 80 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 81 
     | 
    
         
            +
            rubygems_version: 2.0.3
         
     | 
| 
      
 82 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 83 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 84 
     | 
    
         
            +
            summary: Cloudmine API wrapper
         
     | 
| 
      
 85 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 86 
     | 
    
         
            +
            - spec/integration/object_spec.rb
         
     | 
| 
      
 87 
     | 
    
         
            +
            - spec/lib/base_spec.rb
         
     | 
| 
      
 88 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     |