troo 0.0.12 → 0.0.13

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile.lock +1 -1
  4. data/README.md +2 -2
  5. data/Rakefile +1 -1
  6. data/bin/troo +0 -20
  7. data/config/en.yml +1 -1
  8. data/lib/troo.rb +1 -1
  9. data/lib/troo/cli/commands/add.rb +2 -2
  10. data/lib/troo/cli/commands/default.rb +2 -2
  11. data/lib/troo/cli/commands/move/card.rb +2 -2
  12. data/lib/troo/cli/commands/refresh.rb +2 -2
  13. data/lib/troo/cli/commands/show/show_boards.rb +2 -2
  14. data/lib/troo/cli/commands/show/show_comments.rb +2 -2
  15. data/lib/troo/cli/commands/status.rb +2 -2
  16. data/lib/troo/cli/thor_fixes.rb +1 -1
  17. data/lib/troo/cli/wizard.rb +40 -5
  18. data/lib/troo/database.rb +2 -2
  19. data/lib/troo/decorators/resource.rb +1 -1
  20. data/lib/troo/launcher.rb +1 -2
  21. data/lib/troo/preference.rb +1 -1
  22. data/lib/troo/retrieval/remote.rb +2 -2
  23. data/lib/troo/version.rb +1 -1
  24. data/test/lib/troo/api/client_test.rb +2 -0
  25. data/test/lib/troo/api/endpoints_test.rb +2 -0
  26. data/test/lib/troo/api/headers_test.rb +2 -0
  27. data/test/lib/troo/cli/add_test.rb +8 -0
  28. data/test/lib/troo/cli/commands/add_test.rb +2 -0
  29. data/test/lib/troo/cli/commands/default_test.rb +2 -0
  30. data/test/lib/troo/cli/commands/move/card_test.rb +2 -0
  31. data/test/lib/troo/cli/commands/refresh/all_test.rb +2 -0
  32. data/test/lib/troo/cli/commands/refresh_test.rb +2 -0
  33. data/test/lib/troo/cli/commands/show/show_boards_test.rb +2 -0
  34. data/test/lib/troo/cli/commands/show/show_comments_test.rb +2 -0
  35. data/test/lib/troo/cli/commands/show_test.rb +2 -0
  36. data/test/lib/troo/cli/commands/status_test.rb +2 -0
  37. data/test/lib/troo/cli/default_test.rb +6 -0
  38. data/test/lib/troo/cli/main_test.rb +10 -0
  39. data/test/lib/troo/cli/refresh_test.rb +8 -0
  40. data/test/lib/troo/cli/show_test.rb +10 -0
  41. data/test/lib/troo/cli/thor_fixes_test.rb +2 -0
  42. data/test/lib/troo/cli/wizard_test.rb +20 -0
  43. data/test/lib/troo/configuration_test.rb +4 -0
  44. data/test/lib/troo/database_test.rb +18 -0
  45. data/test/lib/troo/decorators/resource_test.rb +66 -0
  46. data/test/lib/troo/helpers/decorator_helpers_test.rb +2 -0
  47. data/test/lib/troo/helpers/model_helpers_test.rb +27 -3
  48. data/test/lib/troo/helpers/remote_model_helpers_test.rb +16 -0
  49. data/test/lib/troo/models/behaviours/set_default_test.rb +4 -0
  50. data/test/lib/troo/models/board_test.rb +2 -0
  51. data/test/lib/troo/models/card_test.rb +2 -0
  52. data/test/lib/troo/models/comment_test.rb +4 -0
  53. data/test/lib/troo/models/list_test.rb +4 -0
  54. data/test/lib/troo/models/member_test.rb +4 -0
  55. data/test/lib/troo/persistence/local_test.rb +2 -0
  56. data/test/lib/troo/preference_test.rb +2 -0
  57. data/test/lib/troo/remote/{comment_data_board.rb → comment_data_board_test.rb} +0 -0
  58. data/test/lib/troo/retrieval/local_test.rb +8 -2
  59. data/test/lib/troo/retrieval/remote_test.rb +7 -1
  60. data/test/lib/troo/version_test.rb +9 -0
  61. data/test/system_test.sh +0 -3
  62. metadata +6 -6
  63. data/test/lib/troo/models/database_test.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f4539888216b2fee0e90cc5a1cffd97a20e8d6d
