aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormms <git@sapka.me>2024-11-12 21:26:10 +0100
committermms <git@sapka.me>2024-11-12 21:26:10 +0100
commit955739e2a7be70e6abf7e95710ffe0f4a9c64481 (patch)
treec7b5256cf7fdd58b4785a521183f6776e1a2375e /lib
parent68d7eb07d88338f28c40a5ba68061a7f4e35f340 (diff)
feat: rename modules
Diffstat (limited to 'lib')
-rw-r--r--lib/osugiru.rb39
-rw-r--r--lib/osugiru/config.rb7
-rw-r--r--lib/osugiru/database.rb (renamed from lib/some/database.rb)2
-rw-r--r--lib/osugiru/helpers.rb (renamed from lib/some/helpers.rb)2
-rw-r--r--lib/osugiru/message.rb (renamed from lib/some/message.rb)4
-rw-r--r--lib/osugiru/messages.rb (renamed from lib/some/messages.rb)2
-rw-r--r--lib/osugiru/ruleset.rb (renamed from lib/some/ruleset.rb)4
-rw-r--r--lib/some.rb47
-rw-r--r--lib/some/config.rb5
9 files changed, 53 insertions, 59 deletions
diff --git a/lib/osugiru.rb b/lib/osugiru.rb
new file mode 100644
index 0000000..91a2c06
--- /dev/null
+++ b/lib/osugiru.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+require 'notmuch'
+require 'pry'
+
+require_relative 'osugiru/database'
+require_relative 'osugiru/config'
+require_relative 'osugiru/message'
+require_relative 'osugiru/messages'
+require_relative 'osugiru/helpers'
+require_relative 'osugiru/ruleset'
+
+module Osugiru
+ class << self
+ attr_accessor :config
+ attr_reader :db, :rule_sets
+
+ def configure(&block)
+ @config ||= Config.new
+ @rule_sets = []
+
+ instance_eval(&block)
+
+ @db = Database.new(path: config.database_path)
+ end
+
+ def rule_set(name, &block)
+ @rule_sets << RuleSet.new(name, block)
+ end
+ end
+end
+
+def eval_rules
+ Osugiru.rule_sets.each do |rule_set|
+ rule_set.run
+ end
+end
+
+
diff --git a/lib/osugiru/config.rb b/lib/osugiru/config.rb
new file mode 100644
index 0000000..033d501
--- /dev/null
+++ b/lib/osugiru/config.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+module Osugiru
+ class Config
+ attr_accessor :database_path
+ end
+end
diff --git a/lib/some/database.rb b/lib/osugiru/database.rb
index d481dd5..d014c94 100644
--- a/lib/some/database.rb
+++ b/lib/osugiru/database.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module Some
+module Osugiru
class Database
attr_reader :db
diff --git a/lib/some/helpers.rb b/lib/osugiru/helpers.rb
index 36dcdef..c493bbd 100644
--- a/lib/some/helpers.rb
+++ b/lib/osugiru/helpers.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module Some
+module Osugiru
module Helpers
def self.header_name_from_dsl(method_name)
method_name
diff --git a/lib/some/message.rb b/lib/osugiru/message.rb
index cd352f1..3446f17 100644
--- a/lib/some/message.rb
+++ b/lib/osugiru/message.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module Some
+module Osugiru
class Message
attr_reader :message
@@ -9,7 +9,7 @@ module Some
end
def method_missing(method_name, *_args)
- handle_get(Some::Helpers.header_name_from_dsl(method_name))
+ handle_get(Osugiru::Helpers.header_name_from_dsl(method_name))
end
def handle_get(header_name)
diff --git a/lib/some/messages.rb b/lib/osugiru/messages.rb
index 9f2520b..4af19b6 100644
--- a/lib/some/messages.rb
+++ b/lib/osugiru/messages.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'pry'
-module Some
+module Osugiru
class Messages
AND_CONJUCTION = :and
OR_CONJUCTION = :or
diff --git a/lib/some/ruleset.rb b/lib/osugiru/ruleset.rb
index 6df1eff..a9bac16 100644
--- a/lib/some/ruleset.rb
+++ b/lib/osugiru/ruleset.rb
@@ -1,7 +1,7 @@
-module Some
+module Osugiru
RuleSet = Struct.new(:name, :rule) do
def messages
- Messages.new(db: Some.db)
+ Messages.new(db: Osugiru.db)
end
def run
diff --git a/lib/some.rb b/lib/some.rb
deleted file mode 100644
index 446fba2..0000000
--- a/lib/some.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-
-require 'notmuch'
-require 'pry'
-
-require_relative 'some/database'
-require_relative 'some/config'
-require_relative 'some/message'
-require_relative 'some/messages'
-require_relative 'some/helpers'
-require_relative 'some/ruleset'
-
-module Some
- class << self
- attr_accessor :config
- attr_reader :db, :rule_sets
-
- def configure(&block)
- @config ||= Config.new
- @rule_sets = []
-
- instance_eval(&block)
-
- @db = Database.new(path: config.database_path)
- end
-
- def rule_set(name, &block)
- @rule_sets << RuleSet.new(name, block)
- end
- end
-end
-
-def eval_rules
- Some.rule_sets.each do |rule_set|
- rule_set.run
- end
-end
-
-CONFIG_FILEPATH = 'some/config.rb'
-XDG_HOME = ENV.fetch('XDG_CONFIG_HOME', "#{Dir.home}/.config")
-def start_some
- config_file = File.read("#{XDG_HOME}/#{CONFIG_FILEPATH}")
- instance_eval(config_file)
- eval_rules
-end
-
-start_some
diff --git a/lib/some/config.rb b/lib/some/config.rb
deleted file mode 100644
index 916db0c..0000000
--- a/lib/some/config.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-class Config
- attr_accessor :database_path
-end