textrepo 0.5.3 → 0.5.4

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: b8a737ed78449fe9562b18fa9a1e6f5a06e8adb7e460dd5fd35ac9f9a5127e6e
4
- data.tar.gz: af06e6e6e6c004253452a8c8871de26b93e800ac090c0cf3d1c446ea498bd386
3
+ metadata.gz: fa38f5fbd3d1fd393eeb4ac200d1c051d8ff082cd92beaf0ab1b3756efd79e92
4
+ data.tar.gz: 70107459347c9685f722a4aa2367c1f04ec3257c12c489a1436d242e2f322f4f
5
5
  SHA512:
6
- metadata.gz: e433bbb36d848f98c0f75999fecd01b29e69e9767e1d11d32897e78b50394c2787087deed5718e2266d81390736435d25e48285b47087179d64411a8a56ad21a
7
- data.tar.gz: 414bdb550479be8dbb7dff29569b04064cb1a40704de8fad3d36c90ffd9ffcf73b69b4a651987245a481878e27a62e8251399ede6f81b5fb4c16c173a76da4e3
6
+ metadata.gz: 19e12a6e1ac352a005aca887e887089a8daa8ae8fa0573e3d640803f19950747addd52ed77ddb9da9534f7b9596cc125917c9892ea2a14a031aaae33df753e01
7
+ data.tar.gz: 3c304dbd6330719398ee377183ac26f29ffdfa89b279ff12fac795e9ad664e7b3b249c8f79d36e3bae215e7e114064dd01d3bb23b6652cd2147c8c09382d01ff
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
  ## [Unreleased]
8
8
  Nothing to record here.
9
9
 
10
+ ## [0.5.4] - 2020-11-05
11
+ ### Add
12
+ - Add a feature for `Repository#update` to keep timestamp unchanged
13
+ - add the third argument as:
14
+ - `Repository#update(timestamp, text, keep_stamp = false)`
15
+
10
16
  ## [0.5.3] - 2020-11-03
11
17
  ### Changed
12
18
  - Fix issue #38: fix typo in code for FileSystemRepository.
@@ -130,30 +130,32 @@ module Textrepo
130
130
  end
131
131
 
132
132
  ##
133
- # Updates the file content in the repository. A new timestamp
134
- # will be attached to the text.
133
+ # Updates the file content in the repository. A new Timestamp
134
+ # object will be attached to the text. Then, returns the new
135
+ # Timestamp object.
136
+ #
137
+ # When true is passed as the third argument, keeps the Timestamp
138
+ # unchanged, though updates the content. Then, returns the given
139
+ # Timestamp object.
135
140
  #
136
141
  # See the documentation of Repository#update to know about errors
137
142
  # and constraints of this method.
138
143
  #
139
144
  # :call-seq:
140
- # update(Timestamp, Array) -> Timestamp
145
+ # update(Timestamp, Array, true or false) -> Timestamp
141
146
 
142
- def update(timestamp, text)
147
+ def update(timestamp, text, keep_stamp = false)
143
148
  raise EmptyTextError if text.empty?
144
149
  raise MissingTimestampError, timestamp unless exist?(timestamp)
145
150
 
146
151
  # does nothing if given text is the same in the repository one
147
152
  return timestamp if read(timestamp) == text
148
153
 
149
- # the text must be stored with the new timestamp
150
- new_stamp = Timestamp.new(Time.now)
151
- write_text(abspath(new_stamp), text)
152
-
153
- # delete the original text file in the repository
154
- FileUtils.remove_file(abspath(timestamp))
154
+ stamp = keep_stamp ? timestamp : Timestamp.new(Time.now)
155
+ write_text(abspath(stamp), text)
156
+ FileUtils.remove_file(abspath(timestamp)) unless keep_stamp
155
157
 
156
- new_stamp
158
+ stamp
157
159
  end
158
160
 
159
161
  ##
@@ -44,11 +44,16 @@ module Textrepo
44
44
 
45
45
  ##
46
46
  # Updates the content with given text in the repository, which is
47
- # associated to the given timestamp. Returns the timestamp newly
48
- # generated during the execution.
47
+ # associated to the given Timestamp object. Returns the Timestamp
48
+ # newly generated during the execution.
49
49
  #
50
- # If the given Timestamp is not existed as a Timestamp attached to
51
- # text in the repository, raises MissingTimestampError.
50
+ # When true is passed as the third argument, keeps the Timestamp
51
+ # unchanged, though updates the content. Then, returns the given
52
+ # Timestamp object.
53
+ #
54
+ # If the given Timestamp object is not existed as a Timestamp
55
+ # attached to text in the repository, raises
56
+ # MissingTimestampError.
52
57
  #
53
58
  # If the given text is empty, raises EmptyTextError.
54
59
  #
@@ -56,9 +61,9 @@ module Textrepo
56
61
  # does nothing. Returns the given timestamp itself.
57
62
  #
58
63
  # :call-seq:
59
- # update(Timestamp, Array) -> Timestamp
64
+ # update(Timestamp, Array, true or false) -> Timestamp
60
65
 
61
- def update(timestamp, text); timestamp; end
66
+ def update(timestamp, text, keep_stamp = false); timestamp; end
62
67
 
63
68
  ##
64
69
  # Deletes the content in the repository, which is associated to
@@ -1,3 +1,3 @@
1
1
  module Textrepo
2
- VERSION = '0.5.3'
2
+ VERSION = '0.5.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textrepo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - mnbi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-03 00:00:00.000000000 Z
11
+ date: 2020-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler