jott 0.1.5 → 0.1.6

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: 15a02145f8225bff6c97da4548f68604183543c9bf88d74abcc434ed5f4528f9
4
- data.tar.gz: ad5435b67e0448c20b687c6bf4d3210bdefe04c8a3e64ea44c15c4bc686a483e
3
+ metadata.gz: dddda1ff591c566dc59bd17103d0c77b4d7d4004a577f32432136cabbddc5b85
4
+ data.tar.gz: 62e7c74f6b2723a6e34305e6f8635ac74039bd1e71eecb718ebf84c0e83a205d
5
5
  SHA512:
6
- metadata.gz: f2c973f1c9b1a88dfcf96254a23b0570790cc853904f428c2eefd81563a5148bfc1730baded8846f21911799c55a8e9895f33c360d2965f2e0576123ae3caebb
7
- data.tar.gz: 5991c898d779b862a427afb538b0b115b96dab11672d7611a9c90cb433444a77c1afe71cc5e30a8707171070e72064001666ac6074fb89ff19497476d3abbf39
6
+ metadata.gz: d8a7fed13bc01ab9456c90dc2f82089982d833a8003412bca61209e4c32e861733105bae955f2accf2e9fd27a0e49eef66d9973f287b509698a85b127f476b14
7
+ data.tar.gz: 128923d9495608f7a40a76007aa48605cb6e56ae141649e2b8c54cbedc68a3e5a01bebea640481091daa92b7e32283b97cfb201cc847a4ddad3e911bd263ff84
data/.rubocop.yml CHANGED
@@ -1,13 +1,13 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.1
3
3
 
4
4
  Style/StringLiterals:
5
5
  Enabled: true
6
- EnforcedStyle: double_quotes
6
+ EnforcedStyle: single_quotes
7
7
 
8
8
  Style/StringLiteralsInInterpolation:
9
9
  Enabled: true
10
- EnforcedStyle: double_quotes
10
+ EnforcedStyle: single_quotes
11
11
 
12
12
  Layout/LineLength:
13
13
  Max: 120
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in jott.gemspec
6
6
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jott (0.1.5)
4
+ jott (0.1.6)
5
5
  colorize
6
6
  sqlite3
7
7
  thor
@@ -10,15 +10,18 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  ast (2.4.2)
13
- colorize (0.8.1)
13
+ colorize (1.1.0)
14
14
  diff-lcs (1.5.0)
15
15
  json (2.6.3)
16
- parallel (1.22.1)
17
- parser (3.2.2.0)
16
+ language_server-protocol (3.17.0.3)
17
+ parallel (1.23.0)
18
+ parser (3.2.2.4)
18
19
  ast (~> 2.4.1)
20
+ racc
21
+ racc (1.7.1)
19
22
  rainbow (3.1.1)
20
- regexp_parser (2.8.0)
21
- rexml (3.2.5)
23
+ regexp_parser (2.8.2)
24
+ rexml (3.2.6)
22
25
  rspec (3.12.0)
23
26
  rspec-core (~> 3.12.0)
24
27
  rspec-expectations (~> 3.12.0)
@@ -32,22 +35,23 @@ GEM
32
35
  diff-lcs (>= 1.2.0, < 2.0)
33
36
  rspec-support (~> 3.12.0)
34
37
  rspec-support (3.12.0)
35
- rubocop (1.50.2)
38
+ rubocop (1.57.2)
36
39
  json (~> 2.3)
40
+ language_server-protocol (>= 3.17.0)
37
41
  parallel (~> 1.10)
38
- parser (>= 3.2.0.0)
42
+ parser (>= 3.2.2.4)
39
43
  rainbow (>= 2.2.2, < 4.0)
40
44
  regexp_parser (>= 1.8, < 3.0)
41
45
  rexml (>= 3.2.5, < 4.0)
