Loader configuration file

Introduced properties

fun client: MongoClient

github :: LoaderConfig :: client

Mongo db client
protected fun client=(client: MongoClient)

github :: LoaderConfig :: client=

Mongo db client
fun db: MongoDb

github :: LoaderConfig :: db

Mongo db instance
protected fun db=(db: MongoDb)

github :: LoaderConfig :: db=

Mongo db instance
fun db_host: String

github :: LoaderConfig :: db_host

MongoDB server used for data persistence
fun db_name: String

github :: LoaderConfig :: db_name

MongoDB DB used for data persistence
fun default_db_host: String

github :: LoaderConfig :: default_db_host

Default database host string for MongoDb
protected fun default_db_host=(default_db_host: String)

github :: LoaderConfig :: default_db_host=

Default database host string for MongoDb
fun default_db_name: String

github :: LoaderConfig :: default_db_name

Default database hostname
protected fun default_db_name=(default_db_name: String)

github :: LoaderConfig :: default_db_name=

Default database hostname
fun logger: PopLogger

github :: LoaderConfig :: logger

Logger used to print things
protected fun logger=(logger: PopLogger)

github :: LoaderConfig :: logger=

Logger used to print things
fun no_branches: Bool

github :: LoaderConfig :: no_branches

Should we avoid loading branches?
fun no_colors: Bool

github :: LoaderConfig :: no_colors

Use colors in console display
fun no_comments: Bool

github :: LoaderConfig :: no_comments

Should we avoid loading issue comments?
fun no_commits: Bool

github :: LoaderConfig :: no_commits

Should we avoid loading commits?
fun no_events: Bool

github :: LoaderConfig :: no_events

Should we avoid loading events?
fun no_issues: Bool

github :: LoaderConfig :: no_issues

Should we avoid loading issues?
protected fun opt_clear=(opt_clear: OptionBool)

github :: LoaderConfig :: opt_clear=

--clear
fun opt_db_host: OptionString

github :: LoaderConfig :: opt_db_host

MongoDb host name
protected fun opt_db_host=(opt_db_host: OptionString)

github :: LoaderConfig :: opt_db_host=

MongoDb host name
fun opt_db_name: OptionString

github :: LoaderConfig :: opt_db_name

MongoDb database name
protected fun opt_db_name=(opt_db_name: OptionString)

github :: LoaderConfig :: opt_db_name=

MongoDb database name
protected fun opt_no_branches=(opt_no_branches: OptionBool)

github :: LoaderConfig :: opt_no_branches=

--no-branches
protected fun opt_no_colors=(opt_no_colors: OptionBool)

github :: LoaderConfig :: opt_no_colors=

--no-colors
protected fun opt_no_comments=(opt_no_comments: OptionBool)

github :: LoaderConfig :: opt_no_comments=

--no-comments
protected fun opt_no_commits=(opt_no_commits: OptionBool)

github :: LoaderConfig :: opt_no_commits=

--no-commits
protected fun opt_no_events=(opt_no_events: OptionBool)

github :: LoaderConfig :: opt_no_events=

--no-events
protected fun opt_no_issues=(opt_no_issues: OptionBool)

github :: LoaderConfig :: opt_no_issues=

--no-issues
protected fun opt_show_jobs=(opt_show_jobs: OptionBool)

github :: LoaderConfig :: opt_show_jobs=

--show-jobs
protected fun opt_show_wallet=(opt_show_wallet: OptionBool)

github :: LoaderConfig :: opt_show_wallet=

--show-wallet
protected fun opt_start=(opt_start: OptionInt)

github :: LoaderConfig :: opt_start=

--from
protected fun opt_tokens=(opt_tokens: OptionArray)

github :: LoaderConfig :: opt_tokens=

--tokens
protected fun opt_verbose=(opt_verbose: OptionCount)

github :: LoaderConfig :: opt_verbose=

--verbose
fun start_from_issue: Int

github :: LoaderConfig :: start_from_issue

At which issue number should we start?
fun tokens: Array[String]

github :: LoaderConfig :: tokens

Github tokens used to access data.
protected fun tokens=(tokens: Array[String])

github :: LoaderConfig :: tokens=

Github tokens used to access data.
fun verbose_level: Int

github :: LoaderConfig :: verbose_level

Verbosity level (the higher the more verbose)
fun wallet: GithubWallet

github :: LoaderConfig :: wallet

Github tokens wallet
protected fun wallet=(wallet: GithubWallet)

github :: LoaderConfig :: wallet=

Github tokens wallet

Redefined properties

redef type SELF: LoaderConfig

github $ LoaderConfig :: SELF

Type of this instance, automatically specialized in every class
redef fun default_config_file: String

github $ LoaderConfig :: default_config_file

Default config file path
redef fun default_config_file=(default_config_file: String)

github $ LoaderConfig :: default_config_file=

Default config file path
redef init init

github $ LoaderConfig :: init

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun add_option(opt: Option...)

config :: Config :: add_option

Add an option to self
fun args: Array[String]

config :: Config :: args

Return the remaining args once options are parsed by from_args
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun client: MongoClient

github :: LoaderConfig :: client

Mongo db client
protected fun client=(client: MongoClient)

github :: LoaderConfig :: client=

Mongo db client
fun config_file: String

config :: IniConfig :: config_file

Return the config file path from options or the default
fun db: MongoDb

github :: LoaderConfig :: db

Mongo db instance
protected fun db=(db: MongoDb)

github :: LoaderConfig :: db=

Mongo db instance
fun db_host: String

github :: LoaderConfig :: db_host

MongoDB server used for data persistence
fun db_name: String

github :: LoaderConfig :: db_name

MongoDB DB used for data persistence
fun default_config_file: String

config :: IniConfig :: default_config_file

Default config file path
fun default_config_file=(default_config_file: String)

config :: IniConfig :: default_config_file=

Default config file path
fun default_db_host: String

github :: LoaderConfig :: default_db_host

Default database host string for MongoDb
protected fun default_db_host=(default_db_host: String)

github :: LoaderConfig :: default_db_host=

Default database host string for MongoDb
fun default_db_name: String

github :: LoaderConfig :: default_db_name

Default database hostname
protected fun default_db_name=(default_db_name: String)

github :: LoaderConfig :: default_db_name=

Default database hostname
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
fun help: Bool

config :: Config :: help

Was the --help option requested?
fun ini: IniFile

config :: IniConfig :: ini

Config tree used to store config options
protected fun ini=(ini: IniFile)

config :: IniConfig :: ini=

Config tree used to store config options
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun logger: PopLogger

github :: LoaderConfig :: logger

Logger used to print things
protected fun logger=(logger: PopLogger)

github :: LoaderConfig :: logger=

Logger used to print things
fun no_branches: Bool

github :: LoaderConfig :: no_branches

Should we avoid loading branches?
fun no_colors: Bool

github :: LoaderConfig :: no_colors

Use colors in console display
fun no_comments: Bool

github :: LoaderConfig :: no_comments

Should we avoid loading issue comments?
fun no_commits: Bool

github :: LoaderConfig :: no_commits

Should we avoid loading commits?
fun no_events: Bool

github :: LoaderConfig :: no_events

Should we avoid loading events?
fun no_issues: Bool

github :: LoaderConfig :: no_issues

Should we avoid loading issues?
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun opt_black_exts: OptionArray

config :: Config :: opt_black_exts

--blacklist-exts
fun opt_black_exts: OptionArray

config :: Config :: opt_black_exts

--blacklist-exts
protected fun opt_black_exts=(opt_black_exts: OptionArray)

config :: Config :: opt_black_exts=

--blacklist-exts
protected fun opt_black_exts=(opt_black_exts: OptionArray)

config :: Config :: opt_black_exts=

--blacklist-exts
protected fun opt_clear=(opt_clear: OptionBool)

github :: LoaderConfig :: opt_clear=

--clear
fun opt_config: OptionString

config :: IniConfig :: opt_config

Path to app config file
protected fun opt_config=(opt_config: OptionString)

config :: IniConfig :: opt_config=

Path to app config file
fun opt_db_host: OptionString

github :: LoaderConfig :: opt_db_host

MongoDb host name
protected fun opt_db_host=(opt_db_host: OptionString)

github :: LoaderConfig :: opt_db_host=

MongoDb host name
fun opt_db_name: OptionString

github :: LoaderConfig :: opt_db_name

MongoDb database name
protected fun opt_db_name=(opt_db_name: OptionString)

github :: LoaderConfig :: opt_db_name=

MongoDb database name
fun opt_help: OptionBool

config :: Config :: opt_help

Help option
protected fun opt_help=(opt_help: OptionBool)

config :: Config :: opt_help=

Help option
protected fun opt_java_cp=(opt_java_cp: OptionString)

config :: Config :: opt_java_cp=

protected fun opt_lang=(opt_lang: OptionString)

config :: Config :: opt_lang=

--lang
protected fun opt_no_branches=(opt_no_branches: OptionBool)

github :: LoaderConfig :: opt_no_branches=

--no-branches
protected fun opt_no_colors=(opt_no_colors: OptionBool)

github :: LoaderConfig :: opt_no_colors=

--no-colors
protected fun opt_no_comments=(opt_no_comments: OptionBool)

github :: LoaderConfig :: opt_no_comments=

--no-comments
protected fun opt_no_commits=(opt_no_commits: OptionBool)

github :: LoaderConfig :: opt_no_commits=

--no-commits
protected fun opt_no_events=(opt_no_events: OptionBool)

github :: LoaderConfig :: opt_no_events=

--no-events
protected fun opt_no_issues=(opt_no_issues: OptionBool)

github :: LoaderConfig :: opt_no_issues=

--no-issues
protected fun opt_port=(opt_port: OptionInt)

config :: Config :: opt_port=

protected fun opt_server=(opt_server: OptionString)

config :: Config :: opt_server=

--server
protected fun opt_show_jobs=(opt_show_jobs: OptionBool)

github :: LoaderConfig :: opt_show_jobs=

--show-jobs
protected fun opt_show_wallet=(opt_show_wallet: OptionBool)

github :: LoaderConfig :: opt_show_wallet=

--show-wallet
protected fun opt_start=(opt_start: OptionInt)

github :: LoaderConfig :: opt_start=

--from
fun opt_stub_man: OptionBool

config :: Config :: opt_stub_man

Option --stub-man
protected fun opt_stub_man=(opt_stub_man: OptionBool)

config :: Config :: opt_stub_man=

Option --stub-man
protected fun opt_tokens=(opt_tokens: OptionArray)

github :: LoaderConfig :: opt_tokens=

--tokens
protected fun opt_verbose=(opt_verbose: OptionCount)

github :: LoaderConfig :: opt_verbose=

--verbose
fun opt_white_exts: OptionArray

config :: Config :: opt_white_exts

--whitelist-exts
fun opt_white_exts: OptionArray

config :: Config :: opt_white_exts

--whitelist-exts
protected fun opt_white_exts=(opt_white_exts: OptionArray)

config :: Config :: opt_white_exts=

--whitelist-exts
protected fun opt_white_exts=(opt_white_exts: OptionArray)

config :: Config :: opt_white_exts=

--whitelist-exts
fun opts: OptionContext

config :: Config :: opts

Context used to store and parse options
protected fun opts=(opts: OptionContext)

config :: Config :: opts=

Context used to store and parse options
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun parse_options(args: Collection[String])

config :: Config :: parse_options

Initialize self options from args
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun start_from_issue: Int

github :: LoaderConfig :: start_from_issue

At which issue number should we start?
fun stub_man_options

config :: Config :: stub_man_options

Generate a manpage stub from self
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun tokens: Array[String]

github :: LoaderConfig :: tokens

Github tokens used to access data.
protected fun tokens=(tokens: Array[String])

github :: LoaderConfig :: tokens=

Github tokens used to access data.
fun tool_description: String

config :: Config :: tool_description

Name, usage and synopsis of the tool.
fun tool_description=(tool_description: String)

config :: Config :: tool_description=

Name, usage and synopsis of the tool.
fun usage

config :: Config :: usage

Display tool_description and options usage in console
fun verbose_level: Int

github :: LoaderConfig :: verbose_level

Verbosity level (the higher the more verbose)
fun wallet: GithubWallet

github :: LoaderConfig :: wallet

Github tokens wallet
protected fun wallet=(wallet: GithubWallet)

github :: LoaderConfig :: wallet=

Github tokens wallet
package_diagram github::LoaderConfig LoaderConfig config::IniConfig IniConfig github::LoaderConfig->config::IniConfig config::Config Config config::IniConfig->config::Config ...config::Config ... ...config::Config->config::Config

Ancestors

class Config

config :: Config

Basic configuration class
interface Object

core :: Object

The root of the class hierarchy.

Parents

class IniConfig

config :: IniConfig

Configuration class based on a INI file.

Class definitions

