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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc5cf6089b4883c93dc228e19aa0a149d71a8d9cc26a92e6c75fdc4ee0b2d694
4
- data.tar.gz: 8ebecace02d486b6b6c12256d52adfd44963a3a14f6d39729b83d426bce3a26e
3
+ metadata.gz: b504229bd3ea2416e0a85cb8903fe0903b6f045a8a2549857a2b1b296f35e32a
4
+ data.tar.gz: baaf7776505e0c430d9c540d88e78847eebc406612b5f9c2cb11ba20c5f3371d
5
5
  SHA512:
6
- metadata.gz: aef27bf0363a66eeb1676ccda0682c253155875a8d0c16b27189674836edf2563b8df87b7f3b56cdb5d02c895f724f47a956588a5d97d24d83cdddce76fc083e
7
- data.tar.gz: 81a4f8a76eb0ec8545e29ddbd537d49ec00f6009f5617dad61c61d8a5552c6df090d6d37fd507a7976c5f5f60b7d0c8b43f9a99d98d7efa1e933828270711d87
6
+ metadata.gz: cb90a5d324536e0c2ba8f87c93923ba19bae2c835f31445f9d0f3701110f37598f44a638b496ac992dab30ea03f82643591ea807623a93bd0afdfa52505595ac
7
+ data.tar.gz: 1affcd1ff8cce4b3374610791ba733d5d5c8fd1d8b90adb5030725752c84c0f671d4ee9b6ca7f4539ebc2171baf1d2c92b9eb530dc84eed14d477df98729154e
@@ -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
- org_abs = abspath(timestamp)
141
- raise MissingTimestampError, timestamp unless FileTest.exist?(org_abs)
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
- new_abs = abspath(new_stamp)
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(org_abs)
152
+ # delete the original text file in the repository
153
+ FileUtils.remove_file(abspath(timestamp))
150
154
 
151
155
  new_stamp
152
156
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Textrepo
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
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.0
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-01 00:00:00.000000000 Z
11
+ date: 2020-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler