rsvejo 0.1.0
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/LICENSE +21 -0
- data/README.markdown +56 -0
- data/lib/rsvejo.rb +60 -0
- data/rsvejo.gemspec +13 -0
- data/test/test_rsvejo.rb +42 -0
- metadata +59 -0
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2009 Mitko Kostov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
RSvejo - Svejo.net API ruby wrapper
|
2
|
+
===================================
|
3
|
+
|
4
|
+
Информация
|
5
|
+
----------
|
6
|
+
RSvejo е библиотека за комуникация със http://svejo.net/.
|
7
|
+
Повече информация можете да намерите тук: http://groups.google.com/group/svejo/web/api
|
8
|
+
|
9
|
+
Инсталация
|
10
|
+
----------
|
11
|
+
>> sudo gem install rsvejo
|
12
|
+
#### Изисквания : http://github.com/jnunemaker/httparty/
|
13
|
+
|
14
|
+
|
15
|
+
Описание на методите
|
16
|
+
--------------------
|
17
|
+
|
18
|
+
|
19
|
+
### Общи заявки:
|
20
|
+
|
21
|
+
>> RSvejo.fresh_stories
|
22
|
+
# Връща последните публикации от секциятa - Свежи
|
23
|
+
|
24
|
+
>> RSvejo.green_stories
|
25
|
+
# Връща последните публикации от секциятa - Нови
|
26
|
+
|
27
|
+
### Потребителски заявки
|
28
|
+
|
29
|
+
>> RSvejo.voted_by "username"
|
30
|
+
# Последните статии, за които е гласувал въпросният потребител
|
31
|
+
|
32
|
+
>> RSvejo.published_by "username"
|
33
|
+
# Последните статии, които е гласувал потребителят
|
34
|
+
|
35
|
+
>> RSvejo.commented_by "username"
|
36
|
+
# Последните статии, които е публикувал потребителят
|
37
|
+
|
38
|
+
### Етикети/Тагове
|
39
|
+
|
40
|
+
>> RSvejo.get_by_tag "tag_name"
|
41
|
+
# Най-новите публикации, които имат търсения етикет
|
42
|
+
|
43
|
+
### Сайтове
|
44
|
+
|
45
|
+
>> RSvejo.get_by_site "domain_name"
|
46
|
+
# Най-новите публикации, които имат търсения етикет
|
47
|
+
|
48
|
+
### Коментари
|
49
|
+
|
50
|
+
>> RSvejo.comments_for "publication_url"
|
51
|
+
# Коментарите в svejo.net относно определена публикация.
|
52
|
+
# Заедно с тях се връщат потребителите и линкове към техните аватари
|
53
|
+
|
54
|
+
## Относно
|
55
|
+
|
56
|
+
* Автор : Митко Костов <> http://mitkokostov.info
|
data/lib/rsvejo.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Library : RSvejo (Svejo.net API in Ruby)
|
4
|
+
# Author : Mitko Kostov
|
5
|
+
# Site : http://mitkokostov.info
|
6
|
+
# Mail : mitko.kostov@gmail.com
|
7
|
+
# LICENCE : MIT
|
8
|
+
# svejo.net API : http://groups.google.com/group/svejo/web/api
|
9
|
+
|
10
|
+
require 'rubygems'
|
11
|
+
require 'httparty'
|
12
|
+
|
13
|
+
$KCODE ='u'
|
14
|
+
|
15
|
+
module RSvejo
|
16
|
+
|
17
|
+
extend self
|
18
|
+
|
19
|
+
API_URL = 'http://svejo.net/public_api/'
|
20
|
+
FORMAT = 'xml'
|
21
|
+
|
22
|
+
def fresh_stories
|
23
|
+
get_data("stories/fresh")
|
24
|
+
end
|
25
|
+
|
26
|
+
def green_stories
|
27
|
+
get_data("stories/green")
|
28
|
+
end
|
29
|
+
|
30
|
+
def voted_by(name)
|
31
|
+
get_data("user/#{name}/voted")
|
32
|
+
end
|
33
|
+
|
34
|
+
def published_by(name)
|
35
|
+
get_data("user/#{name}/published")
|
36
|
+
end
|
37
|
+
|
38
|
+
def commented_by(name)
|
39
|
+
get_data("user/#{name}/commented")
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_by_tag(tag)
|
43
|
+
get_data("tag/#{tag}/new")
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_by_site(site)
|
47
|
+
get_data("site/#{site}/new")
|
48
|
+
end
|
49
|
+
|
50
|
+
def comments_for(url)
|
51
|
+
get_data("comments/show/#{FORMAT}?url=#{url}")
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def get_data(arg)
|
57
|
+
HTTParty.get URI.escape("#{API_URL}#{arg}.#{FORMAT}")
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
data/rsvejo.gemspec
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{rsvejo}
|
3
|
+
s.version = "0.1.0"
|
4
|
+
s.authors = ["Mitko Kostov"]
|
5
|
+
s.date = %q{2010-01-02}
|
6
|
+
s.description = %q{Svejo.net API Ruby wrapper}
|
7
|
+
s.email = %q{mitko.kostov@gmail.com}
|
8
|
+
s.files = ["lib/rsvejo.rb", "test/test_rsvejo.rb","rsvejo.gemspec", "README.markdown", "LICENSE"]
|
9
|
+
s.has_rdoc = false
|
10
|
+
s.homepage = %q{http://github.com/mitkok/rsvejo}
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
s.summary = %q{Simple Ruby lib for Svejo.net}
|
13
|
+
end
|
data/test/test_rsvejo.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rsvejo'
|
5
|
+
|
6
|
+
class TestRSvejo < Test::Unit::TestCase
|
7
|
+
|
8
|
+
|
9
|
+
def test_stories
|
10
|
+
fresh_stories = RSvejo.fresh_stories
|
11
|
+
green_stories = RSvejo.green_stories
|
12
|
+
assert_not_nil fresh_stories
|
13
|
+
assert_not_nil green_stories
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_user_calls
|
17
|
+
name = 'stanislav'
|
18
|
+
voted = RSvejo.voted_by name
|
19
|
+
published = RSvejo.published_by name
|
20
|
+
commented = RSvejo.commented_by name
|
21
|
+
|
22
|
+
assert_not_nil voted
|
23
|
+
assert_not_nil published
|
24
|
+
assert_not_nil commented
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_tag_method
|
28
|
+
tag = RSvejo.get_by_tag("София")
|
29
|
+
assert !tag.include?('nil_classes')
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_site_method
|
33
|
+
site = RSvejo.get_by_site('blog.svejo.net')
|
34
|
+
assert_nil site["hash"]
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_comments_for_method
|
38
|
+
comments = RSvejo.comments_for('http://advance.bg/?pn=pamporovo')
|
39
|
+
assert_not_nil comments
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rsvejo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mitko Kostov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-02 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Svejo.net API Ruby wrapper
|
17
|
+
email: mitko.kostov@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/rsvejo.rb
|
26
|
+
- test/test_rsvejo.rb
|
27
|
+
- rsvejo.gemspec
|
28
|
+
- README.markdown
|
29
|
+
- LICENSE
|
30
|
+
has_rdoc: false
|
31
|
+
homepage: http://github.com/mitkok/rsvejo
|
32
|
+
licenses: []
|
33
|
+
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
requirements: []
|
52
|
+
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.3.5
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: Simple Ruby lib for Svejo.net
|
58
|
+
test_files: []
|
59
|
+
|