troo 0.0.10 → 0.0.11

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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gemfile.lock +7 -7
  4. data/README.md +39 -40
  5. data/Rakefile +17 -11
  6. data/features/step_definitions/troo_steps.rb +1 -1
  7. data/lib/troo.rb +24 -35
  8. data/lib/troo/api/client.rb +3 -0
  9. data/lib/troo/api/endpoints.rb +7 -1
  10. data/lib/troo/api/headers.rb +7 -0
  11. data/lib/troo/api/request.rb +9 -0
  12. data/lib/troo/api/response.rb +3 -0
  13. data/lib/troo/cli/add.rb +11 -0
  14. data/lib/troo/cli/commands/add.rb +9 -0
  15. data/lib/troo/cli/commands/default.rb +7 -0
  16. data/lib/troo/cli/commands/move/card.rb +9 -0
  17. data/lib/troo/cli/commands/refresh.rb +7 -0
  18. data/lib/troo/cli/commands/refresh/all.rb +2 -0
  19. data/lib/troo/cli/commands/show.rb +7 -0
  20. data/lib/troo/cli/commands/show/show_boards.rb +2 -0
  21. data/lib/troo/cli/commands/show/show_comments.rb +5 -0
  22. data/lib/troo/cli/commands/status.rb +5 -0
  23. data/lib/troo/cli/default.rb +6 -0
  24. data/lib/troo/cli/main.rb +8 -0
  25. data/lib/troo/cli/refresh.rb +7 -0
  26. data/lib/troo/cli/show.rb +9 -0
  27. data/lib/troo/cli/thor_fixes.rb +4 -0
  28. data/lib/troo/configuration.rb +5 -30
  29. data/lib/troo/database.rb +7 -0
  30. data/lib/troo/debug.rb +3 -0
  31. data/lib/troo/decorators/member.rb +1 -0
  32. data/lib/troo/decorators/resource.rb +19 -0
  33. data/lib/troo/helpers/model_helpers.rb +13 -0
  34. data/lib/troo/helpers/remote_model_helpers.rb +9 -0
  35. data/lib/troo/launcher.rb +44 -0
  36. data/lib/troo/models/behaviours/set_default.rb +6 -0
  37. data/lib/troo/models/board.rb +9 -0
  38. data/lib/troo/models/card.rb +15 -0
  39. data/lib/troo/models/comment.rb +9 -0
  40. data/lib/troo/models/list.rb +9 -0
  41. data/lib/troo/models/member.rb +8 -0
  42. data/lib/troo/models/refresh.rb +2 -0
  43. data/lib/troo/options.rb +9 -0
  44. data/lib/troo/persistence/local.rb +8 -0
  45. data/lib/troo/preference.rb +29 -0
  46. data/lib/troo/presentation/formatter.rb +12 -0
  47. data/lib/troo/presentation/sentence.rb +7 -0
  48. data/lib/troo/presentation/template.rb +7 -0
  49. data/lib/troo/presenters/board.rb +8 -0
  50. data/lib/troo/presenters/card.rb +4 -0
  51. data/lib/troo/presenters/comment.rb +4 -0
  52. data/lib/troo/presenters/list.rb +5 -0
  53. data/lib/troo/presenters/member.rb +4 -0
  54. data/lib/troo/presenters/resource.rb +7 -0
  55. data/lib/troo/remote/board.rb +6 -0
  56. data/lib/troo/remote/card.rb +7 -0
  57. data/lib/troo/remote/comment.rb +10 -0
  58. data/lib/troo/remote/list.rb +6 -0
  59. data/lib/troo/remote/member.rb +6 -0
  60. data/lib/troo/remote/persistence/board.rb +7 -0
  61. data/lib/troo/remote/persistence/card.rb +9 -0
  62. data/lib/troo/remote/persistence/comment.rb +7 -0
  63. data/lib/troo/remote/persistence/list.rb +7 -0
  64. data/lib/troo/remote/persistence/move_card.rb +9 -0
  65. data/lib/troo/retrieval/local.rb +16 -0
  66. data/lib/troo/retrieval/remote.rb +9 -0
  67. data/lib/troo/troo.rb +4 -0
  68. data/lib/troo/version.rb +1 -1
  69. data/test/lib/troo/api/client_test.rb +4 -4
  70. data/test/lib/troo/api/response_test.rb +27 -0
  71. data/test/lib/troo/cli/commands/refresh/all_test.rb +2 -2
  72. data/test/lib/troo/cli/commands/refresh_test.rb +2 -2
  73. data/test/lib/troo/configuration_test.rb +1 -1
  74. data/test/lib/troo/database_test.rb +7 -0
  75. data/test/lib/troo/decorators/resource_test.rb +5 -3
  76. data/test/lib/troo/launcher_test.rb +7 -0
  77. data/test/lib/troo/models/card_test.rb +5 -5
  78. data/test/lib/troo/options_test.rb +7 -0
  79. data/test/lib/troo/preference_test.rb +21 -0
  80. data/test/lib/troo/presentation/formatter_test.rb +8 -8
  81. data/test/lib/troo/presenters/member_test.rb +33 -3
  82. data/test/lib/troo/presenters/resource_test.rb +2 -2
  83. data/test/lib/troo/remote/board_test.rb +2 -2
  84. data/test/lib/troo/remote/card_test.rb +2 -2
  85. data/test/lib/troo/remote/comment_test.rb +2 -2
  86. data/test/lib/troo/remote/list_test.rb +2 -2
  87. data/test/lib/troo/remote/member_test.rb +2 -2
  88. data/test/lib/troo/remote/persistence/card_test.rb +2 -2
  89. data/test/lib/troo/remote/persistence/comment_test.rb +2 -2
  90. data/test/lib/troo/remote/persistence/list_test.rb +2 -2
  91. data/test/lib/troo_test.rb +5 -0
  92. data/test/support/remotes/board.json +140 -0
  93. data/test/test_helper.rb +1 -1
  94. data/troo.gemspec +2 -1
  95. metadata +34 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25d9e705a6baae8f54e59d630224178f8752c229
