delicious-console 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +7 -0
- data/README.MD +0 -0
- data/README.md +0 -0
- data/Rakefile +18 -0
- data/VERSION +1 -0
- data/bin/delicious +7 -0
- data/lib/delicious-console.rb +10 -0
- data/lib/delicious-console/authentication.rb +28 -0
- data/lib/delicious-console/client.rb +28 -0
- data/lib/delicious-console/console.rb +26 -0
- data/lib/delicious-console/parser.rb +15 -0
- data/spec/delicious-console_spec.rb +9 -0
- data/spec/spec_helper.rb +12 -0
- metadata +109 -0
data/Gemfile
ADDED
data/README.MD
ADDED
File without changes
|
data/README.md
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'jeweler'
|
5
|
+
Jeweler::Tasks.new do |gem|
|
6
|
+
gem.name = "delicious-console"
|
7
|
+
gem.summary = "%Q{A console application to Delicious Web Site}"
|
8
|
+
gem.description = "%Q{Store yours URL's on Delicious using your terminal console}"
|
9
|
+
gem.email = "mateus@mateusprado.com"
|
10
|
+
gem.homepage = "http://github.com/mateusprado/delicious-console"
|
11
|
+
gem.authors = ["Mateus Prado"]
|
12
|
+
gem.add_dependency %q<thor>, ">= 0.16.0"
|
13
|
+
gem.add_development_dependency "rspec", ">= 2.11.0"
|
14
|
+
end
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
rescue
|
17
|
+
puts "Jeweler not available. Run: gem install jeweler"
|
18
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/delicious
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'net/https'
|
3
|
+
require 'thor'
|
4
|
+
require 'rexml/document'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
require 'delicious-console/authentication'
|
8
|
+
require 'delicious-console/parser'
|
9
|
+
require 'delicious-console/client'
|
10
|
+
require 'delicious-console/console'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Delicious
|
2
|
+
module API
|
3
|
+
module Authentication
|
4
|
+
class << self
|
5
|
+
def authenticate(request, connection)
|
6
|
+
if !request.nil?
|
7
|
+
make_setup!
|
8
|
+
request.basic_auth @username, @password
|
9
|
+
response = connection.request(request)
|
10
|
+
else
|
11
|
+
puts "Invalid request"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def make_setup!
|
16
|
+
config = YAML.load_file(filename)
|
17
|
+
@username = config['username']
|
18
|
+
@password = config['password']
|
19
|
+
end
|
20
|
+
|
21
|
+
def filename
|
22
|
+
File.expand_path("~/.delicious_config")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Delicious
|
2
|
+
module API
|
3
|
+
module Client
|
4
|
+
class << self
|
5
|
+
def posts_all
|
6
|
+
request = nil
|
7
|
+
connection = Net::HTTP.new('api.del.icio.us', 443)
|
8
|
+
connection.use_ssl = true
|
9
|
+
connection.start do |connection|
|
10
|
+
request = Net::HTTP::Get.new('/v1/posts/all')
|
11
|
+
end
|
12
|
+
return request, connection
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def post_add(url, description)
|
17
|
+
request = nil
|
18
|
+
connection = Net::HTTP.new('api.del.icio.us', 443)
|
19
|
+
connection.use_ssl = true
|
20
|
+
connection.start do |connection|
|
21
|
+
request = Net::HTTP::Get.new("/v1/posts/add?url=#{url}&description=#{description}")
|
22
|
+
end
|
23
|
+
return request, connection
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Delicious
|
2
|
+
class Console < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
include API::Authentication
|
5
|
+
include API::Parser
|
6
|
+
include API::Client
|
7
|
+
|
8
|
+
# task: posts
|
9
|
+
desc "posts", "Fetch all bookmarks"
|
10
|
+
|
11
|
+
def posts
|
12
|
+
request, connection = Delicious::API::Client.posts_all
|
13
|
+
response = Delicious::API::Authentication.authenticate(request, connection)
|
14
|
+
puts Delicious::API::Parser.response(response.body)
|
15
|
+
end
|
16
|
+
|
17
|
+
#task: add
|
18
|
+
desc "add [url, description]", "Add a url with description"
|
19
|
+
|
20
|
+
def add(url, description)
|
21
|
+
request, connection = Delicious::API::Client.post_add(url, description)
|
22
|
+
response = Delicious::API::Authentication.authenticate(request, connection)
|
23
|
+
puts response
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Delicious
|
2
|
+
module API
|
3
|
+
module Parser
|
4
|
+
class << self
|
5
|
+
def response(body)
|
6
|
+
dom = REXML::Document.new(body)
|
7
|
+
posts = {}
|
8
|
+
dom.root.elements.collect('post') do |result|
|
9
|
+
all_posts = result.attributes['href']
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) do |file|
|
3
|
+
require file
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'rspec'
|
7
|
+
require 'rspec/autorun'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.color_enabled = true
|
11
|
+
config.formatter = 'documentation'
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: delicious-console
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mateus Prado
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.16.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.16.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.11.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.11.0
|
62
|
+
description: ! '%Q{Store yours URL''s on Delicious using your terminal console}'
|
63
|
+
email: mateus@mateusprado.com
|
64
|
+
executables:
|
65
|
+
- delicious
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files:
|
68
|
+
- README.md
|
69
|
+
files:
|
70
|
+
- Gemfile
|
71
|
+
- Rakefile
|
72
|
+
- README.MD
|
73
|
+
- VERSION
|
74
|
+
- bin/delicious
|
75
|
+
- lib/delicious-console.rb
|
76
|
+
- lib/delicious-console/authentication.rb
|
77
|
+
- lib/delicious-console/client.rb
|
78
|
+
- lib/delicious-console/console.rb
|
79
|
+
- lib/delicious-console/parser.rb
|
80
|
+
- spec/delicious-console_spec.rb
|
81
|
+
- spec/spec_helper.rb
|
82
|
+
- README.md
|
83
|
+
homepage: http://github.com/mateusprado/delicious-console
|
84
|
+
licenses: []
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 1.8.24
|
104
|
+
signing_key:
|
105
|
+
specification_version: 3
|
106
|
+
summary: ! '%Q{A console application to Delicious Web Site}'
|
107
|
+
test_files:
|
108
|
+
- spec/delicious-console_spec.rb
|
109
|
+
- spec/spec_helper.rb
|