plan_my_stuff 0.16.0 → 0.17.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: 782add7d506a645b1f2c19c413de0ef21c91d31a91e07280c003523767a48368
4
- data.tar.gz: c20c6aa1e5f98d297cfbcbae5c57c7c5d13dd24b746d26374294196e50b983a5
3
+ metadata.gz: fe4f92dc92eca010b6fc7f53f4ce7701c6852420c9a537fdf0902e591c3309ad
4
+ data.tar.gz: b167fd42a3b5a37fc897bebf8f3696ed2cd863ac7049359445a329d9a7861988
5
5
  SHA512:
6
- metadata.gz: bfcd02d86fa108d59ba15c75b3a7741c0d5c6c2cac701ac785d5d73aeee57025926910785383f5eac0f0c9fdb63ef32a9f72e2174e55ce0cf0c69dcac0c96f00
7
- data.tar.gz: 8439a857e4d4a170b3802cbe34e040e940915c2b07dca61ea0cf9cd2e9a2995f7b02d447318ecda24ad8891ec080b6b2317a9b9e4b471dd11862002064b3ea19
6
+ metadata.gz: 746332e19a507f81dc0ee902a87664dcb0a55e3170d688d878b14faf508bfb67cc5dd3236a4961c6b15768fd47e7489b6b0cdbe5bdd5d328bcf9836f805d561d
7
+ data.tar.gz: 26a20b3318c99f34360bba90eee5698242f4043043991bf53d59e55b2507516452a5094c14366b19f6f53a140ff0b8a41f326a7048c13c4077f447eb2a083513
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.17.0
4
+
5
+ ### Added
6
+
7
+ - `PlanMyStuff.deprecator` returns a gem-scoped `ActiveSupport::Deprecation` instance.
8
+ Consuming apps can silence, filter, or re-route PMS deprecation warnings independently
9
+ of Rails' own deprecator.
10
+
11
+ ### Changed
12
+
13
+ - Issue, comment, and project-readme metadata is now stored in a visible `<details>` block
14
+ with a JSON code fence instead of a hidden HTML comment. GitHub renders the block in-page
15
+ so the metadata is inspectable without opening the body editor (closes #58).
16
+ `MetadataParser.parse` still accepts the legacy `<!-- pms-metadata:... -->` format and
17
+ emits a deprecation warning when it sees one; pre-0.17.0 bodies keep parsing and
18
+ re-serialize to the new format on their next write. Legacy detection will be removed
19
+ in 1.0.0.
20
+
3
21
  ## 0.16.0
4
22
 
5
23
  ### Added
@@ -1,10 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support/deprecation'
3
4
  require 'json'
4
5
 
5
6
  module PlanMyStuff
6
7
  module MetadataParser
7
- METADATA_PATTERN = /\A<!-- pms-metadata:(.*?) -->\n*/m
8
+ LEGACY_DEPRECATION_MESSAGE =
9
+ 'PlanMyStuff: legacy <!-- pms-metadata: ... --> body format detected. It will continue to parse ' \
10
+ 'until 1.0.0, at which point legacy detection will be removed. New writes already use the visible ' \
11
+ '<details> block format introduced in 0.17.0; existing bodies migrate on their next write.'
12
+
13
+ # New format: collapsible <details> block containing a JSON code fence.
14
+ # Renders visibly on GitHub (issue #58) instead of being hidden in an HTML comment.
15
+ METADATA_PATTERN = %r{
16
+ \A<details><summary>pms-metadata</summary>\n\n
17
+ ```json\n(.*?)\n```\n\n
18
+ </details>\n*
19
+ }mx
20
+
21
+ # Legacy format kept for parsing only - existing issues serialized before 0.17.0
22
+ # used a hidden HTML comment. They migrate to the new format on the next write.
23
+ LEGACY_METADATA_PATTERN = /\A<!-- pms-metadata:(.*?) -->\n*/m
8
24
 
9
25
  module_function
10
26
 
@@ -17,11 +33,14 @@ module PlanMyStuff
17
33
  def parse(raw_body)
18
34
  return { metadata: {}, body: '' } if raw_body.blank?
19
35
 
20
- match = raw_body.match(METADATA_PATTERN)
21
- return { metadata: {}, body: raw_body } if match.nil?
36
+ pattern = matching_pattern(raw_body)
37
+ return { metadata: {}, body: raw_body } if pattern.nil?
22
38
 
39
+ PlanMyStuff.deprecator.warn(LEGACY_DEPRECATION_MESSAGE) if pattern == LEGACY_METADATA_PATTERN
40
+
41
+ match = raw_body.match(pattern)
23
42
  metadata = JSON.parse(match[1], symbolize_names: true)
24
- body = raw_body.sub(METADATA_PATTERN, '')
43
+ body = raw_body.sub(pattern, '')
25
44
 
26
45
  { metadata: metadata, body: body }
27
46
  rescue JSON::ParserError
@@ -44,12 +63,21 @@ module PlanMyStuff
44
63
 
45
64
  json =
46
65
  if metadata.is_a?(PlanMyStuff::CustomFields)
47
- metadata.to_json
66
+ JSON.pretty_generate(metadata.to_h)
48
67
  else
49
68
  JSON.pretty_generate(metadata)
50
69
  end
51
70
 
52
- "<!-- pms-metadata:#{json} -->\n\n#{body}"
71
+ "<details><summary>pms-metadata</summary>\n\n```json\n#{json}\n```\n\n</details>\n\n#{body}"
72
+ end
73
+
74
+ # @param raw_body [String]
75
+ #
76
+ # @return [Regexp, nil] the pattern that matches at the start of +raw_body+, or +nil+ when neither matches
77
+ #
78
+ def matching_pattern(raw_body)
79
+ return METADATA_PATTERN if raw_body.match?(METADATA_PATTERN)
80
+ return LEGACY_METADATA_PATTERN if raw_body.match?(LEGACY_METADATA_PATTERN)
53
81
  end
54
82
  end
55
83
  end
@@ -3,7 +3,7 @@
3
3
  module PlanMyStuff
4
4
  module VERSION
5
5
  MAJOR = 0
6
- MINOR = 16
6
+ MINOR = 17
7
7
  TINY = 0
8
8
 
9
9
  # Set PRE to nil unless it's a pre-release (beta, rc, etc.)
data/lib/plan_my_stuff.rb CHANGED
@@ -38,6 +38,11 @@ module PlanMyStuff
38
38
  @configuration ||= PlanMyStuff::Configuration.new
39
39
  end
40
40
 
41
+ # @return [ActiveSupport::Deprecation]
42
+ def deprecator
43
+ @deprecator ||= ActiveSupport::Deprecation.new('1.0', 'PlanMyStuff')
44
+ end
45
+
41
46
  # @return [PlanMyStuff::Configuration]
42
47
  def configure
43
48
  yield(configuration)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plan_my_stuff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brands Insurance