dradis-plugins 3.0.0.pre → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b231853a8ff2f2abe085576c558a48258331c03
4
- data.tar.gz: 47ca422c98df77c01578b824a222e851a58bb198
3
+ metadata.gz: ad5a0f1011a150397c1378acfe17ae79dfcc7118
4
+ data.tar.gz: 5a9b942df578368054a859030a42ab5e752d2369
5
5
  SHA512:
6
- metadata.gz: ee50b07b08ea47999650868d2b056e1a259fd32a9ba3960f79b0062e224516140517ed84f65cf7a707d9019c654eeacb145e0b0466209d06440beee2596487c5
7
- data.tar.gz: 0ba086c181e376c710c0bf814369e230f2d9462b452957b5de99e1c389b98d56f5ae74d2728984b3eaa5699f5e9e0be15b5bd33daf9b7bb32b952de7efdca89d
6
+ metadata.gz: c030f8c2e6a87f50a053100cf4f11343ff88958a719b7c81cabc8c8ec907cbb627df25a2b6c6aa890d1137fe27eb1c1787b1002425d24a0a71bd3efee83064ec
7
+ data.tar.gz: 58508d65a5d4cdd27c1bfd6263929533627569355f3a1185e28503e782f0ac3cd640d8e1e76f30f86047f7c3bc07feb9a22ccda8c3e9584e3ad87f00e87e7cdf
@@ -4,9 +4,12 @@ require 'dradis/plugins/version'
4
4
  require 'dradis/plugins/content_service'
5
5
  require 'dradis/plugins/template_service'
6
6
 
7
+ require 'dradis/plugins/export'
7
8
  require 'dradis/plugins/import'
8
9
  require 'dradis/plugins/upload'
9
10
 
11
+ require 'dradis/plugins/templates'
12
+
10
13
  module Dradis
11
14
  module Plugins
12
15
  module Base
@@ -19,19 +22,12 @@ module Dradis
19
22
  @name = 'Use plugin_info(args) with :name to provide a name for this plugin.'
20
23
  Plugins::register(self)
21
24
  end
25
+
26
+ # Extend the engine with other functionality
27
+ base.send :include, Dradis::Plugins::Templates
22
28
  end
23
29
 
24
30
  module ClassMethods
25
- # def options(key)
26
- # @options[key]
27
- # end
28
- #
29
- # def plugin_info(args={})
30
- # features = args.delete(:provides)
31
- # provides(features)
32
- # @options = args
33
- # end
34
-
35
31
  def description(new_description)
36
32
  @description = new_description
37
33
  end
@@ -25,10 +25,18 @@ module Dradis
25
25
 
26
26
  def create_node(args={})
27
27
  label = args[:label] || "create_node() invoked by #{plugin} without a :label parameter"
28
- type_id = args[:type_id] || default_node_type
29
28
  parent = args[:parent] || default_parent_node
29
+ type_id = begin
30
+ tmp_type = args[:type].to_s.upcase
31
+ class_for(:node)::Types::const_defined?(tmp_type) ? "#{class_for(:node)::Types}::#{tmp_type}".constantize : default_node_type
32
+ end
30
33
 
31
- parent.children.find_or_create_by_label_and_type_id(label, type_id)
34
+ # FIXME: how ugly is this?
35
+ if Rails::VERSION::MAJOR == 3
36
+ parent.children.find_or_create_by_label_and_type_id(label, type_id)
37
+ else
38
+ parent.children.find_or_create_by(label: label, type_id: type_id)
39
+ end
32
40
  end
33
41
 
34
42
  def create_note(args={})
@@ -82,7 +90,7 @@ module Dradis
82
90
  end
83
91
 
84
92
  def default_parent_node
85
- @default_parent_node ||= class_for(:node).create(label: 'plugin.output')
93
+ @default_parent_node ||= class_for(:node).find_or_create_by(label: 'plugin.output')
86
94
  end
87
95
 
88
96
  def issuelib
@@ -0,0 +1 @@
1
+ require 'dradis/plugins/export/base'
@@ -0,0 +1,27 @@
1
+ # This module contains basic Export plugin functions.
2
+ #
3
+
4
+ module Dradis
5
+ module Plugins
6
+ module Export
7
+ class Base
8
+ attr_accessor :logger
9
+
10
+ def initialize(args={})
11
+ @logger = args.fetch(:logger, Rails.logger)
12
+
13
+ post_initialize(args)
14
+ end
15
+
16
+ def export(args={})
17
+ raise "The export() method is not implemented in this plugin [#{self.class.name}]."
18
+ end
19
+
20
+ # This method can be overwriten by plugins to do initialization tasks.
21
+ def post_initialize(args={})
22
+ end
23
+ end # Base
24
+
25
+ end # Export
26
+ end # Plugins
27
+ end # Core
@@ -9,7 +9,7 @@ module Dradis
9
9
  MAJOR = 3
10
10
  MINOR = 0
11
11
  TINY = 0
12
- PRE = 'pre'
12
+ PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
15
15
  end
@@ -0,0 +1,41 @@
1
+ module Dradis
2
+ module Plugins
3
+ module Templates
4
+ def self.included(base)
5
+ base.extend ClassMethods
6
+
7
+ base.class_eval do
8
+ # Keep track of any templates the plugin defines
9
+ paths['dradis/templates'] = 'templates'
10
+ end
11
+ end
12
+
13
+ module ClassMethods
14
+ def copy_templates(args={})
15
+ destination = args[:to]
16
+
17
+ raise ArgumentError.new(':copy_templates called without a :to parameter') unless destination
18
+ FileUtils.mkdir_p(destination) if plugin_templates.any?
19
+
20
+ plugin_templates.each do |template|
21
+ destination_file = File.join(destination, File.basename(template))
22
+ next if File.exist?(destination_file)
23
+
24
+ Rails.logger.info{ "Updating templates for #{plugin_name} plugin. Destination: #{destination}" }
25
+ FileUtils.cp(template, destination_file)
26
+ end
27
+ end
28
+
29
+ def plugin_templates(args={})
30
+ @templates ||= begin
31
+ if paths['dradis/templates'].existent.any?
32
+ Dir["%s/*" % paths['dradis/templates'].existent]
33
+ else
34
+ []
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dradis-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.pre
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-31 00:00:00.000000000 Z
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,12 +56,15 @@ files:
56
56
  - lib/dradis/plugins.rb
57
57
  - lib/dradis/plugins/content_service.rb
58
58
  - lib/dradis/plugins/engine.rb
59
+ - lib/dradis/plugins/export.rb
60
+ - lib/dradis/plugins/export/base.rb
59
61
  - lib/dradis/plugins/gem_version.rb
60
62
  - lib/dradis/plugins/import.rb
61
63
  - lib/dradis/plugins/import/filters.rb
62
64
  - lib/dradis/plugins/import/filters/base.rb
63
65
  - lib/dradis/plugins/import/result.rb
64
66
  - lib/dradis/plugins/template_service.rb
67
+ - lib/dradis/plugins/templates.rb
65
68
  - lib/dradis/plugins/upload.rb
66
69
  - lib/dradis/plugins/upload/base.rb
67
70
  - lib/dradis/plugins/upload/field_processor.rb
@@ -81,9 +84,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
84
  version: '0'
82
85
  required_rubygems_version: !ruby/object:Gem::Requirement
83
86
  requirements:
84
- - - '>'
87
+ - - '>='
85
88
  - !ruby/object:Gem::Version
86
- version: 1.3.1
89
+ version: '0'
87
90
  requirements: []
88
91
  rubyforge_project:
89
92
  rubygems_version: 2.3.0