playfair_app 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+ - rbx-19mode
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'her', github: 'remiprev/her'
4
+
5
+ # Specify your gem's dependencies in playfair.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Trae Robrock
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,36 @@
1
+ # Playfair
2
+
3
+ [![Build Status](https://travis-ci.org/trobrock/playfair_gem.png?branch=master)](https://travis-ci.org/trobrock/playfair_gem)
4
+
5
+ The official playfair api gem.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'playfair'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install playfair
20
+
21
+ ## Usage
22
+
23
+ Create a new Statsd/Graphite instance
24
+
25
+ ```ruby
26
+ u = Playfair::User.me
27
+ u.instances.create
28
+ ```
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,6 @@
1
+ module Playfair
2
+ class Base
3
+ include Her::Model
4
+ use_api -> { Playfair.client.api }
5
+ end
6
+ end
@@ -0,0 +1,20 @@
1
+ module Playfair
2
+ class Client
3
+ include Singleton
4
+
5
+ attr_accessor :email, :password
6
+ attr_reader :api
7
+
8
+ def configure
9
+ yield self
10
+
11
+ @api = Her::API.new
12
+ @api.setup url: "https://playfairapp.com" do |c|
13
+ c.basic_auth @email, @password
14
+ c.use Faraday::Request::UrlEncoded
15
+ c.use Her::Middleware::DefaultParseJSON
16
+ c.use Faraday::Adapter::NetHttp
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ module Playfair
2
+ class Instance < Base
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ module Playfair
2
+ class User < Base
3
+ has_many :instances
4
+
5
+ def self.me
6
+ get "/settings"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Playfair
2
+ VERSION = "0.0.1"
3
+ end
data/lib/playfair.rb ADDED
@@ -0,0 +1,14 @@
1
+ require "playfair/version"
2
+
3
+ require "her"
4
+
5
+ require "playfair/client"
6
+ require "playfair/base"
7
+ require "playfair/user"
8
+ require "playfair/instance"
9
+
10
+ module Playfair
11
+ def self.client
12
+ Client.instance
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'playfair/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "playfair_app"
8
+ spec.version = Playfair::VERSION
9
+ spec.authors = ["Trae Robrock"]
10
+ spec.email = ["trobrock@gmail.com"]
11
+ spec.description = %q{Official gem to interact with https://playfairapp.com}
12
+ spec.summary = %q{Official gem to interact with https://playfairapp.com}
13
+ spec.homepage = "https://playfairapp.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "her", "~> 0.6"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Playfair::Client do
4
+ subject { Playfair::Client.instance }
5
+
6
+ it 'should configure the client' do
7
+ subject.configure do |c|
8
+ c.email = "bob@example.com"
9
+ c.password = "test"
10
+ end
11
+
12
+ subject.email.should == "bob@example.com"
13
+ subject.password.should == "test"
14
+
15
+ subject.api.should be_a(Her::API)
16
+ subject.api.base_uri.should == "https://playfairapp.com"
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Playfair::Instance do
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Playfair do
4
+ it "should fetch a client" do
5
+ Playfair.client.should be_a(Playfair::Client)
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'playfair'
3
+
4
+ RSpec.configure do |config|
5
+ config.include(Module.new do
6
+ def stub_api_for(klass)
7
+ klass.use_api (api = Her::API.new)
8
+
9
+ # Here, you would customize this for your own API (URL, middleware, etc)
10
+ # like you have done in your application’s initializer
11
+ api.setup url: "https://playfairapp.com" do |c|
12
+ c.use Her::Middleware::FirstLevelParseJSON
13
+ c.adapter(:test) { |s| yield(s) }
14
+ end
15
+ end
16
+ end)
17
+ end
data/spec/user_spec.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Playfair::User do
4
+ before do
5
+ stub_api_for(Playfair::Instance) do |stub|
6
+ stub.get("/users/1/instances") { |env| [200, {}, MultiJson.dump([{ id: 2, state: "queued" }])] }
7
+ end
8
+
9
+ stub_api_for(Playfair::User) do |stub|
10
+ stub.get("/settings") { |env| [200, {}, MultiJson.dump({ id: 1, email: "bob@example.com" })] }
11
+ end
12
+ end
13
+
14
+ it "should be able to retrieve the authenticated user" do
15
+ Playfair::User.me.email.should == "bob@example.com"
16
+ end
17
+
18
+ it "should have instances" do
19
+ Playfair::User.me.instances.first.id.should == 2
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: playfair_app
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Trae Robrock
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: her
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.6'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.6'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.3'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.3'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Official gem to interact with https://playfairapp.com
79
+ email:
80
+ - trobrock@gmail.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - .rspec
87
+ - .travis.yml
88
+ - Gemfile
89
+ - LICENSE.txt
90
+ - README.md
91
+ - Rakefile
92
+ - lib/playfair.rb
93
+ - lib/playfair/base.rb
94
+ - lib/playfair/client.rb
95
+ - lib/playfair/instance.rb
96
+ - lib/playfair/user.rb
97
+ - lib/playfair/version.rb
98
+ - playfair_app.gemspec
99
+ - spec/client_spec.rb
100
+ - spec/instance_spec.rb
101
+ - spec/playfair_spec.rb
102
+ - spec/spec_helper.rb
103
+ - spec/user_spec.rb
104
+ homepage: https://playfairapp.com
105
+ licenses:
106
+ - MIT
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ segments:
118
+ - 0
119
+ hash: 4160334754054326816
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ segments:
127
+ - 0
128
+ hash: 4160334754054326816
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 1.8.23
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: Official gem to interact with https://playfairapp.com
135
+ test_files:
136
+ - spec/client_spec.rb
137
+ - spec/instance_spec.rb
138
+ - spec/playfair_spec.rb
139
+ - spec/spec_helper.rb
140
+ - spec/user_spec.rb