cropio-ruby 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +55 -1
- data/lib/cropio/resource/base.rb +10 -0
- data/lib/cropio/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: 322d909d3d7088aa3a9f449a6d489142636d5ec0
|
4
|
+
data.tar.gz: 7fd7bba2137009c7d2ed9f82cde8346d59830a2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29d24cff50057ca959cf9b734a7d35fcbff2eac4efd23b4a280419c7e63358cb6b8c69b96d9f70f220fd312be7fa28d33d056502b9c05270f467fa201fd8db5c
|
7
|
+
data.tar.gz: a706fb76658df9a2deec5edf46403df9ff1bd3c7b72f382587c4105d7d5fd1d630993cbdb4c33818ebad88d433d6ccac5ea2e430f544db013c9430c619022537
|
data/README.md
CHANGED
@@ -21,7 +21,61 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
-
|
24
|
+
Require it:
|
25
|
+
|
26
|
+
$ require 'cropio'
|
27
|
+
|
28
|
+
To load Cropio resources to current namespace:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
include Cropio::Resources
|
32
|
+
```
|
33
|
+
|
34
|
+
You need to specify your email and password. At first time when you'll
|
35
|
+
try to request some data from Cropio gem will get authentication token.
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
Cropio.credentials = {
|
39
|
+
email: 'your account email,
|
40
|
+
password: 'your password'
|
41
|
+
}
|
42
|
+
|
43
|
+
Crop.all
|
44
|
+
|
45
|
+
Cropio.credentials.api_token
|
46
|
+
=> "authenticationToken"
|
47
|
+
```
|
48
|
+
|
49
|
+
Currently supported API methods is:
|
50
|
+
|
51
|
+
- index
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
Crop.all
|
55
|
+
```
|
56
|
+
|
57
|
+
- create
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
Crop.new(name: 'new crop').save
|
61
|
+
```
|
62
|
+
|
63
|
+
- update
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
crop = Crop.all.last
|
67
|
+
crop.short_name = 'new'
|
68
|
+
crop.save
|
69
|
+
|
70
|
+
```
|
71
|
+
|
72
|
+
|
73
|
+
- delete
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
crop = Crop.all.last
|
77
|
+
crop.destroy
|
78
|
+
```
|
25
79
|
|
26
80
|
## Development
|
27
81
|
|
data/lib/cropio/resource/base.rb
CHANGED
@@ -46,6 +46,16 @@ module Cropio
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
def destroy?
|
50
|
+
if persisted?
|
51
|
+
Proxy.delete("#{resources_name}/#{id}")
|
52
|
+
@persisted = false
|
53
|
+
true
|
54
|
+
else
|
55
|
+
raise 'Cropio record is not persisted!'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
49
59
|
private
|
50
60
|
def resources_name
|
51
61
|
self.class.resources_name
|
data/lib/cropio/version.rb
CHANGED