rflak 0.3 → 0.4
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/README +9 -0
- data/lib/comment.rb +1 -0
- data/lib/dummy_entry.rb +14 -0
- data/lib/entry.rb +3 -1
- data/lib/flaker.rb +2 -1
- data/lib/rflak.rb +1 -1
- data/lib/traker.rb +1 -0
- data/lib/user.rb +17 -8
- data/test/entry_test.rb +7 -1
- data/test/user_test.rb +30 -0
- metadata +21 -9
data/README
CHANGED
@@ -3,6 +3,15 @@
|
|
3
3
|
rflak is simple gem to use flaker.pl API. flaker.pl is polish microblogging website. For more information
|
4
4
|
please visit http://flaker.pl.
|
5
5
|
|
6
|
+
From version 0.4 rflak is compatible with Ruby 1.9
|
7
|
+
|
8
|
+
== Instalation
|
9
|
+
|
10
|
+
To install rflak gem just simply execute command written below:
|
11
|
+
gem install rflak
|
12
|
+
|
13
|
+
== Docs & Examples
|
14
|
+
|
6
15
|
You can simply user two classes Flaker and Traker. Flaker class can fetch all entries scoped with
|
7
16
|
conditions described in flaker's API. You can check API http://blog.flaker.pl/api described in polish.
|
8
17
|
|
data/lib/comment.rb
CHANGED
data/lib/dummy_entry.rb
ADDED
data/lib/entry.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
require 'net/http'
|
2
3
|
require 'json'
|
3
4
|
module Rflak
|
@@ -5,7 +6,8 @@ module Rflak
|
|
5
6
|
# and can have many comments assigned to it.
|
6
7
|
class Entry < DummyEntry
|
7
8
|
ATTR_LIST = [:user, :permalink, :timestamp, :comments, :time, :text, :title, :has_video, :id,
|
8
|
-
:has_photo, :link, :has_link, :datetime, :source, :data, :subsource, :comments
|
9
|
+
:has_photo, :link, :has_link, :datetime, :source, :data, :subsource, :comments, :parent_id,
|
10
|
+
:is_private, :tags, :is_favorited, :is_bookmark
|
9
11
|
]
|
10
12
|
|
11
13
|
# define attribute methods public getters and private setters
|
data/lib/flaker.rb
CHANGED
data/lib/rflak.rb
CHANGED
data/lib/traker.rb
CHANGED
data/lib/user.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
module Rflak
|
2
3
|
# Class represents single user of flaker.pl.
|
3
4
|
class User
|
@@ -74,25 +75,33 @@ module Rflak
|
|
74
75
|
end
|
75
76
|
|
76
77
|
|
77
|
-
# Return login list of users that follow user
|
78
|
+
# Return login list of users that follow user. Pass <tt>true</tt> as parameter if you want to get extended
|
79
|
+
# data (avatar, fiest name, url, sex, ...)
|
78
80
|
#
|
81
|
+
# extended:: Boolean, default false
|
79
82
|
# returns:: Array
|
80
|
-
def followers
|
83
|
+
def followers(extended = false)
|
84
|
+
request_path = "/type:list/source:followedby/login:#{ @login }"
|
85
|
+
request_path << "/extended:true" if extended
|
81
86
|
resp = Flaker.auth_connection(self) do |connection|
|
82
|
-
connection.get(
|
87
|
+
connection.get(request_path)
|
83
88
|
end
|
84
|
-
|
89
|
+
resp['followedby']
|
85
90
|
end
|
86
91
|
|
87
92
|
|
88
|
-
# Returns login list of users following by user
|
93
|
+
# Returns login list of users following by user. Pass <tt>true</tt> as parameter if you want to get extended
|
94
|
+
# data (avatar, fiest name, url, sex, ...)
|
89
95
|
#
|
96
|
+
# extended:: Boolean, default false
|
90
97
|
# returns:: Array
|
91
|
-
def following
|
98
|
+
def following(extended = false)
|
99
|
+
request_path = "/type:list/source:following/login:#{ @login }"
|
100
|
+
request_path << "/extended:true" if extended
|
92
101
|
resp = Flaker.auth_connection(self) do |connection|
|
93
|
-
connection.get(
|
102
|
+
connection.get(request_path)
|
94
103
|
end
|
95
|
-
|
104
|
+
resp['following']
|
96
105
|
end
|
97
106
|
end
|
98
107
|
end
|
data/test/entry_test.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
2
3
|
|
3
4
|
require 'test/unit'
|
@@ -15,6 +16,11 @@ class EntryTest < Test::Unit::TestCase
|
|
15
16
|
"time"=>"Thu, 18 Jun 2009 11:35:09 +0200",
|
16
17
|
"text"=>"Jakiś fajny tekst wrzucony na flakerka. Przepraszam oryginalnego autora - prawnik10 za zmianę ;)",
|
17
18
|
"source"=>"flaker",
|
19
|
+
"parent_id" => "1",
|
20
|
+
"is_private" => "0",
|
21
|
+
"tags" => ["#some_tag"],
|
22
|
+
"is_favorited" => "0",
|
23
|
+
"is_bookmark" => "0",
|
18
24
|
"data"=>[],
|
19
25
|
"comments" => [
|
20
26
|
{ "text" => "pi\u0119knie.... niez\u0142a kasa, bardzo niez\u0142a.",
|
@@ -80,7 +86,7 @@ class EntryTest < Test::Unit::TestCase
|
|
80
86
|
end
|
81
87
|
|
82
88
|
|
83
|
-
def
|
89
|
+
def test_bookmark_not_authorized_user
|
84
90
|
flexmock(Rflak::Flaker).should_receive(:get).with('/type:auth').and_return(auth_bad_credentials)
|
85
91
|
user = Rflak::User.new(:login => 'login', :api_key => 'bad_key')
|
86
92
|
|
data/test/user_test.rb
CHANGED
@@ -102,6 +102,21 @@ class UserTest < Test::Unit::TestCase
|
|
102
102
|
end
|
103
103
|
|
104
104
|
|
105
|
+
def test_get_followers_extended
|
106
|
+
followers_list_response = { 'followedby' => %w(seban) }
|
107
|
+
flexmock(Rflak::Flaker).should_receive(:get).with('/type:auth').once.and_return(auth_good_credentials)
|
108
|
+
flexmock(Rflak::Flaker).should_receive(:get).with("/type:list/source:followedby/login:login/extended:true").once.and_return(followers_list_response).times(1)
|
109
|
+
|
110
|
+
user = Rflak::User.new(:login => 'login', :api_key => 'good_key')
|
111
|
+
assert user.auth
|
112
|
+
followers = user.followers(true)
|
113
|
+
|
114
|
+
assert_kind_of(Array, followers)
|
115
|
+
assert_equal 1, followers.size
|
116
|
+
followers.each { |f| assert_kind_of(String, f) }
|
117
|
+
end
|
118
|
+
|
119
|
+
|
105
120
|
def test_get_following_not_authorized
|
106
121
|
flexmock(Rflak::Flaker).should_receive(:get).with('/type:auth').and_return(auth_bad_credentials)
|
107
122
|
user = Rflak::User.new(:login => 'login', :api_key => 'bad_key')
|
@@ -126,6 +141,21 @@ class UserTest < Test::Unit::TestCase
|
|
126
141
|
end
|
127
142
|
|
128
143
|
|
144
|
+
def test_get_following_extended
|
145
|
+
following_list_response = { 'following' => %w(seban) }
|
146
|
+
flexmock(Rflak::Flaker).should_receive(:get).with('/type:auth').once.and_return(auth_good_credentials)
|
147
|
+
flexmock(Rflak::Flaker).should_receive(:get).with("/type:list/source:following/login:login/extended:true").once.and_return(following_list_response).times(1)
|
148
|
+
|
149
|
+
user = Rflak::User.new(:login => 'login', :api_key => 'good_key')
|
150
|
+
assert user.auth
|
151
|
+
following = user.following(true)
|
152
|
+
|
153
|
+
assert_kind_of(Array, following)
|
154
|
+
assert_equal 1, following.size
|
155
|
+
following.each { |f| assert_kind_of(String, f) }
|
156
|
+
end
|
157
|
+
|
158
|
+
|
129
159
|
protected
|
130
160
|
|
131
161
|
|
metadata
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rflak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 4
|
8
|
+
version: "0.4"
|
5
9
|
platform: ruby
|
6
10
|
authors:
|
7
11
|
- Sebastian Nowak
|
@@ -9,19 +13,22 @@ autorequire:
|
|
9
13
|
bindir: bin
|
10
14
|
cert_chain: []
|
11
15
|
|
12
|
-
date: 2010-
|
16
|
+
date: 2010-08-05 00:00:00 +02:00
|
13
17
|
default_executable:
|
14
18
|
dependencies:
|
15
19
|
- !ruby/object:Gem::Dependency
|
16
20
|
name: httparty
|
17
|
-
|
18
|
-
|
19
|
-
|
21
|
+
prerelease: false
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
23
29
|
version: "0"
|
24
|
-
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
25
32
|
description: |
|
26
33
|
Simple Ruby wrapper for Flaker service. Flaker is service collecting your network activities.
|
27
34
|
For more details go to http://flaker.pl
|
@@ -46,6 +53,7 @@ files:
|
|
46
53
|
- test/user_test.rb
|
47
54
|
- test/traker_test.rb
|
48
55
|
- test/flaker_test.rb
|
56
|
+
- lib/dummy_entry.rb
|
49
57
|
- README
|
50
58
|
has_rdoc: true
|
51
59
|
homepage: http://github.com/seban/rflak/tree/master
|
@@ -57,21 +65,25 @@ rdoc_options: []
|
|
57
65
|
require_paths:
|
58
66
|
- lib
|
59
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
60
69
|
requirements:
|
61
70
|
- - ">="
|
62
71
|
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 0
|
63
74
|
version: "0"
|
64
|
-
version:
|
65
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
66
77
|
requirements:
|
67
78
|
- - ">="
|
68
79
|
- !ruby/object:Gem::Version
|
80
|
+
segments:
|
81
|
+
- 0
|
69
82
|
version: "0"
|
70
|
-
version:
|
71
83
|
requirements: []
|
72
84
|
|
73
85
|
rubyforge_project:
|
74
|
-
rubygems_version: 1.3.
|
86
|
+
rubygems_version: 1.3.7
|
75
87
|
signing_key:
|
76
88
|
specification_version: 3
|
77
89
|
summary: Simple wraper for http://flaker.pl API
|