lib/mona.rb in mona-0.2.3 vs lib/mona.rb in mona-0.3.0
- old
+ new
@@ -1,110 +1,27 @@
-# frozen_string_literal: true
-
-require 'mona/version'
-require 'dry/system'
-require 'benchmark'
-require "zeitwerk"
-require 'pry'
-
+#Mona - 2ch library.
+#Copyright (C) 2011- masarakki <masaki@hisme.net>
+#
+#== How to access 2ch.net
+#
+#first, create instance of Board.
+#if you want to access to hayabusa2.2ch.net/news4vip,
+# board = Mona::Board.new('hayabusa2', 'news4vip')
+#then you can get list of Thread by
+# threads = board.threads
+#or if you know thread info, you can create Thread instance
+# thread = Mona::Thread.new(:board => Mona::Board.new('hayabusa2', 'news4vip'), :id => 101010101)
+#
module Mona
- class Error < StandardError; end
+ autoload :Client, 'mona/client'
+ autoload :Board, 'mona/board'
+ autoload :Thread, 'mona/thread'
+ autoload :Response, 'mona/response'
- PROJECT_FILENAME = 'Monafile.rb'
- PACKAGE_FILENAME = 'Package.rb'
+ VERSION_MAJOR = 0
+ VERSION_MINOR = 1
+ VERSION_PATCH = 0
- module Mixins
- def self.included(base)
- require 'sorbet-runtime'
-
- base.extend T::Sig
- end
- end
-
- class Container < Dry::System::Container
- use :env, inferrer: -> { ENV.fetch("RUBY_ENV", :production).to_sym }
- # use :logging
-
- configure do |config|
- config.root = __dir__
-
- config.component_dirs.add 'mona' do |dir|
- dir.namespaces.add nil, key: nil, const: "mona"
- end
- end
- end
-
- Deps = Container.injector
-
- Container.finalize! unless Container.env == :test
-
- Zeitwerk::Loader
- .for_gem
- .tap(&:setup)
- .tap(&:eager_load)
-
- class << self
- attr_accessor :current_project
-
- def init_package(package_name = nil, from: caller_locations.first.path, env: nil, prevent_eager_load: false)
- sync_current_project!(from) do
- package_name ||= Container["package.builder"].call(from, current_project.root_path, current_project.package_dirname).name
- env ||= current_project.env
-
- Container["package.initializer"].call(package_name, env: env, prevent_eager_load: prevent_eager_load)
- end
- end
-
- def root(from = caller_locations.first.path)
- sync_current_project!(from) do
- current_project.root_path
- end
- end
-
- def tasks(from = caller_locations.first.path)
- sync_current_project!(from) do
- Container["task.manager"]
- end
- end
-
- def loader(from = caller_locations.first.path)
- sync_current_project!(from) do
- current_project.loader
- end
- end
-
- def configs(from = caller_locations.first.path)
- sync_current_project!(from) do
- Container["config.manager"]
- end
- end
-
- def packages(from = caller_locations.first.path)
- sync_current_project!(from) do
- Container["package.repo"]
- end
- end
-
- def sync_current_project!(path, &block)
- path = File.expand_path(path)
- path = File.dirname(path) unless File.directory?(path)
-
- root = Container['project.find_root'].call(path)
-
- if @current_project && @current_project.root_path == root
- return block.call
- end
-
- synchronize do
- @current_project = Container["project.initializer"].call(path)
-
- block.call
- end
- end
-
- def synchronize(&block)
- @mutex ||= Mutex.new
-
- @mutex.synchronize(&block)
- end
+ def self.version
+ [VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH].join('.')
end
end