42
- rubocop-ast (>= 1.28.0, < 2.0)
46
+ rubocop-ast (>= 1.28.1, < 2.0)
43
47
  ruby-progressbar (~> 1.7)
44
48
  unicode-display_width (>= 2.4.0, < 3.0)
45
- rubocop-ast (1.28.0)
49
+ rubocop-ast (1.30.0)
46
50
  parser (>= 3.2.1.0)
47
51
  ruby-progressbar (1.13.0)
48
- sqlite3 (1.6.2-x86_64-linux)
49
- thor (1.2.1)
50
- unicode-display_width (2.4.2)
52
+ sqlite3 (1.6.8-x86_64-linux)
53
+ thor (1.3.0)
54
+ unicode-display_width (2.5.0)
51
55
 
52
56
  PLATFORMS
53
57
  x86_64-linux
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- require "rubocop/rake_task"
8
+ require 'rubocop/rake_task'
9
9
 
10
10
  RuboCop::RakeTask.new
11
11
 
data/exe/jott CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "jott"
4
+ require 'jott'
data/jott.gemspec CHANGED
@@ -1,23 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/jott/version"
3
+ require_relative 'lib/jott/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "jott"
6
+ spec.name = 'jott'
7
7
  spec.version = Jott::VERSION
8
- spec.authors = ["seita1996"]
9
- spec.email = ["tahara.seitaro@gmail.com"]
8
+ spec.authors = ['seita1996']
9
+ spec.email = ['tahara.seitaro@gmail.com']
10
10
 
11
- spec.summary = "CLI application for a little note"
11
+ spec.summary = 'CLI application for a little note'
12
12
  # spec.description = "TODO: Write a longer description or delete this line."
13
- spec.homepage = "https://rubygems.org/gems/jott"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = ">= 3.1"
13
+ spec.homepage = 'https://rubygems.org/gems/jott'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 3.1'
16
16
 
17
17
  # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
18
18
 
19
- spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = "https://github.com/seita1996/jott"
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/seita1996/jott'
21
21
  # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
22
 
23
23
  # Specify which files should be added to the gem when it is released.
