3llo 0.2.0 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e700e928448190099e127af4aa5286e9088d983
4
- data.tar.gz: 6ef4c1f9b9ae424e7696e4d30398f7bc63319301
3
+ metadata.gz: e05bd8d3c7bea9ee60906b240c091388184e4564
4
+ data.tar.gz: 3c42a1c12897aba513a736b3afd84d3dcf624838
5
5
  SHA512:
6
- metadata.gz: 42007554dd4936601e24e55b616d2b77fe0ff8e14823816923902a4d73290bc12e82d7f7bb78556f478b5dd1b0494bc0e41335ab5e25a7be08f45ca74e742406
7
- data.tar.gz: 0959136caad56c2ff684d4e6fc5114d8ad66c317febcad2da6bcf9877f82a571015ce8a4053a9a0c91c53a06c9503066fc07856c165df0090c0678d980683398
6
+ metadata.gz: d81e257f0a944ec5ab3dd6373814ee8d4ae0482d0029d169222b827865a10cbfff93b08a6f508dab1c2b068acbecc7f40dbf4d13fe8032617dbfd299e27e56b8
7
+ data.tar.gz: fbaa8605fb23e12ecf5c93133bcbe70933b6eb8f7bcfe33cf4cae18920ecaca99fa6d355eed44e77e79fb37b060b046aa136b86e655be0931d2716b08eec77e1
data/.gitignore CHANGED
@@ -1,10 +1,3 @@
1
1
  /.bundle/
2
- /.yardoc
3
2
  /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
3
  *.gem
data/.travis.yml CHANGED
@@ -1,5 +1,22 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3.0
5
- before_install: gem install bundler -v 1.12.5
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
7
+ - 2.3
8
+ - 2.4
9
+ - 2.5
10
+ - ruby-head
11
+ - jruby
12
+
13
+ before_install:
14
+ - gem install bundler
15
+
16
+ script:
17
+ - bundle exec rspec --order random --format documentation
18
+
19
+ matrix:
20
+ allow_failures:
21
+ rvm:
22
+ - ruby-head
data/3llo.gemspec CHANGED
@@ -4,28 +4,30 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require '3llo/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "3llo"
8
- spec.version = Tr3llo::VERSION
9
- spec.authors = ["Cẩm Huỳnh"]
10
- spec.email = ["huynhquancam@gmail.com"]
7
+ spec.name = "3llo"
8
+ spec.version = Tr3llo::VERSION
9
+ spec.authors = ["Cẩm Huỳnh"]
10
+ spec.email = ["huynhquancam@gmail.com"]
11
11
 
12
- spec.summary = %q{Trello CLI}
13
- spec.description = %q{CLI for Trello}
14
- spec.homepage = "https://github.com/qcam/3llo"
15
- spec.license = "MIT"
12
+ spec.summary = %q{Trello CLI}
13
+ spec.description = %q{CLI for Trello}
14
+ spec.homepage = "https://github.com/qcam/3llo"
15
+ spec.license = "MIT"
16
16
 
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
17
  if spec.respond_to?(:metadata)
20
18
  spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
19
  else
22
20
  raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
21
  end
24
22
 
25
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/|intro\.gif}) }
26
- spec.bindir = "bin"
27
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/|intro\.gif}) }
24
+ spec.bindir = "bin"
25
+ spec.executables = spec.files.grep(%r{^bin/}) { |filename| File.basename(filename) }
28
26
  spec.require_paths = ["lib"]
29
27
 
