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

#default_retrospec_dir, #retrospec_repos_dir, #safe_copy_file, #safe_create_file, #safe_create_module_files, #safe_create_symlink, #safe_create_template_file, #safe_mkdir, #safe_touch

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

.cli_options(global_opts) ⇒ Object

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



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

def self.cli_options(global_opts)
  Trollop::options do
  end
end

.file_typeObject

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

Raises:

  • (NotImplementedError)


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

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



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

def self.plugin_name
  self.name.split('::').last.downcase
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



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

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)


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

def run
  raise NotImplementedError
end