Class: GithubDailyDigest::Configuration
- Inherits:
-
Object
- Object
- GithubDailyDigest::Configuration
- Defined in:
- lib/configuration.rb
Instance Attribute Summary collapse
-
#concise_output ⇒ Object
readonly
Returns the value of attribute concise_output.
-
#fetch_window_duration ⇒ Object
readonly
Returns the value of attribute fetch_window_duration.
-
#gemini_api_key ⇒ Object
readonly
Returns the value of attribute gemini_api_key.
-
#gemini_model ⇒ Object
readonly
Returns the value of attribute gemini_model.
-
#github_org_name ⇒ Object
readonly
Returns the value of attribute github_org_name.
-
#github_org_names ⇒ Object
readonly
Returns the value of attribute github_org_names.
-
#github_token ⇒ Object
readonly
Returns the value of attribute github_token.
-
#help_requested ⇒ Object
readonly
Returns the value of attribute help_requested.
-
#html_show_charts ⇒ Object
readonly
Returns the value of attribute html_show_charts.
-
#html_theme ⇒ Object
readonly
Returns the value of attribute html_theme.
-
#html_title ⇒ Object
readonly
Returns the value of attribute html_title.
-
#json_only ⇒ Object
readonly
Returns the value of attribute json_only.
-
#log_level ⇒ Object
readonly
Returns the value of attribute log_level.
-
#max_api_retries ⇒ Object
readonly
Returns the value of attribute max_api_retries.
-
#no_graphql ⇒ Object
readonly
Returns the value of attribute no_graphql.
-
#output_destination ⇒ Object
readonly
Returns the value of attribute output_destination.
-
#output_formats ⇒ Object
readonly
Returns the value of attribute output_formats.
-
#output_to_stdout ⇒ Object
readonly
Returns the value of attribute output_to_stdout.
-
#rate_limit_sleep_base ⇒ Object
readonly
Returns the value of attribute rate_limit_sleep_base.
-
#specific_users ⇒ Object
readonly
Returns the value of attribute specific_users.
-
#time_since ⇒ Object
readonly
Returns the value of attribute time_since.
-
#time_window_days ⇒ Object
readonly
Returns number of days in the configured time window.
-
#use_graphql ⇒ Object
readonly
Returns the value of attribute use_graphql.
Instance Method Summary collapse
-
#help_requested? ⇒ Boolean
Check if we need to show help.
- #help_text ⇒ Object
-
#initialize(args = nil) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(args = nil) ⇒ Configuration
Returns a new instance of Configuration.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/configuration.rb', line 17 def initialize(args = nil) Dotenv.load @json_only = true # Default to JSON only output @output_to_stdout = true # Default to stdout @gemini_model = ENV.fetch('GEMINI_MODEL', 'gemini-1.5-flash') @help_requested = false # Support multiple output formats - if env specifies a single format, convert to array output_format_env = ENV.fetch('OUTPUT_FORMAT', 'json').downcase @output_formats = output_format_env.include?(',') ? output_format_env.split(',').map(&:strip).map(&:downcase) : [output_format_env.downcase] @output_destination = ENV.fetch('OUTPUT_DESTINATION', 'stdout').downcase # 'stdout' or 'log' @concise_output = ENV.fetch('CONCISE_OUTPUT', 'true').downcase == 'true' # Whether to use concise output format (defaults to true) @use_graphql = ENV.fetch('USE_GRAPHQL', 'true').downcase == 'true' # Whether to use GraphQL API (defaults to true) @no_graphql = !@use_graphql # Inverse of use_graphql for easier API @specific_users = ENV.fetch('SPECIFIC_USERS', '').split(',').map(&:strip).reject(&:empty?) # Specific users to process # HTML-specific options @html_theme = ENV.fetch('HTML_THEME', 'default').downcase # 'default', 'dark', or 'light' @html_title = ENV.fetch('HTML_TITLE', nil) # Custom title for HTML output @html_show_charts = ENV.fetch('HTML_SHOW_CHARTS', 'true').downcase == 'true' # Whether to show charts in HTML output # Parse command line arguments if provided parse_command_line_args(args) if args # Early return if help is requested return if @help_requested # Load environment variables load_env_vars # Validate the configuration validate_config # Calculate the time window calculate_time_window end |
Instance Attribute Details
#concise_output ⇒ Object (readonly)
Returns the value of attribute concise_output.
8 9 10 |
# File 'lib/configuration.rb', line 8 def concise_output @concise_output end |
#fetch_window_duration ⇒ Object (readonly)
Returns the value of attribute fetch_window_duration.
8 9 10 |
# File 'lib/configuration.rb', line 8 def fetch_window_duration @fetch_window_duration end |
#gemini_api_key ⇒ Object (readonly)
Returns the value of attribute gemini_api_key.
8 9 10 |
# File 'lib/configuration.rb', line 8 def gemini_api_key @gemini_api_key end |
#gemini_model ⇒ Object (readonly)
Returns the value of attribute gemini_model.
8 9 10 |
# File 'lib/configuration.rb', line 8 def gemini_model @gemini_model end |
#github_org_name ⇒ Object (readonly)
Returns the value of attribute github_org_name.
8 9 10 |
# File 'lib/configuration.rb', line 8 def github_org_name @github_org_name end |
#github_org_names ⇒ Object (readonly)
Returns the value of attribute github_org_names.
8 9 10 |
# File 'lib/configuration.rb', line 8 def github_org_names @github_org_names end |
#github_token ⇒ Object (readonly)
Returns the value of attribute github_token.
8 9 10 |
# File 'lib/configuration.rb', line 8 def github_token @github_token end |
#help_requested ⇒ Object (readonly)
Returns the value of attribute help_requested.
8 9 10 |
# File 'lib/configuration.rb', line 8 def help_requested @help_requested end |
#html_show_charts ⇒ Object (readonly)
Returns the value of attribute html_show_charts.
8 9 10 |
# File 'lib/configuration.rb', line 8 def html_show_charts @html_show_charts end |
#html_theme ⇒ Object (readonly)
Returns the value of attribute html_theme.
8 9 10 |
# File 'lib/configuration.rb', line 8 def html_theme @html_theme end |
#html_title ⇒ Object (readonly)
Returns the value of attribute html_title.
8 9 10 |
# File 'lib/configuration.rb', line 8 def html_title @html_title end |
#json_only ⇒ Object (readonly)
Returns the value of attribute json_only.
8 9 10 |
# File 'lib/configuration.rb', line 8 def json_only @json_only end |
#log_level ⇒ Object (readonly)
Returns the value of attribute log_level.
8 9 10 |
# File 'lib/configuration.rb', line 8 def log_level @log_level end |
#max_api_retries ⇒ Object (readonly)
Returns the value of attribute max_api_retries.
8 9 10 |
# File 'lib/configuration.rb', line 8 def max_api_retries @max_api_retries end |
#no_graphql ⇒ Object (readonly)
Returns the value of attribute no_graphql.
8 9 10 |
# File 'lib/configuration.rb', line 8 def no_graphql @no_graphql end |
#output_destination ⇒ Object (readonly)
Returns the value of attribute output_destination.
8 9 10 |
# File 'lib/configuration.rb', line 8 def output_destination @output_destination end |
#output_formats ⇒ Object (readonly)
Returns the value of attribute output_formats.
8 9 10 |
# File 'lib/configuration.rb', line 8 def output_formats @output_formats end |
#output_to_stdout ⇒ Object (readonly)
Returns the value of attribute output_to_stdout.
8 9 10 |
# File 'lib/configuration.rb', line 8 def output_to_stdout @output_to_stdout end |
#rate_limit_sleep_base ⇒ Object (readonly)
Returns the value of attribute rate_limit_sleep_base.
8 9 10 |
# File 'lib/configuration.rb', line 8 def rate_limit_sleep_base @rate_limit_sleep_base end |
#specific_users ⇒ Object (readonly)
Returns the value of attribute specific_users.
8 9 10 |
# File 'lib/configuration.rb', line 8 def specific_users @specific_users end |
#time_since ⇒ Object (readonly)
Returns the value of attribute time_since.
8 9 10 |
# File 'lib/configuration.rb', line 8 def time_since @time_since end |
#time_window_days ⇒ Object (readonly)
Returns number of days in the configured time window
105 106 107 |
# File 'lib/configuration.rb', line 105 def time_window_days @time_window_days end |
#use_graphql ⇒ Object (readonly)
Returns the value of attribute use_graphql.
8 9 10 |
# File 'lib/configuration.rb', line 8 def use_graphql @use_graphql end |
Instance Method Details
#help_requested? ⇒ Boolean
Check if we need to show help
100 101 102 |
# File 'lib/configuration.rb', line 100 def help_requested? @help_requested end |
#help_text ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/configuration.rb', line 57 def help_text <<~HELP USAGE: github-daily-digest [options] GitHub Daily Digest generates insights about developer activity using GitHub API and Google's Gemini AI. Options: -h, --help Show this help message -t, --token TOKEN GitHub API token (instead of GITHUB_TOKEN env var) -g, --gemini-key KEY Gemini API key (instead of GEMINI_API_KEY env var) -o, --org NAME GitHub organization name(s) (instead of GITHUB_ORG_NAME env var) Multiple organizations can be comma-separated (e.g., 'org1,org2,org3') -u, --users USERNAMES Specific users to process (comma-separated, e.g. 'user1,user2,user3') If not specified, all organization members will be processed -m, --model MODEL Gemini model to use (default: gemini-1.5-flash) -w, --window DURATION Time window for fetching data (e.g., '1.day', '12.hours') -v, --verbose Enable verbose output (instead of JSON-only) -l, --log-level LEVEL Set log level (DEBUG, INFO, WARN, ERROR, FATAL) -f, --format FORMAT Output format: json, markdown, html (default: json) html option generates a standalone web page with charts -d, --destination DEST Output destination: stdout or log (default: stdout) -c, --[no-]concise Use concise output format (overview + combined only, default: true) -q, --[no-]graphql Use GraphQL API for better performance and data quality (default: true) Use --no-graphql to fall back to REST API HTML Output Options: --html-theme THEME Theme for HTML output: default, dark, light (default: default) --html-title TITLE Custom title for HTML output --[no-]html-charts Include interactive charts in HTML output (default: true) Examples: github-daily-digest --token YOUR_TOKEN --gemini-key YOUR_KEY --org acme-inc github-daily-digest --window 2.days --verbose github-daily-digest --format markdown --destination log github-daily-digest --org "org1,org2,org3" --format markdown Environment variables can also be used instead of command-line options: GITHUB_TOKEN, GEMINI_API_KEY, GITHUB_ORG_NAME, GEMINI_MODEL, FETCH_WINDOW, LOG_LEVEL, OUTPUT_FORMAT, OUTPUT_DESTINATION, CONCISE_OUTPUT, USE_GRAPHQL HELP end |