ememo 0.1.3 → 0.1.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: e1ca177efd44fb41e17369880b0b1eeef3ebd0621d8b0a0cb6bcfcc745226a2b
4
- data.tar.gz: b69e951784f07858f1a5c41ac77750d602f673df4b277b23818e8b2da64215c8
3
+ metadata.gz: dede73f4554893f7c86e93fcace9f46cdd5a0e400a48f0bba9fa6b90b247a1a4
4
+ data.tar.gz: 370969e099cbb3cf7f4f2c7df8394d732b870bd7ebe06e281bb9875cb5b07950
5
5
  SHA512:
6
- metadata.gz: c3641578d3a85335068f9c494d78628cc2aa4f917b59006021e467fdcea397272121f65d71b17f7e86b070d313ee22f2dec1e0058715b0714d49858a8bcbf679
7
- data.tar.gz: 6eedb18028daace0dbb1a4e4cd99d70624501fcb4eb53f00b43efed2225d1dc5b551e09d7e45a97af0a3d36609a9cd846f48fa236aedb023b3b15fd1e7c8d4d3
6
+ metadata.gz: a612d30f432a03bdc4fafcf69e3bf931a6a6a02e0fb03431a5135a7f52cd2c65fcf16dccacea769fca69dacc2070aae6325f84ff2324d6cd5e62aa4a4f11ebd6
7
+ data.tar.gz: 663834f3dd486413f6817fd84dc02e6d07894211dc994eab279ac4c9a8869b336a548aebd39f8b1c8cbe626e9158c377aaee0c6c4e0922d2f13d6cc348503236
data/Gemfile CHANGED
@@ -6,5 +6,6 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
+ gem "pry"
9
10
 
10
11
  gem "test-unit", "~> 3.0"
@@ -1,13 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ememo (0.1.3)
4
+ ememo (0.1.8)
5
5
  tomlrb
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ coderay (1.1.3)
11
+ method_source (1.0.0)
10
12
  power_assert (1.2.0)
13
+ pry (0.13.1)
14
+ coderay (~> 1.1)
15
+ method_source (~> 1.0)
11
16
  rake (13.0.3)
12
17
  test-unit (3.3.7)
13
18
  power_assert
@@ -18,6 +23,7 @@ PLATFORMS
18
23
 
19
24
  DEPENDENCIES
20
25
  ememo!
26
+ pry
21
27
  rake (~> 13.0)
22
28
  test-unit (~> 3.0)
23
29
 
data/README.md CHANGED
@@ -70,8 +70,28 @@ $ memo p todo -n project1
70
70
  # with namespace_alias
71
71
  $ memo p todo -n p
72
72
 
73
+ # copy to clipboard
74
+ $ memo p todo -n p -c
75
+ $ memo p todo -n p -copy
73
76
  ```
74
77
 
78
+ ### List
79
+ ```bash
80
+ # list of ~/.memo/mymemo/memo.md
81
+ $ memo l
82
+ $ memo list
83
+
84
+ # list ~/.memo/project1/todo.md
85
+ $ memo l -n project1
86
+
87
+ # all
88
+ $ memo l -a
89
+ $ memo l -all
90
+
91
+ # list of direcory
92
+ $ memo l -d
93
+ $ memo l -dir
94
+ ```
75
95
  ### Today
76
96
  ```bash
77
97
  # edit today's memo (~/.memo/2021/1/1.md)
@@ -115,6 +135,8 @@ $ memo ptw
115
135
  ext = "md"
116
136
  root = "~/.memo"
117
137
  editor = "vim"
138
+ # pbcopy = "pbcopy"
139
+ # pbcopy = "xsel --clipboard --input"
118
140
  preview = "bat"
119
141
  fuzzy_finder = "fzf --preview 'bat --color=always {}'"
120
142
  default_filename = "memo"
@@ -123,6 +145,7 @@ default_namespace = "general"
123
145
  [namespace_alias]
124
146
  w = "work"
125
147
  p = "private"
148
+ w1 = "work/project1"
126
149
 
127
150
  [command_alias]
128
151
  etw = "e todo -n w"
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "memo/version"
4
- require "pry"
5
4
  require "tomlrb"
6
5
 
7
6
  Dir["#{__dir__}/**/*.rb"].
@@ -3,19 +3,41 @@ module Memo
3
3
  attr_reader :namespace
4
4
 
5
5
  def initialize(args)
6
- @args = args.to_a
6
+ @raw_args = args.to_a
7
7
 
8
- case args
8
+ case @raw_args
9
9
  in [*, "-n", namespace, *]
10
10
  @namespace = namespace
11
- @args.delete("-n")
12
- @args.delete(namespace)
11
+ @raw_args.delete("-n")
12
+ @raw_args.delete(namespace)
13
13
  else
14
14
  end
15
+
16
+ @args = @raw_args.select do |s|
17
+ !s.start_with? "-"
18
+ end
15
19
  end
16
20
 
17
21
  def [](index)
18
22
  @args[index]
19
23
  end
24
+
25
+ def dir?
26
+ include_any? "-dir", "-d"
27
+ end
28
+
29
+ def all?
30
+ include_any? "-all", "-a"
31
+ end
32
+
33
+ def copy?
34
+ include_any? "-copy", "-c"
35
+ end
36
+
37
+ private
38
+
39
+ def include_any?(*args)
40
+ args.map { |a| @raw_args.include?(a) }.any?
41
+ end
20
42
  end
21
43
  end
@@ -17,6 +17,8 @@ module Memo
17
17
  Command::Preview
18
18
  when "today", "t"
19
19
  Command::Today
20
+ when "list", "l"
21
+ Command::List
20
22
  when "config", "c"
21
23
  Command::Config
22
24
  when "help", "h"
@@ -0,0 +1,33 @@
1
+ module Memo
2
+ class Cli
3
+ module Command
4
+ class List
5
+ def initialize(
6
+ options,
7
+ os: Memo::OS.new
8
+ )
9
+ @options = options
10
+ @os = os
11
+ @config = Memo::Config.new
12
+ end
13
+
14
+ def call
15
+ namespace = @options.namespace
16
+ is_all = @options.all?
17
+ type = @options.dir? ? "d" : "f"
18
+
19
+ dir = if is_all
20
+ ""
21
+ else
22
+ Memo::File.new(
23
+ "",
24
+ @options.namespace,
25
+ ).dir
26
+ end
27
+
28
+ @os.exec "find #{@config.root}/#{dir} -type #{type}"
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -15,6 +15,7 @@ module Memo
15
15
 
16
16
  def call
17
17
  filename = @options[0]
18
+
18
19
  path = case filename
19
20
  when "today", "t"
20
21
  @today.fullpath
@@ -25,7 +26,12 @@ module Memo
25
26
  ).fullpath
26
27
  end
27
28
 
28
- @os.exec "#{@config.preview} #{@config.root}/#{path}"
29
+ cmd ="#{@config.preview} #{@config.root}/#{path}"
30
+ if @options.copy?
31
+ @os.exec "#{cmd} | (#{@config.pbcopy})"
32
+ end
33
+
34
+ @os.exec cmd
29
35
  end
30
36
  end
31
37
  end
@@ -24,6 +24,7 @@ module Memo
24
24
 
25
25
  def ext = @config[:ext] || Default::Ext.to_s
26
26
  def root = @config[:root] || Default::Root.to_s
27
+ def pbcopy = @config[:pbcopy] || Default::Pbcopy.to_s
27
28
  def preview = @config[:preview] || Default::Preview.to_s
28
29
 
29
30
  def fuzzy_finder = @config[:fuzzy_finder] ||
@@ -8,6 +8,10 @@ module Memo
8
8
  def self.to_s = "cat"
9
9
  end
10
10
 
11
+ class Pbcopy
12
+ def self.to_s = "pbcopy"
13
+ end
14
+
11
15
  class Root
12
16
  def self.to_s = "~/.memo"
13
17
  end
@@ -7,7 +7,7 @@ module Memo
7
7
  end
8
8
 
9
9
  def dir = "#{@year}/#{@month}"
10
- def file = "#{@day}.#{@config.ext}"
10
+ def file = "#{@day}.#{@config.ext}"
11
11
  def fullpath = "#{dir}/#{file}"
12
12
  end
13
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Memo
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.8"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ememo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuma Ishikawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-14 00:00:00.000000000 Z
11
+ date: 2021-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb
@@ -52,6 +52,7 @@ files:
52
52
  - lib/memo/cli/command/edit.rb
53
53
  - lib/memo/cli/command/fuzzy.rb
54
54
  - lib/memo/cli/command/help.rb
55
+ - lib/memo/cli/command/list.rb
55
56
  - lib/memo/cli/command/preview.rb
56
57
  - lib/memo/cli/command/setup.rb
57
58
  - lib/memo/cli/command/today.rb