github $ LoaderConfig
# Loader configuration file
class LoaderConfig
	super IniConfig

	redef var default_config_file = "loader.ini"

	# Default database host string for MongoDb
	var default_db_host = "mongodb://mongo:27017/"

	# Default database hostname
	var default_db_name = "github_loader"

	# MongoDb host name
	var opt_db_host = new OptionString("MongoDb host", "--db-host")

	# MongoDb database name
	var opt_db_name = new OptionString("MongoDb database name", "--db-name")

	# --verbose
	var opt_verbose = new OptionCount("Verbosity level", "-v", "--verbose")

	# --no-colors
	var opt_no_colors = new OptionBool("Do not use colors in output", "--no-colors")

	# --tokens
	var opt_tokens = new OptionArray("Token list", "--tokens")

	# --show-wallet
	var opt_show_wallet = new OptionBool("Show wallet status", "--show-wallet")

	# --show-jobs
	var opt_show_jobs = new OptionBool("Show jobs status", "--show-jobs")

	# --no-branches
	var opt_no_branches = new OptionBool("Do not load branches", "--no-branches")

	# --no-commits
	var opt_no_commits = new OptionBool("Do not load commits from default branch", "--no-commits")

	# --no-issues
	var opt_no_issues = new OptionBool("Do not load issues", "--no-issues")

	# --no-comments
	var opt_no_comments = new OptionBool("Do not load issue comments", "--no-comments")

	# --no-events
	var opt_no_events = new OptionBool("Do not load issues events", "--no-events")

	# --from
	var opt_start = new OptionInt("Start loading issues from a number", 0, "--from")

	# --clear
	var opt_clear = new OptionBool("Clear job for given repo name", "--clear")

	init do
		super
		tool_description = "Usage: loader <repo_name>\nLoad a GitHub repo into a MongoDb."
		add_option(opt_db_host, opt_db_name)
		add_option(opt_tokens, opt_show_wallet)
		add_option(opt_verbose, opt_no_colors)
		add_option(opt_show_jobs, opt_no_commits, opt_no_issues, opt_no_comments, opt_no_events)
		add_option(opt_start, opt_clear)
	end

	# MongoDB server used for data persistence
	fun db_host: String do
		return opt_db_host.value or else ini["db.host"] or else default_db_host
	end

	# MongoDB DB used for data persistence
	fun db_name: String do
		return opt_db_name.value or else ini["db.name"] or else default_db_name
	end

	# Mongo db client
	var client = new MongoClient(db_host) is lazy

	# Mongo db instance
	var db: MongoDb = client.database(db_name) is lazy

	# Github tokens used to access data.
	var tokens: Array[String] is lazy do
		var opt_tokens = self.opt_tokens.value
		if opt_tokens.not_empty then return opt_tokens

		var res = new Array[String]
		var ini_tokens = ini.section("tokens")
		if ini_tokens == null then return res

		for token in ini_tokens.values do
			if token == null then continue
			res.add token
		end
		return res
	end

	# Github tokens wallet
	var wallet: GithubWallet is lazy do
		return new GithubWallet(tokens)
	end

	# Use colors in console display
	fun no_colors: Bool do
		if opt_no_colors.value then return true
		return ini["loader.no_colors"] == "true"
	end

	# Verbosity level (the higher the more verbose)
	fun verbose_level: Int do
		var opt = opt_start.value
		if opt > 0 then
			return info_level
		end
		var v = ini["loader.verbose"]
		if v != null and v.to_i > 0 then
			return info_level
		end
		return warn_level
	end

	# Logger used to print things
	var logger: PopLogger is lazy do
		var logger = new PopLogger
		logger.level = verbose_level
		return logger
	end

	# Should we avoid loading branches?
	fun no_branches: Bool do
		if opt_no_branches.value then return true
		return ini["loader.no_branches"] == "true"
	end

	# Should we avoid loading commits?
	fun no_commits: Bool do
		if opt_no_commits.value then return true
		return ini["loader.no_commits"] == "true"
	end

	# Should we avoid loading issues?
	fun no_issues: Bool do
		if opt_no_issues.value then return true
		return ini["loader.no_issues"] == "true"
	end

	# Should we avoid loading issue comments?
	fun no_comments: Bool do
		if opt_no_comments.value then return true
		return ini["loader.no_comments"] == "true"
	end

	# Should we avoid loading events?
	fun no_events: Bool do
		if opt_no_events.value then return true
		return ini["loader.no_events"] == "true"
	end

	# At which issue number should we start?
	fun start_from_issue: Int do
		var opt = opt_start.value
		if opt > 0 then return opt
		var v = ini["loader.start"]
		if v != null then return v.to_i
		return 1
	end
end
lib/github/loader.nit:25,1--190,3