Class: Shiny::Plugin::PluginBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/shiny/plugin/plugin_builder.rb

Overview

Supporting code for the ShinyCMS plugin generator

Instance Method Summary collapse

Instance Method Details

#appObject



17
18
19
# File 'lib/generators/shiny/plugin/plugin_builder.rb', line 17

def app
  directory 'app'
end

#bin(force: false) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/generators/shiny/plugin/plugin_builder.rb', line 49

def bin( force: false )
  bin_file = 'bin/rails.tt'
  template bin_file, force: force do |content|
    "#{shebang}\n" + content
  end
  chmod 'bin', 0o755, verbose: false
end

#configObject



44
45
46
47
# File 'lib/generators/shiny/plugin/plugin_builder.rb', line 44

def config
  template 'config/routes.rb'
  template 'config/locales/en.yml'
end

#gemfileObject



25
26
27
# File 'lib/generators/shiny/plugin/plugin_builder.rb', line 25

def gemfile
  template 'Gemfile'
end

#gemfile_entryObject



57
58
59
60
61
62
63
64
65
# File 'lib/generators/shiny/plugin/plugin_builder.rb', line 57

def gemfile_entry
  return unless inside_application?

  gemfile_in_app_path = File.join( rails_app_path, 'Gemfile' )
  return unless File.exist? gemfile_in_app_path

  entry = "\ngem '#{name}', path: '#{relative_path}'"
  append_file gemfile_in_app_path, entry
end

#gemspecObject



33
34
35
# File 'lib/generators/shiny/plugin/plugin_builder.rb', line 33

def gemspec
  template '%name%.gemspec'
end

#libObject



37
38
39
40
41
42
# File 'lib/generators/shiny/plugin/plugin_builder.rb', line 37

def lib
  template 'lib/%namespaced_name%.rb'
  template 'lib/%namespaced_name%/engine.rb'
  template 'lib/%namespaced_name%/version.rb'
  template 'lib/tasks/%namespaced_name%_tasks.rake'
end

#licenseObject



29
30
31
# File 'lib/generators/shiny/plugin/plugin_builder.rb', line 29

def license
  template 'LICENSE'
end

#rakefileObject



13
14
15
# File 'lib/generators/shiny/plugin/plugin_builder.rb', line 13

def rakefile
  template 'Rakefile'
end

#readmeObject



21
22
23
# File 'lib/generators/shiny/plugin/plugin_builder.rb', line 21

def readme
  template 'README.md'
end