putson 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/putson/client.rb +6 -0
- data/lib/putson/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 797fec819e3d1d42e91130dcfbbdebdab1d83ca8
|
4
|
+
data.tar.gz: 33cc61a5ac947e2d3e7901fd60b356817a3e10dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5f7e1d4922f67f439cb3c8ad940705e70ce97890bb09bdb60d639cfbce84e4d44bb4a015aa124dee2d1e18c58fa7e45b0fe8c5a7e587ca39ae5c8dc161b2817
|
7
|
+
data.tar.gz: b0097dc0f32b04c9fe4a5074d720afcbf21c79a4d6b9c5da6d7e7ab62c29eddd1c6e0b77699eafe2b568a3a9a07cffbbcc996427079dae8f30d59a3b3aa91468
|
data/README.md
CHANGED
@@ -30,7 +30,7 @@ Post some data
|
|
30
30
|
```ruby
|
31
31
|
# Data can be JSON (as a string). Or another object that responds to `to_json`.
|
32
32
|
> putson.post({yo: 'lo'})
|
33
|
-
=> "lwdaz"
|
33
|
+
=> "https://api.myjson.com/bins/lwdaz"
|
34
34
|
```
|
35
35
|
|
36
36
|
Get some data
|
@@ -45,7 +45,7 @@ Get some data
|
|
45
45
|
Update some data
|
46
46
|
```ruby
|
47
47
|
> putson.put({yo: 'no'})
|
48
|
-
=> "lwdaz"
|
48
|
+
=> "https://api.myjson.com/bins/lwdaz"
|
49
49
|
> putson.get
|
50
50
|
=> "{\"yo\":\"no\"}"
|
51
51
|
```
|
data/lib/putson/client.rb
CHANGED
@@ -36,11 +36,17 @@ module Putson
|
|
36
36
|
response.body
|
37
37
|
end
|
38
38
|
|
39
|
+
def url
|
40
|
+
return if id.nil?
|
41
|
+
"#{URL}bins/#{id}"
|
42
|
+
end
|
43
|
+
|
39
44
|
private
|
40
45
|
|
41
46
|
def parse_post_response(response)
|
42
47
|
body = JSON.parse(response.body)
|
43
48
|
@id ||= body.fetch('uri', nil).gsub("#{URL}bins/", '')
|
49
|
+
url
|
44
50
|
end
|
45
51
|
|
46
52
|
def client
|
data/lib/putson/version.rb
CHANGED