smart_todo 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a61dfef2e6101321b34f154e8143441b3f28502709b26cb2db504fe83251ba1a
4
- data.tar.gz: 3f12eef19063ed2f8585b56be3b483f1312dc44a7c96cc93931c8ae89a4ac7c5
3
+ metadata.gz: f43df881f5ab5894069683abbe3d09571232a896a429d0d2795d57e8102e42dc
4
+ data.tar.gz: 070dc363e6e1aa44e605e1fe53126bfc613af23985cfc7cdb48a145fe93362e0
5
5
  SHA512:
6
- metadata.gz: 25d629887ac69968359d5bd26a15736adebad37c881eeec2c5b05432be1a05fca0d69cf9c978c638b7033e9deffcc2f24111fee307359325f70c07d6905d6b04
7
- data.tar.gz: 7a5472d3ad8d69187ccc5d46975b1f3ac0368886259c1f42d2303c4a0e8cb6f4de34a33f08b12d205ddde13f8ba5184a423eba95dece54335f0e7ed405861a15
6
+ metadata.gz: 69d9f4f170b854769a3141a41135c25463b2839274be7a6cea062b2d524fa5cee37e64c0a134f9de10944b9fce9e3580ed8f3b5ca4c8a8101528c3f9691a1c36
7
+ data.tar.gz: c5b66f439a2176728ca2f8ef4297fceeaa6d9f08c1ba190d4a255b8e3164264262536681d34a9cab4a9837c2455e75ecdf1dd9dc6b7b8b9877e37ef026719c01
@@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.2.0] - 2019-11-25
10
+ ### Fixed
11
+ - Fixed crash with badly formated TODO(on:) (i.e. `TODO(on: 'blabla'))
12
+
13
+ ### Added
14
+ - Added the `on: gem_bump` event which will remind you when a gem inside your
15
+ Gemfile.lock snapshot gets updated to a specific version.
16
+
17
+ ```ruby
18
+ # TODO(on: gem_bump('rails', '6.1'), to: '...')
19
+ ```
20
+
9
21
  ## [1.1.0] - 2019-09-06
10
22
  ### Fixed
11
23
  - Fixed the SmartTodo cop to add an offense in case a SmartTodo has a wrong event.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_todo (1.1.0)
4
+ smart_todo (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -15,6 +15,7 @@ module SmartTodo
15
15
 
16
16
  module Events
17
17
  autoload :Date, 'smart_todo/events/date'
18
+ autoload :GemBump, 'smart_todo/events/gem_bump'
18
19
  autoload :GemRelease, 'smart_todo/events/gem_release'
19
20
  autoload :IssueClose, 'smart_todo/events/issue_close'
20
21
  end
@@ -38,6 +38,15 @@ module SmartTodo
38
38
  GemRelease.new(gem_name, requirements).met?
39
39
  end
40
40
 
41
+ # Check if +gem_name+ was bumped to the +requirements+ expected
42
+ #
43
+ # @param gem_name [String]
44
+ # @param requirements [Array<String>] a list of version specifiers
45
+ # @return [false, String]
46
+ def gem_bump(gem_name, *requirements)
47
+ GemBump.new(gem_name, requirements).met?
48
+ end
49
+
41
50
  # Check if the issue +issue_number+ is closed
42
51
  #
43
52
  # @param organization [String] the GitHub organization name
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ gem('bundler')
4
+ require 'bundler'
5
+
6
+ module SmartTodo
7
+ module Events
8
+ # An event that compare the version of a gem specified in your Gemfile.lock
9
+ # with the expected version specifiers.
10
+ class GemBump
11
+ # @param gem_name [String]
12
+ # @param requirements [Array] a list of version specifiers.
13
+ # The specifiers are the same as the one used in Gemfiles or Gemspecs
14
+ #
15
+ # @example Expecting a specific version
16
+ # GemBump.new('rails', ['6.0'])
17
+ #
18
+ # @example Expecting a version in the 5.x.x series
19
+ # GemBump.new('rails', ['> 5.2', '< 6'])
20
+ def initialize(gem_name, requirements)
21
+ @gem_name = gem_name
22
+ @requirements = Gem::Requirement.new(requirements)
23
+ end
24
+
25
+ # @return [String, false]
26
+ def met?
27
+ return error_message if spec_set[@gem_name].empty?
28
+
29
+ installed_version = spec_set[@gem_name].first.version
30
+ if @requirements.satisfied_by?(installed_version)
31
+ message(installed_version)
32
+ else
33
+ false
34
+ end
35
+ end
36
+
37
+ # Error message send to Slack in case a gem couldn't be found
38
+ #
39
+ # @return [String]
40
+ def error_message
41
+ "The gem *#{@gem_name}* is not in your dependencies, I can't determine if your TODO is ready to be addressed."
42
+ end
43
+
44
+ # @return [String]
45
+ def message(version_number)
46
+ "The gem *#{@gem_name}* was updated to version *#{version_number}* and your TODO is now ready to be addressed."
47
+ end
48
+
49
+ private
50
+
51
+ # @return [Bundler::SpecSet] an instance of Bundler::SpecSet
52
+ def spec_set
53
+ @spec_set ||= Bundler.load.specs
54
+ end
55
+ end
56
+ end
57
+ end
@@ -103,6 +103,8 @@ module SmartTodo
103
103
  # @param method_node [MethodNode]
104
104
  # @return [void]
105
105
  def on_todo_event(method_node)
106
+ return unless method_node.is_a?(MethodNode)
107
+
106
108
  events << method_node
107
109
  end
108
110
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SmartTodo
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_todo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-06 00:00:00.000000000 Z
11
+ date: 2019-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,6 +114,7 @@ files:
114
114
  - lib/smart_todo/dispatchers/slack.rb
115
115
  - lib/smart_todo/events.rb
116
116
  - lib/smart_todo/events/date.rb
117
+ - lib/smart_todo/events/gem_bump.rb
117
118
  - lib/smart_todo/events/gem_release.rb
118
119
  - lib/smart_todo/events/issue_close.rb
119
120
  - lib/smart_todo/parser/comment_parser.rb