ememo 0.1.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 06e51c0750adcc78957988fc197cd038732188558ea98a3fc688e14cc55c5f84
4
+ data.tar.gz: 56886682e8241d285877849bf899231afb2410709b7f2081e1cae7d0b80c6fb0
5
+ SHA512:
6
+ metadata.gz: d5ff03a485f8d75a2ab9ec3bd5e3916a1368528d7161253c3bb3bb21d1d16339a8902b5a67d663c88c34492874e776090105a252eb69a81f42803cc63bdda2a5
7
+ data.tar.gz: a7cf9b2b0de9d863eafefc6f52241a89590dc335daedc562e1e8157ea96cf6844c09455d83529b72e22f46865c68ec46bd640845d3fe19a6c3ab11d9bac3b802
@@ -0,0 +1,18 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.0
14
+ - name: Run the default task
15
+ run: |
16
+ gem install bundler -v 2.2.5
17
+ bundle install
18
+ bundle exec rake
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ config.test.toml
@@ -0,0 +1 @@
1
+ 3.0.0
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at yuma.fuu05@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in memo.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "test-unit", "~> 3.0"
@@ -0,0 +1,31 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ememo (0.1.2)
5
+ pry
6
+ tomlrb
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ coderay (1.1.3)
12
+ method_source (1.0.0)
13
+ power_assert (1.2.0)
14
+ pry (0.13.1)
15
+ coderay (~> 1.1)
16
+ method_source (~> 1.0)
17
+ rake (13.0.3)
18
+ test-unit (3.3.7)
19
+ power_assert
20
+ tomlrb (2.0.1)
21
+
22
+ PLATFORMS
23
+ x86_64-linux
24
+
25
+ DEPENDENCIES
26
+ ememo!
27
+ rake (~> 13.0)
28
+ test-unit (~> 3.0)
29
+
30
+ BUNDLED WITH
31
+ 2.2.3
@@ -0,0 +1,138 @@
1
+ # Ememo
2
+ Easy Memo
3
+
4
+ ## Requirement
5
+ - Ruby 3.0.0+
6
+
7
+ #### Optional
8
+ - <a href="http://github.com/junegunn/fzf" target="_blank">
9
+ fzf
10
+ </a> ( or other fuzzy finder )
11
+
12
+ ## Demo
13
+ ![memo](https://user-images.githubusercontent.com/32477095/104561601-fb81de80-568a-11eb-9e4b-a823a6311be7.gif)
14
+
15
+
16
+ ## Installation
17
+ ```bash
18
+ $ gem install ememo
19
+ ```
20
+
21
+ ## Config
22
+ ```bash
23
+ # Create config file to ENV["MEMO_CONFIG"] or "~/.memo/config"
24
+ # You can skip this step
25
+ $ memo setup
26
+
27
+ # edit config file
28
+ # with ENV["EDITOR"] or vim
29
+ $ memo c
30
+ $ memo config
31
+ ```
32
+
33
+ ## Usage
34
+ ### Edit
35
+ ```toml
36
+ [config]
37
+ # default is ENV["EDITOR"] or vim
38
+ editor = "emacs"
39
+
40
+ [namespace_alias]
41
+ p = "project1"
42
+ ```
43
+ ```bash
44
+ # edit ~/.memo/mymemo/memo.md with editor
45
+ $ memo e
46
+ $ memo edit
47
+
48
+ # edit ~/.memo/mymemo/todo.md with editor
49
+ $ memo edit todo
50
+
51
+ # edit ~/.memo/project1/todo.md with editor
52
+ $ memo edit todo -n project1
53
+
54
+ # with namespace_alias
55
+ $ memo edit todo -n p
56
+ ```
57
+
58
+ ### Preview
59
+ ```bash
60
+ # preview ~/.memo/mymemo/memo.md
61
+ $ memo p
62
+ $ memo preview
63
+
64
+ # preview ~/.memo/mymemo/todo.md
65
+ $ memo p todo
66
+
67
+ # preview ~/.memo/project1/todo.md
68
+ $ memo p todo -n project1
69
+
70
+ # with namespace_alias
71
+ $ memo p todo -n p
72
+
73
+ ```
74
+
75
+ ### Today
76
+ ```bash
77
+ # edit today's memo (~/.memo/2021/1/1.md)
78
+ $ memo t
79
+ $ memo today
80
+
81
+ # preview today's memo (~/.memo/2021/1/1.md)
82
+ $ memo p t
83
+ ```
84
+
85
+ ### FuzzyFind
86
+ ```toml
87
+ [config]
88
+ # default is fzf
89
+ fuzzy_finder = "peco"
90
+ ```
91
+ ```bash
92
+ # fuzzy find memo
93
+ $ memo fuzzy
94
+ $ memo f
95
+ ```
96
+
97
+ ### Custom Command
98
+ You can register command_alias
99
+ ```toml
100
+ [command_alias]
101
+ etw = "e todo -n w"
102
+ ptw = "p todo -n w"
103
+ ```
104
+ ```bash
105
+ $ memo etw
106
+ # => `memo edit todo -n work`
107
+
108
+ $ memo ptw
109
+ # => `memo preview todo -n work`
110
+ ```
111
+
112
+ ## Sample Config
113
+ ```toml
114
+ [config]
115
+ ext = "md"
116
+ root = "~/.memo"
117
+ editor = "vim"
118
+ preview = "bat"
119
+ fuzzy_finder = "fzf --preview 'bat --color=always {}'"
120
+ default_filename = "memo"
121
+ default_namespace = "general"
122
+
123
+ [namespace_alias]
124
+ w = "work"
125
+ p = "private"
126
+
127
+ [command_alias]
128
+ etw = "e todo -n w"
129
+ ptw = "p todo -n w"
130
+ ```
131
+
132
+ ## Author
133
+
134
+ [@YumaFuu](https://github.com/YumaFuu)
135
+
136
+ ## Licence
137
+ mit
138
+
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "memo"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/memo"
4
+ Memo::Cli.new(ARGV).()
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "memo/version"
4
+ require "pry"
5
+ require "tomlrb"
6
+
7
+ Dir["#{__dir__}/**/*.rb"].
8
+ each &method(:require)
9
+
10
+ module Memo
11
+ end
@@ -0,0 +1,26 @@
1
+ module Memo
2
+ module Alias
3
+ class Command
4
+ def initialize(name)
5
+ @name = name
6
+ @config = Memo::Config.new
7
+ end
8
+
9
+ def call
10
+ @config.command_alias[:"#{@name}"]
11
+ end
12
+ end
13
+
14
+ class Namespace
15
+ def initialize(name)
16
+ @name = name
17
+ @config = Memo::Config.new
18
+ end
19
+
20
+ def call
21
+ @config.namespace_alias[:"#{@name}"] ||
22
+ @name
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ module Memo
2
+ class Option
3
+ attr_reader :namespace
4
+
5
+ def initialize(args)
6
+ @args = args.to_a
7
+
8
+ case args
9
+ in [*, "-n", namespace, *]
10
+ @namespace = namespace
11
+ @args.delete("-n")
12
+ @args.delete(namespace)
13
+ else
14
+ end
15
+ end
16
+
17
+ def [](index)
18
+ @args[index]
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,36 @@
1
+ module Memo
2
+ class Cli
3
+ def initialize(
4
+ input,
5
+ os: Memo::OS.new
6
+ )
7
+ @command = input[0]
8
+ @options = Option.new input[1..]
9
+ @os = os
10
+ end
11
+
12
+ def call
13
+ cmd = case @command
14
+ when "edit", "e", nil
15
+ Command::Edit
16
+ when "preview", "p"
17
+ Command::Preview
18
+ when "today", "t"
19
+ Command::Today
20
+ when "config", "c"
21
+ Command::Config
22
+ when "help", "h"
23
+ Command::Help
24
+ when "setup", "s"
25
+ Command::Setup
26
+ when "fuzzy", "f"
27
+ Command::Fuzzy
28
+ else
29
+ @options = @command
30
+ Command::Custom
31
+ end
32
+
33
+ cmd.new(@options, os: @os).()
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,23 @@
1
+ module Memo
2
+ class Cli
3
+ module Command
4
+ class Config
5
+ def initialize(
6
+ _,
7
+ os: Memo::OS.new
8
+ )
9
+ @os = os
10
+ @config = Memo::Config.new
11
+ @file = Default::Configfile.to_s
12
+ end
13
+
14
+ def call
15
+ tomlfile = ENV["MEMO_CONFIG"] ||
16
+ "#{@config.root}/#{@file}"
17
+
18
+ @os.exec "#{@config.editor} #{tomlfile}"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ module Memo
2
+ class Cli
3
+ module Command
4
+ class Custom
5
+ def initialize(
6
+ command,
7
+ os: Memo::OS.new
8
+ )
9
+ @command = command
10
+ @os = os
11
+ end
12
+
13
+ def call
14
+ input = Memo::Alias::Command.new(
15
+ @command,
16
+ ).()&.split(" ")
17
+
18
+ if input.nil?
19
+ puts Error::Unknown.new.to_s
20
+ puts Usage::Help.new.to_s
21
+ return
22
+ end
23
+
24
+ Memo::Cli.new(input, os: @os).call
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ module Memo
2
+ class Cli
3
+ module Command
4
+ class Edit
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
+ filename = @options[0]
16
+ namespace = @options.namespace
17
+
18
+ file = Memo::File.new(filename, namespace)
19
+
20
+ @os.exec "mkdir -p #{@config.root}/#{file.dir}"
21
+ @os.exec "#{@config.editor} #{@config.root}/#{file.fullpath}"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ module Memo
2
+ class Cli
3
+ module Command
4
+ class Fuzzy
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
+ @os.exec "#{@config.editor} "\
16
+ "$(find #{@config.root} -type f | "\
17
+ "#{@config.fuzzy_finder})"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ module Memo
2
+ class Cli
3
+ module Command
4
+ class Help
5
+ def initialize(*); end
6
+
7
+ def call
8
+ puts Usage::Help.new.to_s
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ module Memo
2
+ class Cli
3
+ module Command
4
+ class Preview
5
+ def initialize(
6
+ options,
7
+ os: Memo::OS.new
8
+ )
9
+ @options = options
10
+ @os = os
11
+ @config = Memo::Config.new
12
+ @today = Memo::Today.new
13
+ @defaultfile = Memo::File.new
14
+ end
15
+
16
+ def call
17
+ filename = @options[0]
18
+ path = case filename
19
+ when "today", "t"
20
+ @today.fullpath
21
+ else
22
+ Memo::File.new(
23
+ filename,
24
+ @options.namespace,
25
+ ).fullpath
26
+ end
27
+
28
+ @os.exec "#{@config.preview} #{@config.root}/#{path}"
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,53 @@
1
+ module Memo
2
+ class Cli
3
+ module Command
4
+ class Setup
5
+ def initialize(
6
+ _,
7
+ os: Memo::OS.new
8
+ )
9
+ @os = os
10
+ @config = Memo::Config.new
11
+ end
12
+
13
+ def call
14
+ toml = <<~TOML
15
+ [config]
16
+ # ext = "md"
17
+ # root = "~/.memo"
18
+ # editor = "vim"
19
+ # preview = "bat"
20
+ # fuzzy_finder = "fzf --preview 'bat --color=always {}'"
21
+ # default_filename = "memo"
22
+ # default_namespace = "mymemo"
23
+
24
+ [namespace_alias]
25
+ # p1 = "project1"
26
+
27
+ [command_alias]
28
+ # ep1 = "edit memo -n project1"
29
+ TOML
30
+
31
+ if ::File.exist? @config.path
32
+ puts "WARNING: config file already exists"
33
+ puts
34
+ print "reset config? (y/n) "
35
+ ans = STDIN.gets.chomp
36
+ if ans != "y"
37
+ puts "aborted"
38
+ return
39
+ end
40
+ end
41
+
42
+ @os.write @config.path, toml
43
+
44
+ puts
45
+ puts <<~TEXT
46
+ Create config file to #{@config.path}
47
+ You can edit by `$ memo config`
48
+ TEXT
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,23 @@
1
+ module Memo
2
+ class Cli
3
+ module Command
4
+ class Today
5
+ require "date"
6
+
7
+ def initialize(
8
+ _,
9
+ os: Memo::OS.new
10
+ )
11
+ @os = os
12
+ @config = Memo::Config.new
13
+ @today = Memo::Today.new
14
+ end
15
+
16
+ def call
17
+ @os.exec "mkdir -p #{@config.root}/#{@today.dir}"
18
+ @os.exec "#{@config.editor} #{@config.root}/#{@today.fullpath}"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,41 @@
1
+ module Memo
2
+ class Config
3
+ attr_reader :command_alias, :namespace_alias, :path
4
+
5
+ def initialize
6
+ @path = ENV["MEMO_CONFIG"].dup ||
7
+ "~/.memo/config.toml"
8
+
9
+ @path.sub!("~", ENV["HOME"])
10
+ @path.sub!("$HOME", ENV["HOME"])
11
+
12
+ conf = Tomlrb.load_file(
13
+ @path,
14
+ symbolize_keys: true,
15
+ ) rescue {}
16
+
17
+ @config = conf[:config].to_h
18
+
19
+ @namespace_alias = conf[:namespace_alias].to_h
20
+ @command_alias = conf[:command_alias].to_h
21
+
22
+ system "mkdir -p #{root}"
23
+ end
24
+
25
+ def ext = @config[:ext] || Default::Ext.to_s
26
+ def root = @config[:root] || Default::Root.to_s
27
+ def preview = @config[:preview] || Default::Preview.to_s
28
+
29
+ def fuzzy_finder = @config[:fuzzy_finder] ||
30
+ Default::FuzzyFinder.to_s
31
+
32
+ def editor = @config[:editor] ||
33
+ ENV["EDITOR"] || Default::Editor.to_s
34
+
35
+ def default_filename = \
36
+ @config[:default_filename] || Default::Filename.to_s
37
+
38
+ def default_namespace = \
39
+ @config[:default_namespace] || Default::Namespace.to_s
40
+ end
41
+ end
@@ -0,0 +1,17 @@
1
+ module Memo
2
+ class Cli
3
+ module Error
4
+ class NoFile
5
+ def to_s
6
+ "ERROR: no file specified"
7
+ end
8
+ end
9
+
10
+ class Unknown
11
+ def to_s
12
+ "ERROR: unknown command"
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ module Memo
2
+ class Cli
3
+ module Usage
4
+ class Config
5
+ def to_s
6
+ <<~TEXT
7
+ $ memo config
8
+ TEXT
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,50 @@
1
+ module Memo
2
+ class Cli
3
+ module Usage
4
+ class Help
5
+ def to_s
6
+ <<~TEXT
7
+ EASY EDIT MEMO
8
+
9
+ USAGE
10
+ - Config
11
+ You can edit basic config and register aliases
12
+
13
+ $ memo c
14
+ $ memo config
15
+
16
+ - Edit
17
+ $ memo e
18
+ $ memo edit
19
+ $ memo edit todo
20
+ $ memo edit todo -n project1
21
+ $ memo edit todo -n p # use namespace_alias
22
+
23
+ - Preview
24
+ $ memo p
25
+ $ memo preview
26
+ $ memo p todo
27
+ $ memo p todo -n project1
28
+ $ memo p todo -n p # use namespace_alias
29
+
30
+ - Today
31
+ # edit
32
+ $ memo t
33
+ $ memo today
34
+
35
+ # preview
36
+ $ memo preview today
37
+ $ memo p t
38
+
39
+ - Fuzzy
40
+ $ memo fuzzy
41
+ $ memo f
42
+
43
+ - Custom Command
44
+ $ memo todo # use command_alias
45
+ TEXT
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,21 @@
1
+ module Memo
2
+ class Cli
3
+ module Usage
4
+ class New
5
+ def initialize(err:)
6
+ @err = err
7
+ end
8
+
9
+ def to_s
10
+ <<~TEXT
11
+ #{@err}
12
+
13
+ usage:
14
+ $ memo new new-memo
15
+ $ memo n new-memo
16
+ TEXT
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ module Memo
2
+ class Cli
3
+ module Usage
4
+ class Preview
5
+ def initialize(err:)
6
+ @err = err.to_s
7
+ end
8
+
9
+ def to_s
10
+ <<~TEXT
11
+ #{@err}
12
+
13
+ usage:
14
+ $ memo preview my-memo
15
+ TEXT
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ module Memo
2
+ class OS
3
+ def exec(cmd) = system(cmd)
4
+
5
+ def write(path, text)
6
+ ::File.open(path, "w") do |f|
7
+ f.puts text
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ module Memo
2
+ module Default
3
+ class Ext
4
+ def self.to_s = "md"
5
+ end
6
+
7
+ class Preview
8
+ def self.to_s = "cat"
9
+ end
10
+
11
+ class Root
12
+ def self.to_s = "~/.memo"
13
+ end
14
+
15
+ class Editor
16
+ def self.to_s = "vim"
17
+ end
18
+
19
+ class FuzzyFinder
20
+ def self.to_s = "fzf"
21
+ end
22
+
23
+ class Filename
24
+ def self.to_s = "memo"
25
+ end
26
+
27
+ class Namespace
28
+ def self.to_s = "mymemo"
29
+ end
30
+
31
+ class Configfile
32
+ def self.to_s = "config.toml"
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,18 @@
1
+ module Memo
2
+ class File
3
+ def initialize(
4
+ file = nil,
5
+ namespace = nil,
6
+ config: Memo::Config.new
7
+ )
8
+ @config = config
9
+ @file = file || @config.default_filename
10
+ @namespace = Alias::Namespace.new(namespace).call ||
11
+ @config.default_namespace
12
+ end
13
+
14
+ def dir = "#{@namespace}"
15
+ def file = "#{@file}.#{@config.ext}"
16
+ def fullpath = "#{dir}/#{file}"
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ module Memo
2
+ class Today
3
+ def initialize(config: Memo::Config.new)
4
+ @config = config
5
+ @today = Date.today.to_s
6
+ @year, @month, @day = @today.split("-")
7
+ end
8
+
9
+ def dir = "#{@year}/#{@month}"
10
+ def file = "#{@day}.#{@config.ext}"
11
+ def fullpath = "#{dir}/#{file}"
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Memo
4
+ VERSION = "0.1.2"
5
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/memo/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "ememo"
7
+ spec.version = Memo::VERSION
8
+ spec.authors = ["Yuma Ishikawa"]
9
+ spec.email = ["yuma.fuu05@gmail.com"]
10
+
11
+ spec.summary = "memo easily"
12
+ spec.description = "memo easily on cli"
13
+ spec.homepage = "https://github.com/YumaFuu/ememo"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/YumaFuu/ememo"
18
+ spec.metadata["changelog_uri"] = "https://github.com/YumaFuu/ememo"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ # Uncomment to register a new dependency of your gem
30
+ spec.add_dependency "tomlrb"
31
+ spec.add_dependency "pry"
32
+
33
+ # For more information and examples about making a new gem, checkout our
34
+ # guide at: https://bundler.io/guides/creating_gem.html
35
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ememo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Yuma Ishikawa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-01-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tomlrb
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: memo easily on cli
42
+ email:
43
+ - yuma.fuu05@gmail.com
44
+ executables:
45
+ - memo
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".github/workflows/main.yml"
50
+ - ".gitignore"
51
+ - ".ruby-version"
52
+ - CODE_OF_CONDUCT.md
53
+ - Gemfile
54
+ - Gemfile.lock
55
+ - README.md
56
+ - Rakefile
57
+ - bin/console
58
+ - bin/setup
59
+ - exe/memo
60
+ - lib/memo.rb
61
+ - lib/memo/cli/arg/alias.rb
62
+ - lib/memo/cli/arg/option.rb
63
+ - lib/memo/cli/cli.rb
64
+ - lib/memo/cli/command/config.rb
65
+ - lib/memo/cli/command/custom.rb
66
+ - lib/memo/cli/command/edit.rb
67
+ - lib/memo/cli/command/fuzzy.rb
68
+ - lib/memo/cli/command/help.rb
69
+ - lib/memo/cli/command/preview.rb
70
+ - lib/memo/cli/command/setup.rb
71
+ - lib/memo/cli/command/today.rb
72
+ - lib/memo/cli/config/config.rb
73
+ - lib/memo/cli/error/error.rb
74
+ - lib/memo/cli/usage/config.rb
75
+ - lib/memo/cli/usage/help.rb
76
+ - lib/memo/cli/usage/new.rb
77
+ - lib/memo/cli/usage/preview.rb
78
+ - lib/memo/os/os.rb
79
+ - lib/memo/value/default.rb
80
+ - lib/memo/value/file.rb
81
+ - lib/memo/value/today.rb
82
+ - lib/memo/version.rb
83
+ - memo.gemspec
84
+ homepage: https://github.com/YumaFuu/ememo
85
+ licenses: []
86
+ metadata:
87
+ homepage_uri: https://github.com/YumaFuu/ememo
88
+ source_code_uri: https://github.com/YumaFuu/ememo
89
+ changelog_uri: https://github.com/YumaFuu/ememo
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: 3.0.0
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubygems_version: 3.2.3
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: memo easily
109
+ test_files: []