4
- data.tar.gz: f02c744c0f64a0a18448b0668d6a7803fc47f4c5
3
+ metadata.gz: e68baa9983b5fa453d4feceb5542febfa90bb445
4
+ data.tar.gz: 3b3a8343f7f8b1d80ac3ee811faa29fdaefde523
5
5
  SHA512:
6
- metadata.gz: fdbd5da52500592454d7c5f25cb60259697bba0401a7a78966b0c06332682f0a215098135ef805cda54235676d5f9d01ee27ec44b27e1bcd7409a364dbc8af7d
7
- data.tar.gz: 700c9f4d5776861fe287b689e5d3b79472c2ac2bbe9863f167d063719da7885d6a71c8fb0c5c793228b82650966405a380dee11b7c0425835f7539e40e17c664
6
+ metadata.gz: 58654c3f6350bd6e016a44b94191263577cb655835882926896c553c7b8c10e79eb8b387130b71b7ced574533a0a8f9dfc47b9158263616836a67b2f5f3c8f9f
7
+ data.tar.gz: f3d8a493bba1fcc134496dd3f437b7ba613ba978802cd45fd74786d46adedfdaae4e1ea579148eaec983b20a8864ecc42485c32016db149e07bc40b224951259
data/.gitignore CHANGED
@@ -23,3 +23,5 @@ test/support/fake_trello/my-server.crt
23
23
  test/support/fake_trello/my-server.key
24
24
 
