chotto 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/chotto +28 -0
- data/lib/chotto.rb +58 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9c41d0ab7f3b4a69a3ddc7386d5246476f177dbb2494f35323829fc00156df00
|
4
|
+
data.tar.gz: e3a675154168eb084157975d87efc4ab52446b160d4e53a6dbb687eb2ada1054
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c4108b72fba8e744a832d8c8238d99951b3070afbc7a710ec7d96cbff84b9ae7a908972dacad76fee9be2703c8240f43c73c073b64c28d1258d45c788f9eded7
|
7
|
+
data.tar.gz: 91243ec3f65d27ec16f85d005bdea9b09d4fe04ca58b798cce5501f123a4099ed268d0c765007b5230059d6d91e8e9b5d78cc12d4a849dc93cc6c4af9b51dd7e
|
data/bin/chotto
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
require_relative '../lib/chotto'
|
6
|
+
|
7
|
+
CONFIG_FILEPATH = 'chotto/config.rb'
|
8
|
+
XDG_HOME = ENV.fetch('XDG_CONFIG_HOME', "#{Dir.home}/.config")
|
9
|
+
def start_chotto(options)
|
10
|
+
Chotto.configure do
|
11
|
+
config.only_new = options.fetch(:only_new, false)
|
12
|
+
end
|
13
|
+
|
14
|
+
config_file = File.read("#{XDG_HOME}/#{CONFIG_FILEPATH}")
|
15
|
+
instance_eval(config_file)
|
16
|
+
eval_rules(options)
|
17
|
+
end
|
18
|
+
|
19
|
+
options = {}
|
20
|
+
OptionParser.new do |opts|
|
21
|
+
opts.banner = 'Usage: chotto [options]'
|
22
|
+
|
23
|
+
opts.on('-n', '--new', 'Run only for new mesages') do |v|
|
24
|
+
options[:only_new] = v
|
25
|
+
end
|
26
|
+
end.parse!
|
27
|
+
|
28
|
+
start_chotto(options)
|
data/lib/chotto.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'notmuch'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
require_relative '../filters/mailing_lists_filter'
|
7
|
+
require_relative '../filters/spam_filter'
|
8
|
+
require_relative 'chotto/config'
|
9
|
+
require_relative 'chotto/database'
|
10
|
+
require_relative 'chotto/helpers'
|
11
|
+
require_relative 'chotto/message'
|
12
|
+
require_relative 'chotto/message_thread'
|
13
|
+
require_relative 'chotto/messages'
|
14
|
+
require_relative 'chotto/ruleset'
|
15
|
+
require_relative 'chotto/token'
|
16
|
+
require_relative 'chotto/token_group'
|
17
|
+
|
18
|
+
module Chotto
|
19
|
+
class << self
|
20
|
+
attr_reader :rule_sets, :config
|
21
|
+
|
22
|
+
def configure(&block)
|
23
|
+
@rule_sets ||= []
|
24
|
+
@config ||= force_fresh_config
|
25
|
+
|
26
|
+
instance_eval(&block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def force_fresh_config
|
30
|
+
@db = nil
|
31
|
+
@rule_sets = []
|
32
|
+
@config = Config.new(
|
33
|
+
db_class: ::Notmuch::Database
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def db
|
38
|
+
@db ||= Database.new(path: config.database_path, db_class: config.db_class)
|
39
|
+
end
|
40
|
+
|
41
|
+
def rule_set(name, &block)
|
42
|
+
@rule_sets << RuleSet.new(name, db, config.only_new, block)
|
43
|
+
end
|
44
|
+
|
45
|
+
def close_db
|
46
|
+
db.close
|
47
|
+
end
|
48
|
+
|
49
|
+
def include_rule(rule)
|
50
|
+
rule.call
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def eval_rules(_options = {})
|
56
|
+
Chotto.rule_sets.each(&:run)
|
57
|
+
Chotto.close_db
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chotto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mms
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-11-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: chotto@sapka.me
|
15
|
+
executables:
|
16
|
+
- chotto
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/chotto
|
21
|
+
- lib/chotto.rb
|
22
|
+
homepage: https://crys.site/projects/chotto
|
23
|
+
licenses:
|
24
|
+
- BSD-3-Clause
|
25
|
+
metadata:
|
26
|
+
source_code_uri: https://cgit.crys.site/chotto
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubygems_version: 3.5.16
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Initial tagging script for Notmuch
|
46
|
+
test_files: []
|