github :: LoaderConfig :: default_db_host
Default database host string for MongoDbgithub :: LoaderConfig :: default_db_host=
Default database host string for MongoDbgithub :: LoaderConfig :: default_db_name=
Default database hostnamegithub :: LoaderConfig :: defaultinit
github :: LoaderConfig :: logger=
Logger used to print thingsgithub :: LoaderConfig :: opt_db_host=
MongoDb host namegithub :: LoaderConfig :: opt_db_name=
MongoDb database namegithub :: LoaderConfig :: opt_no_branches=
--no-branchesgithub :: LoaderConfig :: opt_no_colors=
--no-colorsgithub :: LoaderConfig :: opt_no_comments=
--no-commentsgithub :: LoaderConfig :: opt_no_commits=
--no-commitsgithub :: LoaderConfig :: opt_no_events=
--no-eventsgithub :: LoaderConfig :: opt_no_issues=
--no-issuesgithub :: LoaderConfig :: opt_show_jobs=
--show-jobsgithub :: LoaderConfig :: opt_show_wallet=
--show-walletgithub :: LoaderConfig :: opt_verbose=
--verbosegithub :: LoaderConfig :: start_from_issue
At which issue number should we start?github :: LoaderConfig :: verbose_level
Verbosity level (the higher the more verbose)github $ LoaderConfig :: SELF
Type of this instance, automatically specialized in every classgithub $ LoaderConfig :: default_config_file
Default config file pathgithub $ LoaderConfig :: default_config_file=
Default config file pathgithub $ LoaderConfig :: init
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
config :: IniConfig :: config_file
Return the config file path from options or the defaultconfig :: IniConfig :: default_config_file=
Default config file pathgithub :: LoaderConfig :: default_db_host
Default database host string for MongoDbgithub :: LoaderConfig :: default_db_host=
Default database host string for MongoDbgithub :: LoaderConfig :: default_db_name=
Default database hostnameconfig :: IniConfig :: defaultinit
github :: LoaderConfig :: defaultinit
config :: Config :: defaultinit
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
github :: LoaderConfig :: logger=
Logger used to print thingsconfig :: Config :: opt_black_exts=
--blacklist-extsconfig :: Config :: opt_black_exts=
--blacklist-extsconfig :: IniConfig :: opt_config=
Path to app config filegithub :: LoaderConfig :: opt_db_host=
MongoDb host namegithub :: LoaderConfig :: opt_db_name=
MongoDb database nameconfig :: Config :: opt_java_cp
config :: Config :: opt_java_cp=
github :: LoaderConfig :: opt_no_branches=
--no-branchesgithub :: LoaderConfig :: opt_no_colors=
--no-colorsgithub :: LoaderConfig :: opt_no_comments=
--no-commentsgithub :: LoaderConfig :: opt_no_commits=
--no-commitsgithub :: LoaderConfig :: opt_no_events=
--no-eventsgithub :: LoaderConfig :: opt_no_issues=
--no-issuesgithub :: LoaderConfig :: opt_show_jobs=
--show-jobsgithub :: LoaderConfig :: opt_show_wallet=
--show-walletconfig :: Config :: opt_stub_man=
Option --stub-mangithub :: LoaderConfig :: opt_verbose=
--verboseconfig :: Config :: opt_white_exts=
--whitelist-extsconfig :: Config :: opt_white_exts=
--whitelist-extscore :: Object :: output_class_name
Display class name on stdout (debug only).config :: Config :: parse_options
Initializeself
options from args
github :: LoaderConfig :: start_from_issue
At which issue number should we start?config :: Config :: tool_description
Name, usage and synopsis of the tool.config :: Config :: tool_description=
Name, usage and synopsis of the tool.github :: LoaderConfig :: verbose_level
Verbosity level (the higher the more verbose)
# 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