4
- data.tar.gz: e35fc3a74a984d5f3eb0a76f4331d69fe85f5f78
3
+ metadata.gz: 355a88b81a74299dc28bff18c0a914cbcf5afda2
4
+ data.tar.gz: 0cacd07a0f2d44cc02809293dcfae5cebbc5bdab
5
5
  SHA512:
6
- metadata.gz: a90ddbf943db77a1544cf98590ba2d4fe2eb491edcfe99cbf254a2f792e88cfa6e7150bf9a71f230e5355e2d140f7a58ed19ede803a7d9db51cd06ca36bcf4db
7
- data.tar.gz: 94686af4d0318e6fea58e6392ea4475dcb060a2ea00cd81af47168dca8fe5c227351f8053a72b9bdf0f0e019be16d64c9cf988e2c6bc9d33589ec2afedc6ec08
6
+ metadata.gz: 4f59cc95a9bd5520f7002f6bd580eb58b03dc32ff2c4457248121915a19194246bbcc59cc7e120b00603dc8ed230504f78e5279a06d943b40ab6adb0a40796a2
7
+ data.tar.gz: ff15f1ab11fe9b71c3858870727d16d8b251acc1cf1e8fb09a12a6706f7dbe19805555955a86fd702ff2d72a588e0af3c89f132902baf10801479c9266f5f390
data/.gitignore CHANGED
@@ -24,4 +24,5 @@ test/support/fake_trello/my-server.key
24
24
 
