noopi 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: noopi
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.3
5
+ version: 1.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Julien DUMAS
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-12 00:00:00 +02:00
13
+ date: 2011-05-26 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -33,13 +33,8 @@ extensions: []
33
33
 
34
34
  extra_rdoc_files: []
35
35
 
36
- files:
37
- - .gitignore
38
- - Gemfile
39
- - Rakefile
40
- - lib/noopi.rb
41
- - lib/noopi/version.rb
42
- - noopi.gemspec
36
+ files: []
37
+
43
38
  has_rdoc: true
44
39
  homepage: ""
45
40
  licenses: []
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in noopi.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
@@ -1,80 +0,0 @@
1
- require 'net/http'
2
- require 'json'
3
- require 'cgi'
4
-
5
- class Noopi
6
-
7
- @@api_server = 'api.noop.fr'
8
- @@api_version = 1
9
- @@api_key = nil
10
-
11
- attr_accessor :api_key
12
-
13
- def initialize( api_key = nil )
14
- @api_key = api_key || @@api_key
15
- end
16
-
17
- def shorten( *args )
18
- long_url = CGI.escape( args.shift )
19
- options = ( !args.last.nil? and args.last.is_a?( Hash ) ) ? args.pop : {}
20
-
21
- params = {}
22
- params[:apiKey] = @api_key
23
- params[:long_url] = long_url
24
-
25
- request = Net::HTTP::Get.new( "/v#{@@api_version}/shorten?#{hash_to_params( params )}" )
26
-
27
- return send_request( request )
28
- end
29
-
30
- def list( *args )
31
- params = {}
32
- params[:apiKey] = @api_key
33
-
34
- request = Net::HTTP::Get.new( "/v#{@@api_version}/list?#{hash_to_params( params )}" )
35
-
36
- return send_request( request )
37
- end
38
-
39
- def self.api_key=( value )
40
- @@api_key = value
41
- end
42
-
43
- def self.api_key
44
- @@api_key
45
- end
46
-
47
- def self.api_version=( value )
48
- @@api_version = value
49
- end
50
-
51
- def self.api_version
52
- @@api_version
53
- end
54
-
55
- def self.api_server=( value )
56
- @@api_version = value
57
- end
58
-
59
- def self.api_server
60
- @@api_version
61
- end
62
-
63
- private
64
- def send_request( request )
65
- http = Net::HTTP.new( @@api_server )
66
- result = http.request( request )
67
-
68
- return JSON.parse( result.body )
69
- end
70
-
71
- def hash_to_params( hash )
72
- params = []
73
- hash.each do |k, v|
74
- params << "#{k}=#{CGI.escape( v )}"
75
- end
76
-
77
- return params.join("&")
78
- end
79
-
80
- end
@@ -1,3 +0,0 @@
1
- class Noopi
2
- VERSION = "1.0.3"
3
- end
@@ -1,22 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "noopi/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "noopi"
7
- s.version = Noopi::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Julien DUMAS"]
10
- s.email = ["julien7.dumas@gmail.com"]
11
- s.homepage = ""
12
- s.summary = %q{n/a}
13
- s.description = %q{n/a}
14
- s.add_dependency( 'json', '>= 1.5.1' )
15
-
16
- s.rubyforge_project = "noopi"
17
-
18
- s.files = `git ls-files`.split("\n")
19
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
- s.require_paths = ["lib"]
22
- end