rbitter 0.1.0 → 0.1.2

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +21 -21
  3. data/.rspec +2 -2
  4. data/.travis.yml +15 -15
  5. data/Gemfile +12 -12
  6. data/LICENSE.txt +22 -22
  7. data/Rakefile +8 -8
  8. data/XMLRPC.md +19 -19
  9. data/bin/rbitter +20 -20
  10. data/lib/rbitter/arcserver.rb +130 -126
  11. data/lib/rbitter/console.rb +93 -93
  12. data/lib/rbitter/default/config_json.rb +37 -38
  13. data/lib/rbitter/dlthread.rb +62 -65
  14. data/lib/rbitter/env.rb +62 -62
  15. data/lib/rbitter/libtwitter_connection_override.rb +45 -45
  16. data/lib/rbitter/records.rb +121 -121
  17. data/lib/rbitter/records_migrate/20150327_add_index.rb +11 -11
  18. data/lib/rbitter/records_migrate/20150504_add_replyto_column.rb +11 -11
  19. data/lib/rbitter/streaming.rb +104 -104
  20. data/lib/rbitter/version.rb +20 -20
  21. data/lib/rbitter/xmlrpc.rb +3 -3
  22. data/lib/rbitter/xmlrpcd/base.rb +24 -24
  23. data/lib/rbitter/xmlrpcd/rpchandles.rb +11 -11
  24. data/lib/rbitter/xmlrpcd/xmlrpc_auth_server.rb +82 -82
  25. data/lib/rbitter/xmlrpcd/xmlrpcd.rb +69 -69
  26. data/lib/rbitter.rb +86 -86
  27. data/rbitter.gemspec +46 -42
  28. data/spec/config/default.json +32 -32
  29. data/spec/rbitter/arcserver_spec.rb +30 -30
  30. data/spec/rbitter/console_spec.rb +9 -9
  31. data/spec/rbitter/default/config_json_spec.rb +3 -3
  32. data/spec/rbitter/dlthread_spec.rb +8 -13
  33. data/spec/rbitter/env_spec.rb +62 -62
  34. data/spec/rbitter/libtwitter_connection_override_spec.rb +8 -8
  35. data/spec/rbitter/records_spec.rb +13 -13
  36. data/spec/rbitter/streaming_spec.rb +9 -9
  37. data/spec/rbitter/version_spec.rb +8 -8
  38. data/spec/rbitter/xmlrpc_spec.rb +8 -8
  39. data/spec/rbitter/xmlrpcd/base_spec.rb +29 -29
  40. data/spec/rbitter/xmlrpcd/rpchandles_spec.rb +10 -10
  41. data/spec/rbitter/xmlrpcd/xmlrpc_auth_server_spec.rb +8 -8
  42. data/spec/rbitter/xmlrpcd/xmlrpcd_spec.rb +9 -9
  43. data/spec/rbitter_spec.rb +42 -42
  44. data/spec/spec_helper.rb +39 -39
  45. metadata +29 -56
