rbitter 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +21 -21
  3. data/.rspec +2 -2
  4. data/.travis.yml +15 -9
  5. data/Gemfile +12 -11
  6. data/LICENSE.txt +22 -22
  7. data/README.md +23 -16
  8. data/Rakefile +8 -8
  9. data/XMLRPC.md +19 -19
  10. data/bin/rbitter +20 -6
  11. data/lib/rbitter/arcserver.rb +126 -97
  12. data/lib/rbitter/console.rb +93 -61
  13. data/lib/rbitter/default/config_json.rb +38 -37
  14. data/lib/rbitter/dlthread.rb +66 -66
  15. data/lib/rbitter/env.rb +62 -59
  16. data/lib/rbitter/libtwitter_connection_override.rb +45 -45
  17. data/lib/rbitter/records.rb +121 -109
  18. data/lib/rbitter/records_migrate/20150327_add_index.rb +11 -7
  19. data/lib/rbitter/records_migrate/20150504_add_replyto_column.rb +12 -0
  20. data/lib/rbitter/streaming.rb +104 -75
  21. data/lib/rbitter/version.rb +20 -3
  22. data/lib/rbitter/xmlrpc.rb +3 -3
  23. data/lib/rbitter/xmlrpcd/base.rb +24 -24
  24. data/lib/rbitter/xmlrpcd/rpchandles.rb +11 -11
  25. data/lib/rbitter/xmlrpcd/xmlrpc_auth_server.rb +82 -83
  26. data/lib/rbitter/xmlrpcd/xmlrpcd.rb +69 -63
  27. data/lib/rbitter.rb +86 -92
  28. data/rbitter.gemspec +42 -42
  29. data/spec/config/default.json +32 -32
  30. data/spec/rbitter/arcserver_spec.rb +30 -9
  31. data/spec/rbitter/console_spec.rb +9 -9
  32. data/spec/rbitter/default/config_json_spec.rb +3 -3
  33. data/spec/rbitter/dlthread_spec.rb +13 -9
  34. data/spec/rbitter/env_spec.rb +62 -56
  35. data/spec/rbitter/libtwitter_connection_override_spec.rb +8 -8
  36. data/spec/rbitter/records_spec.rb +13 -13
  37. data/spec/rbitter/streaming_spec.rb +9 -9
  38. data/spec/rbitter/version_spec.rb +8 -8
  39. data/spec/rbitter/xmlrpc_spec.rb +8 -8
  40. data/spec/rbitter/xmlrpcd/base_spec.rb +29 -29
  41. data/spec/rbitter/xmlrpcd/rpchandles_spec.rb +10 -10
  42. data/spec/rbitter/xmlrpcd/xmlrpc_auth_server_spec.rb +8 -8
  43. data/spec/rbitter/xmlrpcd/xmlrpcd_spec.rb +9 -9
  44. data/spec/rbitter_spec.rb +42 -46
  45. data/spec/spec_helper.rb +39 -36
  46. metadata +68 -41
  47. data/config.json.example +0 -30
@@ -1,9 +1,30 @@
1
- # encoding: utf-8
2
- require "rbitter/arcserver"
3
-
4
- describe Rbitter::ArcServer do
5
- # TODO: Perform test...
6
- it 'is presented' do
7
- expect(Rbitter::ArcServer).to be_a(Class)
8
- end
9
- 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,9 +1,13 @@
1
- # encoding: utf-8
2
- require "rbitter/dlthread"
3
-
4
- describe Rbitter::DLThread do
5
- # TODO: Perform test...
6
- it 'is presented' do
7
- expect(Rbitter::DLThread).to be_a(Class)
8
- end
9
- end
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,56 +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::ConfigurationFileError)
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::ConfigurationFileError)
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.env).to be_a(Hash)
43
- end
44
-
45
- after(:all) do
46
- File.delete('config.json')
47
- end
48
- end
49
-
50
- context 'when config.json is corrupted' do
51
- # TODO: Perform test with spec/config/default.json
52
- # TODO: Adding configuration validator on env.rb
53
- end
54
-
55
- # TODO: Perform test with spec/config/default.json
56
- 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,46 +1,42 @@
1
- # encoding: utf-8
2
-
3
- require "rbitter"
4
-
5
- describe Rbitter do
6
- it 'Rbitter is a module' do
7
- expect(Rbitter.class === Module).to be(true)
8
- end
9
-
10
- context 'when a user requests help message,' do
11
- it 'shows help message' do
12
- Rbitter.bootstrap(['help'])
13
- end
14
- end
15
-
16
- context 'when \'configure\' option is given,' do
17
- it 'installs default config.json' do
18
- Rbitter.bootstrap(["configure"])
19
- expect(File.file?('config.json')).to be(true)
20
- expect(File.delete('config.json')).to be(1)
21
- end
22
- end
23
-
24
- context 'when config.json is installed,' do
25
- before(:all) do
26
- Rbitter.bootstrap(['configure'])
27
- end
28
-
29
- it 'executes prebootstrap properly' do
30
- Rbitter.prebootstrap
31
- end
32
-
33
- it 'bootstraps nothing when empty ARGV is given' do
34
- Rbitter.bootstrap([])
35
- end
36
-
37
- it 'displays buffered logs with \'logs\' argument' do
38
- Rbitter.bootstrap(["logs"])
39
- end
40
-
41
- after(:all) do
42
- expect(File.file?('config.json')).to be(true)
43
- expect(File.delete('config.json')).to be(1)
44
- end
45
- end
46
- 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,36 +1,39 @@
1
- require 'simplecov'
2
-
3
- SimpleCov.start do
4
- add_filter '/spec/'
5
- end
6
-
7
- require 'rbitter'
8
- require 'rspec'
9
-
10
- RSpec.configure do |config|
11
- # rspec-expectations config goes here. You can use an alternate
12
- # assertion/expectation library such as wrong or the stdlib/minitest
13
- # assertions if you prefer.
14
- config.expect_with :rspec do |expectations|
15
- # This option will default to `true` in RSpec 4. It makes the `description`
16
- # and `failure_message` of custom matchers include text for helper methods
17
- # defined using `chain`, e.g.:
18
- # be_bigger_than(2).and_smaller_than(4).description
19
- # # => "be bigger than 2 and smaller than 4"
20
- # ...rather than:
21
- # # => "be bigger than 2"
22
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
23
- end
24
-
25
- # rspec-mocks config goes here. You can use an alternate test double
26
- # library (such as bogus or mocha) by changing the `mock_with` option here.
27
- config.mock_with :rspec do |mocks|
28
- # Prevents you from mocking or stubbing a method that does not exist on
29
- # a real object. This is generally recommended, and will default to
30
- # `true` in RSpec 4.
31
- mocks.verify_partial_doubles = true
32
- end
33
-
34
- config.warnings = true
35
- config.order = :random
36
- 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