25
25
  test/support/private_remotes/*.json
26
+ .gemtags
27
+ .tags
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- troo (0.0.9)
4
+ troo (0.0.11)
5
5
  addressable
6
- curses (= 1.0.0)
6
+ curses (= 1.0.1)
7
7
  dispel
8
8
  json
9
9
  oauth
@@ -26,7 +26,6 @@ GEM
26
26
  cucumber (>= 1.1.1)
27
27
  rspec-expectations (>= 2.7.0)
28
28
  ast (1.1.0)
29
- atomic (1.1.16)
30
29
  axiom-types (0.1.1)
31
30
  descendants_tracker (~> 0.0.4)
32
31
  ice_nine (~> 0.11.0)
@@ -50,7 +49,7 @@ GEM
50
49
  gherkin (~> 2.12)
51
50
  multi_json (>= 1.7.5, < 2.0)
52
51
  multi_test (>= 0.1.1)
53
- curses (1.0.0)
52
+ curses (1.0.1)
54
53
  descendants_tracker (0.0.4)
55
54
  thread_safe (~> 0.3, >= 0.3.1)
56
55
  diff-lcs (1.2.5)
@@ -147,11 +146,10 @@ GEM
147
146
  term-ansicolor (1.3.0)
148
147
  tins (~> 1.0)
149
148
  thor (0.18.1)
150
- thread_safe (0.3.1)
151
- atomic (>= 1.1.7, < 2)
149
+ thread_safe (0.3.3)
152
150
  tilt (1.4.1)
153
151
  timers (1.1.0)
154
- tins (1.0.1)
152
+ tins (1.1.0)
155
153
  vcr (2.9.0)
156
154
  virtus (1.0.2)
157
155
  axiom-types (~> 0.1)
@@ -162,6 +160,7 @@ GEM
162
160
  addressable (>= 2.2.7)
163
161
  crack (>= 0.3.2)
164
162
  yajl-ruby (1.2.0)
163
+ yard (0.8.7.4)
165
164
 
166
165
  PLATFORMS
167
166
  ruby
@@ -184,3 +183,4 @@ DEPENDENCIES
184
183
  troo!
185
184
  vcr
186
185
  webmock
186
+ yard
data/README.md CHANGED
@@ -4,6 +4,45 @@
4
4
 
5
5
  CLI interface for Trello. Named after Trello's mascot 'Roo'.
6
6
 
7
+ ## Requirements
8
+
9
+ - A Trello account with API key/secret.
10
+ - MacOSX/Linux (I've not tested with Windows, sorry.)
11
+ - Ruby 2.1.1 (>= 1.9.3 should be fine, developed mainly in 2.1.0 so far.)
12
+ - Redis.
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'troo'
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install troo
27
+
28
+ ## Usage
29
+
30
+ You will need user authentication tokens to access your Trello account.
31
+
32
+ 1) Sign in to Trello in the normal way.
33
+
34
+ 2) Create your developer key at Trello:
35
+
36
+ https://trello.com/1/appKey/generate
37
+
38
+ 3) Go to:
39
+
40
+ https://trello.com/1/connect?key=your_key_here&name=troo&response_type=token&scope=read,write
41
+
42
+ 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`)
43
+
44
+ 5) Have fun, and tweet me @gavinlaking if you like it.
45
+
7
46
  ## Commands
8
47
 
9
48
  - Add board, list, card or comment.
@@ -50,46 +89,6 @@ CLI interface for Trello. Named after Trello's mascot 'Roo'.
50
89
 
51
90
  troo version
52
91
 
53
-
54
- ## Requirements
55
-
56
- - A Trello account with API key/secret.
57
- - MacOSX/Linux (I've not tested with Windows, sorry.)
58
- - Ruby 2.1.1 (>= 1.9.3 should be fine, developed mainly in 2.1.0 so far.)
59
- - Redis.
60
-
61
- ## Installation
62
-
63
- Add this line to your application's Gemfile:
64
-
65
- gem 'troo'
66
-
67
- And then execute:
68
-
69
- $ bundle
70
-
71
- Or install it yourself as:
72
-
73
- $ gem install troo
74
-
75
- ## Usage
76
-
77
- You will need user authentication tokens to access your Trello account.
78
-
79
- 1) Sign in to Trello in the normal way.
80
-
81
- 2) Create your developer key at Trello:
82
-
83
- https://trello.com/1/appKey/generate
84
-
85
- 3) Go to:
86
-
87
- https://trello.com/1/connect?key=your_key_here&name=troo&response_type=token&scope=read,write
88
-
89
- 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`)
90
-
91
- 5) Have fun, and tweet me @gavinlaking if you like it.
92
-
93
92
  ## Todo
94
93
 
95
94
  - Fix multitude of sins.
data/Rakefile CHANGED
@@ -3,17 +3,23 @@ require "rake/testtask"
3
3
  require 'cucumber'
4
4
  require 'cucumber/rake/task'
5
5
 
6
- Cucumber::Rake::Task.new(:cucumber) do |t|
7
- t.cucumber_opts = "features --format progress"
8
- end
6
+ if File.exist?(Dir.home + '/.trooconf')
7
+ Cucumber::Rake::Task.new(:cucumber) do |t|
8
+ t.cucumber_opts = "features --format progress"
9
+ end
9
10
 
10
- Rake::TestTask.new do |t|
11
- t.libs << 'lib/troo'
12
- t.test_files = FileList["test/lib/troo/*_test.rb",
13
- "test/lib/troo/**/*_test.rb"]
14
- t.verbose = false
15
- end
11
+ Rake::TestTask.new do |t|
12
+ t.libs << 'lib/troo'
13
+ t.test_files = FileList["test/lib/troo/*_test.rb",
14
+ "test/lib/troo/**/*_test.rb"]
15
+ t.verbose = false
16
+ end
16
17
 
17
- task :default => :test
18
+ task :default => :test
18
19
 
