troo 0.0.11 → 0.0.12

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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/.simplecov +3 -0
  3. data/Gemfile.lock +4 -1
  4. data/README.md +7 -7
  5. data/Rakefile +2 -2
  6. data/config/en.yml +2 -0
  7. data/features/support/env.rb +0 -4
  8. data/lib/troo.rb +14 -26
  9. data/lib/troo/api/client.rb +28 -6
  10. data/lib/troo/api/endpoints.rb +42 -30
  11. data/lib/troo/api/response.rb +5 -0
  12. data/lib/troo/cli/main.rb +3 -0
  13. data/lib/troo/cli/wizard.rb +71 -0
  14. data/lib/troo/configuration.rb +29 -15
  15. data/lib/troo/debug.rb +9 -0
  16. data/lib/troo/decorators/resource.rb +8 -4
  17. data/lib/troo/launcher.rb +22 -12
  18. data/lib/troo/models/board.rb +2 -2
  19. data/lib/troo/models/card.rb +2 -2
  20. data/lib/troo/models/member.rb +1 -1
  21. data/lib/troo/models/refresh.rb +2 -2
  22. data/lib/troo/remote/list.rb +1 -1
  23. data/lib/troo/remote/member.rb +1 -1
  24. data/lib/troo/remote/persistence/board.rb +6 -10
  25. data/lib/troo/remote/persistence/card.rb +6 -10
  26. data/lib/troo/remote/persistence/comment.rb +6 -10
  27. data/lib/troo/remote/persistence/list.rb +6 -10
  28. data/lib/troo/remote/persistence/move_card.rb +6 -10
  29. data/lib/troo/troo.rb +3 -2
  30. data/lib/troo/version.rb +1 -1
  31. data/test/lib/troo/api/endpoints_test.rb +12 -22
  32. data/test/lib/troo/cli/commands/status_test.rb +1 -1
  33. data/test/lib/troo/cli/wizard_test.rb +44 -0
  34. data/test/lib/troo/configuration_test.rb +39 -0
  35. data/test/lib/troo/decorators/resource_test.rb +2 -1
  36. data/test/lib/troo/models/member_test.rb +1 -1
  37. data/test/support/fake_trello/fake_response.rb +1 -2
  38. data/test/support/fake_trello/server.rb +22 -14
  39. data/test/test_helper.rb +0 -5
  40. data/troo.gemspec +1 -0
  41. metadata +20 -6
  42. data/config/trello_api.yml +0 -19
  43. data/lib/troo/decorators/member.rb +0 -12
  44. data/test/lib/troo/decorators/member_test.rb +0 -8
@@ -12,7 +12,7 @@ module Troo
12
12
  describe '.dispatch' do
13
13
  subject { described_class.dispatch(klass) }
14
14
 
15
- before { @board = Fabricate(:board, default: default) }
15
+ before { Fabricate(:board, default: default) }
16
16
  after { database_cleanup }
17
17
 
18
18
  context 'when a default is set' do
@@ -0,0 +1,44 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ module Troo
4
+ module CLI
5
+ describe Wizard do
6
+ let(:described_class) { Wizard }
7
+ let(:described_instance) { described_class.new }
8
+
9
+ before do
10
+ $stdin.stubs(:gets).returns("y\n")
11
+ Launchy.stubs(:open).returns(true)
12
+ Dir.stubs(:home).returns('./tmp')
13
+ end
14
+
15
+ describe '#start' do
16
+ subject { capture_io { described_class.new.start }.join }
17
+
18
+ it 'returns a welcome message' do
19
+ subject.must_match(/Welcome/)
20
+ end
21
+
22
+ context 'when the user proceeds to step one' do
23
+ it 'returns a thank you message' do
24
+ subject.must_match(/Thank you/)
25
+ end
26
+ end
27
+
28
+ context 'when the user proceeds to step two' do
29
+ it 'returns a completion message' do
30
+ subject.must_match(/All done/)
31
+ end
32
+ end
33
+
34
+ context 'when the user aborts' do
35
+ before { $stdin.stubs(:gets).returns("n\n") }
36
+
37
+ it 'aborts the wizard' do
38
+ proc { subject }.must_raise(Troo::ConfigurationAborted)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -44,5 +44,44 @@ module Troo
44
44
  subject.logs.must_equal(true)
45
45
  end
46
46
  end
47
+
48
+ # describe '#save' do
49
+ # subject do
50
+ # described_class.load('config/trooconf.yml', 'test')
51
+ # .save('config/trooconf.yml', 'test')
52
+ # end
53
+
54
+ # before { File.stubs(:open).returns(outcome) }
55
+
56
+ # context 'when the save is successful' do
57
+ # let(:outcome) { true }
58
+
59
+ # it { subject.must_equal(true) }
60
+ # end
61
+
62
+ # context 'when the save fails' do
63
+ # let(:outcome) { false }
64
+
65
+ # it { subject.must_equal(false) }
66
+ # end
67
+ # end
68
+
69
+ describe '#view' do
70
+ subject do
71
+ described_class.load('config/trooconf.yml', 'test').view
72
+ end
73
+
74
+ it 'returns the configuration' do
75
+ subject.must_equal(" api_key: some_key
76
+ api_token: some_secret
77
+ api_oauth_token: some_oauth_token
78
+ api_oauth_token_secret: some_oauth_token_secret
79
+ allow_remote: true
80
+ logs: true
81
+ name: My Example Test Configuration
82
+ api_url: https://api.trello.com/1
83
+ database: 2")
84
+ end
85
+ end
47
86
  end
48
87
  end
@@ -11,7 +11,8 @@ module Troo
11
11
  member: member,
12
12
  text: 'Some text...',
13
13
  date: 'Wed, Dec 17 at 22:01',
14
- type: :resource_type)
14
+ type: :resource_type,
15
+ username: 'gavinlaking1')
15
16
  }
16
17
  let(:options) { {} }
17
18
  let(:described_instance) { described_class.new(klass, options) }
@@ -67,7 +67,7 @@ module Troo
67
67
  subject { described_class.new.decorator(options) }
68
68
 
69
69
  it 'returns a new instance of the decorator for this model' do
70
- subject.must_be_instance_of(Decorators::Member)
70
+ subject.must_be_instance_of(Decorators::Resource)
71
71
  end
72
72
  end
73
73
 
@@ -19,8 +19,7 @@ class FakeResponse
19
19
  attr_reader :resource, :id, :collection
20
20
 
21
21
  def output
22
- return converted if id
23
- raw
22
+ id ? converted : raw
24
23
  end
25
24
 
26
25
  def converted
@@ -7,21 +7,9 @@ require 'openssl'
7
7
 
8
8
  require_relative 'fake_response'
9
9
 
10
+ -> { its -> { a } }
10
11
  trap('INT') { exit! }
11
12
 
12
- my_server_crt = File.open(File.join('./', 'my-server.crt')).read
13
- my_server_key = File.open(File.join('./', 'my-server.key')).read
14
- webrick_options = {
15
- Port: 8443,
16
- Logger: WEBrick::Log.new($stderr, WEBrick::Log::DEBUG),
17
- DocumentRoot: '/',
18
- SSLEnable: true,
19
- SSLVerifyClient: OpenSSL::SSL::VERIFY_NONE,
20
- SSLCertificate: OpenSSL::X509::Certificate.new(my_server_crt),
21
- SSLPrivateKey: OpenSSL::PKey::RSA.new(my_server_key),
22
- SSLCertName: [['CN', WEBrick::Utils.getservername]]
23
- }
24
-
25
13
  class MyFakeTrello < Sinatra::Base
26
14
  helpers do
27
15
  def fake(resource, id = nil, collection = false)
@@ -123,4 +111,24 @@ class MyFakeTrello < Sinatra::Base
123
111
  end
124
112
  end
125
113
 
126
- Rack::Handler::WEBrick.run MyFakeTrello, webrick_options
114
+ begin
115
+ my_server_crt = File.open(File.dirname(__FILE__) + '/my-server.crt').read
116
+ my_server_key = File.open(File.dirname(__FILE__) + '/my-server.key').read
117
+ webrick_options = {
118
+ Port: 8443,
119
+ Logger: WEBrick::Log.new($stderr, WEBrick::Log::DEBUG),
120
+ DocumentRoot: '/',
121
+ SSLEnable: true,
122
+ SSLVerifyClient: OpenSSL::SSL::VERIFY_NONE,
123
+ SSLCertificate: OpenSSL::X509::Certificate.new(my_server_crt),
124
+ SSLPrivateKey: OpenSSL::PKey::RSA.new(my_server_key),
125
+ SSLCertName: [['CN', WEBrick::Utils.getservername]]
126
+ }
127
+
128
+ Rack::Handler::WEBrick.run MyFakeTrello, webrick_options
129
+ rescue Errno::ENOENT
130
+ puts ""
131
+ puts "Cannot find self-signed SSL certificates."
132
+ puts "Please see the README.md for more information."
133
+ puts ""
134
+ end
data/test/test_helper.rb CHANGED
@@ -3,11 +3,6 @@ require 'minitest/autorun'
3
3
  require 'minitest/pride'
4
4
  require 'fabrication'
5
5
 
6
- SimpleCov.start do
7
- command_name 'MiniTest::Spec'
8
- add_filter '/test/'
9
- end
10
-
11
6
  module MiniTest
12
7
  class Spec
13
8
  class << self
data/troo.gemspec CHANGED
@@ -40,6 +40,7 @@ Gem::Specification.new do |spec|
40
40
  spec.add_dependency "curses", '1.0.1'
41
41
  spec.add_dependency "dispel"
42
42
  spec.add_dependency "json"
43
+ spec.add_dependency "launchy"
43
44
  spec.add_dependency "oauth"
44
45
  spec.add_dependency "ohm", '1.3.2'
