GithubHelp home page GithubHelp logo

textrepo's People

Contributors

mnbi avatar

Watchers

 avatar

textrepo's Issues

Add new method, Repository#exist?

Like FileTest.exist? in Ruby, the method returns true when a note exists with the given timestamp in the repository. Otherwise, returns false. If the argument is invalid as a timestamp string, it raises an error.

Add a new feature to update without changing its timestamp

Is it annoying to change the timestamp with slight portion of change?
For example, just fix a typo.

So, Repository#update needs an option to keep timestamp unchanged. When the option was specified, it would update only the content and it would not touch the timestamp.

The interface should be like:

Repository#update(timestamp, text, keep_stamp = false)

The third argument is optional, and it has a default value, false. That is, this modification would not cause any inconsistency for existing client programs.

Short usage should be in README.md

The current example in the examples directory is too long to grab what textrepo is.
Short usage will help people to visit this repository.
Could you write 3 lines usage to illustrate the characteristic of textrepo?
Or 5 lines, 10 lines, ...

Add a new method, `Repository#find`

Repository#find accepts on argument which specifies a timestamp pattern.
A timestamp pattern looks like, "20201016", "2020", "1016".

It returns an array of notes those timestamp match the pattern.
If no note match, an empty array will be returned.

`FileSystemRepository#entries` returns wrong value

FileSystemRepository#entries returns an array. Currently, the array contains strings those are represents Timestamps. Should they be Timestamp objects?

The original concept of this method is intended to be written as:

repo = Textrepo.init(conf)
notes = repo.entries("20201027")
notes.each { |n|
  repo.delete(n)
}

If entries returns an array of string, user code must convert it to Timestamp object to use it with other Repository methods, since all other Repository methods accepts a Timestamp object instead of a string.

A month and day pattern matches incorrectly (`FileSystemRepository#entries`)

In the ri document of Repository#entries, 4 digits pattern specifies year only or month and day.
However, in FileSystemRepository#entries, 4 digits pattern such "1116" matches to not only "Nov. 16th" but "11:16" or "11 minute 16 second".

That is, FileSystemRepository#entries("1116") might match the followings:

  • 20201116131700
  • 20200901111600
  • 20201030121116

According to the spec (the ri doc), 1116 pattern must not match the 2nd and the 3rd ones.

More documenation

At least, description of API for the following module/class is needed to use textrepo.

  • Textrepo
  • Textrepo::Timestamp
  • Textrepo::Repository

Use "-H" option for searcher option

All of BSD grep, GNU grep, and ripgrep have "-H" option. When use this option, filename will be shown as a prefix for each line of search result.

Using the option, the code of FileSystemRepository#invoke_searcher_for_entries will be written more simple.

Add more methods for Timestamp class

Enrich Timestamp class.

A Timestamp class object has two aspects. It could be handled as a Time object. In some case, it could be also handled as a String object. That is, some methods of Time class or String class are also useful to Timestamp class.

Enable Travis CI

Currently, this repository does not work with Travis CI.
It must be enable it.

Some trailing spaces exists in some files.

Following files has trailing spaces.

  • lib/textrepo/file_system_repository.rb (65)
  • lib/textrepo/timestmp.rb (158)
  • examples/rbnotes/lib/rbnotes/commands/list.rb (39)
  • test/fixtures/setup_test_repo.rb (31)
  • test/textrepo_timestamp_test.rb (94)

They should be removed.

Trailing spaces can be found using searcher like rg. Here is an example to find:

> rg '[\s]+$'

Repository#update should not update with the same text

Current implementation of FileSystemRepository#update always update the text in the repository even if the given content is identical to the text. Though the text is essentially unchanged, the timestamp is replaced with the new one. This behavior is weird.

Document for FileSystemRepository.new has a typo

It says:

search behavior equivalent to grep with "-inR". ...

However, in he below of the document, the description about the default value of the searcher options says:

"grep" => ["-i", "-n", "-R", "-E"]

It is an inconsistency. It seems that the former such "-inR" must be "-inRE".

Clear definition of an array stored text must be documented

Textrepo::Repository APIs (such create, read, and update) accept and return an array of text.

However, the definition is unclear.

In textrepo and its client programs, "text" is defined as;

  • a "text" contains multiple physical "line"s
  • a physical "line" is represented with a String object
  • a "text" is represented with an Array object of String objects

So, a newline code at the end of String object is needless.
This means that newlines must be removed from at the end of lines when they are read from the file.

However, the above definition is not documented. It must be.

`Timestamp.parse_s` crashes when year and date string was passed

This issue was originally opened against rbnotes (mnbi/rbnotes#97).

Describe the symptom shortly again:

a. Timestamp.parse_s raises InvalidTimestampStringError when an invalid argument was passed such as "202012" (year and month), since some information is missing in the string. This behavior is correct. That is, it works as designed.

b. The same method causes a crash when a string was passed such as "20201211" (year and date). Though the string is also invalid as a timestamp, the crash is not correct behavior.

Add a new interface to Repository to search text

The interface is to search full text in the repository. Currently, textrepo assumes that all text is written in the UTF-8 encoding. So, the given search word must be in the UTF-8.

The API should be:

  • Repository#search(String) -> Array of match information

The only argument is a search keyword or a pattern (regular expression?).

Match information contains at lease a Timestamp object and line numbers contains the key word (or pattern).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.