19
- Rake::Task['cucumber'].execute
20
+ Rake::Task['cucumber'].execute
21
+ else
22
+ warn "\nConfiguration cannot be found, please run 'troo " \
23
+ "init' or './bin/troo init' first.\n"
24
+ exit(1)
25
+ end
@@ -7,7 +7,7 @@ Then(/^the output should be the version number of troo$/) do
7
7
  end
8
8
 
9
9
  Before do
10
- config = Troo::Configuration.load('config/trooconf.yml', :test)
10
+ config = Troo::Configuration.load('config/trooconf.yml', 'test')
11
11
  Ohm.connect(db: config.database)
12
12
  end
13
13
 
@@ -8,58 +8,47 @@ module Troo
8
8
  InvalidAccessToken = Class.new(StandardError)
9
9
  EndpointNotFound = Class.new(StandardError)
10
10
 
11
- def self.configuration(file = Dir.home + '/.trooconf', env = :default)
11
+ # @param []
12
+ # @param [String]
13
+ # @return []
14
+ def self.configuration(file = Dir.home + '/.trooconf', env = 'default')
15
+ unless File.exist?(file)
16
+ warn "\nConfiguration cannot be found, please run 'troo " \
17
+ "init' or './bin/troo init' first.\n"
18
+ file = configuration_path + '/trooconf.yml'
19
+ end
20
+
12
21
  @configuration ||= Troo::Configuration.load(file, env)
13
22
  end
14
23
 
15
- def self.endpoints(version = :version_1)
24
+ # @param [String]
25
+ # @return []
26
+ def self.endpoints(version = 'version_1')
16
27
  @endpoints ||= Troo::API::Endpoints
17
- .load(File.dirname(__FILE__) + '/../config/trello_api.yml', version)
28
+ .load(configuration_path + '/trello_api.yml', version)
18
29
  end
19
- endpoints
20
30
 
31
+ # @return []
21
32
  def self.logger
22
33
  @logger ||= Logger
23
- .new(File.dirname(__FILE__) + '/../logs/troo.log').tap do |log|
34
+ .new(log_path + '/troo.log').tap do |log|
24
35
  log.formatter = proc do |mode, time, prog, msg|
25
- "#{time.iso8601} #{mode}:\n#{msg}\n\n"
36
+ "#{time.iso8601} #{mode}:\n#{msg}\n"
26
37
  end
27
38
  end
28
39
  end
29
40
 
30
- # RestClient.log = File.dirname(__FILE__) + '/../logs/restclient.log'
41
+ # RestClient.log = log_dir + '/restclient.log'
31
42
 
32
43
  Database.connect(configuration)
33
44
 
34
- class Launcher
35
- def initialize(argv, stdin = STDIN,
36
- stdout = STDOUT,
37
- stderr = STDERR,
38
- kernel = Kernel)
39
- @argv = argv
40
- @stdin = stdin
41
- @stdout = stdout
42
- @stderr = stderr
43
- @kernel = kernel
44
- end
45
+ private
45
46
 
46
- def execute!
47
- $stdin, $stdout, $stderr = @stdin, @stdout, @stderr
48
- pad { Troo::CLI::Main.start(@argv) }
49
- @kernel.exit(0)
50
- rescue Redis::CannotConnectError
51
- pad { puts 'Cannot connect to Redis database.' }
52
- @kernel.exit(1)
53
- ensure
54
- $stdin, $stdout, $stderr = STDIN, STDOUT, STDERR
55
- end
56
-
57
- private
47
+ def self.configuration_path
48
+ File.dirname(__FILE__) + '/../config'
49
+ end
58
50
 
59
- def pad
60
- puts
61
- yield
62
- puts
63
- end
51
+ def self.log_path
52
+ File.dirname(__FILE__) + '/../logs'
64
53
  end
65
54
  end
@@ -10,11 +10,14 @@ module Troo
10
10
  attribute :model
11
11
 
12
12
  class << self
13
+ # @param [Hash]
14
+ # @return [Array]
13
15
  def perform(parameters)
14
16
  new(parameters).perform
15
17
  end
16
18
  end
17
19
 
20
+ # @return [Array]
18
21
  def perform
19
22
  return [] unless allow_remote?
20
23
  return [] if missing_parameters?
@@ -25,11 +25,17 @@ module Troo
25
25
  end
26
26
 
27
27
  class << self
28
+ # @param [String]
29
+ # @param [String]
30
+ # @return [Troo::API::Endpoints]
28
31
  def load(file, version)
29
- new(YAML.load_file(file)[version.to_s])
32
+ new(YAML.load_file(file)[version])
30
33
  end
31
34
  end
32
35
 
