minly 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +78 -14
- data/circle.yml +3 -0
- data/lib/minly/url.rb +24 -18
- data/lib/minly/version.rb +1 -1
- data/minly.gemspec +4 -1
- metadata +51 -4
- data/minly-0.1.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6d783e1d88bb72bf9f4ce80d327a83868ce60c3
|
4
|
+
data.tar.gz: 917853514de5bb74bfdc3792b3871d781a860c38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f1f740f7d76e103b5e6d952a6125d3e5d903191aaf6b021159a14a3bb9ba862028c7f9a3194aee547fd54c9f44cc2751987728e4e6d357aefa3ec933755abc0
|
7
|
+
data.tar.gz: ca1e93d4f038f3e5b0a3db08fb38203349761caa3e34f5df18f205c611875ebd7b906a1e98f659babb5c8095d7a5bd426d8b1422b28644a5a99988779439a4ab
|
data/README.md
CHANGED
@@ -1,28 +1,93 @@
|
|
1
|
-
# Minly
|
1
|
+
# Minly-gem [![Code Climate](https://codeclimate.com/github/andela-ooranagwa/minly-gem/badges/gpa.svg)](https://codeclimate.com/github/andela-ooranagwa/minly-gem)
|
2
2
|
|
3
|
-
|
3
|
+
Minly-gem provides access to all features of the [_Minly URL shortening service_](http://github.com/andela-ooranagwa/minly) by integrating the Minly API. With the gem, you can effortlessly create and expand minlys; have access to the most popular minlys ever create and also the recent additions to the Minly database. Even features such as deleting, deactivating and editing minlys that are reserved for registered users of the Minly service can also be accessed using a valid token.
|
4
4
|
|
5
|
-
|
5
|
+
## Dependencies
|
6
|
+
You need to have Ruby set up on you machine. The gem is built using Ruby version _2.1.7_. Also, you need to have _bundler_ installed (especially if you are including the gem in another app or project).
|
6
7
|
|
7
8
|
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
9
|
+
Add this line to your application's Gemfile
|
11
10
|
```ruby
|
12
11
|
gem 'minly'
|
13
12
|
```
|
13
|
+
And then execute
|
14
|
+
```ruby
|
15
|
+
$ bundle
|
16
|
+
```
|
17
|
+
Or install it yourself as
|
18
|
+
```ruby
|
19
|
+
$ gem install minly
|
20
|
+
```
|
14
21
|
|
15
|
-
|
22
|
+
## Usage
|
23
|
+
To starting using minly, you need to require it. Do:
|
24
|
+
```ruby
|
25
|
+
$ require 'minly'
|
26
|
+
```
|
27
|
+
Or add to your code
|
16
28
|
|
17
|
-
|
29
|
+
Next you create an instance of the minly gem:
|
30
|
+
```ruby
|
31
|
+
$ minly = Minly::Url.new
|
32
|
+
```
|
33
|
+
Optionally, you can also instantiate with a valid token i.e
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
$ minly = Minly::Url.new(_your_valid_token_)
|
37
|
+
```
|
38
|
+
You can always do:
|
39
|
+
```ruby
|
40
|
+
$ minly.token #=> to view your token (it returns nil if token is not available)
|
41
|
+
$ minly.token = _token_ #=> to set your token
|
42
|
+
```
|
43
|
+
### Without token
|
44
|
+
```ruby
|
45
|
+
# To get the details including the orignal url of a minly:
|
46
|
+
$ minly.expand_minly(_xxx_) #=> (requires a valid minly as argument) returns all the details of the given minly: xxx. Returns an empty hash if the details of the given minly is not found.
|
47
|
+
```
|
48
|
+
```ruby
|
49
|
+
# To get the most popular minlys
|
50
|
+
$ minly.popular_minlys #=> returns an array containing the five most popular minlys.
|
51
|
+
```
|
52
|
+
```ruby
|
53
|
+
# To get the recent minlys
|
54
|
+
$ minly.recent_minlys #=> returns an array containing the five recent minlys.
|
55
|
+
```
|
18
56
|
|
19
|
-
|
57
|
+
### With a _valid_ token
|
58
|
+
In addition to the above methods
|
59
|
+
```ruby
|
60
|
+
# To create a customized minly
|
61
|
+
$ minly.create_minly(_original-url_, _vanity-string_) #=> (original-url should be a valid url, vanity-string should be any alphanumeric character(s)) returns details of the created minly.
|
20
62
|
|
21
|
-
|
63
|
+
```
|
64
|
+
```ruby
|
65
|
+
# To change the url target of a minly
|
66
|
+
$ minly.change_minly_target(_xxx_, _new-origin_) #=> (xxx is a valid minly, new-origin is the new origin to assign to xxx) returns the updated minly information
|
67
|
+
```
|
68
|
+
```ruby
|
69
|
+
# To deactivate or activate a minly
|
70
|
+
$ minly.change_minly_status(_xxx_, _new-status_) #=> (xxx is a valid minly, new-status is the status (true or false) to assign to xxx) returns the updated minly information
|
71
|
+
```
|
72
|
+
```ruby
|
73
|
+
# To change minly target and status at once
|
74
|
+
$ minly.update_minly (_xxx_, _new-origin_, _new-status_) #=> (xxx is a valid minly, new-origin is the new origin to assign to xxx, new-status is the status (true or false) to assign to xxx)
|
75
|
+
```
|
76
|
+
```ruby
|
77
|
+
# To delete a minly
|
78
|
+
$ minly.destroy_minly(_xxx_) #=> (xxx is a valid minly) returns the information of the deleted minly
|
79
|
+
```
|
22
80
|
|
23
|
-
|
81
|
+
The response of every Minly request is parsed into two: _request status_ and _request response_
|
24
82
|
|
25
|
-
|
83
|
+
```ruby
|
84
|
+
$ minly.status #=> [request-type, request-info]
|
85
|
+
$ minly.status["type"] #=> success or error
|
86
|
+
$ minly.status["info"] #=> more information about the request
|
87
|
+
```
|
88
|
+
```ruby
|
89
|
+
$ minly.response #=> response of the api call
|
90
|
+
```
|
26
91
|
|
27
92
|
## Development
|
28
93
|
|
@@ -32,10 +97,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
97
|
|
33
98
|
## Contributing
|
34
99
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
100
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/andela-ooranagwa/minly. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
36
101
|
|
37
102
|
|
38
103
|
## License
|
39
104
|
|
40
105
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
data/circle.yml
ADDED
data/lib/minly/url.rb
CHANGED
@@ -7,72 +7,78 @@ API_SHOW_ACTION = API_URL + "api/v1/requests/show/"
|
|
7
7
|
module Minly
|
8
8
|
class Url
|
9
9
|
attr_accessor :token
|
10
|
-
attr_reader :status, :response
|
10
|
+
attr_reader :status, :response, :connection
|
11
11
|
|
12
12
|
def initialize(token = nil)
|
13
13
|
@connection = Faraday.new(:url => API_URL)
|
14
14
|
@token = token
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def expand_minly(url)
|
18
18
|
make_get_request(API_SHOW_ACTION + "expand/" + url)
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
21
|
+
def popular_minlys
|
22
22
|
make_get_request(API_SHOW_ACTION + "popular/")
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def recent_minlys
|
26
26
|
make_get_request(API_SHOW_ACTION + "recent/")
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
return false if
|
29
|
+
def create_minly(url, vanity_string = '')
|
30
|
+
return false if (vanity_string.nil? || (!vanity_string.empty? && has_no_token_error) )
|
31
31
|
@token ||= 0
|
32
32
|
params = {
|
33
33
|
"url[shortened]" => vanity_string,
|
34
34
|
"url[original]" => url,
|
35
35
|
"user_token" => token
|
36
36
|
}
|
37
|
-
|
37
|
+
process_response connection.post("/urls.json", params)
|
38
38
|
# user_token=vBIPTJtcHX7cORPGjFXOLvIzKU9hmHX05FST_t-sY6s
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
41
|
+
def change_minly_target(url, target)
|
42
42
|
return false if has_no_token_error
|
43
43
|
params = {
|
44
44
|
"url[original]" => target,
|
45
45
|
user_token: token
|
46
46
|
}
|
47
|
-
|
47
|
+
process_response connection.put("/urls/#{url}.json", params)
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
50
|
+
def change_minly_status(url, data)
|
51
51
|
return false if has_no_token_error
|
52
52
|
params = {
|
53
53
|
"url[active]" => data,
|
54
54
|
user_token: token
|
55
55
|
}
|
56
|
-
|
56
|
+
process_response connection.put("/urls/#{url}.json", params)
|
57
57
|
end
|
58
58
|
|
59
|
-
def
|
59
|
+
def destroy_minly(url)
|
60
60
|
return false if has_no_token_error
|
61
61
|
params = {
|
62
62
|
user_token: token
|
63
63
|
}
|
64
|
-
|
64
|
+
process_response connection.delete("/urls/#{url}.json", params)
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
68
|
-
return false if has_no_token_error
|
67
|
+
def update_minly(url, origin, active)
|
68
|
+
return false if (has_no_token_error || !origin || origin.empty? || active.nil?)
|
69
|
+
params = {
|
70
|
+
"url[active]" => active,
|
71
|
+
"url[orignal]" => origin,
|
72
|
+
user_token: token
|
73
|
+
}
|
74
|
+
process_response connection.put("/urls/#{url}.json", params)
|
69
75
|
end
|
70
76
|
|
71
77
|
def make_get_request(request)
|
72
|
-
|
78
|
+
process_response(connection.get(request))
|
73
79
|
end
|
74
80
|
|
75
|
-
def
|
81
|
+
def process_response(response)
|
76
82
|
response = JSON.parse(response.body)
|
77
83
|
@status = parse_status(response)
|
78
84
|
@response = response["payload"]
|
@@ -80,7 +86,7 @@ module Minly
|
|
80
86
|
|
81
87
|
def has_no_token_error
|
82
88
|
if !token || token == 0
|
83
|
-
@status = {type: "
|
89
|
+
@status = {type: "error", info: "Request requires a valid user token."}
|
84
90
|
return true
|
85
91
|
end
|
86
92
|
false
|
data/lib/minly/version.rb
CHANGED
data/minly.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Minly::VERSION
|
9
9
|
spec.authors = ["Osmond Oscar"]
|
10
10
|
spec.email = ["oskarromero3@gmail.com"]
|
11
|
-
|
11
|
+
spec.description = %q[Minly-gem provides access to all features of the Minly URL shortening service by integrating the Minly API. With the gem, you can effortlessly create and expand minlys; have access to the most popular minlys ever create and also the recent additions to the Minly database. Even features such as deleting, deactivating and editing minlys that are reserved for registered users of the Minly service can also be accessed using a valid token.]
|
12
12
|
spec.summary = %q{Gem to wrap minly url shortener api}
|
13
13
|
spec.homepage = "http://github.com/andela-ooranagwa/minly/"
|
14
14
|
spec.license = "MIT"
|
@@ -23,6 +23,9 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "minitest", "~> 5.8", ">= 5.8.0"
|
24
24
|
spec.add_development_dependency "vcr", "~> 2.9", ">= 2.9.3"
|
25
25
|
spec.add_development_dependency "webmock", "~> 1.22", ">= 1.22.1"
|
26
|
+
spec.add_development_dependency "simplecov", "~> 0.10.0"
|
27
|
+
spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4.8"
|
28
|
+
spec.add_development_dependency "pry", "~>0.10.3"
|
26
29
|
|
27
30
|
spec.add_dependency "faraday", "~> 0.9", ">= 0.9.2"
|
28
31
|
spec.add_dependency "json", "~> 1.8", ">= 1.8.3"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Osmond Oscar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,6 +98,48 @@ dependencies:
|
|
98
98
|
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: 1.22.1
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: simplecov
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - "~>"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: 0.10.0
|
108
|
+
type: :development
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - "~>"
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 0.10.0
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: codeclimate-test-reporter
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 0.4.8
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - "~>"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 0.4.8
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
name: pry
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - "~>"
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 0.10.3
|
136
|
+
type: :development
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - "~>"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 0.10.3
|
101
143
|
- !ruby/object:Gem::Dependency
|
102
144
|
name: faraday
|
103
145
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,7 +180,12 @@ dependencies:
|
|
138
180
|
- - ">="
|
139
181
|
- !ruby/object:Gem::Version
|
140
182
|
version: 1.8.3
|
141
|
-
description:
|
183
|
+
description: Minly-gem provides access to all features of the Minly URL shortening
|
184
|
+
service by integrating the Minly API. With the gem, you can effortlessly create
|
185
|
+
and expand minlys; have access to the most popular minlys ever create and also the
|
186
|
+
recent additions to the Minly database. Even features such as deleting, deactivating
|
187
|
+
and editing minlys that are reserved for registered users of the Minly service can
|
188
|
+
also be accessed using a valid token.
|
142
189
|
email:
|
143
190
|
- oskarromero3@gmail.com
|
144
191
|
executables: []
|
@@ -154,10 +201,10 @@ files:
|
|
154
201
|
- Rakefile
|
155
202
|
- bin/console
|
156
203
|
- bin/setup
|
204
|
+
- circle.yml
|
157
205
|
- lib/minly.rb
|
158
206
|
- lib/minly/url.rb
|
159
207
|
- lib/minly/version.rb
|
160
|
-
- minly-0.1.0.gem
|
161
208
|
- minly.gemspec
|
162
209
|
homepage: http://github.com/andela-ooranagwa/minly/
|
163
210
|
licenses:
|
data/minly-0.1.0.gem
DELETED
Binary file
|