moose 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9adab972b27bf672d0e903f1cd1f93f279dc2d85
4
+ data.tar.gz: 45cf6a7bb27857b30ea22ee45fec437ae136e2e7
5
+ SHA512:
6
+ metadata.gz: ece69fe6d7a5a30252c9cec6a57872628cd978943b9bf72096309a754533b95f05966df00dd2b8a339f89616160f8b9d2eeb7dfd91e0a8f8362f2382236511a4
7
+ data.tar.gz: 95e5da7fa3d76e81757380163823d01ae68c67f5049e9daf9e56b0b1a0e53fe36384c126b83e6c02fb972a3ec26f3248fe4d8d73bcba3ff37c513947680c2d5d
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ Gemfile.lock
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Dan Croak
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.
@@ -0,0 +1,50 @@
1
+ Moose
2
+ =====
3
+
4
+ A Ruby library for making HTTP requests to JSON APIs.
5
+
6
+ Setup
7
+ -----
8
+
9
+ ```ruby
10
+ gem 'moose'
11
+ ```
12
+
13
+ ```
14
+ bundle
15
+ ```
16
+
17
+ ```ruby
18
+ class YourClass
19
+ include Moose
20
+ end
21
+ ```
22
+
23
+ API
24
+ ---
25
+
26
+ The `Moose` module adds these instance methods to the class:
27
+
28
+ ```ruby
29
+ get 'https://api.example.com/v1/resource', 'options'
30
+ put 'https://api.example.com/v1/resource', { data: 'hash' }, 'options'
31
+ ```
32
+
33
+ Examples
34
+ --------
35
+
36
+ ```ruby
37
+ class Trello
38
+ include Moose
39
+
40
+ def add_to_organization(name, email)
41
+ put "organizations/#{name}/members", email: email
42
+ end
43
+
44
+ private
45
+
46
+ def url_for(endpoint)
47
+ "https://api.trello.com/1/#{endpoint}?key=#{ENV['KEY']}"
48
+ end
49
+ end
50
+ ```
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,17 @@
1
+ require 'json'
2
+
3
+ module Moose
4
+ def get(endpoint, options = '-s')
5
+ JSON.parse `curl #{options} '#{url}'`
6
+ end
7
+
8
+ def put(endpoint, data, options = '-s')
9
+ `curl #{options} -X PUT -d '#{data.to_json}' '#{url_for(endpoint)}'`
10
+ end
11
+
12
+ private
13
+
14
+ def url_for(endpoint)
15
+ endpoint
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.add_development_dependency 'bundler', '~> 1.3'
7
+ spec.add_development_dependency 'rake'
8
+ spec.authors = ['Dan Croak']
9
+ spec.description = 'Shells out to cURL. Parses JSON as expected.'
10
+ spec.email = ['dan@thoughtbot.com']
11
+ spec.executables = spec.files.grep(%r{^bin/}) { |file| File.basename(file) }
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+ spec.name = 'moose'
16
+ spec.require_paths = ['lib']
17
+ spec.summary = 'Makes HTTP requests to JSON APIs.'
18
+ spec.test_files = spec.files.grep(%r{^spec/})
19
+ spec.version = '0.0.1'
20
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: moose
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dan Croak
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
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: Shells out to cURL. Parses JSON as expected.
42
+ email:
43
+ - dan@thoughtbot.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/moose.rb
54
+ - moose.gemspec
55
+ homepage: ''
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.0.5
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Makes HTTP requests to JSON APIs.
79
+ test_files: []