36
+ # @param [Symbol]
37
+ # @param [Hash]
38
+ # @return [String, EndpointNotFound]
33
39
  def interpolate!(endpoint, value = {})
34
40
  return send(endpoint) % value if respond_to?(endpoint)
35
41
  fail EndpointNotFound
@@ -2,15 +2,22 @@ module Troo
2
2
  module API
3
3
  class Headers
4
4
  class << self
5
+ # @param [String]
6
+ # @param [Hash]
7
+ # @return [Hash]
5
8
  def build!(uri, headers = {})
6
9
  new(uri, headers).build!
7
10
  end
8
11
  end
9
12
 
13
+ # @param [String]
14
+ # @param [Hash]
15
+ # @return [Troo::API::Headers]
10
16
  def initialize(uri, headers = {})
11
17
  @uri, @headers = uri, headers
12
18
  end
13
19
 
20
+ # @return [Hash]
14
21
  def build!
15
22
  defaults.merge!(@headers)
16
23
  end
@@ -2,15 +2,24 @@ module Troo
2
2
  module API
3
3
  class Request
4
4
  class << self
5
+ # @param [Symbol]
6
+ # @param [String]
7
+ # @param [Hash]
8
+ # @return [Response, ErrorResponse]
5
9
  def make(verb, uri, query = {})
6
10
  new(verb, uri, query).make
7
11
  end
8
12
  end
9
13
 
14
+ # @param [Symbol]
15
+ # @param [String]
16
+ # @param [Hash]
17
+ # @return [Troo::API::Request]
10
18
  def initialize(verb, uri, query = {})
11
19
  @verb, @uri, @query = verb, uri, query
12
20
  end
13
21
 
22
+ # @return [Response, ErrorResponse]
14
23
  def make
15
24
  @request ||= request
16
25
  rescue RestClient::Exception => e
@@ -9,11 +9,14 @@ module Troo
9
9
  end
10
10
 
11
11
  class << self
12
+ # @param [Hash]
13
+ # @return [Response, ErrorResponse]
12
14
  def build(response)
13
15
  new(response).build
14
16
  end
15
17
  end
16
18
 
19
+ # @return [Response, ErrorResponse]
17
20
  def build
18
21
  ok? ? Response.new(attributes) : ErrorResponse.new(attributes)
19
22
  end
@@ -3,6 +3,8 @@ module Troo
3
3
  class Add < ThorFixes
4
4
  package_name 'add'
5
5
 
6
+ # @param [String]
7
+ # @return [String]
6
8
  desc 'board (<name>)',
7
9
  'Add a new board with <name>; prompts if <name> not ' \
8
10
  'provided.'
@@ -11,6 +13,9 @@ module Troo
11
13
  say Commands::Add.dispatch(value, nil, type: :board)
12
14
  end
13
15
 
16
+ # @param [String]
17
+ # @param [String]
18
+ # @return [String]
14
19
  desc 'card <list_id> (<name>)',
15
20
  'Add a new card to the list with <list_id> with <name>; ' \
16
21
  'prompts if <name> not provided.'
@@ -19,6 +24,9 @@ module Troo
19
24
  say Commands::Add.dispatch(value, id, type: :card)
20
25
  end
21
26
 
27
+ # @param [String]
28
+ # @param [String]
29
+ # @return [String]
22
30
  desc 'comment <card_id> (<comment>)',
23
31
  'Add a new comment to the card with <card_id> with ' \
24
32
  '<comment>; prompts if <comment> not provided.'
@@ -27,6 +35,9 @@ module Troo
27
35
  say Commands::Add.dispatch(value, id, type: :comment)
28
36
  end
29
37
 
38
+ # @param [String]
39
+ # @param [String]
40
+ # @return [String]
30
41
  desc 'list <board_id> (<name>)',
31
42
  'Add a new list to the board with <board_id> with ' \
32
43
  '<name>; prompts if <name> not provided.'
@@ -4,15 +4,24 @@ module Troo
4
4
  attr_reader :id, :value
5
5
 
6
6
  class << self
7
+ # @param []
8
+ # @param []
9
+ # @param [Hash]
10
+ # @return []
7
11
  def dispatch(value, id = nil, options = {})
8
12
  new(value, id, options).add
9
13
  end
10
14
  end
11
15
 
16
+ # @param []
17
+ # @param []
18
+ # @param [Hash]
19
+ # @return []
12
20
  def initialize(value, id = nil, options = {})
13
21
  @value, @id, @options = value, id, options
14
22
  end
15
23
 
24
+ # @return []
16
25
  def add
17
26
  return success if create
18
27
  error