@@ -1,30 +1,30 @@
1
- # encoding: utf-8
2
-
3
- require "rbitter/arcserver"
4
- require "rbitter/streaming"
5
- require "rbitter/xmlrpcd/xmlrpcd"
6
-
7
- describe Rbitter::ArcServer do
8
- it 'is presented' do
9
- expect(Rbitter::ArcServer).to be_a(Class)
10
- end
11
-
12
- context 'With dummy implementations, ' do
13
- before(:all) do
14
- Rbitter.bootstrap(['configure'])
15
- expect(File.file?('config.json')).to be(true)
16
- end
17
-
18
- it 'successfully returns from main_loop' do
19
- Rbitter.config_initialize
20
-
21
- arcserver = Rbitter::ArcServer.new(Rbitter::DummyRPCServer)
22
- arcserver.main_loop(Rbitter::DummyStreamClient)
23
- end
24
-
25
- after(:all) do
26
- File.delete('config.json') if File.exist?('config.json')
27
- File.delete('rbitter.sqlite') if File.exist?('rbitter.sqlite')
28
- end
29
- end
30
- end
1
+ # encoding: utf-8
2
+
3
+ require "rbitter/arcserver"
4
+ require "rbitter/streaming"
5
+ require "rbitter/xmlrpcd/xmlrpcd"
6
+
7
+ describe Rbitter::ArcServer do
8
+ it 'is presented' do
9
+ expect(Rbitter::ArcServer).to be_a(Class)
10
+ end
11
+
12
+ context 'With dummy implementations, ' do
13
+ before(:all) do
14
+ Rbitter.bootstrap(['configure'])
15
+ expect(File.file?('config.json')).to be(true)
16
+ end
17
+
18
+ it 'successfully returns from main_loop' do
19
+ Rbitter.config_initialize
20
+
21
+ arcserver = Rbitter::ArcServer.new(Rbitter::DummyRPCServer)
22
+ arcserver.main_loop(Rbitter::DummyStreamClient)
23
+ end
24
+
25
+ after(:all) do
26
+ File.delete('config.json') if File.exist?('config.json')
27
+ File.delete('rbitter.sqlite') if File.exist?('rbitter.sqlite')
28
+ end
29
+ end
30
+ end
@@ -1,9 +1,9 @@
1
- # encoding: utf-8
2
- require "rbitter/console"
3
-
4
- describe Rbitter::Console do
5
- # TODO: Perform test...
6
- it 'is presented' do
7
- expect(Rbitter::Console).to be_a(Class)
8
- end
9
- end
1
+ # encoding: utf-8
2
+ require "rbitter/console"
3
+
4
+ describe Rbitter::Console do
5
+ # TODO: Perform test...
6
+ it 'is presented' do
7
+ expect(Rbitter::Console).to be_a(Class)
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
- # encoding: utf-8
2
-
3
- require "rbitter/default/config_json"
1
+ # encoding: utf-8
2
+
3
+ require "rbitter/default/config_json"
@@ -1,13 +1,8 @@
1
- # encoding: utf-8
2
- require "rbitter/dlthread"
3
-
4
- describe Rbitter::DLThread do
5
- # TODO:
6
- #t = DLThread.new(".")
7
- #t << ["https://www.google.co.kr/images/nav_logo195.png"]
8
- #sleep 4
9
-
10
- it 'is presented' do
11
- expect(Rbitter::DLThread).to be_a(Class)
12
- end
13
- end
1
+ # encoding: utf-8
2
+ require "rbitter/dlthread"
3
+
4
+ describe Rbitter::DLThread do
5
+ it 'is presented' do
6
+ expect(Rbitter::DLThread).to be_a(Class)
7
+ end
8
+ end
@@ -1,62 +1,62 @@
1
- # encoding: utf-8
2
-
3
- require "rbitter"
4
-
5
- describe Rbitter do
6
- it 'has env_reset function and clears Rbitter.env,' do
7
- Rbitter.env_reset
8
- expect(Rbitter.env).to be_a(Hash)
9
- expect(Rbitter.env.length).to be(0)
10
- end
11
-
12
- context 'when config.json is not installed,' do
13
- it 'fails on loading' do
14
- expect{Rbitter.config_initialize}.to raise_error(Rbitter::ConfigFileError)
15
- end
16
- end
17
-
18
- context 'when path to config.json is invalid,' do
19
- it 'fals on loading' do
20
- expect{Rbitter.config_initialize("/silly/dummy/.")}.to raise_error(Rbitter::ConfigFileError)
21
- end
22
- end
23
-
24
-
25
- context 'when default config.json is installed,' do
26
- before(:all) do
27
- Rbitter.bootstrap(['configure'])
28
- expect(File.file?('config.json')).to be(true)
29
- end
30
-
31
- it 'loads configuration successfully with autodetection' do
32
- expect{Rbitter.config_initialize}.to_not raise_error
33
- expect(Rbitter.env.length > 0).to be(true)
34
- end
35
-
36
- it 'loads configuration successfully with given config.json path' do
37
- expect{Rbitter.config_initialize('config.json')}.to_not raise_error
38
- expect(Rbitter.env.length > 0).to be(true)
39
- end
40
-
41
- it 'checks that Rbitter.env returns Hash' do
42
- expect{Rbitter.config_initialize}.to_not raise_error
43
- expect(Rbitter.env).to be_a(Hash)
44
- end
45
-
46
- it 'checks that Rbitter[] works' do
47
- expect{Rbitter.config_initialize}.to_not raise_error
48
- expect(Rbitter["twitter"]).to be_a(Hash)
49
- end
50
-
51
- after(:all) do
52
- File.delete('config.json')
53
- end
54
- end
55
-
56
- context 'when env_validator validates loaded configuration' do
57
- # TODO: Perform test with spec/config/default.json
58
- # TODO: Adding configuration validator on env.rb
59
- end
60
-
61
- # TODO: Perform test with spec/config/default.json
62
- end
1
+ # encoding: utf-8
2
+
3
+ require "rbitter"
4
+
5
+ describe Rbitter do
6
+ it 'has env_reset function and clears Rbitter.env,' do
7
+ Rbitter.env_reset
8
+ expect(Rbitter.env).to be_a(Hash)
9
+ expect(Rbitter.env.length).to be(0)
10
+ end
11
+
12
+ context 'when config.json is not installed,' do
13
+ it 'fails on loading' do
14
+ expect{Rbitter.config_initialize}.to raise_error(Rbitter::ConfigFileError)
15
+ end
16
+ end
17
+
18
+ context 'when path to config.json is invalid,' do
19
+ it 'fals on loading' do
20
+ expect{Rbitter.config_initialize("/silly/dummy/.")}.to raise_error(Rbitter::ConfigFileError)
21
+ end
22
+ end
23
+
24
+
25
+ context 'when default config.json is installed,' do
26
+ before(:all) do
27
+ Rbitter.bootstrap(['configure'])
28
+ expect(File.file?('config.json')).to be(true)
29
+ end
30
+
31
+ it 'loads configuration successfully with autodetection' do
32
+ expect{Rbitter.config_initialize}.to_not raise_error
33
+ expect(Rbitter.env.length > 0).to be(true)
34
+ end
35
+
36
+ it 'loads configuration successfully with given config.json path' do
37
+ expect{Rbitter.config_initialize('config.json')}.to_not raise_error
38
+ expect(Rbitter.env.length > 0).to be(true)
39
+ end
40
+
41
+ it 'checks that Rbitter.env returns Hash' do
42
+ expect{Rbitter.config_initialize}.to_not raise_error
43
+ expect(Rbitter.env).to be_a(Hash)
44
+ end
45
+
46
+ it 'checks that Rbitter[] works' do
47
+ expect{Rbitter.config_initialize}.to_not raise_error
48
+ expect(Rbitter["twitter"]).to be_a(Hash)
49
+ end
50
+
51
+ after(:all) do
52
+ File.delete('config.json')
53
+ end
54
+ end
55
+
56
+ context 'when env_validator validates loaded configuration' do
57
+ # TODO: Perform test with spec/config/default.json
58
+ # TODO: Adding configuration validator on env.rb
59
+ end
60
+
61
+ # TODO: Perform test with spec/config/default.json
62
+ end
@@ -1,8 +1,8 @@
1
- # encoding: utf-8
2
- require "rbitter/libtwitter_connection_override"
3
-
4
- describe Rbitter do
5
- it 'overrides twitter gem' do
6
- expect(Twitter::Streaming::Connection::MODIFIED).to be(true)
7
- end
8
- end
1
+ # encoding: utf-8
2
+ require "rbitter/libtwitter_connection_override"
3
+
4
+ describe Rbitter do
5
+ it 'overrides twitter gem' do
6
+ expect(Twitter::Streaming::Connection::MODIFIED).to be(true)
7
+ end
8
+ end
@@ -1,13 +1,13 @@
1
- # encoding: utf-8
2
- require "rbitter/records"
3
-
4
- describe Rbitter::Record do
5
- # TODO: Perform test...
6
- it 'has ActiveRecord class named Record' do
7
- expect(Rbitter::Record).to be_a(Class)
8
- end
9
-
10
- it 'has supportive module of ActiveRecord' do
11
- expect(ARSupport).to be_a(Module)
12
- end
13
- end
1
+ # encoding: utf-8
2
+ require "rbitter/records"
3
+
4
+ describe Rbitter::Record do
5
+ # TODO: Perform test...
6
+ it 'has ActiveRecord class named Record' do
7
+ expect(Rbitter::Record).to be_a(Class)
8
+ end
9
+
10
+ it 'has supportive module of ActiveRecord' do
11
+ expect(ARSupport).to be_a(Module)
12
+ end
13
+ end
@@ -1,9 +1,9 @@
1
- # encoding: utf-8
2
- require "rbitter/streaming"
3
-
4
- describe Rbitter::StreamClient do
5
- # TODO: Perform test...
6
- it 'is presented' do
7
- expect(Rbitter::StreamClient).to be_a(Class)
8
- end
9
- end
1
+ # encoding: utf-8
2
+ require "rbitter/streaming"
3
+
4
+ describe Rbitter::StreamClient do
5
+ # TODO: Perform test...
6
+ it 'is presented' do
7
+ expect(Rbitter::StreamClient).to be_a(Class)
8
+ end
9
+ end
@@ -1,8 +1,8 @@
1
- # encoding: utf-8
2
- require "rbitter/version"
3
-
4
- describe Rbitter do
5
- it 'has version string' do
6
- expect(Rbitter::VERSION).to be_a(String)
7
- end
8
- end
1
+ # encoding: utf-8
2
+ require "rbitter/version"
3
+
4
+ describe Rbitter do
5
+ it 'has version string' do
6
+ expect(Rbitter::VERSION).to be_a(String)
7
+ end
8
+ end
@@ -1,8 +1,8 @@
1
- # encoding: utf-8
2
- require "rbitter/xmlrpc"
3
-
4
- describe Rbitter do
5
- it 'Rbitter is a module' do
6
- expect(Rbitter.class === Module).to be(true)
7
- end
8
- end
1
+ # encoding: utf-8
2
+ require "rbitter/xmlrpc"
3
+
4
+ describe Rbitter do
5
+ it 'Rbitter is a module' do
6
+ expect(Rbitter.class === Module).to be(true)
7
+ end
8
+ end
@@ -1,29 +1,29 @@
1
- # encoding: utf-8
2
-
3
- require "rbitter/xmlrpcd/base"
4
-
5
- describe RPCHandles do
6
- context 'when RH_INFO Struct is served as RPCHandle information,' do
7
- it 'structs corrct Struct::RPCHANDLE_INFO' do
8
- # String comparison: use eq(==), not be(===)
9
- expect(RPCHandles::RH_INFO.to_s).to eq("Struct::RPCHANDLE_INFO")
10
- end
11
-
12
- it 'provides correct information when #digest is called' do
13
- digest_string = RPCHandles::RH_INFO.new('test', 0.1, 'test', 'test').digest
14
- expect(digest_string).to eq("<rpchandle: test-0.1 (written by test, test)>")
15
- end
16
- end
17
- end
18
-
19
- describe RPCHandles::BaseHandle do
20
- context 'when an RPCHandle inherits one of classes Auth and NoAuth' do
21
- it 'returns false on #auth? when an RPCHandle class inherits NoAuth' do
22
- expect(RPCHandles::BaseHandle::NoAuth.auth?).to be(false)
23
- end
24
-
25
- it 'returns true on #auth? when an RPCHandle class inherits Auth' do
26
- expect(RPCHandles::BaseHandle::Auth.auth?).to be(true)
27
- end
28
- end
29
- end
1
+ # encoding: utf-8
2
+
3
+ require "rbitter/xmlrpcd/base"
4
+
5
+ describe RPCHandles do
6
+ context 'when RH_INFO Struct is served as RPCHandle information,' do
7
+ it 'structs corrct Struct::RPCHANDLE_INFO' do
8
+ # String comparison: use eq(==), not be(===)
9
+ expect(RPCHandles::RH_INFO.to_s).to eq("Struct::RPCHANDLE_INFO")
10
+ end
11
+
12
+ it 'provides correct information when #digest is called' do
13
+ digest_string = RPCHandles::RH_INFO.new('test', 0.1, 'test', 'test').digest
14
+ expect(digest_string).to eq("<rpchandle: test-0.1 (written by test, test)>")
15
+ end
16
+ end
17
+ end
18
+
19
+ describe RPCHandles::BaseHandle do
20
+ context 'when an RPCHandle inherits one of classes Auth and NoAuth' do
21
+ it 'returns false on #auth? when an RPCHandle class inherits NoAuth' do
22
+ expect(RPCHandles::BaseHandle::NoAuth.auth?).to be(false)
23
+ end
24
+
25
+ it 'returns true on #auth? when an RPCHandle class inherits Auth' do
26
+ expect(RPCHandles::BaseHandle::Auth.auth?).to be(true)
27
+ end
28
+ end
29
+ end
@@ -1,10 +1,10 @@
1
- # encoding: utf-8
2
- require "rbitter/xmlrpcd/rpchandles"
3
-
4
- describe RPCHandles do
5
- context 'When features related to authentication needs ::auth method,'
6
- it 'responds to ::auth' do
7
- expect(RPCHandles.respond_to?(:auth)).to be(true)
8
- expect(RPCHandles.auth).to be_a(NilClass)
9
- end
10
- end
1
+ # encoding: utf-8
2
+ require "rbitter/xmlrpcd/rpchandles"
3
+
4
+ describe RPCHandles do
5
+ context 'When features related to authentication needs ::auth method,'
6
+ it 'responds to ::auth' do
7
+ expect(RPCHandles.respond_to?(:auth)).to be(true)
8
+ expect(RPCHandles.auth).to be_a(NilClass)
9
+ end
10
+ end
@@ -1,8 +1,8 @@
1
- # encoding: utf-8
2
- require "rbitter/xmlrpcd/xmlrpc_auth_server"
3
-
4
- describe Rbitter do
5
- it 'Rbitter is a module' do
6
- expect(Rbitter.class === Module).to be(true)
7
- end
8
- end
1
+ # encoding: utf-8
2
+ require "rbitter/xmlrpcd/xmlrpc_auth_server"
3
+
4
+ describe Rbitter do
5
+ it 'Rbitter is a module' do
6
+ expect(Rbitter.class === Module).to be(true)
7
+ end
8
+ end
@@ -1,9 +1,9 @@
1
- # encoding: utf-8
2
-
3
- require "rbitter/xmlrpcd/xmlrpcd"
4
-
5
- describe Rbitter do
6
- it 'Rbitter is a module' do
7
- expect(Rbitter.class === Module).to be(true)
8
- end
9
- end
1
+ # encoding: utf-8
2
+
3
+ require "rbitter/xmlrpcd/xmlrpcd"
4
+
5
+ describe Rbitter do
6
+ it 'Rbitter is a module' do
7
+ expect(Rbitter.class === Module).to be(true)
8
+ end
9
+ end
data/spec/rbitter_spec.rb CHANGED
@@ -1,42 +1,42 @@
1
- # encoding: utf-8
2
-
3
- require "rbitter"
4
-
5
- describe Rbitter do
6
- context 'when a user requests help message,' do
7
- it 'shows help message' do
8
- Rbitter.bootstrap(['help'])
9
- end
10
- end
11
-
12
- context 'when \'configure\' option is given,' do
13
- it 'installs default config.json' do
14
- Rbitter.bootstrap(["configure"])
15
- expect(File.file?('config.json')).to be(true)
16
- expect(File.delete('config.json')).to be(1)
17
- end
18
- end
19
-
20
- context 'when config.json is installed,' do
21
- before(:all) do
22
- Rbitter.bootstrap(['configure'])
23
- end
24
-
25
- it 'executes prebootstrap properly' do
26
- Rbitter.prebootstrap
27
- end
28
-
29
- it 'bootstraps nothing when empty ARGV is given' do
30
- Rbitter.bootstrap([])
31
- end
32
-
33
- it 'displays buffered logs with \'logs\' argument' do
34
- Rbitter.bootstrap(["logs"])
35
- end
36
-
37
- after(:all) do
38
- expect(File.file?('config.json')).to be(true)
39
- expect(File.delete('config.json')).to be(1)
40
- end
41
- end
42
- end
1
+ # encoding: utf-8
2
+
3
+ require "rbitter"
4
+
5
+ describe Rbitter do
6
+ context 'when a user requests help message,' do
7
+ it 'shows help message' do
8
+ Rbitter.bootstrap(['help'])
9
+ end
10
+ end
11
+
12
+ context 'when \'configure\' option is given,' do
13
+ it 'installs default config.json' do
14
+ Rbitter.bootstrap(["configure"])
15
+ expect(File.file?('config.json')).to be(true)
16
+ expect(File.delete('config.json')).to be(1)
17
+ end
18
+ end
19
+
20
+ context 'when config.json is installed,' do
21
+ before(:all) do
22
+ Rbitter.bootstrap(['configure'])
23
+ end
24
+
25
+ it 'executes prebootstrap properly' do
26
+ Rbitter.prebootstrap
27
+ end
28
+
29
+ it 'bootstraps nothing when empty ARGV is given' do
30
+ Rbitter.bootstrap([])
31
+ end
32
+
33
+ it 'displays buffered logs with \'logs\' argument' do
34
+ Rbitter.bootstrap(["logs"])
35
+ end
36
+
37
+ after(:all) do
38
+ expect(File.file?('config.json')).to be(true)
39
+ expect(File.delete('config.json')).to be(1)
40
+ end
41
+ end
42
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,39 +1,39 @@
1
- require 'simplecov'
2
- require 'coveralls'
3
-
4
- Coveralls.wear!
5
-
6
- SimpleCov.start do
7
- add_filter '/spec/'
8
- end
9
-
10
- require 'rbitter'
11
- require 'rspec'
12
-
13
- RSpec.configure do |config|
14
- # rspec-expectations config goes here. You can use an alternate
15
- # assertion/expectation library such as wrong or the stdlib/minitest
16
- # assertions if you prefer.
17
- config.expect_with :rspec do |expectations|
18
- # This option will default to `true` in RSpec 4. It makes the `description`
19
- # and `failure_message` of custom matchers include text for helper methods
20
- # defined using `chain`, e.g.:
21
- # be_bigger_than(2).and_smaller_than(4).description
22
- # # => "be bigger than 2 and smaller than 4"
23
- # ...rather than:
24
- # # => "be bigger than 2"
25
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
26
- end
27
-
28
- # rspec-mocks config goes here. You can use an alternate test double
29
- # library (such as bogus or mocha) by changing the `mock_with` option here.
30
- config.mock_with :rspec do |mocks|
31
- # Prevents you from mocking or stubbing a method that does not exist on
32
- # a real object. This is generally recommended, and will default to
33
- # `true` in RSpec 4.
34
- mocks.verify_partial_doubles = true
35
- end
36
-
37
- config.warnings = true
38
- config.order = :random
39
- end
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ Coveralls.wear!
5
+
6
+ SimpleCov.start do
7
+ add_filter '/spec/'
8
+ end
9
+
10
+ require 'rbitter'
11
+ require 'rspec'
12
+
13
+ RSpec.configure do |config|
14
+ # rspec-expectations config goes here. You can use an alternate
15
+ # assertion/expectation library such as wrong or the stdlib/minitest
16
+ # assertions if you prefer.
17
+ config.expect_with :rspec do |expectations|
18
+ # This option will default to `true` in RSpec 4. It makes the `description`
19
+ # and `failure_message` of custom matchers include text for helper methods
20
+ # defined using `chain`, e.g.:
21
+ # be_bigger_than(2).and_smaller_than(4).description
22
+ # # => "be bigger than 2 and smaller than 4"
23
+ # ...rather than:
24
+ # # => "be bigger than 2"
25
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
26
+ end
27
+
28
+ # rspec-mocks config goes here. You can use an alternate test double
29
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
30
+ config.mock_with :rspec do |mocks|
31
+ # Prevents you from mocking or stubbing a method that does not exist on
32
+ # a real object. This is generally recommended, and will default to
33
+ # `true` in RSpec 4.
34
+ mocks.verify_partial_doubles = true
35
+ end
36
+
37
+ config.warnings = true
38
+ config.order = :random
39
+ end