30
- spec.add_runtime_dependency 'tty-prompt', '~> 0.11.0'
28
+ spec.required_ruby_version = '~> 2.0'
29
+
30
+ spec.add_runtime_dependency 'tty-prompt', '~> 0.12.0'
31
+
32
+ spec.add_development_dependency 'rspec', '~> 3.0'
31
33
  end
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # CHANGELOG
2
+
3
+ ## v0.3.0
4
+
5
+ * Accept multiline in "card comment" command [#33](https://github.com/qcam/3llo/pull/33).
6
+ * Upgrade `tty-prompt` dependency to 0.12.0.
7
+ * Support Ruby 2.0+.
data/bin/3llo CHANGED
@@ -6,7 +6,7 @@ require 'container'
6
6
  require 'tty-prompt'
7
7
 
8
8
  $container = Container.new
9
- $container.register(:api_client, Tr3llo::Client)
9
+ $container.register(:api_client, Tr3llo::HTTP::Client)
10
10
  prompt = TTY::Prompt.new
11
11
  $container.register(:interface, Tr3llo::Interface.new(prompt, $stdout))
12
12
 
data/lib/3llo.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "core_ext"
2
2
  require "3llo/version"
3
- require "3llo/client"
3
+ require "3llo/http/client"
4
4
  require "3llo/presenter"
5
5
  require "3llo/interface"
6
6
  require 'container'
@@ -4,9 +4,8 @@ require '3llo/commands/board/invalid'
4
4
 
5
5
  module Tr3llo
6
6
  class BoardCommandFactory
7
- def initialize(subcommand, args)
7
+ def initialize(subcommand, _)
8
8
  @subcommand = subcommand
9
- @args = args
10
9
  end
11
10
 
12
11
  def factory
@@ -23,6 +22,6 @@ module Tr3llo
23
22
 
24
23
  private
25
24
 
26
- attr_reader :subcommand, :args
25
+ attr_reader :subcommand
27
26
  end
28
27
  end
@@ -22,7 +22,7 @@ module Tr3llo
22
22
  CardCommandFactory.new(subcommand, args).factory
23
23
  when 'list'
24
24
  ListCommandFactory.new(subcommand, args).factory
25
- when 'help', ''
25
+ when 'help'
26
26
  Command::HelpCommand.new
27
27
  when 'exit'
28
28
  Command::ExitCommand.new
@@ -8,7 +8,7 @@ module Tr3llo
8
8
 
9
9
  def execute
10
10
  interface.print_frame do
11
- text = interface.input.ask("Comment:")
11
+ text = interface.input.multiline("Comment (press Ctrl+d to finish):").join("")
12
12
 
13
13
  interface.puts(
14
14
  create_comment!(text) &&
@@ -18,7 +18,7 @@ module Tr3llo
18
18
  .new(command_buffer)
19
19
  .factory
20
20
  .execute
21
- rescue Tr3llo::Client::RequestError => e
21
+ rescue Tr3llo::HTTP::Client::RequestError => e
22
22
  interface.print_frame { interface.puts(e.message) }
23
23
  end
24
24
  end
@@ -0,0 +1,75 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+ require 'openssl'
4
+ require '3llo/http/request_error'
5
+
6
+ module Tr3llo
7
+ module HTTP
8
+ module Client
9
+ extend self
10
+
11
+ BASE_URL = "https://api.trello.com/1"
12
+
13
+ def get(path, params = {})
14
+ uri = URI("#{BASE_URL}#{path}?#{query_string(params)}")
15
+
16
+ http = Net::HTTP.new(uri.host, uri.port)
17
+ http.use_ssl = true
18
+ request = Net::HTTP::Get.new(uri.request_uri)
19
+
20
+ res = http.request(request)
21
+
22
+ case res
23
+ when Net::HTTPSuccess then res.body
24
+ else raise(RequestError.new(res.body))
25
+ end
26
+ end
27
+
28
+ def post(path, params)
29
+ uri = URI("#{BASE_URL}#{path}")
30
+
31
+ http = Net::HTTP.new(uri.host, uri.port)
32
+ http.use_ssl = true
33
+ req_headers = {
34
+ 'Accept' => 'application/json',
35
+ 'Content-Type' => 'application/json',
36
+ }
37
+ request = Net::HTTP::Post.new(uri.request_uri, req_headers)
38
+ request.body = JSON.dump(params)
39
+
40
+ res = http.request(request)
41
+
42
+ case res
43
+ when Net::HTTPOK then res.body
44
+ else raise(RequestError.new(res.body))
45
+ end
46
+ end
47
+
48
+ def put(path, params)
49
+ uri = URI("#{BASE_URL}#{path}")
50
+
51
+ http = Net::HTTP.new(uri.host, uri.port)
52
+ http.use_ssl = true
53
+ req_headers = {
54
+ 'Accept' => 'application/json',
55
+ 'Content-Type' => 'application/json',
56
+ }
57
+ request = Net::HTTP::Put.new(uri.request_uri, req_headers)
58
+ request.body = JSON.dump(params)
59
+
60
+ res = http.request(request)
61
+
62
+ case res
63
+ when Net::HTTPOK then res.body
64
+ else raise(RequestError.new(res.body))
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ def query_string(params)
71
+ URI.encode_www_form(params)
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,18 @@
1
+ module Tr3llo
2
+ module HTTP
3
+ module Client
4
+ class RequestError < ::StandardError
5
+ attr_reader :response
6
+
7
+ def initialize(response)
8
+ @response = response
9
+ super()
10
+ end
11
+
12
+ def message
13
+ "Request error: #{response}"
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -7,7 +7,7 @@ module Tr3llo
7
7
 
8
8
  def prompt_for_confirmation(message)
9
9
  answer = interface.input.select(message, ['No', 'Yes'])
10
- answer == 'Yes' ? true : false
10
+ answer == 'Yes'
11
11
  end
12
12
 
13
13
  private
data/lib/3llo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tr3llo
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: 3llo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cẩm Huỳnh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-22 00:00:00.000000000 Z
11
+ date: 2018-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.11.0
19
+ version: 0.12.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.11.0
26
+ version: 0.12.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
27
41
  description: CLI for Trello
28
42
  email:
29
43
  - huynhquancam@gmail.com
@@ -32,9 +46,10 @@ executables:
32
46
  extensions: []
33
47
  extra_rdoc_files: []
34
48
  files:
35
- - .gitignore
36
- - .travis.yml
49
+ - ".gitignore"
50
+ - ".travis.yml"
37
51
  - 3llo.gemspec
52
+ - CHANGELOG.md
38
53
  - CODE_OF_CONDUCT.md
39
54
  - Gemfile
40
55
  - LICENSE.md
@@ -49,7 +64,6 @@ files:
49
64
  - lib/3llo/api/user.rb
50
65
  - lib/3llo/board_command_factory.rb
51
66
  - lib/3llo/card_command_factory.rb
52
- - lib/3llo/client.rb
53
67
  - lib/3llo/command_factory.rb
54
68
  - lib/3llo/commands/.gitkeep
55
69
  - lib/3llo/commands/board/invalid.rb
@@ -77,6 +91,8 @@ files:
77
91
  - lib/3llo/configuration.rb
78
92
  - lib/3llo/controller.rb
79
93
  - lib/3llo/errors.rb
94
+ - lib/3llo/http/client.rb
95
+ - lib/3llo/http/request_error.rb
80
96
  - lib/3llo/interface.rb
81
97
  - lib/3llo/list_command_factory.rb
82
98
  - lib/3llo/presenter.rb
@@ -106,17 +122,17 @@ require_paths:
106
122
  - lib
107
123
  required_ruby_version: !ruby/object:Gem::Requirement
108
124
  requirements:
109
- - - '>='
125
+ - - "~>"
110
126
  - !ruby/object:Gem::Version
111
- version: '0'
127
+ version: '2.0'
112
128
  required_rubygems_version: !ruby/object:Gem::Requirement
113
129
  requirements:
114
- - - '>='
130
+ - - ">="
115
131
  - !ruby/object:Gem::Version
116
132
  version: '0'
117
133
  requirements: []
118
134
  rubyforge_project:
119
- rubygems_version: 2.0.14.1
135
+ rubygems_version: 2.5.2
120
136
  signing_key:
121
137
  specification_version: 4
122
138
  summary: Trello CLI
data/lib/3llo/client.rb DELETED
@@ -1,85 +0,0 @@
1
- require 'uri'
2
- require 'net/http'
3
- require 'openssl'
4
-
5
- module Tr3llo
6
- module Client
7
- extend self
8
-
9
- BASE_URL = "https://api.trello.com/1"
10
-
11
- class RequestError < RuntimeError
12
- attr_reader :response
13
-
14
- def initialize(response)
15
- @response = response
16
- super()
17
- end
18
-
19
- def message
20
- "Request error: #{response}"
21
- end
22
- end
23
-
24
- def get(path, params = {})
25
- uri = URI("#{BASE_URL}#{path}?#{query_string(params)}")
26
-
27
- http = Net::HTTP.new(uri.host, uri.port)
28
- http.use_ssl = true
29
- request = Net::HTTP::Get.new(uri.request_uri)
30
-
31
- res = http.request(request)
32
-
33
- case res
34
- when Net::HTTPSuccess then res.body
35
- else raise(RequestError.new(res.body))
36
- end
37
- end
38
-
39
- def post(path, params)
40
- uri = URI("#{BASE_URL}#{path}")
41
-
42
- http = Net::HTTP.new(uri.host, uri.port)
43
- http.use_ssl = true
44
- req_headers = {
45
- 'Accept' => 'application/json',
46
- 'Content-Type' => 'application/json',
47
- }
48
- request = Net::HTTP::Post.new(uri.request_uri, req_headers)
49
- request.body = JSON.dump(params)
50
-
51
- res = http.request(request)
52
-
53
- case res
54
- when Net::HTTPOK then res.body
55
- else raise(RequestError.new(res.body))
56
- end
57
- end
58
-
59
- def put(path, params)
60
- uri = URI("#{BASE_URL}#{path}")
61
-
62
- http = Net::HTTP.new(uri.host, uri.port)
63
- http.use_ssl = true
64
- req_headers = {
65
- 'Accept' => 'application/json',
66
- 'Content-Type' => 'application/json',
67
- }
68
- request = Net::HTTP::Put.new(uri.request_uri, req_headers)
69
- request.body = JSON.dump(params)
70
-
71
- res = http.request(request)
72
-
73
- case res
74
- when Net::HTTPOK then res.body
75
- else raise(RequestError.new(res.body))
76
- end
77
- end
78
-
79
- private
80
-
81
- def query_string(params)
82
- params.keys.map { |key| "#{key}=#{params[key]}" }.join("&")
83
- end
84
- end
85
- end