rbnotes 0.3.1 → 0.4.0

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: 2cb54d2116edee3136979232f749434f0b4c068fa5162321bd02dfc96fcd8ece
4
- data.tar.gz: 1d3d61b2cafa2d7a2825deb764ee232729e0a7bc8afa51868dbd98db2b7c016f
3
+ metadata.gz: 87313e606a2e62b90b3e1c3f00ff46300f0e7a14e3b2fc8ffcad0abfda217646
4
+ data.tar.gz: 95b8a57ca200b8a8460f61edfe0d796dcfec2f63cba4ec024294915f07752aa8
5
5
  SHA512:
6
- metadata.gz: 07a40884e1f0a73bc4b3d70104d98d56814084ce643b86715cf739ece89124da45236cccc4ba881f78e176b8ee318eceaa5974811e4f990d81dce17a018b8a74
7
- data.tar.gz: fd70d8ed8d461610cf0f60fe506588414abbd2f9a6fe9deabe8de49ca7a3146d49efcb799b25bb4f66158afc4298643993f1d2a3a7e21d095efe2e7462d8792f
6
+ metadata.gz: 238f9140497e09ee4aedc331716c5725e61e00332255160d70844099e7f5d3f072f00edc3800e063f1f09e9e9c67669ca901c60c16c88a37e4594c07c9744238
7
+ data.tar.gz: de00ee60c187517ec47f4601c572abc83f99dc3f4cde96c4db86e8cdda012eda5bdd5b1529fdf086f7f1858637720752bba8fa244d3e21f63d25456c56b7c71e
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
  ## [Unreleased]
8
8
  Nothing to record here.
9
9
 
