textrepo 0.5.7 → 0.5.8

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: b85b70f9d672503576cbce911f202dac9d00cf8af3915109f304c4c2745ce32f
4
- data.tar.gz: 9ca1decf965281c4f1a34b908a919478aafc915293412b3a9fa6e4903f57de45
3
+ metadata.gz: bf69f1606a2c55098ab6b3b8ea063aa7ee45dc06917d230abd4a29cc7a119c71
4
+ data.tar.gz: a366497c8ff6b8e305780aab3c0ac8c6bdc315e175f39ceb95ea020a6df163a1
5
5
  SHA512:
6
- metadata.gz: 6c24a75691c34d72dae4e33c13a22c7dc4a04539d29edcfafa31b93815b8fada5b0c7840f0c90b32b461eb925d28c32d0918dc65a5bda05592379d6f02ddd4bc
7
- data.tar.gz: bc16b111bf4bc9cc7ca62942025961ac572ee892925bcce0f6a6b8c2e78ea664affbbcb18d79832cd4168fcaf62b57410f0c058c315e600750e6e348d5541153
6
+ metadata.gz: 93b08a70c122530e33f05d9581052cfd17dcb56a85e03281ba9405394f946771f1b17734c1b6fd1d2771423f08c384bf2a8c0c895c5f08ff0f9b65bea3e23ae3
7
+ data.tar.gz: b9f1ce017a0e4f1b0bb68d05c9a2211b8bda3a4d78c4440c08549001b538f38c701ed0e712b14f7de510321a66afd610fc2520180322eecb4bf089fa0fbd4d4b
data/CHANGELOG.md CHANGED
@@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
- Nothing to record here.
8
+ - add a section to describe about **text** into `README.md`.
9
9
 
10
10
  ## [0.5.7] - 2020-11-16
11
11
  ### Fixed
data/README.md CHANGED
@@ -61,6 +61,32 @@ stamps.each { |stamp|
61
61
  Also see `examples` directory. There is a small tool to demonstrate
62
62
  how to use `textrepo`.
63
63
 
64
+ ## What is TEXT?
65
+
66
+ In macOS (or similar unix OS), text is a date stored into a regular
67
+ file. Its characteristics are;
68
+
69
+ - a character stream coded in some encoding system (such UTF-8),
70
+ - divided into multiple physical lines with newline character (`\n`).
71
+
72
+ In `textrepo` and its client program, a **text** is usually generated
73
+ from a text file mentioned above. It is;
74
+
75
+ - a character stream coded in UTF-8,
76
+ - consists of multiple logical lines (each of them does not contain a
77
+ newline character).
78
+
79
+ That is, newline characters are removed when text is read from a file
80
+ and added appropriately when it is written into a file.
81
+
82
+ So, **text** is represented with Ruby objects as follows:
83
+
84
+ - **Text** is represented with an `Array` object which contains
85
+ multiple `String` objects.
86
+ - A `String` object represents a **logical line** of **text**.
87
+ - Each `String` does not contain a newline character.
88
+ - An empty string ("") represents a empty line.
89
+
64
90
  ## Development
65
91
 
66
92
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -329,11 +329,11 @@ module Textrepo
329
329
  # Raises InvalidTimestampStringError if nil was passed as an arguemnt.
330
330
 
331
331
  def split_stamp(stamp_str)
332
- raise InvalidTimestampStringError, stamp_str if stamp_str.nil?
332
+ raise InvalidTimestampStringError, "(nil)" if stamp_str.nil?
333
333
  # yyyy mo dd hh mi ss sfx
334
334
  a = [0..3, 4..5, 6..7, 8..9, 10..11, 12..13, 15..17].map {|r| stamp_str[r]}
335
335
  a.delete_at(-1) if a[-1].nil?
336
- a
336
+ a.map{|e| e || "" }
337
337
  end
338
338
 
339
339
  ##
@@ -348,18 +348,15 @@ module Textrepo
348
348
  # parse_s("20201028163529_034") -> Timestamp
349
349
 
350
350
  def parse_s(stamp_str)
351
+ raise InvalidTimestampStringError, "(nil)" if stamp_str.nil?
352
+ raise InvalidTimestampStringError, "(empty string)" if stamp_str.empty?
353
+ raise InvalidTimestampStringError, stamp_str if stamp_str.size < 14
354
+
351
355
  begin
352
356
  ye, mo, da, ho, mi, se, sfx = split_stamp(stamp_str).map(&:to_i)
353
357
  Timestamp.new(Time.new(ye, mo, da, ho, mi, se), sfx)
354
- rescue InvalidTimestampStringError, ArgumentError => _
355
- emsg = if stamp_str.nil?
356
- "(nil)"
357
- elsif stamp_str.empty?
358
- "(empty string)"
359
- else
360
- stamp_str
361
- end
362
- raise InvalidTimestampStringError, emsg
358
+ rescue ArgumentRangeError, ArgumentError => _
359
+ raise InvalidTimestampStringError, stamp_str
363
360
  end
364
361
  end
365
362
  end
@@ -1,3 +1,3 @@
1
1
  module Textrepo
2
- VERSION = '0.5.7'
2
+ VERSION = '0.5.8'
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.7
4
+ version: 0.5.8
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-16 00:00:00.000000000 Z
11
+ date: 2021-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 3.1.4
80
+ rubygems_version: 3.2.3
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: A repository to store text with timestamp.