25
25
  test/support/private_remotes/*.json
26
26
  .gemtags
27
- .tags
27
+ .tags
28
+ .DS_Store
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- troo (0.0.12)
4
+ troo (0.0.13)
5
5
  addressable
6
6
  curses (= 1.0.1)
7
7
  dispel
data/README.md CHANGED
@@ -45,7 +45,7 @@ Simply run `troo wizard` and follow the on screen instructions.
45
45
 
46
46
  https://trello.com/1/connect?key=your_key_here&name=troo&response_type=token&scope=read,write
47
47
 
48
- 4) Add your authentication tokens to the configuration file `.trooconf` in your home directory. (This file will be created for you the first time you run `troo init`)
48
+ 4) Add your authentication tokens to the configuration file `.trooconf` in your home directory. (This file will be created for you the first time you run `troo wizard`)
49
49
 
50
50
  5) Have fun, and tweet me @gavinlaking if you like it.
51
51
 
@@ -73,7 +73,7 @@ Simply run `troo wizard` and follow the on screen instructions.
73
73
 
74
74
  - Prepare to use Troo.
75
75
 
76
- troo init
76
+ troo wizard
77
77
 
78
78
  - Move card with <card_id> to list with <list_id> optionally to another board with <board_id>.
79
79
 
data/Rakefile CHANGED
@@ -20,6 +20,6 @@ if File.exist?(Dir.home + '/.trooconf')
20
20
  Rake::Task['cucumber'].execute
21
21
  else
22
22
  warn "\nConfiguration cannot be found, please run `troo " \
23
- "init` or `./bin/troo init` first.\n"
23
+ "wizard` or `./bin/troo wizard` first.\n"
24
24
  exit(1)
25
25
  end
data/bin/troo CHANGED
@@ -8,26 +8,6 @@ if ARGV.include?('autocomplete')
8
8
  %w{add cleanup config default init move refresh
9
9
  show status version}.select { |e| /^#{command}/ =~ e }
10
10
  .map { |c| puts c }
11
- elsif ARGV.include?('init')
12
- require 'fileutils'
13
-
14
- source = File.dirname(__FILE__) + '/../config/trooconf.yml'
15
- destination = Dir.home + '/.trooconf'
16
-
17
- if File.exist?(destination)
18
- puts "\nA configuration file already exists in your home " \
19
- "directory.\n\n"
20
- else
21
- print "\nCreating a configuration file in your home directory..."
22
-
23
- FileUtils.cp(source, destination)
24
-
25
- sleep 1 # simulate work being done
26
- print " done.\n\n"
27
-
28
- help = File.read(File.dirname(__FILE__) + '/../config/help')
29
- print help
30
- end
31
11
  elsif ARGV.include?('path')
32
12
  puts File.expand_path File.dirname(__FILE__)
33
13
  else
@@ -1,6 +1,6 @@
1
1
  en:
2
2
  configuration:
3
- not_found: 'Configuration cannot be found, please run `troo init` or `./bin/troo init` first.'
3
+ not_found: 'Configuration cannot be found, please run `troo wizard` or `./bin/troo wizard` first.'
4
4
  cli:
5
5
  add:
6
6
  board: 'Add a new board with <name>; prompts if <name> not provided.'
@@ -15,7 +15,7 @@ module Troo
15
15
  def self.configuration(file = Dir.home + '/.trooconf', env = 'default')
16
16
  unless File.exist?(file)
17
17
  warn "\nConfiguration cannot be found, please run `troo " \
18
- "init` or `./bin/troo init` first.\n"
18
+ "wizard` or `./bin/troo wizard` first.\n"
19
19
  file = root_path + '/config/trooconf.yml'
20
20
  end
21
21
 
@@ -7,7 +7,7 @@ module Troo
7
7
  # @param []
8
8
  # @param []
9
9
  # @param [Hash]
10
- # @return []
10
+ # @return [String]
11
11
  def dispatch(value, id = nil, options = {})
12
12
  new(value, id, options).add
13
13
  end
@@ -21,7 +21,7 @@ module Troo
21
21
  @value, @id, @options = value, id, options
22
22
  end
23
23
 
24
- # @return []
24
+ # @return [String]
25
25
  def add
26
26
  return success if create
27
27
  error
@@ -4,7 +4,7 @@ module Troo
4
4
  class << self
5
5
  # @param []
6
6
  # @param []
7
- # @return []
7
+ # @return [String]
8
8
  def dispatch(klass, id)
9
9
  new(klass, id).set_default
10
10
  end
@@ -17,7 +17,7 @@ module Troo
17
17
  @klass, @id = klass, id
18
18
  end
19
19
 
20
- # @return []
20
+ # @return [String]
21
21
  def set_default
22
22
  return success if resource && resource.set_default!
23
23
  error
@@ -6,7 +6,7 @@ module Troo
6
6
  # @param []
7
7
  # @param []
8
8
  # @param []
9
- # @return []
9
+ # @return [String]
10
10
  def dispatch(card_id, list_id, board_id = nil)
11
11
  new(card_id, list_id, board_id).move
12
12
  end
@@ -20,7 +20,7 @@ module Troo
20
20
  @card_id, @list_id, @board_id = card_id, list_id, board_id
21
21
  end
22
22
 
23
- # @return []
23
+ # @return [String]
24
24
  def move
25
25
  return 'Card cannot be found.' if card_not_found?
26
26
  return 'List cannot be found.' if list_not_found?
@@ -6,7 +6,7 @@ module Troo
6
6
  class << self
7
7
  # @param []
8
8
  # @param []
9
- # @return []
9
+ # @return [String]
10
10
  def dispatch(klass, id = nil)
11
11
  new(klass, id).refresh
12
12
  end
@@ -19,7 +19,7 @@ module Troo
19
19
  @klass, @id = klass, id
20
20
  end
21
21
 
22
- # @return []
22
+ # @return [String]
23
23
  def refresh
24
24
  return not_found if not_found?
25
25
  return many_success if multiple_refreshed?
@@ -2,7 +2,7 @@ module Troo
2
2
  module Commands
3
3
  class ShowBoards
4
4
  class << self
5
- # @return []
5
+ # @return [String]
6
6
  def dispatch
7
7
  new.render
8
8
  end
@@ -10,7 +10,7 @@ module Troo
10
10
 
11
11
  def initialize; end
12
12
 
13
- # @return []
13
+ # @return [String]
14
14
  def render
15
15
  return presenter if resources.any?
16
16
  error
@@ -5,7 +5,7 @@ module Troo
5
5
 
6
6
  class << self
7
7
  # @param []
8
- # @return []
8
+ # @return [String]
9
9
  def dispatch(id = nil)
10
10
  new(id).render
11
11
  end
@@ -17,7 +17,7 @@ module Troo
17
17
  @id = id
18
18
  end
19
19
 
20
- # @return []
20
+ # @return [String]
21
21
  def render
22
22
  if resource
23
23
  presenter
@@ -3,7 +3,7 @@ module Troo
3
3
  class Status
4
4
  class << self
5
5
  # @param []
6
- # @return []
6
+ # @return [String]
7
7
  def dispatch(klass)
8
8
  new(klass).report_status
9
9
  end
@@ -15,7 +15,7 @@ module Troo
15
15
  @klass = klass
16
16
  end
17
17
 
18
- # @return []
18
+ # @return [String]
19
19
  def report_status
20
20
  return success if resource
21
21
  error
@@ -4,7 +4,7 @@ module Troo
4
4
  # @param []
5
5
  # @param []
6
6
  # @param []
7
- # @return []
7
+ # @return [String]
8
8
  def self.banner(command, namespace = nil, subcommand = false)
9
9
  [basename, @package_name, command.usage].compact.join(' ')
10
10
  end
@@ -9,10 +9,12 @@ module Troo
9
9
  def start
10
10
  say Troo::Formatter.wordwrap(welcome_message)
11
11
 
12
- proceed?
13
- step_one!
12
+ step_zero!
14
13
 
15
14
  say Troo::Formatter.wordwrap(step_one_message)
15
+ step_one!
16
+
17
+ say Troo::Formatter.wordwrap(step_two_message)
16
18
 
17
19
  proceed?
18
20
  step_two!
@@ -39,6 +41,18 @@ module Troo
39
41
  raise ConfigurationAborted unless yes?(user_input('Proceed?'))
40
42
  end
41
43
 
44
+ def step_zero!
45
+ if destination_exists?
46
+ say "A configuration file already exists.\n"
47
+
48
+ raise ConfigurationAborted unless yes?(user_input('Overwrite?'))
49
+ end
50
+
51
+ copy_configuration
52
+
53
+ say "A configuration file was created.\n"
54
+ end
55
+
42
56
  def step_one!
43
57
  Launchy.open(generate_url)
44
58
  config.api_key = ask(user_input('Key:'))
@@ -52,13 +66,18 @@ module Troo
52
66
  end
53
67
 
54
68
  def welcome_message
55
- "Welcome to Troo. This wizard will help you configure your " \
56
- "API credentials for Trello. First, you'll need to sign in " \
69
+ "Welcome to Troo. This wizard will create a configuration file " \
70
+ "in your home directory and help you configure your API credentials " \
71
+ "for Trello.\n\n"
72
+ end
73
+
74
+ def step_one_message
75
+ "First, you'll need to sign in " \
57
76
  "to Trello in the normal way. Copy the API key and paste " \
58
77
  "when prompted, then do the same for the secret.\n"
59
78
  end
60
79
 
61
- def step_one_message
80
+ def step_two_message
62
81
  "Thank you. You must now allow this application to use " \
63
82
  "Trello account. Copy and paste the token when prompted.\n"
64
83
  end
@@ -66,6 +85,22 @@ module Troo
66
85
  def user_input(value)
67
86
  [Esc.yellow, value, Esc.reset].join
68
87
  end
88
+
89
+ def copy_configuration
90
+ FileUtils.cp(source, destination)
91
+ end
92
+
93
+ def destination_exists?
94
+ File.exist?(destination)
95
+ end
96
+
97
+ def destination
98
+ Dir.home + '/.trooconf'
99
+ end
100
+
101
+ def source
102
+ File.dirname(__FILE__) + '/../../../config/trooconf.yml'
103
+ end
69
104
  end
70
105
  end
71
106
  end
@@ -11,12 +11,12 @@ module Troo
11
11
 
12
12
  # @param []
13
13
  # @param [Hash]
14
- # @return []
14
+ # @return [Troo::Database]
15
15
  def initialize(configuration, options = {})
16
16
  @configuration, @options = configuration, options
17
17
  end
18
18
 
19
- # @return []
19
+ # @return [NilClass]
20
20
  def connect
21
21
  Ohm.connect(db: configuration.database)
22
22
  end
@@ -39,7 +39,7 @@ module Troo
39
39
  end
40
40
  end
41
41
 
42
- # @return [String]
42
+ # @return [Fixnum]
43
43
  def id
44
44
  (klass.type == :card) ? klass.short_id : klass.id
45
45
  end
@@ -26,8 +26,7 @@ module Troo
26
26
  rescue ConfigurationNotFound
27
27
  pad do
28
28
  puts "Configuration cannot be found, please run " \
29
- "`troo wizard` for help, or 'troo init' to manually " \
30
- "configure."
29
+ "`troo wizard` to get started."
31
30
  end
32
31
  rescue ConfigurationAborted
33
32
  pad { puts 'Configuration wizard aborted.' }
@@ -9,7 +9,7 @@ module Troo
9
9
 
10
10
  class << self
11
11
  # @param [Hash]
12
- # @return []
12
+ # @return [String]
13
13
  def view(parameters)
14
14
  new(parameters).view
15
15
  end
@@ -16,14 +16,14 @@ module Troo
16
16
  # @param []
17
17
  # @param []
18
18
  # @param [Hash]
19
- # @return []
19
+ # @return [Troo::Retrieval::Remote]
20
20
  def initialize(klass, external_id, options = {})
21
21
  @klass = klass
22
22
  @external_id = external_id
23
23
  @options = options
24
24
  end
25
25
 
26
- # @return []
26
+ # @return [Array]
27
27
  def fetch
28
28
  return [] if none?
29
29
  return persist if persist?
@@ -1,3 +1,3 @@
1
1
  module Troo
2
- VERSION = '0.0.12'
2
+ VERSION = '0.0.13'
3
3
  end
@@ -26,6 +26,8 @@ module Troo
26
26
  describe '#perform' do
27
27
  subject { described_class.perform(parameters) }
28
28
 
29
+ it { subject.must_be_instance_of(Array) }
30
+
29
31
  context 'when all required parameters are provided' do
30
32
  context 'and the API request returns a collection' do
31
33
  let(:parsed_response) {
@@ -11,6 +11,8 @@ module Troo
11
11
 
12
12
  subject { described_class.interpolate(endpoint, value) }
13
13
 
14
+ it { subject.must_be_instance_of(String) }
15
+
14
16
  context 'when the endpoint exists' do
15
17
  it 'returns the interpolated endpoint' do
16
18
  subject.must_equal('/boards/20001')
@@ -12,6 +12,8 @@ module Troo
12
12
  described_class.build!(uri, headers)['Authorization']
13
13
  end
14
14
 
15
+ it { subject.must_be_instance_of(String) }
16
+
15
17
  it 'returns the built headers' do
16
18
  subject.must_match(/consumer_key/)
17
19
  subject.must_match(/nonce/)
@@ -20,6 +20,8 @@ module Troo
20
20
  context 'when a value is provided' do
21
21
  let(:value) { 'some value' }
22
22
 
23
+ it { subject.must_be_instance_of(String) }
24
+
23
25
  it 'returns the output of the command' do
24
26
  subject.must_match(/could not be created/)
25
27
  end
@@ -45,6 +47,8 @@ module Troo
45
47
  context 'when a value is provided' do
46
48
  let(:value) { 'some value' }
47
49
 
50
+ it { subject.must_be_instance_of(String) }
51
+
48
52
  it 'returns the output of the command' do
49
53
  subject.must_match(/could not be created/)
50
54
  end
@@ -70,6 +74,8 @@ module Troo
70
74
  context 'when a value is provided' do
71
75
  let(:value) { 'some value' }
72
76
 
77
+ it { subject.must_be_instance_of(String) }
78
+
73
79
  it 'returns the output of the command' do
74
80
  subject.must_match(/could not be created/)
75
81
  end
@@ -95,6 +101,8 @@ module Troo
95
101
  context 'when a value is provided' do
96
102
  let(:value) { 'some value' }
97
103
 
104
+ it { subject.must_be_instance_of(String) }
105
+
98
106
  it 'returns the output of the command' do
99
107
  subject.must_match(/could not be created/)
100
108
  end