3llo 1.0.0.pre.rc.0 → 1.0.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
  SHA256:
3
- metadata.gz: 9c80cabc5ec119676b74fbcc4bc8690d1a2bf55b2f53358f8069e788e36e4049
4
- data.tar.gz: a1690b3ce4cbdb9ded4421f168037f458064769c802def01d21faf1e7f0bbab1
3
+ metadata.gz: 8e6ca4c800b73fb0a5514e1a87204547c243045b9e3a0b5842f327513b726073
4
+ data.tar.gz: c6bc2f0e09bd27a558c8914d34734863efce9d6b534d2bae38d5d1267d378eb7
5
5
  SHA512:
6
- metadata.gz: e4aae96a782fda12b5f87ada27e76a173e04f6dc707f46a45779e2b3c9440833c90e9ab099e35717ad49d55132664f94207f1e9b26c68df1371c7dafd539a70b
7
- data.tar.gz: 1d0a9482ace979945ff7f8f25ec6b92cb07e8d1733c9b9a97624aeeeaa319ad29e73eda694c5618a1ef2efe665d51d1be4923e20efea98f03e724d355b403ce9
6
+ metadata.gz: 035ff3a48dcfe77e558d5eec4e341dcfc78caf0b6d55fa60c91f8a9d56b32a8d8221634e78ec3f34e26fc13c9d10df130017483fd3b9bcfb5aa0c64ce3d19e0f
7
+ data.tar.gz: 152e793d22f7db0ab50d9504c3d2c2d36051dcfa74293931d368a5e58ec9b176fa34f77215498566947fc6851a33bc9eadc3f891fbe43fa0221be13407d1c9b7
@@ -25,5 +25,9 @@ jobs:
25
25
  run: |
26
26
  gem install bundler
27
27
  bundle install --jobs 4 --retry 3
28
+ - name: Start httpbin container
29
+ run: docker run -d -p 8080:80 kennethreitz/httpbin
30
+ - name: Run Rubocop
31
+ run: bundle exec rubocop
28
32
  - name: Run test
29
33
  run: bundle exec rspec
