Class: PryTheme::WhenStartedHook
- Inherits:
-
Object
- Object
- PryTheme::WhenStartedHook
- Includes:
- Helper
- Defined in:
- lib/pry-theme/when_started_hook.rb
Instance Method Summary collapse
Methods included from Helper
default_theme, example_themes, fetch_collection, installed?, installed_themes, local_theme, lputs, make_bold, theme_file_version
Instance Method Details
#call(target, options, _pry_) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pry-theme/when_started_hook.rb', line 7 def call(target, , _pry_) FileUtils.mkdir_p(THEME_DIR) unless File.exists?(THEME_DIR) example_themes.each do |theme| # Copy a default theme to theme directory if it isn't there yet. Update # an installed theme if a theme from the gem has a more recent version # (version determines by theme's meta information). if File.exists?(local_theme(theme)) new_version = theme_file_version(default_theme(theme)) old_version = theme_file_version(local_theme(theme)) if new_version > old_version FileUtils.cp(default_theme(theme), THEME_DIR) end else FileUtils.cp(default_theme(theme), THEME_DIR) end end if Helper.installed?(Pry.config.theme) PryTheme.set_theme(Pry.config.theme) else _pry_.output.puts %{Can't find "#{Pry.config.theme}" theme. Using "#{DEFAULT_THEME_NAME}"} PryTheme.set_theme(DEFAULT_THEME_NAME) end end |