nutrella 1.5.4 → 1.6.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: 24e66cfc7e3e0b2cf58e7ecb47d16d2689c417e60f4c499bf7ecf777a6e08015
4
- data.tar.gz: 53d417160b545b06988e41c1d6b434d0d61822e04cb54dd7482d725e11e450a7
3
+ metadata.gz: d8f9d4dd38032bffc0e82c45319e2b5606d5e4b12709fad7f1caf5e904cf540b
4
+ data.tar.gz: 98cfb7a5e03bc56f461e5c7b62b958a9c58ba82ce82e85573726f52e276e2b7d
5
5
  SHA512:
6
- metadata.gz: 44e1e12f2f85e870b7d48324450e6d42fa109d606760b31b8a5f0ff70b22b4109a4b304bd00eb765f69b0dc8f40db1ee2571e60014346ea509cf0573cfa4beea
7
- data.tar.gz: 874d0d22d8fc5a51fc27712226927363a3e1c0883b029d0dd449f2b245c4a47073c64f98ad25a45a08ec150fb36bea16b473d43c08ac146d4c063adb5ac903fd
6
+ metadata.gz: 58be0c5fe2c1063ee726927b183e0fc1e9c0ca821988a47cc65100ec7180cb33df23b7d79457e2f1965c60de97072f0b17e3520997638167f22620e841ce5cbd
7
+ data.tar.gz: 70da9a7fc7034c9c62ade428e5e1b65258ca66d3a218b898de8ca074b76bdc7984b1b2adca693d255268a137748c7a78ae3bb9ed6c0bed56c5ec138fafe58c10
data/.codeclimate.yml CHANGED
@@ -7,11 +7,6 @@ engines:
7
7
  - ruby
8
8
  fixme:
9
9
  enabled: true
10
- rubocop:
11
- enabled: true
12
- checks:
13
- Rubocop/Rails/Output:
14
- enabled: false
15
10
  reek:
16
11
  enabled: true
17
12
  ratings:
data/.rubocop.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  require:
2
- - rubocop-rake
3
2
  - rubocop-rspec
4
3
 
5
4
  AllCops:
@@ -9,6 +8,9 @@ AllCops:
9
8
  Exclude:
10
9
  - 'bin/**/*'
11
10
 
11
+ Layout/LineLength:
12
+ Max: 120
13
+
12
14
  # Rubocop and I cannot agree.
13
15
  Layout/MultilineMethodCallBraceLayout:
14
16
  Enabled: false
@@ -19,18 +21,12 @@ Metrics/BlockLength:
19
21
  Naming/MemoizedInstanceVariableName:
20
22
  EnforcedStyleForLeadingUnderscores: required
21
23
 
22
- Rake/Desc:
23
- Enabled: false
24
-
25
24
  RSpec/AnyInstance:
26
25
  Enabled: false
27
26
 
28
27
  RSpec/ExampleLength:
29
28
  Max: 15
30
29
 
31
- Metrics/LineLength:
32
- Max: 120
33
-
34
30
  RSpec/DescribeClass:
35
31
  Enabled: false
36
32
 
data/CHANGELOG.md CHANGED
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.6.0] - 2021-07-30
10
+
11
+ #### New Features
12
+
13
+ - Allow opening a previously created Trello board based on a JIRA ticket
14
+ - Added a configuration option to specify exactly how to search in the cache first
15
+
9
16
  ## [1.5.4] - 2021-07-29
10
17
 
11
18
  #### New Features
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![Gem Version](http://img.shields.io/gem/v/nutrella.svg?style=flat)](https://rubygems.org/gems/nutrella)
4
4
  [![Code Climate](https://codeclimate.com/github/amckinnell/nutrella/badges/gpa.svg)](https://codeclimate.com/github/amckinnell/nutrella)
5
- [![Build Status](https://travis-ci.org/amckinnell/nutrella.svg?branch=master)](https://travis-ci.org/amckinnell/nutrella)
6
5
 
7
6
  A command line tool for associating a Trello board with the current git branch.
8
7
 
@@ -45,7 +44,7 @@ Insert your `token` into your `~/.nutrella.yml` file.
45
44
 
46
45
  If your haven't already done so, insert your `key`, `secret`, and `token` into your `~/.nutrella.yml` file.
47
46
 
48
- The configuration file should look like the following (don't use the keys below, they won't work):
47
+ The configuration file should look like the following (don't use the keys below as they won't work for you):
49
48
 
50
49
  ```yaml
51
50
  # Trello Developer API Keys
@@ -59,6 +58,7 @@ The configuration file should look like the following (don't use the keys below,
59
58
  enable_trello_app: false
60
59
  enable_logging: true
61
60
  cache_capacity: 5
61
+ cache_first: '^PM-\d+'
62
62
  ```
63
63
 
64
64
  **Step 6**: Adjust configuration file (Optional)
@@ -89,22 +89,43 @@ Adjust the `cache_capacity` configuration to increase the capacity of the cache
89
89
  cache_capacity: 15
90
90
  ```
91
91
 
92
+ Adjust the `cache_first` configuration to allow searching the cache first before creating or opening a Trello board:
93
+
94
+ ```yaml
95
+ cache_first: '^(PM|QC)-\d+'
96
+ ```
97
+
98
+ The string that you specify will be treated as a regular expression.
99
+
100
+
92
101
 
93
102
  ## Usage
94
103
 
95
- Create or open a Trello board based on the name of the current git branch:
104
+ There are three ways to invoke the nutrella command:
105
+
106
+ 1. Create or open a Trello board based on the name of the current git branch:
96
107
 
97
- ```sh
108
+ ```sh
98
109
  $ nutrella
99
- ```
110
+ ```
111
+
112
+ This is the command invocation that should meet your needs 90% of the time.
100
113
 
101
- Create or open a named Trello board:
102
114
 
103
- ```sh
115
+ 1. Create or open a named Trello board using the full git branch name:
116
+
117
+ ```sh
104
118
  $ nutrella <git-branch-name>
105
- ```
119
+ ```
120
+
121
+
122
+ 2. Create or open a previously created Trello board using a JIRA ticket like `PM-9423`:
123
+
124
+ ```sh
125
+ $ nutrella <JIRA Ticket>
126
+ ```
106
127
 
107
- Note: you can invoke `nutrella` from your project directory or from any subdirectory.
128
+ This behaviour relies on the `cache_first` configuration setting. Invoking `nutrella` with a JIRA ticket number is for those situations where you make multiple git branches for the same JIRA ticket with a different suffix.
108
129
 
109
130
 
110
131
  ## Troubleshooting
data/exe/nutrella CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  require "nutrella"
4
4
 
5
- board_name = Nutrella::TaskBoardName.board_name(ARGV)
5
+ board_name = Nutrella::TaskBoardName.board_name_from_git_branch(ARGV)
6
6
 
7
7
  Nutrella::Command.new(Dir.home, board_name).run
data/lib/nutrella.rb CHANGED
@@ -1,5 +1,4 @@
1
- require "nutrella/string_ext"
2
-
1
+ require "nutrella/board_name_resolver"
3
2
  require "nutrella/cache"
4
3
  require "nutrella/command"
5
4
  require "nutrella/configuration"
@@ -0,0 +1,29 @@
1
+ module Nutrella
2
+ #
3
+ # Knows how to take the supplied board name and resolve it to a Trello board url.
4
+ #
5
+ class BoardNameResolver
6
+ def initialize(url_cache, search_specification)
7
+ @url_cache = url_cache
8
+ @search_specification = search_specification
9
+ end
10
+
11
+ def resolve(board_name, &block)
12
+ matching_url(board_name) || cached_url(board_name, &block)
13
+ end
14
+
15
+ private
16
+
17
+ def matching_url(board_name)
18
+ return nil unless @search_specification.match?(board_name)
19
+
20
+ search_reg_exp = Regexp.new(board_name, Regexp::IGNORECASE)
21
+
22
+ @url_cache.search(search_reg_exp)
23
+ end
24
+
25
+ def cached_url(board_name, &block)
26
+ @url_cache.fetch(board_name, &block)
27
+ end
28
+ end
29
+ end
@@ -20,6 +20,12 @@ module Nutrella
20
20
  value
21
21
  end
22
22
 
23
+ def search(search_reg_exp)
24
+ cache_contents.find { |k, _v| search_reg_exp.match?(k) }.last
25
+ rescue
26
+ nil
27
+ end
28
+
23
29
  private
24
30
 
25
31
  def lookup(key)
@@ -41,7 +47,11 @@ module Nutrella
41
47
  end
42
48
 
43
49
  def cache_contents
44
- @_cache_contents ||= YAML.load_file(path)
50
+ @_cache_contents ||= begin
51
+ YAML.load_file(path)
52
+ rescue
53
+ nil
54
+ end
45
55
  end
46
56
  end
47
57
  end
@@ -42,7 +42,7 @@ module Nutrella
42
42
  end
43
43
 
44
44
  def cached_url
45
- @_cached_url ||= url_cache.fetch(@board_name) { task_board.lookup_or_create(@board_name).url }
45
+ @_cached_url ||= board_name_resolver.resolve(@board_name) { task_board.lookup_or_create(@board_name).url }
46
46
  end
47
47
 
48
48
  def configuration_values
@@ -65,6 +65,10 @@ module Nutrella
65
65
  http_url.gsub(/^http.?:/, "trello:")
66
66
  end
67
67
 
68
+ def board_name_resolver
69
+ Nutrella::BoardNameResolver.new(url_cache, configuration_values.fetch(:cache_first, ""))
70
+ end
71
+
68
72
  def task_board
69
73
  Nutrella::TaskBoard.new(configuration_values)
70
74
  end
@@ -21,6 +21,7 @@ module Nutrella
21
21
  enable_trello_app: false
22
22
  enable_logging: false
23
23
  cache_capacity: 5
24
+ cache_first: '^PM-\d+'
24
25
  YAML
25
26
 
26
27
  attr_reader :path, :values
@@ -46,7 +47,8 @@ module Nutrella
46
47
  launch_command: configuration.fetch("launch_command", "open $url$"),
47
48
  enable_trello_app: configuration.fetch("enable_trello_app", "false"),
48
49
  enable_logging: configuration.fetch("enable_logging", "false"),
49
- cache_capacity: configuration.fetch("cache_capacity", 5)
50
+ cache_capacity: configuration.fetch("cache_capacity", 5),
51
+ cache_first: to_reg_exp("cache_first")
50
52
  }
51
53
  rescue => e
52
54
  abort "#{path} #{e}"
@@ -77,5 +79,9 @@ module Nutrella
77
79
  See https://github.com/amckinnell/nutrella for instructions.
78
80
  TEXT
79
81
  end
82
+
83
+ def to_reg_exp(key)
84
+ Regexp.new(configuration.fetch(key, '^PM-\d+'), Regexp::IGNORECASE)
85
+ end
80
86
  end
81
87
  end
@@ -9,7 +9,7 @@ module Nutrella
9
9
  # Note: will also accept the name of a branch as an argument.
10
10
  #
11
11
  class TaskBoardName
12
- def self.board_name(args)
12
+ def self.board_name_from_git_branch(args)
13
13
  git_branch_name = args[0]
14
14
  return git_branch_name if git_branch_name.present?
15
15
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nutrella
4
- VERSION = "1.5.4"
4
+ VERSION = "1.6.0"
5
5
  end
data/nutrella.gemspec CHANGED
@@ -31,7 +31,6 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "rake", "~> 13.0"
32
32
  spec.add_development_dependency "rspec", "~> 3.10"
33
33
  spec.add_development_dependency "rubocop", "~> 1.18"
34
- spec.add_development_dependency "rubocop-rake", "~> 0.6"
35
34
  spec.add_development_dependency "rubocop-rspec", "~> 2.4"
36
35
  spec.add_development_dependency "simplecov", "~> 0.21"
37
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nutrella
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alistair McKinnell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-29 00:00:00.000000000 Z
11
+ date: 2021-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-trello
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.18'
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop-rake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0.6'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.6'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rubocop-rspec
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +109,6 @@ files:
123
109
  - ".rspec"
124
110
  - ".rubocop.yml"
125
111
  - ".ruby-version"
126
- - ".travis.yml"
127
112
  - CHANGELOG.md
128
113
  - CODE_OF_CONDUCT.md
129
114
  - Gemfile
@@ -138,11 +123,11 @@ files:
138
123
  - bin/setup
139
124
  - exe/nutrella
140
125
  - lib/nutrella.rb
126
+ - lib/nutrella/board_name_resolver.rb
141
127
  - lib/nutrella/cache.rb
142
128
  - lib/nutrella/command.rb
143
129
  - lib/nutrella/configuration.rb
144
130
  - lib/nutrella/developer_keys.rb
145
- - lib/nutrella/string_ext.rb
146
131
  - lib/nutrella/task_board.rb
147
132
  - lib/nutrella/task_board_name.rb
148
133
  - lib/nutrella/version.rb
data/.travis.yml DELETED
@@ -1 +0,0 @@
1
- language: ruby
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Simpler versions of an extension from ActiveSupport.
4
- #
5
- class String
6
- def titleize
7
- tr("_-", " ").split.map(&:capitalize).join(" ")
8
- end
9
- end