45
46
  spec.add_dependency "ohm-contrib", '1.2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: troo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-09 00:00:00.000000000 Z
11
+ date: 2014-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -304,6 +304,20 @@ dependencies:
304
304
  - - ">="
305
305
  - !ruby/object:Gem::Version
306
306
  version: '0'
307
+ - !ruby/object:Gem::Dependency
308
+ name: launchy
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - ">="
312
+ - !ruby/object:Gem::Version
313
+ version: '0'
314
+ type: :runtime
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - ">="
319
+ - !ruby/object:Gem::Version
320
+ version: '0'
307
321
  - !ruby/object:Gem::Dependency
308
322
  name: oauth
309
323
  requirement: !ruby/object:Gem::Requirement
@@ -458,6 +472,7 @@ files:
458
472
  - ".gitignore"
459
473
  - ".rubocop.yml"
460
474
  - ".ruby-version"
475
+ - ".simplecov"
461
476
  - ".travis.yml"
462
477
  - Gemfile
463
478
  - Gemfile.lock
@@ -473,7 +488,6 @@ files:
473
488
  - config/cucumber.yml
474
489
  - config/en.yml
475
490
  - config/help
476
- - config/trello_api.yml
477
491
  - config/trooconf.yml
478
492
  - features/add/board.feature
479
493
  - features/add/card.feature
@@ -538,10 +552,10 @@ files:
538
552
  - lib/troo/cli/refresh.rb
539
553
  - lib/troo/cli/show.rb
540
554
  - lib/troo/cli/thor_fixes.rb
555
+ - lib/troo/cli/wizard.rb
541
556
  - lib/troo/configuration.rb
542
557
  - lib/troo/database.rb
543
558
  - lib/troo/debug.rb
544
- - lib/troo/decorators/member.rb
545
559
  - lib/troo/decorators/resource.rb
546
560
  - lib/troo/helpers/decorator_helpers.rb
547
561
  - lib/troo/helpers/model_helpers.rb
@@ -614,10 +628,10 @@ files:
614
628
  - test/lib/troo/cli/refresh_test.rb
615
629
  - test/lib/troo/cli/show_test.rb
616
630
  - test/lib/troo/cli/thor_fixes_test.rb
631
+ - test/lib/troo/cli/wizard_test.rb
617
632
  - test/lib/troo/configuration_test.rb
618
633
  - test/lib/troo/database_test.rb
619
634
  - test/lib/troo/debug_test.rb
620
- - test/lib/troo/decorators/member_test.rb
621
635
  - test/lib/troo/decorators/resource_test.rb
622
636
  - test/lib/troo/helpers/decorator_helpers_test.rb
623
637
  - test/lib/troo/helpers/model_helpers_test.rb
@@ -778,10 +792,10 @@ test_files:
778
792
  - test/lib/troo/cli/refresh_test.rb
779
793
  - test/lib/troo/cli/show_test.rb
780
794
  - test/lib/troo/cli/thor_fixes_test.rb
795
+ - test/lib/troo/cli/wizard_test.rb
781
796
  - test/lib/troo/configuration_test.rb
782
797
  - test/lib/troo/database_test.rb
783
798
  - test/lib/troo/debug_test.rb
784
- - test/lib/troo/decorators/member_test.rb
785
799
  - test/lib/troo/decorators/resource_test.rb
786
800
  - test/lib/troo/helpers/decorator_helpers_test.rb
787
801
  - test/lib/troo/helpers/model_helpers_test.rb
@@ -1,19 +0,0 @@
1
- version_1:
2
- boards_all: '/members/me/boards'
3
- board_by_id: '/boards/%{external_id}'
4
- card_by_id: '/cards/%{external_id}'
5
- list_by_id: '/lists/%{external_id}'
6
- member_by_id: '/members/%{external_id}'
7
- cards_by_board_id: '/boards/%{external_id}/cards'
8
- cards_by_list_id: '/lists/%{external_id}/cards'
9
- comments_by_board_id: '/boards/%{external_id}/actions'
10
- comments_by_card_id: '/cards/%{external_id}/actions'
11
- comments_by_list_id: '/lists/%{external_id}/actions'
12
- lists_by_board_id: '/boards/%{external_id}/lists'
13
- members_by_board_id: '/boards/%{external_id}/members'
14
- create_board: '/boards'
15
- create_card: '/cards'
16
- create_comment: '/cards/%{external_id}/actions/comments'
17
- create_list: '/lists'
18
- move_card_list: '/cards/%{external_id}/idList'
19
- move_card_board: '/cards/%{external_id}/idBoard'
@@ -1,12 +0,0 @@
1
- module Troo
2
- module Decorators
3
- class Member < Resource
4
- include DecoratorHelpers
5
-
6
- # @return [String]
7
- def username
8
- ['@', klass.username].join
9
- end
10
- end
11
- end
12
- end
@@ -1,8 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- module Troo
4
- module Decorators
5
- describe Member do
6
- end
7
- end
8
- end