textrepo 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/textrepo/file_system_repository.rb +13 -11
- data/lib/textrepo/repository.rb +11 -6
- data/lib/textrepo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa38f5fbd3d1fd393eeb4ac200d1c051d8ff082cd92beaf0ab1b3756efd79e92
|
4
|
+
data.tar.gz: 70107459347c9685f722a4aa2367c1f04ec3257c12c489a1436d242e2f322f4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19e12a6e1ac352a005aca887e887089a8daa8ae8fa0573e3d640803f19950747addd52ed77ddb9da9534f7b9596cc125917c9892ea2a14a031aaae33df753e01
|
7
|
+
data.tar.gz: 3c304dbd6330719398ee377183ac26f29ffdfa89b279ff12fac795e9ad664e7b3b249c8f79d36e3bae215e7e114064dd01d3bb23b6652cd2147c8c09382d01ff
|
data/CHANGELOG.md
CHANGED
@@ -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
|
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
|
-
|
150
|
-
|
151
|
-
|
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
|
-
|
158
|
+
stamp
|
157
159
|
end
|
158
160
|
|
159
161
|
##
|
data/lib/textrepo/repository.rb
CHANGED
@@ -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
|
48
|
-
# generated during the execution.
|
47
|
+
# associated to the given Timestamp object. Returns the Timestamp
|
48
|
+
# newly generated during the execution.
|
49
49
|
#
|
50
|
-
#
|
51
|
-
#
|
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
|
data/lib/textrepo/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|