Class: Boppers::Generator::Plugin

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/boppers/generator/plugin.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#plugin_typeObject

Returns the value of attribute plugin_type.



8
9
10
# File 'lib/boppers/generator/plugin.rb', line 8

def plugin_type
  @plugin_type
end

Class Method Details

.source_rootObject



12
13
14
# File 'lib/boppers/generator/plugin.rb', line 12

def self.source_root
  File.join(__dir__, "plugin")
end

Instance Method Details

#copy_filesObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/boppers/generator/plugin.rb', line 16

def copy_files
  template "#{plugin_type}/gemspec.erb", "#{plugin_name}.gemspec"
  copy_file "Gemfile"
  copy_file ".gitignore"
  copy_file ".rubocop.yml"
  copy_file "CODE_OF_CONDUCT.md"
  copy_file "LICENSE.txt"
  copy_file "Rakefile"
  template "#{plugin_type}/README.erb", "README.md"
end

#copy_lib_filesObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/boppers/generator/plugin.rb', line 27

def copy_lib_files
  template "#{plugin_type}/entry.erb",
           "lib/#{plugin_name}.rb"

  template "#{plugin_type}/main.erb",
           "lib/boppers/#{plugin_dir}#{name}.rb"

  template "#{plugin_type}/version.erb",
           "lib/boppers/#{plugin_dir}#{name}/version.rb"
end

#copy_test_filesObject



38
39
40
41
42
43
44
# File 'lib/boppers/generator/plugin.rb', line 38

def copy_test_files
  template "test/test_helper.erb", "test/test_helper.rb"

  test_file_name = name.tr("-", "_")
  template "#{plugin_type}/test_file.erb",
           "test/boppers/#{plugin_dir}#{test_file_name}_test.rb"
end

#run_commandsObject



46
47
48
49
50
51
# File 'lib/boppers/generator/plugin.rb', line 46

def run_commands
  inside destination_root do
    run "git init"
    run "bundle install"
  end
end