textrepo 0.5.0 → 0.5.1
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 +10 -6
- data/lib/textrepo/repository.rb +11 -2
- 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: b504229bd3ea2416e0a85cb8903fe0903b6f045a8a2549857a2b1b296f35e32a
|
4
|
+
data.tar.gz: baaf7776505e0c430d9c540d88e78847eebc406612b5f9c2cb11ba20c5f3371d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb90a5d324536e0c2ba8f87c93923ba19bae2c835f31445f9d0f3701110f37598f44a638b496ac992dab30ea03f82643591ea807623a93bd0afdfa52505595ac
|
7
|
+
data.tar.gz: 1affcd1ff8cce4b3374610791ba733d5d5c8fd1d8b90adb5030725752c84c0f671d4ee9b6ca7f4539ebc2171baf1d2c92b9eb530dc84eed14d477df98729154e
|
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.1] - 2020-11-02
|
11
|
+
### Changed
|
12
|
+
- Fix issue #28.
|
13
|
+
- Modify `Repository#update` to do nothing when the given text is
|
14
|
+
identical to the one in the repository.
|
15
|
+
|
10
16
|
## [0.5.0] - 2020-11-01
|
11
17
|
### Added
|
12
18
|
- Add a new API `Repository#search`.
|
@@ -132,21 +132,25 @@ module Textrepo
|
|
132
132
|
# Updates the file content in the repository. A new timestamp
|
133
133
|
# will be attached to the text.
|
134
134
|
#
|
135
|
+
# See the documentation of Repository#update to know about errors
|
136
|
+
# and constraints of this method.
|
137
|
+
#
|
135
138
|
# :call-seq:
|
136
139
|
# update(Timestamp, Array) -> Timestamp
|
137
140
|
|
138
141
|
def update(timestamp, text)
|
139
142
|
raise EmptyTextError if text.empty?
|
140
|
-
|
141
|
-
|
143
|
+
raise MissingTimestampError, timestamp unless exist?(timestamp)
|
144
|
+
|
145
|
+
# does nothing if given text is the same in the repository one
|
146
|
+
return timestamp if read(timestamp) == text
|
142
147
|
|
143
148
|
# the text must be stored with the new timestamp
|
144
149
|
new_stamp = Timestamp.new(Time.now)
|
145
|
-
|
146
|
-
write_text(new_abs, text)
|
150
|
+
write_text(abspath(new_stamp), text)
|
147
151
|
|
148
|
-
# delete the original file in the repository
|
149
|
-
FileUtils.remove_file(
|
152
|
+
# delete the original text file in the repository
|
153
|
+
FileUtils.remove_file(abspath(timestamp))
|
150
154
|
|
151
155
|
new_stamp
|
152
156
|
end
|
data/lib/textrepo/repository.rb
CHANGED
@@ -43,8 +43,17 @@ module Textrepo
|
|
43
43
|
def read(timestamp); []; end
|
44
44
|
|
45
45
|
##
|
46
|
-
# Updates the content with text in the repository, which is
|
47
|
-
# associated to the timestamp. Returns the timestamp
|
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.
|
49
|
+
#
|
50
|
+
# If the given Timestamp is not existed as a Timestamp attached to
|
51
|
+
# text in the repository, raises MissingTimestampError.
|
52
|
+
#
|
53
|
+
# If the given text is empty, raises EmptyTextError.
|
54
|
+
#
|
55
|
+
# If the given text is identical to the text in the repository,
|
56
|
+
# does nothing. Returns the given timestamp itself.
|
48
57
|
#
|
49
58
|
# :call-seq:
|
50
59
|
# update(Timestamp, Array) -> Timestamp
|
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.1
|
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-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|