Module: PryTheme

Defined in:
lib/pry-theme.rb,
lib/pry-theme/hex.rb,
lib/pry-theme/rgb.rb,
lib/pry-theme/term.rb,
lib/pry-theme/color.rb,
lib/pry-theme/theme.rb,
lib/pry-theme/config.rb,
lib/pry-theme/preview.rb,
lib/pry-theme/commands.rb,
lib/pry-theme/definition.rb,
lib/pry-theme/theme_list.rb,
lib/pry-theme/color_table.rb,
lib/pry-theme/declaration.rb,
lib/pry-theme/formattable.rb,
lib/pry-theme/basic_editor.rb,
lib/pry-theme/colors/color8.rb,
lib/pry-theme/colors/color16.rb,
lib/pry-theme/colors/color256.rb,
lib/pry-theme/when_started_hook.rb

Defined Under Namespace

Modules: Formattable, ThemeList Classes: BasicEditor, Color, Color16, Color256, Color8, ColorTable, Config, HEX, Preview, RGB, TERM, Theme, WhenStartedHook

Constant Summary collapse

VERSION_FILE =

The VERSION file must be in the root directory of the library.

File.expand_path('../../VERSION', __FILE__)
VERSION =
File.exist?(VERSION_FILE) ?
File.read(VERSION_FILE).chomp : '(could not find VERSION file)'
ROOT =

The root path of Pry Theme source code.

File.expand_path(File.dirname(__FILE__))
CONFIG_DIR =

The path of the directory with Pry configuration files.

File.join(ENV['HOME'], '.pry')
DEF_THEMES_DIR =

The path of the default Pry Theme themes.

File.join(ROOT, '..', 'themes')
USER_THEMES_DIR =

The path where the user should keep their themes.

File.join(CONFIG_DIR, 'themes')
PT_EXT =

Every Pry Theme file must end with this extension.

'.prytheme.rb'
PTC =

Pry Theme Collection.

'https://api.github.com/repos/kyrylo/pry-theme-collection/contents/'
SHORTENER =

The default URL shortener (used for listing themes from PTC).

'http://is.gd/create.php?format=simple&url='
ThemeError =

Raised when something goes wrong with Pry Theme themes. It’s a general exception for everything that comes into collision in theme files.

Class.new(StandardError)
Command =
Class.new

Class Method Summary collapse

Class Method Details

.color_const(color) ⇒ Class

Returns the class, which corresponds to the given color.

Parameters:

  • color (Integer)

Returns:

  • (Class)

    the class, which corresponds to the given color



99
100
101
# File 'lib/pry-theme.rb', line 99

def color_const(color)
  const_get(:"Color#{ color }")
end

.create(config = {}, &block) ⇒ Object

Creates a new Pry Theme theme.

Examples:

my_theme = PryTheme.create name: 'my-theme', color_model: 8 do
  author name: 'John Doe', email: '[email protected]'
  description 'My first theme'

  define_theme do
    class_variable 'red'
    integer 'black'
    method 'white', 'red'
    symbol bg: 'yellow'

    string do
      content 'blue', 'black'
    end
  end
end

my_theme.definition.class_variable.foreground(true) #=> "red"
my_theme.definition.string.content.background(true) #=> "black"

Parameters:

  • config (Hash) (defaults to: {})

Options Hash (config):

  • :name (String) — default: 'prytheme-\d+'

    The name of the theme. It must be no longer than 18 characters

  • :color_model (Integer) — default: 256

    The number of colours available in the theme that is being created. Besides 256, valid arguments are ‘8` and `16`

See Also:



85
86
87
# File 'lib/pry-theme.rb', line 85

def create(config = {}, &block)
  Theme.new(config, &block)
end

.tput_colorsInteger

Returns the number of supported terminal colours. Always equal to 16 on Windows.

Returns:

  • (Integer)

    the number of supported terminal colours. Always equal to 16 on Windows.



91
92
93
94
95
# File 'lib/pry-theme.rb', line 91

def tput_colors
  `tput colors`.to_i
rescue Errno::ENOENT
  16
end