Class: Retrospec::Plugins::V1::Plugin

Inherits:
Object
  • Object
show all
Includes:
ModuleHelpers
Defined in:
lib/retrospec/plugins/v1/plugin.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ModuleHelpers

#create_content, #default_retrospec_dir, #notify, #overwrite?, #overwrite_all, #overwrite_enabled?, #prompt_for_overwrite, #retrospec_file?, #retrospec_repos_dir, #safe_copy_file, #safe_create_directory_files, #safe_create_file, #safe_create_module_files, #safe_create_symlink, #safe_create_template_file, #safe_mkdir, #safe_move_file, #safe_touch, #should_create?, #sync_file?

Constructor Details

#initialize(supplied_module_path = '.', config = {}) ⇒ Plugin

Returns a new instance of Plugin.


18
19
20
21
# File 'lib/retrospec/plugins/v1/plugin.rb', line 18

def initialize(supplied_module_path='.',config={})
  @config_data = config
  @module_path = File.expand_path(supplied_module_path)
end

Instance Attribute Details

#config_dataObject

Returns the value of attribute config_data


9
10
11
# File 'lib/retrospec/plugins/v1/plugin.rb', line 9

def config_data
  @config_data
end

#module_pathObject

Returns the value of attribute module_path


9
10
11
# File 'lib/retrospec/plugins/v1/plugin.rb', line 9

def module_path
  @module_path
end

#plugin_nameObject (readonly)

Returns the value of attribute plugin_name


10
11
12
# File 'lib/retrospec/plugins/v1/plugin.rb', line 10

def plugin_name
  @plugin_name
end

Class Method Details

.file_typeObject

the main file type that is used to help discover what the module is

Raises:

  • (NotImplementedError)

58
59
60
# File 'lib/retrospec/plugins/v1/plugin.rb', line 58

def self.file_type
  raise NotImplementedError
end

.plugin_nameObject

the name of the plugin that will be sent to the cli the cli turns this into a subcommand where the user interacts with your plugin


48
49
50
# File 'lib/retrospec/plugins/v1/plugin.rb', line 48

def self.plugin_name
  self.name.split('::').last.downcase
end

.run_cli(global_opts, global_config, plugin_config) ⇒ Object

used to display subcommand options to the cli the global options are passed in for your usage

Raises:

  • (NotImplemented)

42
43
44
# File 'lib/retrospec/plugins/v1/plugin.rb', line 42

def self.run_cli(global_opts, global_config, plugin_config)
  raise NotImplemented
end

.valid_module_dir?(dir) ⇒ Boolean

validates that the module meets the plugins criteria returns boolean true if module files are valid, false otherwise validates module directory fits the description of this plugin this is used in the discover method

Returns:

  • (Boolean)

27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/retrospec/plugins/v1/plugin.rb', line 27

def self.valid_module_dir?(dir)
  if ! File.exist?(dir)
    false
  else
    module_files ||= Dir.glob("#{dir}/**/*#{file_type}")
    if module_files.length < 1
      false
    else
      true
    end
  end
end

Instance Method Details

#config=(config_map) ⇒ Object

sets the config which should be a hash


53
54
55
# File 'lib/retrospec/plugins/v1/plugin.rb', line 53

def config=(config_map)
  @config = config_map
end

#runObject

the main entry point that is called when retrospec is run using this as the starting point after initialization

Raises:

  • (NotImplementedError)

64
65
66
# File 'lib/retrospec/plugins/v1/plugin.rb', line 64

def run
  raise NotImplementedError
end