mgnetme 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +3 -0
- data/LICENSE.md +20 -0
- data/README.md +22 -0
- data/lib/mgnetme.rb +1 -0
- data/lib/mgnetme/short.rb +20 -0
- data/mgnetme.gemspec +17 -0
- metadata +83 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Emanuel Andersson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The Mgnet.me Ruby Gem
|
2
|
+
====================
|
3
|
+
A simple wrapper for the Mgnet.me magnet link shortening API
|
4
|
+
|
5
|
+
Installation
|
6
|
+
------------
|
7
|
+
gem install mgnetme
|
8
|
+
|
9
|
+
|
10
|
+
Usage Examples
|
11
|
+
--------------
|
12
|
+
require 'mgnetme'
|
13
|
+
|
14
|
+
# Give it a long magnet link and it will give you a short url back, if you say please of course
|
15
|
+
MgnetMe::Short.please "magnet:?xt=urn:btih:a38d02c287893842a32825aa866e00828a318f07&dn=Ubuntu+11.04+i386+iso" # http://mgnet.me/0rt
|
16
|
+
|
17
|
+
|
18
|
+
ZOMG ZOMG WHERE ARE THE SPECS?!
|
19
|
+
-------------------------------
|
20
|
+
Yeah, no. I didn't write them.
|
21
|
+
The gem is fairly basic.
|
22
|
+
Still want them? Send me a pull-request.
|
data/lib/mgnetme.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'mgnetme/short'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module MgnetMe
|
6
|
+
class Short
|
7
|
+
def self.please(magnet_long)
|
8
|
+
magnet_long = URI.escape(magnet_long)
|
9
|
+
doc = Nokogiri::XML(open('http://mgnet.me/api/create/?m=' + magnet_long + '&format=xml'))
|
10
|
+
|
11
|
+
state = doc.xpath('//state').text
|
12
|
+
shorturl = doc.xpath('//shorturl').text
|
13
|
+
message = doc.xpath('//message').text
|
14
|
+
|
15
|
+
raise message if state == "failure"
|
16
|
+
|
17
|
+
shorturl
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/mgnetme.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
spec = Gem::Specification.new do |s|
|
2
|
+
s.name = %q{mgnetme}
|
3
|
+
s.version = '0.1'
|
4
|
+
s.summary = %q{A simple wrapper for the Mgnet.me magnet-link shortening API}
|
5
|
+
s.description = %q{A simple wrapper for the Mgnet.me magnet-link shortening API}
|
6
|
+
s.files = `git ls-files`.split("\n")
|
7
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
8
|
+
s.require_paths = ["lib"]
|
9
|
+
s.extra_rdoc_files = Dir['[A-Z]*']
|
10
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
11
|
+
s.authors = ["Emanuel Andersson"]
|
12
|
+
s.date = %q{2011-05-23}
|
13
|
+
s.email = %q{manusdude@gmail.com}
|
14
|
+
s.homepage = %q{http://github.com/emnl/mgnetme}
|
15
|
+
|
16
|
+
s.add_dependency "nokogiri"
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mgnetme
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
version: "0.1"
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- Emanuel Andersson
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
14
|
+
cert_chain: []
|
15
|
+
|
16
|
+
date: 2011-05-23 00:00:00 +02:00
|
17
|
+
default_executable:
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
20
|
+
name: nokogiri
|
21
|
+
prerelease: false
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
description: A simple wrapper for the Mgnet.me magnet-link shortening API
|
33
|
+
email: manusdude@gmail.com
|
34
|
+
executables: []
|
35
|
+
|
36
|
+
extensions: []
|
37
|
+
|
38
|
+
extra_rdoc_files:
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE.md
|
41
|
+
- README.md
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- LICENSE.md
|
46
|
+
- README.md
|
47
|
+
- lib/mgnetme.rb
|
48
|
+
- lib/mgnetme/short.rb
|
49
|
+
- mgnetme.gemspec
|
50
|
+
has_rdoc: true
|
51
|
+
homepage: http://github.com/emnl/mgnetme
|
52
|
+
licenses: []
|
53
|
+
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options:
|
56
|
+
- --charset=UTF-8
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.7
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: A simple wrapper for the Mgnet.me magnet-link shortening API
|
82
|
+
test_files: []
|
83
|
+
|