Module: RubyRaider::Plugin
- Defined in:
- lib/plugin/plugin.rb
Class Method Summary collapse
- .add_plugin(plugin_name) ⇒ Object
- .available?(plugin_name) ⇒ Boolean
- .camelize(str) ⇒ Object
- .delete_plugin(plugin_name) ⇒ Object
- .installed?(plugin_name) ⇒ Boolean
- .installed_plugins ⇒ Object
- .plugins ⇒ Object
Class Method Details
.add_plugin(plugin_name) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/plugin/plugin.rb', line 9 def add_plugin(plugin_name) return gemfile_guard unless File.exist?('Gemfile') return pp 'The plugin was not found' unless available?(plugin_name) return pp 'The plugin is already installed' if installed?(plugin_name) pp "Adding #{plugin_name}..." add_plugin_to_gemfile(plugin_name) system('bundle install') PluginExposer.expose_commands(plugin_name) pp "The plugin #{plugin_name} is added" end |
.available?(plugin_name) ⇒ Boolean
43 44 45 |
# File 'lib/plugin/plugin.rb', line 43 def available?(plugin_name) plugins.include?(plugin_name) end |
.camelize(str) ⇒ Object
47 48 49 |
# File 'lib/plugin/plugin.rb', line 47 def camelize(str) str.split('_').collect(&:capitalize).join end |
.delete_plugin(plugin_name) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/plugin/plugin.rb', line 21 def delete_plugin(plugin_name) return gemfile_guard unless File.exist?('Gemfile') return 'The plugin is not installed' unless installed_plugins.include?(plugin_name) pp "Deleting #{plugin_name}..." remove_plugin_from_gemfile(plugin_name) PluginExposer.remove_command(plugin_name) system('bundle install') pp "The plugin #{plugin_name} is deleted" end |
.installed?(plugin_name) ⇒ Boolean
39 40 41 |
# File 'lib/plugin/plugin.rb', line 39 def installed?(plugin_name) installed_plugins.include?(plugin_name) end |
.installed_plugins ⇒ Object
32 33 34 35 36 37 |
# File 'lib/plugin/plugin.rb', line 32 def installed_plugins return gemfile_guard unless File.exist?('Gemfile') parsed_gemfile = File.readlines('Gemfile').map { |line| line.sub('gem ', '').strip.delete("'") } parsed_gemfile.select { |line| plugins.include?(line) } end |
.plugins ⇒ Object
51 52 53 |
# File 'lib/plugin/plugin.rb', line 51 def plugins ['great_axe'] end |