thimbl 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,71 @@
1
+ module Thimbl
2
+ class Command
3
+ CONFIG_FILE = File.expand_path( "~#{ENV['USER']}/.thimbl/thimbl.cnf" )
4
+
5
+ def self.setup( *args )
6
+ if( args.size != 4 )
7
+ raise ArgumentError, "use: $ thimbl setup <plan_path> <cache_path> <thimbl_user> <thimbl_password>"
8
+ end
9
+
10
+ FileUtils.mkdir_p File.dirname( config_file )
11
+
12
+ File.open( config_file, 'w' ) do |f|
13
+ f.write( { :plan_path => args[0], :cache_path => args[1], :user => args[2], :password => args[3] }.to_json )
14
+ end
15
+
16
+ thimbl = Thimbl::Command.load
17
+ thimbl.setup( 'address' => args[2] )
18
+ end
19
+
20
+ def self.print
21
+ thimbl = Thimbl::Command.load
22
+ thimbl.load_data
23
+ return thimbl.print
24
+ end
25
+
26
+ def self.fetch
27
+ thimbl = Thimbl::Command.load
28
+ thimbl.load_data
29
+ thimbl.fetch
30
+ end
31
+
32
+ def self.post( text )
33
+ if( text.nil? || text.empty? )
34
+ raise ArgumentError, "use: $ thimbl post <message>"
35
+ end
36
+ thimbl = Thimbl::Command.load
37
+ thimbl.load_data
38
+ thimbl.post text
39
+ end
40
+
41
+ def self.push
42
+ thimbl = Thimbl::Command.load
43
+ thimbl.load_data
44
+ thimbl.push
45
+ end
46
+
47
+ def self.follow( nick, address )
48
+ if( nick.nil? || nick.empty? || address.nil? || address.empty? )
49
+ raise ArgumentError, "use: $ thimbl follow <nick> <address>"
50
+ end
51
+ thimbl = Thimbl::Command.load
52
+ thimbl.load_data
53
+ thimbl.follow nick, address
54
+ end
55
+
56
+ def self.load
57
+ if( !File.exists? config_file )
58
+ raise ArgumentError, "Thimbl need to setup, use: $ thimbl setup <plan_path> <cache_path> <thimbl_user> <thimbl_password>"
59
+ end
60
+
61
+ config = JSON.load( File.read config_file )
62
+ thimbl = Thimbl::Base.new( config )
63
+
64
+ return thimbl
65
+ end
66
+
67
+ def self.config_file
68
+ CONFIG_FILE
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,9 @@
1
+ module Thimbl
2
+ class Finger
3
+ # Wrapper for `finger` system call
4
+ #
5
+ def self.run( *args )
6
+ %x[`whereis finger` #{args.join(' ')}]
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ [telekommunisten.org]
2
+ Login: dk Name: Dmytri Kleiner
3
+ Directory: /home/dk Shell: /bin/bash
4
+ Office: +xxx
5
+ On since Sun Feb 6 14:25 (EST) on pts/1 from dslb-178-000-216-054.pools.arcor-ip.net
6
+ 1 hour 25 minutes idle
7
+ Mail last read Sun Nov 1 15:07 2009 (EST)
8
+ Plan:
9
+ {"name": "Dmytri Kleiner", "address": "dk@telekommunisten.org", "messages": [{"text": "@bernd, would be cool to inegrate thimbl in http://bau-ha.us\\!", "time": "20101129060335", "address": "dk@telekommunisten.org"}, {"text": "back in berlin, call +31108208622 to here the noise created in Rotterdam", "time": "20101206065528", "address": "dk@telekommunisten.org"}, {"text": "What is thimbl's equivilent of #FF? In any case, follow the earliest Thimbl users: ossa@nummo.strangled.net and ed@ping01.stura.uni-weimar.de", "address": "dk@telekommunisten.org", "time": "20101206070601"}, {"text": "@mark, would it be better if the posts where sorted by data, and not user?", "time": "20101207034655", "address": "dk@telekommunisten.org"}, {"text": "@mark, not using the version I am, seems to sort by user then date, instead of just date, I tried to pull in the latest from your repo, but then the thimbl executable vanished.", "address": "dk@telekommunisten.org", "time": "20101207080308"}, {"text": "@mark, ok, using climbl now, posts are sorted in order. great. can't we keep the command as 'thimbl' though? it's nicer and more obvious (principal of least surprise)", "time": "20101207083809", "address": "dk@telekommunisten.org"}, {"text": "@mark, also a feature request, can we have a 'read' command that combines fetch+print? and unfollow would be nice (like when you make a typo in an address)", "time": "20101207084025", "address": "dk@telekommunisten.org"}, {"text": "@mark, or perhaps follow would first try to finger the account before adding it, to verify it's a real thimbl account?", "time": "20101207084116", "address": "dk@telekommunisten.org"}, {"text": "@mark, just one more thing! perhaps convert dates to GMT? Otherwise sorting is affected by timezones", "address": "dk@telekommunisten.org", "time": "20101207084249"}, {"text": "@mark, never mind about unfollow, I just read your blog ;)", "time": "20101207091343", "address": "dk@telekommunisten.org"}, {"text": "@mark, if we store the dats in GMT/UTC in the .plan, then timezones a\
10
+ re no longer an issue", "time": "20101207130325", "address": "dk@telekommunisten.org"}, {"text": "@mark, great updates, your lates has been merged into the Telekommunisten repos", "time": "20101208104508", "address": "dk@telekommunisten.org"}, {"text": "I'm working on a new option parser for node called Operetta, will release soon", "time": "20101214165553", "address": "dk@telekommunisten.org"}, {"text": "just launched the new thimbl website. http://www.thimbl.net", "time": "20110125065111", "address": "dk@telekommunisten.org"}, {"text": "@spaetz: first response ;)", "time": "20110201143140", "address": "dk@telekommunisten.org"}, {"text": "@ed: have you tried frozen soup?", "time": "20110201143220", "address": "dk@telekommunisten.org"}, {"text": "Hello from the thimbl workshop", "address": "dk@telekommunisten.org", "time": "20110202152339"}, {"text": "Tonight @cbase: monochrom & Telekommunisten run DISMALWARE an antivirus toolkit for your liberal Western brain http://bit.ly/dismalware", "address": "dk@telekommunisten.org", "time": "20110203121940"}, {"text": "If rocker hair and skinny jeans could make comebacks, why not Finger? http://ping.fm/3C95t", "time": "20110203162208", "address": "dk@telekommunisten.org"}, {"text": "http://kleiner.posterous.com/last-to-chance-to-vote-for-thimbl-we-need-you", "time": "20110204145719", "address": "dk@telekommunisten.org"}, {"text": "transmediale was fun, Thimbl got a distinction and moves onwards...", "address": "dk@telekommunisten.org", "time": "20110206192607"}], "replies": {}, "following": [{"nick": "anthony", "address": "as@telekommunisten.org"}, {"nick": "bernd", "address": "ed@ping01.stura.uni-weimar.de"}, {"nick": "meschugge", "address": "meschugge@ping01.stura.uni-weimar.de"}, {"nick": "mike", "address": "mike@mikepearce.net"}, {"nick": "ww", "address": "ww@river.styx.org"}, {"nick": "spaetz", "address": "spaetz@spaetz.dyndns.org"}, {"nick": "marcell", "address": "marcell@telekommunisten.org"}, {"nick": "dk", "address": "rw@telekommunisten.org"}, {"nick": "n", "addres\
11
+ s": "naikodemus@telekommunisten.org"}], "properties": {"website": "http://dmytri.info", "mobile": "", "email": "dk@telekommunisten.net"}}
@@ -0,0 +1,10 @@
1
+ [telekommunisten.org]
2
+ Login: dk Name: Dmytri Kleiner
3
+ Directory: /home/dk Shell: /bin/bash
4
+ Office: +491632866163
5
+ Last login Mon Feb 7 06:16 (EST) on pts/1 from dslb-178-000-216-054.pools.arcor-ip.net
6
+ Mail last read Sun Nov 1 15:07 2009 (EST)
7
+ Plan:
8
+ {"name": "Dmytri Kleiner", "address": "dk@telekommunisten.org", "messages": [{"text": "@bernd, would be cool to inegrate thimbl in http://bau-ha.us\\!", "time": "20101129060335", "address": "dk@telekommunisten.org"}, {"text": "back in berlin, call +31108208622 to here the noise created in Rotterdam", "time": "20101206065528", "address": "dk@telekommunisten.org"}, {"text": "What is thimbl's equivilent of #FF? In any case, follow the earliest Thimbl users: ossa@nummo.strangled.net and ed@ping01.stura.uni-weimar.de", "address": "dk@telekommunisten.org", "time": "20101206070601"}, {"text": "@mark, would it be better if the posts where sorted by data, and not user?", "time": "20101207034655", "address": "dk@telekommunisten.org"}, {"text": "@mark, not using the version I am, seems to sort by user then date, instead of just date, I tried to pull in the latest from your repo, but then the thimbl executable vanished.", "address": "dk@telekommunisten.org", "time": "20101207080308"}, {"text": "@mark, ok, using climbl now, posts are sorted in order. great. can't we keep the command as 'thimbl' though? it's nicer and more obvious (principal of least surprise)", "time": "20101207083809", "address": "dk@telekommunisten.org"}, {"text": "@mark, also a feature request, can we have a 'read' command that combines fetch+print? and unfollow would be nice (like when you make a typo in an address)", "time": "20101207084025", "address": "dk@telekommunisten.org"}, {"text": "@mark, or perhaps follow would first try to finger the account before adding it, to verify it's a real thimbl account?", "time": "20101207084116", "address": "dk@telekommunisten.org"}, {"text": "@mark, just one more thing! perhaps convert dates to GMT? Otherwise sorting is affected by timezones", "address": "dk@telekommunisten.org", "time": "20101207084249"}, {"text": "@mark, never mind about unfollow, I just read your blog ;)", "time": "20101207091343", "address": "dk@telekommunisten.org"}, {"text": "@mark, if we store the dats in GMT/UTC in the .plan, then timezones a\
9
+ re no longer an issue", "time": "20101207130325", "address": "dk@telekommunisten.org"}, {"text": "@mark, great updates, your lates has been merged into the Telekommunisten repos", "time": "20101208104508", "address": "dk@telekommunisten.org"}, {"text": "I'm working on a new option parser for node called Operetta, will release soon", "time": "20101214165553", "address": "dk@telekommunisten.org"}, {"text": "just launched the new thimbl website. http://www.thimbl.net", "time": "20110125065111", "address": "dk@telekommunisten.org"}, {"text": "@spaetz: first response ;)", "time": "20110201143140", "address": "dk@telekommunisten.org"}, {"text": "@ed: have you tried frozen soup?", "time": "20110201143220", "address": "dk@telekommunisten.org"}, {"text": "Hello from the thimbl workshop", "address": "dk@telekommunisten.org", "time": "20110202152339"}, {"text": "Tonight @cbase: monochrom & Telekommunisten run DISMALWARE an antivirus toolkit for your liberal Western brain http://bit.ly/dismalware", "address": "dk@telekommunisten.org", "time": "20110203121940"}, {"text": "If rocker hair and skinny jeans could make comebacks, why not Finger? http://ping.fm/3C95t", "time": "20110203162208", "address": "dk@telekommunisten.org"}, {"text": "http://kleiner.posterous.com/last-to-chance-to-vote-for-thimbl-we-need-you", "time": "20110204145719", "address": "dk@telekommunisten.org"}, {"text": "transmediale was fun, Thimbl got a distinction and moves onwards...", "address": "dk@telekommunisten.org", "time": "20110206192607"}, {"text": "@naikomdemus, it works. Welcome.", "address": "dk@telekommunisten.org", "time": "20110207113246"}], "replies": {}, "following": [{"nick": "anthony", "address": "as@telekommunisten.org"}, {"nick": "bernd", "address": "ed@ping01.stura.uni-weimar.de"}, {"nick": "meschugge", "address": "meschugge@ping01.stura.uni-weimar.de"}, {"nick": "mike", "address": "mike@mikepearce.net"}, {"nick": "ww", "address": "ww@river.styx.org"}, {"nick": "spaetz", "address": "spaetz@spaetz.dyndns.org"}, {"nick": "marcell", "address\
10
+ ": "marcell@telekommunisten.org"}, {"nick": "dk", "address": "rw@telekommunisten.org"}, {"nick": "n", "address": "naikodemus@telekommunisten.org"}, {"nick": "aharon", "address": "aharon@telekommunisten.org"}, {"nick": "ashull", "address": "ashull@telekommunisten.org"}, {"nick": "fguillen", "address": "fguillen@telekommunisten.org"}, {"nick": "rw", "address": "rw@telekommunisten.org"}, {"nick": "rw", "address": "hatfinch@telekommunisten.org"}, {"nick": "mike", "address": "mikepearce@telekommunisten.org"}, {"nick": "t", "address": "t@telekommunisten.org"}], "properties": {"website": "http://dmytri.info", "mobile": "", "email": "dk@telekommunisten.net"}}
@@ -0,0 +1,5 @@
1
+ require "#{File.dirname(__FILE__)}/../lib/thimbl"
2
+ require 'test/unit'
3
+ require 'mocha'
4
+ require 'ruby-debug'
5
+ require 'delorean'
@@ -0,0 +1,220 @@
1
+ require "#{File.dirname(__FILE__)}/test_helper"
2
+
3
+ class ThimblBaseTest < Test::Unit::TestCase
4
+ def setup
5
+ @data = {
6
+ 'me' => 'my address',
7
+ 'plans' => {
8
+ 'my address' => {
9
+ 'name' => 'my name',
10
+ 'bio' => 'my bio',
11
+ 'properties' => {
12
+ 'email' => 'my email',
13
+ 'mobile' => 'my mobile',
14
+ 'website' => 'my website'
15
+ },
16
+ 'following' => [],
17
+ 'messages' => [],
18
+ 'replies' => {}
19
+ }
20
+ }
21
+ }
22
+ end
23
+
24
+ def teardown
25
+ end
26
+
27
+ def test_new
28
+ thimbl =
29
+ Thimbl::Base.new(
30
+ 'plan_path' => 'plan_path',
31
+ 'cache_path' => 'cache_path',
32
+ 'user' => 'user',
33
+ 'password' => 'password'
34
+ )
35
+
36
+ assert_equal( 'plan_path', thimbl.plan_path )
37
+ assert_equal( 'cache_path', thimbl.cache_path )
38
+ assert_equal( 'user', thimbl.user )
39
+ assert_equal( 'password', thimbl.password )
40
+ end
41
+
42
+ def test_setup_without_options
43
+ thimbl = Thimbl::Base.new
44
+ thimbl.expects(:save_data)
45
+ thimbl.setup
46
+
47
+ assert_equal( 'address', thimbl.address )
48
+
49
+ data = thimbl.data['plans'][thimbl.address]
50
+ assert_equal( 'name', data['name'] )
51
+ assert_equal( [], data['messages'] )
52
+ assert_equal( 'bio', data['bio'] )
53
+ assert_equal( {}, data['replies'] )
54
+ assert_equal( [], data['following'] )
55
+ assert_equal( 'mobile', data['properties']['mobile'] )
56
+ assert_equal( 'website', data['properties']['website'] )
57
+ assert_equal( 'email', data['properties']['email'] )
58
+ end
59
+
60
+ def test_setup_with_options
61
+ thimbl = Thimbl::Base.new
62
+ thimbl.expects(:save_data)
63
+ thimbl.setup(
64
+ 'bio' => 'my bio',
65
+ 'website' => 'my website',
66
+ 'mobile' => 'my mobile',
67
+ 'email' => 'my email',
68
+ 'address' => 'my address',
69
+ 'name' => 'my name'
70
+ )
71
+
72
+ assert_equal( 'my address', thimbl.address )
73
+
74
+ data = thimbl.data['plans'][thimbl.address]
75
+ assert_equal( 'my name', data['name'] )
76
+ assert_equal( 'my bio', data['bio'] )
77
+ assert_equal( 'my mobile', data['properties']['mobile'] )
78
+ assert_equal( 'my website', data['properties']['website'] )
79
+ assert_equal( 'my email', data['properties']['email'] )
80
+ end
81
+
82
+ def test_post
83
+ Thimbl::Base.any_instance.expects(:save_data)
84
+ thimbl = Thimbl::Base.new
85
+
86
+ thimbl.stubs( :address ).returns( @data['me'] )
87
+ thimbl.stubs( :data ).returns( @data )
88
+
89
+ Delorean.time_travel_to("2011-02-03 04:05:06") do
90
+ thimbl.post( "wadus wadus" )
91
+ end
92
+
93
+ message = thimbl.data['plans'][thimbl.address]['messages'].last
94
+ assert_equal( thimbl.address, message['address'] )
95
+ assert_equal( '20110203040506', message['time'] )
96
+ assert_equal( 'wadus wadus', message['text'] )
97
+ end
98
+
99
+ def test_follow
100
+ Thimbl::Base.any_instance.expects(:save_data)
101
+ thimbl = Thimbl::Base.new
102
+ thimbl.stubs( :address ).returns( @data['me'] )
103
+ thimbl.stubs( :data ).returns( @data )
104
+
105
+ thimbl.follow( 'nick', 'address' )
106
+
107
+ following = thimbl.data['plans'][thimbl.address]['following'].last
108
+ assert_equal( 'nick', following['nick'] )
109
+ assert_equal( 'address', following['address'] )
110
+ end
111
+
112
+ def test_fetch
113
+ finger_fixture = File.read "#{File.dirname(__FILE__)}/fixtures/finger_dk_telekommunisten_org.txt"
114
+ finger_sequence = sequence('finger_sequence')
115
+
116
+ Thimbl::Finger.
117
+ expects(:run).
118
+ with( 'wadus1@telekommunisten.org' ).
119
+ returns( finger_fixture ).
120
+ in_sequence( finger_sequence )
121
+
122
+ Thimbl::Finger.
123
+ expects(:run).
124
+ with( 'wadus2@telekommunisten.org' ).
125
+ returns( finger_fixture ).
126
+ in_sequence( finger_sequence )
127
+
128
+ Thimbl::Base.any_instance.expects(:save_data)
129
+
130
+ thimbl = Thimbl::Base.new
131
+ thimbl.stubs(:data).returns( @data )
132
+ thimbl.expects(:following).returns( [
133
+ {'nick' => 'wadus1', 'address' => 'wadus1@telekommunisten.org' },
134
+ {'nick' => 'wadus2', 'address' => 'wadus2@telekommunisten.org' },
135
+ ] )
136
+
137
+ thimbl.fetch
138
+
139
+ assert_equal( 21, thimbl.data['plans']['wadus1@telekommunisten.org']['messages'].count )
140
+ assert_equal( 21, thimbl.data['plans']['wadus2@telekommunisten.org']['messages'].count )
141
+ end
142
+
143
+ def test_fetch_with_plan_with_two_break_lines
144
+ finger_fixture = File.read "#{File.dirname(__FILE__)}/fixtures/finger_dk_telekommunisten_org_two_break_lines.txt"
145
+ Thimbl::Finger.
146
+ expects(:run).
147
+ with( 'wadus1@telekommunisten.org' ).
148
+ returns( finger_fixture )
149
+
150
+ Thimbl::Base.any_instance.expects(:save_data)
151
+
152
+ thimbl = Thimbl::Base.new
153
+ thimbl.stubs(:data).returns( @data )
154
+ thimbl.expects(:following).returns( [{'nick' => 'wadus1', 'address' => 'wadus1@telekommunisten.org' }] )
155
+
156
+ thimbl.fetch
157
+
158
+ assert_equal( 22, thimbl.data['plans']['wadus1@telekommunisten.org']['messages'].count )
159
+ end
160
+
161
+ def test_push
162
+ thimbl = Thimbl::Base.new( 'user' => 'user@domain', 'password' => 'my password' )
163
+ Net::SCP.expects(:start).with( 'domain', 'user', :password => 'my password' )
164
+ thimbl.push
165
+ end
166
+
167
+ def test_load_data
168
+ thimbl = Thimbl::Base.new( 'cache_path' => "#{File.dirname(__FILE__)}/fixtures/cache.json" )
169
+ thimbl.load_data
170
+
171
+ assert_equal( 'fguillen@telekommunisten.org', thimbl.data['me'] )
172
+ assert_equal( 2, thimbl.data['plans'].size )
173
+ assert_equal( 4, thimbl.data['plans']['fguillen@telekommunisten.org']['messages'].size )
174
+ end
175
+
176
+ def test_messages
177
+ thimbl = Thimbl::Base.new( 'cache_path' => "#{File.dirname(__FILE__)}/fixtures/cache.json" )
178
+ thimbl.load_data
179
+ assert_equal( 24, thimbl.messages.size )
180
+ end
181
+
182
+ def test_print
183
+ messages = [
184
+ {
185
+ "address" => "fguillen@telekommunisten.org",
186
+ "text" => "Here I am",
187
+ "time" => "20110131002202"
188
+ },
189
+ {
190
+ "address" => "fguillen@telekommunisten.org",
191
+ "text" => "testing :)",
192
+ "time" => "20110205150637"
193
+ }
194
+ ]
195
+
196
+ thimbl = Thimbl::Base.new
197
+ thimbl.expects( :messages ).returns( messages )
198
+
199
+ print = thimbl.print
200
+
201
+ assert_equal( 2, print.lines.to_a.size )
202
+ assert_equal( "2011-01-31 00:22:02 fguillen@telekommunisten.org > Here I am\n", print.lines.to_a[0] )
203
+ assert_equal( "2011-02-05 15:06:37 fguillen@telekommunisten.org > testing :)\n", print.lines.to_a[1] )
204
+ end
205
+
206
+ def test_save_data
207
+ thimbl = Thimbl::Base.new( 'plan_path' => '/tmp/plan_path', 'cache_path' => '/tmp/cache_path' )
208
+ thimbl.stubs( :address ).returns( @data['me'] )
209
+ thimbl.stubs( :data ).returns( @data )
210
+ thimbl.data
211
+ thimbl.save_data
212
+
213
+ assert_equal( thimbl.data['plans'][thimbl.address], JSON.load( File.read '/tmp/plan_path' ) )
214
+ assert_equal( thimbl.data, JSON.load( File.read '/tmp/cache_path' ) )
215
+ end
216
+
217
+ def test_parse_time
218
+ assert_equal( Time.utc( 2010, 11, 29, 6, 3, 35 ), Thimbl::Base.parse_time( '20101129060335' ) )
219
+ end
220
+ end
@@ -0,0 +1,106 @@
1
+ require "#{File.dirname(__FILE__)}/test_helper"
2
+
3
+ class CommandTest < Test::Unit::TestCase
4
+ def setup
5
+ end
6
+
7
+ def teardown
8
+ end
9
+
10
+ def test_setup_should_exit_if_parameters_not_correct
11
+ assert_raise( ArgumentError ) do
12
+ Thimbl::Command.setup
13
+ end
14
+ end
15
+
16
+ def test_setup
17
+ Thimbl::Command.stubs( :config_file ).returns( '/tmp/.thimbl/config_file' )
18
+ Thimbl::Command.expects( :load ).returns( Thimbl::Base.new )
19
+ Thimbl::Base.any_instance.expects( :setup )
20
+
21
+ Thimbl::Command.setup( 'plan_path', 'cache_path', 'user', 'password' )
22
+
23
+ config_written = JSON.load( File.read( '/tmp/.thimbl/config_file' ) )
24
+
25
+ assert_equal( 'plan_path', config_written['plan_path'] )
26
+ assert_equal( 'cache_path', config_written['cache_path'] )
27
+ assert_equal( 'user', config_written['user'] )
28
+ assert_equal( 'password', config_written['password'] )
29
+
30
+ FileUtils.remove_dir '/tmp/.thimbl'
31
+ end
32
+
33
+ def test_print
34
+ thimbl = Thimbl::Base.new
35
+ Thimbl::Command.expects( :load ).returns( thimbl )
36
+ thimbl.expects( :load_data )
37
+ thimbl.expects( :print )
38
+
39
+ Thimbl::Command.print
40
+ end
41
+
42
+ def test_fetch
43
+ thimbl = Thimbl::Base.new
44
+ Thimbl::Command.expects( :load ).returns( thimbl )
45
+ thimbl.expects( :load_data )
46
+ thimbl.expects( :fetch )
47
+
48
+ Thimbl::Command.fetch
49
+ end
50
+
51
+ def test_post_should_raise_error_if_wrong_parameters
52
+ assert_raise( ArgumentError ) do
53
+ Thimbl::Command.post
54
+ end
55
+ end
56
+
57
+ def test_post
58
+ thimbl = Thimbl::Base.new
59
+ Thimbl::Command.expects( :load ).returns( thimbl )
60
+ thimbl.expects( :load_data )
61
+ thimbl.expects( :post ).with( 'wadus' )
62
+
63
+ Thimbl::Command.post 'wadus'
64
+ end
65
+
66
+ def test_push
67
+ thimbl = Thimbl::Base.new
68
+ Thimbl::Command.expects( :load ).returns( thimbl )
69
+ thimbl.expects( :load_data )
70
+ thimbl.expects( :push )
71
+
72
+ Thimbl::Command.push
73
+ end
74
+
75
+ def test_follow_should_raise_error_if_wrong_parameters
76
+ assert_raise( ArgumentError ) do
77
+ Thimbl::Command.follow
78
+ end
79
+ end
80
+
81
+ def test_follow
82
+ thimbl = Thimbl::Base.new
83
+ Thimbl::Command.expects( :load ).returns( thimbl )
84
+ thimbl.expects( :load_data )
85
+ thimbl.expects( :follow ).with( 'wadus', 'wadus@domain.com' )
86
+
87
+ Thimbl::Command.follow 'wadus', 'wadus@domain.com'
88
+ end
89
+
90
+ def test_load_should_raise_error_if_not_config_file
91
+ Thimbl::Command.stubs( :config_file ).returns( '/tmp/not_exists_file' )
92
+
93
+ assert_raise( ArgumentError ) do
94
+ Thimbl::Command.load
95
+ end
96
+ end
97
+
98
+ def test_load
99
+ Thimbl::Command.stubs( :config_file ).returns( '/tmp/config_file' )
100
+ File.expects( :exists? ).with( '/tmp/config_file' ).returns( true )
101
+ File.expects( :read ).with( '/tmp/config_file' ).returns( "{ \"a\" : 1 }" )
102
+ Thimbl::Base.expects( :new ).with( { 'a' => 1 } )
103
+
104
+ Thimbl::Command.load
105
+ end
106
+ end
data/thimbl.gemspec CHANGED
@@ -2,36 +2,50 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{thimbl}
5
- s.version = "0.0.1"
5
+ s.version = "0.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Fernando Guillen"]
9
- s.date = %q{2011-02-05}
9
+ s.date = %q{2011-02-08}
10
+ s.default_executable = %q{thimbl}
10
11
  s.description = %q{Small client for the distributed microbloging protocol: [thimbl](http://www.thimbl.net/)}
11
12
  s.email = %q{fguillen.mail@gmail.com}
12
- s.extra_rdoc_files = ["README.md", "lib/finger.rb", "lib/thimbl.rb"]
13
- s.files = ["Gemfile", "Manifest", "README.md", "Rakefile", "lib/finger.rb", "lib/thimbl.rb", "test/fixtures/cache.json", "test/thimbl_test.rb", "thimbl.rb", "thimbl.gemspec"]
13
+ s.executables = ["thimbl"]
14
+ s.extra_rdoc_files = ["README.md", "bin/thimbl", "lib/thimbl.rb", "lib/thimbl/base.rb", "lib/thimbl/command.rb", "lib/thimbl/finger.rb"]
15
+ s.files = ["Gemfile", "Gemfile.lock", "Manifest", "README.md", "Rakefile", "bin/thimbl", "lib/thimbl.rb", "lib/thimbl/base.rb", "lib/thimbl/command.rb", "lib/thimbl/finger.rb", "test/fixtures/cache.json", "test/fixtures/finger_dk_telekommunisten_org.txt", "test/fixtures/finger_dk_telekommunisten_org_two_break_lines.txt", "test/test_helper.rb", "test/thimbl_base_test.rb", "test/thimbl_command_test.rb", "thimbl.gemspec"]
14
16
  s.homepage = %q{http://github.com/fguillen/ThimblClient}
15
17
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Thimbl", "--main", "README.md"]
16
18
  s.require_paths = ["lib"]
17
19
  s.rubyforge_project = %q{thimbl}
18
20
  s.rubygems_version = %q{1.3.7}
19
21
  s.summary = %q{Small client for the distributed microbloging protocol: [thimbl](http://www.thimbl.net/)}
20
- s.test_files = ["test/thimbl_test.rb"]
22
+ s.test_files = ["test/test_helper.rb", "test/thimbl_base_test.rb", "test/thimbl_command_test.rb"]
21
23
 
22
24
  if s.respond_to? :specification_version then
23
25
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
26
  s.specification_version = 3
25
27
 
26
28
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
29
+ s.add_runtime_dependency(%q<json>, [">= 0"])
30
+ s.add_runtime_dependency(%q<net-scp>, [">= 0"])
31
+ s.add_runtime_dependency(%q<fileutils>, [">= 0"])
27
32
  s.add_development_dependency(%q<mocha>, [">= 0"])
28
33
  s.add_development_dependency(%q<ruby-debug>, [">= 0"])
34
+ s.add_development_dependency(%q<delorean>, [">= 0"])
29
35
  else
36
+ s.add_dependency(%q<json>, [">= 0"])
37
+ s.add_dependency(%q<net-scp>, [">= 0"])
38
+ s.add_dependency(%q<fileutils>, [">= 0"])
30
39
  s.add_dependency(%q<mocha>, [">= 0"])
31
40
  s.add_dependency(%q<ruby-debug>, [">= 0"])
41
+ s.add_dependency(%q<delorean>, [">= 0"])
32
42
  end
33
43
  else
44
+ s.add_dependency(%q<json>, [">= 0"])
45
+ s.add_dependency(%q<net-scp>, [">= 0"])
46
+ s.add_dependency(%q<fileutils>, [">= 0"])
34
47
  s.add_dependency(%q<mocha>, [">= 0"])
35
48
  s.add_dependency(%q<ruby-debug>, [">= 0"])
49
+ s.add_dependency(%q<delorean>, [">= 0"])
36
50
  end
37
51
  end