@@ -0,0 +1,113 @@
1
+ # The behavior of RuboCop can be controlled via the .rubocop.yml
2
+ # configuration file. It makes it possible to enable/disable
3
+ # certain cops (checks) and to alter their behavior if they accept
4
+ # any parameters. The file can be placed either in your home
5
+ # directory or in some project directory.
6
+ #
7
+ # RuboCop will start looking for the configuration file in the directory
8
+ # where the inspected file is and continue its way up to the root directory.
9
+ #
10
+ # See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md
11
+
12
+ AllCops:
13
+ TargetRubyVersion: 2.5
14
+
15
+ Layout/LineLength:
16
+ Max: 120
17
+
18
+ Layout/DotPosition:
19
+ EnforcedStyle: leading
20
+
21
+ Layout/EmptyLinesAroundBlockBody:
22
+ EnforcedStyle: no_empty_lines
23
+
24
+ Layout/FirstArrayElementIndentation:
25
+ EnforcedStyle: consistent
26
+
27
+ Layout/FirstHashElementIndentation:
28
+ EnforcedStyle: consistent
29
+
30
+ Layout/HeredocIndentation:
31
+ Enabled: false
32
+
33
+ Layout/MultilineMethodCallIndentation:
34
+ EnforcedStyle: indented
35
+
36
+ Layout/SpaceInsideBlockBraces:
37
+ EnforcedStyle: space
38
+
39
+ Layout/SpaceInsideHashLiteralBraces:
40
+ EnforcedStyle: no_space
41
+
42
+ Layout/SpaceInsideParens:
43
+ EnforcedStyle: no_space
44
+
45
+ Lint/AssignmentInCondition:
46
+ Enabled: false
47
+
48
+ Metrics:
49
+ Enabled: false
50
+
51
+ Naming/RescuedExceptionsVariableName:
52
+ Enabled: false
53
+
54
+ Security/JSONLoad:
55
+ Enabled: false
56
+
57
+ Style/Alias:
58
+ EnforcedStyle: prefer_alias
59
+
60
+ Style/BracesAroundHashParameters:
61
+ Enabled: false
62
+
63
+ Style/DefWithParentheses:
64
+ Enabled: false
65
+
66
+ Style/Documentation:
67
+ Enabled: false
68
+
69
+ Style/FrozenStringLiteralComment:
70
+ Enabled: false
71
+
72
+ Style/GlobalVars:
73
+ AllowedVariables: ['$application']
74
+
75
+ Style/GuardClause:
76
+ Enabled: false
77
+
78
+ Style/HashSyntax:
79
+ EnforcedStyle: ruby19
80
+
81
+ Style/MethodCallWithoutArgsParentheses:
82
+ Enabled: false
83
+
84
+ Style/ModuleFunction:
85
+ Enabled: false
86
+
87
+ Style/MultilineBlockChain:
88
+ Enabled: false
89
+
90
+ Style/PreferredHashMethods:
91
+ EnforcedStyle: verbose
92
+
93
+ Style/TrailingCommaInArguments:
94
+ EnforcedStyleForMultiline: no_comma
95
+
96
+ Style/TrailingCommaInHashLiteral:
97
+ EnforcedStyleForMultiline: no_comma
98
+
99
+ Style/WordArray:
100
+ EnforcedStyle: percent
101
+ MinSize: 3
102
+
103
+ Style/SpecialGlobalVars:
104
+ EnforcedStyle: use_english_names
105
+
106
+ Style/StringLiterals:
107
+ EnforcedStyle: double_quotes
108
+
109
+ Style/StringLiteralsInInterpolation:
110
+ EnforcedStyle: double_quotes
111
+
112
+ Style/RaiseArgs:
113
+ EnforcedStyle: compact
@@ -1,7 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("lib", __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require '3llo/version'
3
+ require "3llo/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "3llo"
@@ -9,13 +8,13 @@ Gem::Specification.new do |spec|
9
8
  spec.authors = ["Cẩm Huỳnh"]
10
9
  spec.email = ["huynhquancam@gmail.com"]
11
10
 
12
- spec.summary = %q{Trello CLI app}
13
- spec.description = %q{Interactive CLI application for Trello}
11
+ spec.summary = "Trello CLI app"
12
+ spec.description = "Interactive CLI application for Trello"
14
13
  spec.homepage = "https://github.com/qcam/3llo"
15
14
  spec.license = "MIT"
16
15
 
17
16
  if spec.respond_to?(:metadata)
18
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
18
  else
20
19
  raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
21
20
  end
@@ -25,9 +24,10 @@ Gem::Specification.new do |spec|
25
24
  spec.executables = spec.files.grep(%r{^bin/}) { |filename| File.basename(filename) }
26
25
  spec.require_paths = ["lib"]
27
26
 
28
- spec.required_ruby_version = '~> 2.5'
27
+ spec.required_ruby_version = "~> 2.5"
29
28
 
30
- spec.add_runtime_dependency 'tty-prompt', '~> 0.20'
29
+ spec.add_runtime_dependency "tty-prompt", "~> 0.20"
31
30
 
32
- spec.add_development_dependency 'rspec', '~> 3.0'
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "rubocop", "~> 0.79"
33
33
  end
@@ -10,6 +10,8 @@
10
10
  * Improve performance of several commands.
11
11
  * Support checklist related commands.
12
12
  * Support Ruby 2.5+.
13
+ * Introduce `card edit` command.
14
+ * Improve command auto completion.
13
15
 
14
16
  ## v0.3.1
15
17
 
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in trecli.gemspec
4
4
  gemspec
5
5
 
6
- gem 'bundler'
7
- gem 'rake'
6
+ gem "bundler"
7
+ gem "rake"
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require "rake/testtask"
4
4
  Rake::TestTask.new(:test) do |t|
5
5
  t.libs << "test"
6
6
  t.libs << "lib"
7
- t.test_files = FileList['test/**/*_test.rb']
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
8
  end
9
9
 
10
- task :default => :test
10
+ task default: :test
data/bin/3llo CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.unshift File.expand_path("../../lib", __FILE__)
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
4
  require "3llo"
5
- require 'container'
6
- require 'tty-prompt'
7
- require 'optparse'
5
+ require "container"
6
+ require "tty-prompt"
7
+ require "optparse"
8
8
 
9
9
  Tr3llo::Application.start(ARGV)
@@ -1,17 +1,17 @@
1
1
  require "3llo/version"
2
- require "3llo/http/client"
2
+ require "3llo/remote_server"
3
3
  require "3llo/interface"
4
- require 'container'
5
- require 'json'
6
- require 'erb'
4
+ require "container"
5
+ require "json"
6
+ require "erb"
7
7
 
8
- require '3llo/application'
9
- require '3llo/configuration'
10
- require '3llo/utils'
11
- require '3llo/controller'
12
- require '3llo/errors'
13
- require '3llo/api'
14
- require '3llo/view'
15
- require '3llo/command'
16
- require '3llo/registry'
17
- require '3llo/entities'
8
+ require "3llo/application"
9
+ require "3llo/configuration"
10
+ require "3llo/utils"
11
+ require "3llo/controller"
12
+ require "3llo/errors"
13
+ require "3llo/api"
14
+ require "3llo/view"
15
+ require "3llo/command"
16
+ require "3llo/registry"
17
+ require "3llo/entities"
@@ -1,6 +1,6 @@
1
- require '3llo/api/board'
2
- require '3llo/api/card'
3
- require '3llo/api/list'
4
- require '3llo/api/user'
5
- require '3llo/api/checklist'
6
- require '3llo/api/token'
1
+ require "3llo/api/board"
2
+ require "3llo/api/card"
3
+ require "3llo/api/list"
4
+ require "3llo/api/user"
5
+ require "3llo/api/checklist"
6
+ require "3llo/api/token"
@@ -4,45 +4,29 @@ module Tr3llo
4
4
  extend self
5
5
 
6
6
  def find_all_by_user(user_id)
7
- JSON.parse(
8
- client.get(
7
+ client = Application.fetch_client!()
8
+ req_path =
9
+ Utils.build_req_path(
9
10
  "/members/#{user_id}/boards",
10
- key: api_key,
11
- token: api_token,
12
- filter: "open"
11
+ {"filter" => "open"}
13
12
  )
14
- ).map do |board_payload|
15
- make_struct(board_payload)
16
- end
13
+
14
+ client
15
+ .get(req_path, {})
16
+ .map do |board_payload|
17
+ make_struct(board_payload)
18
+ end
17
19
  end
18
20
 
19
21
  def find(board_id)
20
- payload =
21
- JSON.parse(
22
- client.get(
23
- "/boards/#{board_id}",
24
- key: api_key,
25
- token: api_token,
26
- )
27
- )
22
+ client = Application.fetch_client!()
23
+ req_path = Utils.build_req_path("/boards/#{board_id}")
28
24
 
29
- make_struct(payload)
25
+ make_struct(client.get(req_path, {}))
30
26
  end
31
27
 
32
28
  private
33
29
 
34
- def client
35
- Application.fetch_client!()
36
- end
37
-
38
- def api_key
39
- Application.fetch_configuration!().api_key
40
- end
41
-
42
- def api_token
43
- Application.fetch_configuration!().api_token
44
- end
45
-
46
30
  def make_struct(payload)
47
31
  id, name = payload.fetch_values("id", "name")
48
32
  shortcut = Entities.make_shortcut(:board, id)
@@ -4,131 +4,116 @@ module Tr3llo
4
4
  extend self
5
5
 
6
6
  def find_all_by_list(list_id)
7
- JSON.parse(
8
- client.get(
7
+ req_path =
8
+ Utils.build_req_path(
9
9
  "/lists/#{list_id}/cards",
10
- key: api_key,
11
- token: api_token,
12
- members: 'true',
13
- member_fields: "id,username"
10
+ {"members" => "true", "member_fields" => "id,username"}
14
11
  )
15
- ).map do |card_payload|
16
- make_struct(card_payload)
17
- end
12
+
13
+ client
14
+ .get(req_path, {})
15
+ .map do |card_payload|
16
+ make_struct(card_payload)
17
+ end
18
18
  end
19
19
 
20
20
  def find_all_by_user(board_id, user_id)
21
- JSON.parse(
22
- client.get(
21
+ req_path =
22
+ Utils.build_req_path(
23
23
  "/boards/#{board_id}/members/#{user_id}/cards",
24
- list: true,
25
- key: api_key,
26
- token: api_token
24
+ {"list" => "true"}
27
25
  )
28
- ).map do |card_payload|
29
- make_struct(card_payload)
30
- end
26
+
27
+ client
28
+ .get(req_path, {})
29
+ .map do |card_payload|
30
+ make_struct(card_payload)
31
+ end
31
32
  end
32
33
 
33
34
  def create(name, description, list_id)
34
- client.post(
35
- "/cards",
36
- key: api_key,
37
- token: api_token,
38
- name: name,
39
- desc: description,
40
- idList: list_id
41
- )
35
+ req_path = Utils.build_req_path("/cards", {})
36
+ payload = {
37
+ "name" => name,
38
+ "desc" => description,
39
+ "idList" => list_id
40
+ }
41
+
42
+ client.post(req_path, {}, payload)
43
+ end
44
+
45
+ def update(card_id, data)
46
+ req_path = Utils.build_req_path("/cards/#{card_id}")
47
+
48
+ client.put(req_path, {}, data)
42
49
  end
43
50
 
44
51
  def find(card_id)
45
- card_payload =
46
- JSON.parse(
47
- client.get(
48
- "/cards/#{card_id}",
49
- list: true,
50
- members: true,
51
- key: api_key,
52
- token: api_token
53
- )
52
+ req_path =
53
+ Utils.build_req_path(
54
+ "/cards/#{card_id}",
55
+ {"list" => "true", "members" => "true"}
54
56
  )
55
57
 
58
+ card_payload = client.get(req_path, {})
59
+
56
60
  make_struct(card_payload)
57
61
  end
58
62
 
63
+ # TODO: Use ".update".
59
64
  def move_to_list(card_id, list_id)
60
- url = "/cards/#{card_id}/idList"
61
- JSON.parse(
62
- client.put(
63
- url,
64
- key: api_key,
65
- token: api_token,
66
- value: list_id
67
- )
68
- )
65
+ req_path = Utils.build_req_path("/cards/#{card_id}/idList")
66
+
67
+ client.put(req_path, {}, {"value" => list_id})
69
68
  end
70
69
 
70
+ # TODO: Use ".update".
71
71
  def assign_members(card_id, members)
72
- url = "/cards/#{card_id}/idMembers"
73
- JSON.parse(
74
- client.put(
75
- url,
76
- key: api_key,
77
- token: api_token,
78
- value: members.join(',')
79
- )
80
- )
72
+ req_path = Utils.build_req_path("/cards/#{card_id}/idMembers")
73
+
74
+ client.put(req_path, {}, {"value" => members.join(",")})
81
75
  end
82
76
 
83
77
  def list_comments(card_id)
84
- url = "/cards/#{card_id}/actions"
85
-
86
- JSON.parse(
87
- client.get(
88
- url,
89
- key: api_key,
90
- token: api_token,
91
- filter: "commentCard",
78
+ req_path =
79
+ Utils.build_req_path(
80
+ "/cards/#{card_id}/actions",
81
+ {"filter" => "commentCard"}
92
82
  )
93
- ).map do |comment_payload|
94
- id, creator_payload, date = comment_payload.fetch_values("id", "memberCreator", "date")
95
- text = comment_payload.dig("data", "text")
96
83
 
97
- created_at = DateTime.iso8601(date)
84
+ client
85
+ .get(req_path, {})
86
+ .map do |comment_payload|
87
+ id, creator_payload, date = comment_payload.fetch_values("id", "memberCreator", "date")
88
+ text = comment_payload.dig("data", "text")
98
89
 
99
- creator_id, creator_username = creator_payload.fetch_values("id", "username")
100
- creator = Entities::User.new(creator_id, _creator_shortcut = nil, creator_username)
90
+ created_at = DateTime.iso8601(date)
101
91
 
102
- Entities::Comment.new(
103
- id: id,
104
- creator: creator,
105
- created_at: created_at,
106
- text: text
107
- )
108
- end
92
+ creator_id, creator_username = creator_payload.fetch_values("id", "username")
93
+ creator = Entities::User.new(creator_id, _creator_shortcut = nil, creator_username)
94
+
95
+ Entities::Comment.new(
96
+ id: id,
97
+ creator: creator,
98
+ created_at: created_at,
99
+ text: text
100
+ )
101
+ end
109
102
  end
110
103
 
111
104
  def comment(card_id, text)
112
- url = "/cards/#{card_id}/actions/comments"
113
- JSON.parse(
114
- client.post(
115
- url,
116
- key: api_key,
117
- token: api_token,
118
- text: text
119
- )
120
- )
105
+ req_path = Utils.build_req_path("/cards/#{card_id}/actions/comments")
106
+ payload = {"text" => text}
107
+
108
+ client.post(req_path, {}, payload)
121
109
  end
122
110
 
111
+ # TODO: Use ".update".
123
112
  def archive(card_id)
124
- url = "/cards/#{card_id}?closed=true"
125
- JSON.parse(
126
- client.put(
127
- url,
128
- key: api_key,
129
- token: api_token
130
- )
131
- )
113
+ req_path = Utils.build_req_path("/cards/#{card_id}")
114
+ payload = {"closed" => "true"}
115
+
116
+ client.put(req_path, {}, payload)
132
117
  end
133
118
 
134
119
  private
@@ -139,8 +124,8 @@ module Tr3llo
139
124
 
140
125
  members =
141
126
  payload
142
- .fetch("members", [])
143
- .map do |member_payload|
127
+ .fetch("members", [])
128
+ .map do |member_payload|
144
129
  user_id, username = member_payload.fetch_values("id", "username")
145
130
 
146
131
  Entities::User.new(user_id, _user_shortcut = nil, username)
@@ -148,8 +133,8 @@ module Tr3llo
148
133
 
149
134
  labels =
150
135
  payload
151
- .fetch("labels", [])
152
- .map do |label_payload|
136
+ .fetch("labels", [])
137
+ .map do |label_payload|
153
138
  label_name = label_payload.fetch("name")
154
139
  label_color = label_payload["color"]
155
140
 
@@ -175,14 +160,6 @@ module Tr3llo
175
160
  card
176
161
  end
177
162
 
178
- def api_key
179
- Application.fetch_configuration!().api_key
180
- end
181
-
182
- def api_token
183
- Application.fetch_configuration!().api_token
184
- end
185
-
186
163
  def client
187
164
  Application.fetch_client!()
188
165
  end