10
+ ## [0.4.0] - 2020-11-03
11
+ ### Added
12
+ - Add a new command `search` to perform full text search. (#33)
13
+
10
14
  ## [0.3.1] - 2020-10-30
11
15
  ### Added
12
16
  - Add feature to specify configuration file in the command line. (#21)
data/Gemfile CHANGED
@@ -6,4 +6,4 @@ gemspec
6
6
  gem "rake", "~> 13.0"
7
7
  gem "minitest", "~> 5.0"
8
8
 
9
- gem 'textrepo', "~> 0.4"
9
+ gem 'textrepo', "~> 0.5"
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbnotes (0.3.1)
5
- textrepo (~> 0.4)
4
+ rbnotes (0.4.0)
5
+ textrepo (~> 0.5)
6
6
  unicode-display_width (~> 1.7)
7
7
 
8
8
  GEM
@@ -10,7 +10,7 @@ GEM
10
10
  specs:
11
11
  minitest (5.14.2)
12
12
  rake (13.0.1)
13
- textrepo (0.4.5)
13
+ textrepo (0.5.3)
14
14
  unicode-display_width (1.7.0)
15
15
 
16
16
  PLATFORMS
@@ -20,7 +20,7 @@ DEPENDENCIES
20
20
  minitest (~> 5.0)
21
21
  rake (~> 13.0)
22
22
  rbnotes!
23
- textrepo (~> 0.4)
23
+ textrepo (~> 0.5)
24
24
 
25
25
  BUNDLED WITH
26
26
  2.1.4
@@ -4,8 +4,6 @@ require "rbnotes"
4
4
 
5
5
  include Rbnotes
6
6
 
7
- DEBUG = true
8
-
9
7
  class App
10
8
  def initialize
11
9
  @gopts = {}
@@ -24,6 +24,9 @@ module Rbnotes
24
24
  # "20201027": specifies year and date
25
25
  # - all Timestamps those have the same year and date would match
26
26
  #
27
+ # "202011": specifies year and month
28
+ # - all Timestamps those have the same year and month would match
29
+ #
27
30
  # "2020": specifies year only
28
31
  # - all Timestamps those have the same year would match
29
32
  #
@@ -0,0 +1,46 @@
1
+ # :markup: markdown
2
+
3
+ ##
4
+ # Searches a given pattern in notes those have timestamps match a
5
+ # given timestamp pattern. The first argument is a pattern to search.
6
+ # It is a String object represents a portion of text or it may a
7
+ # String represents a regular expression. The second argument is
8
+ # optional and it is a timestamp pattern to specify the search target.
9
+ #
10
+ # A pattern for search is mandatory. If no pattern, raises
11
+ # Rbnotes::MissingArgumentError.
12
+ #
13
+ # Example of PATTERN:
14
+ # ""rbnotes" (a word)
15
+ # "macOS Big Sur" (a few words)
16
+ # "2[0-9]{3}(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])" (a regular expression)
17
+ #
18
+ # A timestamp pattern is optional. If no timestamp pattern, all notes
19
+ # in the repository would be target of search.
20
+ #
21
+ # See the document of `Rbnotes::Commands::List#execute` to know about
22
+ # a timestamp pattern.
23
+
24
+ # :stopdoc:
25
+
26
+ module Rbnotes
27
+ class Commands::Search < Commands::Command
28
+ def execute(args, conf)
29
+ pattern = args.shift
30
+ raise MissingArgumentError, args if pattern.nil?
31
+
32
+ timestamp_pattern = args.shift # `nil` is acceptable
33
+
34
+ repo = Textrepo.init(conf)
35
+ begin
36
+ result = repo.search(pattern, timestamp_pattern)
37
+ rescue Textrepo::InvalidSearchResultError => e
38
+ puts e.message
39
+ else
40
+ result.each { |stamp, num, match|
41
+ puts "#{stamp}:#{num}:#{match}"
42
+ }
43
+ end
44
+ end
45
+ end
46
+ end
@@ -44,7 +44,7 @@ module Rbnotes::Commands
44
44
  end
45
45
 
46
46
  tmpfile = run_with_tmpfile(editor, target_stamp.to_s, text)
47
- text = File.readlines(tmpfile)
47
+ text = File.readlines(tmpfile, :chomp => true)
48
48
 
49
49
  unless text.empty?
50
50
  newstamp = nil
@@ -53,7 +53,7 @@ module Rbnotes::Commands
53
53
  rescue StandardError => e
54
54
  puts e.message
55
55
  else
56
- puts "Update the note [%s -> %s]" % [target_stamp, newstamp]
56
+ puts "Update the note [%s -> %s]" % [target_stamp, newstamp] unless target_stamp == newstamp
57
57
  ensure
58
58
  # Don't forget to remove the temporary file.
59
59
  File.delete(tmpfile)
@@ -113,7 +113,11 @@ module Rbnotes
113
113
  # foo bar baz ...
114
114
  #
115
115
  # then, only the first string is interested
116
- io.gets.split(" ")[0]
116
+ begin
117
+ io.gets.split(":")[0].rstrip
118
+ rescue NoMethodError => _
119
+ nil
120
+ end
117
121
  end
118
122
  module_function :read_arg
119
123
 
@@ -1,4 +1,4 @@
1
1
  module Rbnotes
2
- VERSION = "0.3.1"
3
- RELEASE = '2020-10-30'
2
+ VERSION = "0.4.0"
3
+ RELEASE = "2020-11-03"
4
4
  end
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
27
 
28
- spec.add_dependency "textrepo", "~> 0.4"
28
+ spec.add_dependency "textrepo", "~> 0.5"
29
29
  spec.add_dependency "unicode-display_width", "~> 1.7"
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbnotes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mnbi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-30 00:00:00.000000000 Z
11
+ date: 2020-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: textrepo
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.4'
19
+ version: '0.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.4'
26
+ version: '0.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: unicode-display_width
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,7 @@ files:
66
66
  - lib/rbnotes/commands/delete.rb
67
67
  - lib/rbnotes/commands/import.rb
68
68
  - lib/rbnotes/commands/list.rb
69
+ - lib/rbnotes/commands/search.rb
69
70
  - lib/rbnotes/commands/show.rb
70
71
  - lib/rbnotes/commands/update.rb
71
72
  - lib/rbnotes/conf.rb