@@ -27,16 +27,16 @@ Gem::Specification.new do |spec|
27
27
  (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
28
28
  end
29
29
  end
30
- spec.bindir = "exe"
31
- spec.executables = "jott"
32
- spec.require_paths = ["lib"]
30
+ spec.bindir = 'exe'
31
+ spec.executables = 'jott'
32
+ spec.require_paths = ['lib']
33
33
 
34
- spec.add_dependency "colorize"
35
- spec.add_dependency "sqlite3"
36
- spec.add_dependency "thor"
34
+ spec.add_dependency 'colorize'
35
+ spec.add_dependency 'sqlite3'
36
+ spec.add_dependency 'thor'
37
37
 
38
- spec.add_development_dependency("rspec", "~> 3.0")
39
- spec.add_development_dependency("rubocop", "~> 1.21")
38
+ spec.add_development_dependency('rspec', '~> 3.0')
39
+ spec.add_development_dependency('rubocop', '~> 1.21')
40
40
 
41
41
  # For more information and examples about making a new gem, check out our
42
42
  # guide at: https://bundler.io/guides/creating_gem.html
data/lib/jott/cli.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'colorize'
2
4
  require 'tempfile'
3
5
  require 'thor'
@@ -6,14 +8,13 @@ require_relative 'memo'
6
8
  require_relative 'version'
7
9
 
8
10
  class CLI < Thor
9
- desc "clear", "clear all memos"
10
- method_option :aliases => "-cl"
11
+ desc 'clear', 'clear all memos'
11
12
  def clear
12
13
  Memo.new.clear
13
- puts "Clear all memos".colorize(:green)
14
+ puts 'Clear all memos'.colorize(:green)
14
15
  end
15
16
 
16
- desc "add", "Add a new memo"
17
+ desc 'add', 'Add a new memo'
17
18
  def add(*str)
18
19
  if str.empty? # open text editor
19
20
  tempfile = Tempfile.new
@@ -21,11 +22,11 @@ class CLI < Thor
21
22
  text = File.read(tempfile.path)
22
23
  tempfile.unlink
23
24
  else # add memo from command line
24
- text = str.join(" ")
25
+ text = str.join(' ')
25
26
  end
26
27
 
27
- if text.chomp == ""
28
- puts "Please enter text.".colorize(:red)
28
+ if text.chomp == ''
29
+ puts 'Please enter text.'.colorize(:red)
29
30
  exit
30
31
  end
31
32
 
@@ -34,67 +35,67 @@ class CLI < Thor
34
35
  puts "Added new memo: #{title}".colorize(:green)
35
36
  end
36
37
 
37
- desc "delete", "delete memo ID"
38
+ desc 'delete', 'delete memo ID'
38
39
  def rm(id)
39
40
  Memo.new.delete(id:)
40
41
  puts "Deleted the memo: #{id}".colorize(:green)
41
42
  end
42
43
 
43
- desc "edit", "open the memo with text editor and update"
44
+ desc 'edit', 'open the memo with text editor and update'
44
45
  def edit(*args)
45
46
  id = args.first
46
47
  id = Memo.new.last[0][0] if id.nil?
47
- str = args[1..-1]
48
+ str = args[1..]
48
49
  memo = Memo.new.find(id)
49
50
 
50
51
  if str.nil? || str.empty? # open text editor
51
52
  tempfile = Tempfile.new
52
- File.open(tempfile.path, "w") do |f|
53
+ File.open(tempfile.path, 'w') do |f|
53
54
  f.puts memo[0][2]
54
55
  end
55
56
  system(editor, tempfile.path)
56
57
  text = File.read(tempfile.path)
57
58
  tempfile.unlink
58
59
  else # add memo from command line
59
- text = str.join(" ")
60
+ text = str.join(' ')
60
61
  end
61
62
 
62
- if text.chomp == ""
63
- puts "Please enter text.".colorize(:red)
63
+ if text.chomp == ''
64
+ puts 'Please enter text.'.colorize(:red)
64
65
  exit
65
66
  end
66
67
 
67
68
  title = text[0, 30]
68
- Memo.new.update(id: id, title: title, body: text)
69
+ Memo.new.update(id:, title:, body: text)
69
70
  puts "Edited the memo: #{id}".colorize(:green)
70
71
  end
71
72
 
72
- desc "list", "list all memos"
73
+ desc 'list', 'list all memos'
73
74
  def ls
74
75
  memos = Memo.new.all
75
76
  memos.each do |memo|
76
- puts "#{memo[0]}. #{memo[1]}: #{memo[2]}"
77
+ puts "#{memo[0]}. #{memo[1]}"
77
78
  end
78
79
  end
79
80
 
80
- desc "show", "show memo ID"
81
+ desc 'show', 'show memo ID'
81
82
  def show(id)
82
83
  memo = Memo.new.find(id)
83
- puts "#{memo[0][2]}"
84
+ puts(memo[0][2])
84
85
  end
85
86
 
86
- desc "set-editor", "Set the default editor"
87
+ desc 'set-editor', 'Set the default editor'
87
88
  def set_editor(editor)
88
89
  Config.new.set_editor(editor)
89
90
  puts "Set editor: #{editor}".colorize(:green)
90
91
  end
91
92
 
92
- desc "config", "Show the current configuration"
93
+ desc 'config', 'Show the current configuration'
93
94
  def config
94
95
  puts "editor: #{editor}"
95
96
  end
96
97
 
97
- desc "version", "show version"
98
+ desc 'version', 'show version'
98
99
  def version
99
100
  puts "jott version #{Jott::VERSION}"
100
101
  end
data/lib/jott/config.rb CHANGED
@@ -1,27 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Config
2
4
  attr_reader :editor
3
5
 
4
6
  def initialize
5
- @file_path = File.join("#{File.dirname(__FILE__)}", "jott.config")
6
- unless File.exist?(@file_path)
7
- File.new(@file_path, "w")
8
- end
7
+ @file_path = File.join(File.dirname(__FILE__).to_s, 'jott.config')
8
+ File.new(@file_path, 'w') unless File.exist?(@file_path)
9
9
  @editor = get_editor
10
10
  end
11
11
 
12
12
  def get_editor
13
- File.open(@file_path, "r") do |file|
13
+ File.open(@file_path, 'r') do |file|
14
14
  file.each_line do |line|
15
- if line.include?("editor")
16
- return line.split(":")[1].strip
17
- end
15
+ return line.split(':')[1].strip if line.include?('editor')
18
16
  end
19
17
  end
20
- return "vi"
18
+ 'vi'
21
19
  end
22
20
 
23
21
  def set_editor(editor)
24
- File.open(@file_path, "w") do |file|
22
+ File.open(@file_path, 'w') do |file|
25
23
  file.puts "editor: #{editor}"
26
24
  end
27
25
  @editor = editor
data/lib/jott/memo.rb CHANGED
@@ -1,42 +1,44 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sqlite3'
2
4
 
3
5
  class Memo
4
6
  def initialize
5
- @db = SQLite3::Database.new(File.join(File.dirname(__FILE__), "jott.db"))
6
- @db.execute("CREATE TABLE IF NOT EXISTS memos(id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, body TEXT)")
7
+ @db = SQLite3::Database.new(File.join(File.dirname(__FILE__), 'jott.db'))
8
+ @db.execute('CREATE TABLE IF NOT EXISTS memos(id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, body TEXT)')
7
9
  end
8
10
 
9
11
  def all
10
- @db.execute("SELECT * FROM memos")
12
+ @db.execute('SELECT * FROM memos')
11
13
  end
12
14
 
13
15
  def clear
14
- @db.execute("DROP TABLE memos")
16
+ @db.execute('DROP TABLE memos')
15
17
  end
16
18
 
17
19
  def count
18
- @db.execute("SELECT COUNT(id) FROM memos")
20
+ @db.execute('SELECT COUNT(id) FROM memos')
19
21
  end
20
22
 
21
23
  def create(title:, body:)
22
- title = title.gsub(/\n/, "")
23
- @db.execute("INSERT INTO memos(title, body) VALUES (?, ?)", [title, body])
24
+ title = title.gsub(/\n/, '')
25
+ @db.execute('INSERT INTO memos(title, body) VALUES (?, ?)', [title, body])
24
26
  end
25
27
 
26
28
  def delete(id:)
27
- @db.execute("DELETE FROM memos WHERE id = ?", id)
29
+ @db.execute('DELETE FROM memos WHERE id = ?', id)
28
30
  end
29
31
 
30
32
  def find(id)
31
- @db.execute("SELECT * FROM memos WHERE id = ?", id)
33
+ @db.execute('SELECT * FROM memos WHERE id = ?', id)
32
34
  end
33
35
 
34
36
  def last
35
- @db.execute("SELECT max(id), * FROM memos")
37
+ @db.execute('SELECT max(id), * FROM memos')
36
38
  end
37
39
 
38
40
  def update(id:, title:, body:)
39
- title = title.gsub(/\n/, "")
40
- @db.execute("UPDATE memos SET title = ?, body = ? WHERE id = ?", [title, body, id])
41
+ title = title.gsub(/\n/, '')
42
+ @db.execute('UPDATE memos SET title = ?, body = ? WHERE id = ?', [title, body, id])
41
43
  end
42
44
  end
data/lib/jott/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jott
4
- VERSION = "0.1.5"
4
+ VERSION = '0.1.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jott
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - seita1996
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-01 00:00:00.000000000 Z
11
+ date: 2023-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize