jenkins-plugin 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,86 +5,14 @@ Creating a new Ruby plugin for Jenkins needs to be as simple as running a single
5
5
  that will generate a project skeleton. This skeleton will come complete with git repository and all
6
6
  the goodies that you need to do your plugin develompent.
7
7
 
8
- Background: Creating a brand new Jenkins Ruby Plugin
9
- Given I've run "jenkins-plugin create newplugin"
10
-
11
8
  Scenario: The directory skeleton is generated
12
- Then I should see this structure
13
- """
14
- [-] newplugin
15
- | [+] .git
16
- | .gitignore
17
- | Gemfile
18
- | Rakefile
19
- | [-] lib
20
- | [-] newplugin
21
- | | | version.rb
22
- | | newplugin.rb
23
- | [-] spec
24
- | | spec_helper.rb
25
- | [-] plugin
26
- | | [+] models
27
- | | [+] views
28
- """
29
-
30
- Scenario: The .gitignore contents
31
- When I open ".gitignore"
32
- Then I should see
33
- """
34
- .bundle
35
- .rvmrc
36
- .rspec
37
- """
38
-
39
- Scenario: The Gemfile contents
40
- When I open "Gemfile"
41
- Then I should see
42
- """
43
- source :rubygems
44
-
45
- gem "jenkins-war"
46
- gem "jenkins-plugins"
47
- """
48
-
49
- Scenario: The Rakefile contents
50
- When I open "Rakefile"
51
- Then I should see
52
- """
53
- require 'jenkins/rake'
54
- Jenkins::Rake.install_tasks
55
- """
56
-
57
- Scenario: The plugin module contents
58
- When I open "lib/newplugin.rb"
59
- Then I should see
60
- """
61
- module Newplugin
62
-
63
- def self.start
64
- #do any startup when this plugin initializes
65
- end
66
-
67
- def self.stop
68
- #perform any necessary cleanup when this plugin is shut down.
69
- end
70
- end
71
- """
72
-
73
- Scenario: The version file is generated
74
- When I open "lib/newplugin/version.rb"
75
- Then I should see
76
- """
77
-
78
- module Newplugin
79
- VERSION = 0.0.1
80
- end
81
- """
82
-
83
- Scenario: The spec_helper is created
84
- When I open "spec/spec_helper.rb"
85
- Then I should see
86
- """
87
- $:.unshift(Pathname(__FILE__).dirname.join('../lib'))
88
- require 'newplugin'
89
- """
90
-
9
+ When I run "jpi new newplugin"
10
+ # Then I should see this structure
11
+ # """
12
+ # [-] newplugin
13
+ # | [+] .git
14
+ # | .gitignore
15
+ # | Gemfile
16
+ # | Rakefile
17
+ # | newplugin.pluginspec
18
+ # """
@@ -0,0 +1,7 @@
1
+ When /^I run "([^"]*)"$/ do |cmd|
2
+ run cmd
3
+ end
4
+
5
+ Then /^I should see this structure$/ do |structure|
6
+ fail "no match" unless DirectoryStructure.new(structure).matches? work_dir
7
+ end
@@ -0,0 +1,49 @@
1
+
2
+ class DirectoryStructure
3
+ def initialize(structure)
4
+
5
+ @root = context = DirChild.new('.')
6
+
7
+ structure.each_line do |line|
8
+ if line =~ /(\[[-+]\]|\|)?\s+(\.?\w+)$/
9
+ op, name = $1, $2
10
+ case op
11
+ when "[+]"
12
+ context.add(DirChild.new name)
13
+ when "[-]"
14
+ new_context = DirChild.new name
15
+ context.add(new_context)
16
+ context = new_context
17
+ when "|"
18
+ context.add(FileChild.new name)
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ def matches?(dir)
25
+ @root.matches?(dir)
26
+ end
27
+
28
+ Entry = Struct.new(:name)
29
+
30
+ class DirChild < Entry
31
+ def initialize(name)
32
+ super(name)
33
+ @entries = []
34
+ end
35
+
36
+ def add(entry)
37
+ @entries << entries
38
+ end
39
+
40
+ def matches?(realdir)
41
+ entries = Dir.new(realdir).entries
42
+ !@entries.detect {|e| !entries.map{|e| File.basename(e)}.member?(e)}
43
+ end
44
+ end
45
+
46
+ class FileChild < Entry
47
+
48
+ end
49
+ end
@@ -0,0 +1,20 @@
1
+ module Work
2
+ def run cmd
3
+ Dir.chdir(work_dir) do
4
+ root = Pathname(__FILE__).join('..', '..', '..')
5
+ full_cmd = "ruby -rubygems -I #{root.join('lib')} -S #{root.join('bin',cmd)}"
6
+ system(full_cmd) or fail "failed to run command #{cmd}"
7
+ end
8
+ end
9
+
10
+ def work_dir
11
+ @work_dir ||= File.expand_path("tmp/work")
12
+ end
13
+ end
14
+
15
+ Before do
16
+ FileUtils.rm_rf work_dir
17
+ FileUtils.mkdir_p work_dir
18
+ end
19
+
20
+ World(Work)
@@ -9,13 +9,13 @@ module Jenkins
9
9
 
10
10
  argument :name
11
11
 
12
- desc "publisher", "publisher NAME", "generate a publish step definition"
12
+ desc "publisher", "publisher NAME", :desc => "generate a publish step definition"
13
13
  def publisher
14
14
  @step_class = "Publisher"
15
15
  template('templates/build_step.tt', "models/#{name.downcase}_publisher.rb")
16
16
  end
17
17
 
18
- desc "builder", "builder NAME", "generate a build step definition"
18
+ desc "builder", "builder NAME", :desc => "generate a build step definition"
19
19
  def builder
20
20
  @step_class = "Builder"
21
21
  template('templates/build_step.tt', "models/#{name.downcase}_builder.rb")
@@ -1,4 +1,6 @@
1
1
 
2
+ #require 'jenkins/plugin/version'
3
+
2
4
  require 'jenkins/plugin/version'
3
5
 
4
6
  module Jenkins
@@ -11,37 +13,66 @@ module Jenkins
11
13
  end
12
14
 
13
15
  def write_hpi(io)
14
- io.puts "Manifest-Version: 1.0"
15
- io.puts "Created-By: #{Jenkins::Plugin::VERSION}"
16
- io.puts "Build-Ruby-Platform: #{RUBY_PLATFORM}"
17
- io.puts "Build-Ruby-Version: #{RUBY_VERSION}"
16
+ w = Writer.new(io)
17
+ w.put "Manifest-Version", "1.0"
18
+ w.put "Created-By", Jenkins::Plugin::VERSION
19
+ w.put "Build-Ruby-Platform", RUBY_PLATFORM
20
+ w.put "Build-Ruby-Version", RUBY_VERSION
18
21
 
19
- io.puts "Group-Id: org.jenkins-ci.plugins"
20
- io.puts "Short-Name: #{@spec.name}"
21
- io.puts "Long-Name: #{@spec.name}" # TODO: better name
22
- io.puts "Url: http://jenkins-ci.org/" # TODO: better value
22
+ w.put "Group-Id", "org.jenkins-ci.plugins"
23
+ w.put "Short-Name", @spec.name
24
+ w.put "Long-Name", @spec.name # TODO: better name
25
+ w.put "Url", "http://jenkins-ci.org/" # TODO: better value
23
26
 
24
- io.puts "Plugin-Class: ruby.RubyPlugin"
25
- io.puts "Plugin-Version: #{@spec.version}"
26
- io.puts "Jenkins-Version: 1.426"
27
+ w.put "Plugin-Class", "ruby.RubyPlugin"
28
+ w.put "Plugin-Version", @spec.version
29
+ w.put "Jenkins-Version", "1.426"
27
30
 
28
- io.puts "Plugin-Dependencies: " + @spec.dependencies.map{|k,v| "#{k}:#{v}"}.join(",")
31
+ w.put "Plugin-Dependencies", @spec.dependencies.map{|k,v| "#{k}:#{v}"}.join(",")
29
32
  end
30
33
 
31
34
  def write_hpl(io, loadpath)
32
35
  write_hpi(io)
33
36
 
34
- io.puts "Load-Path: #{loadpath.to_a.join(':')}"
35
- io.puts "Lib-Path: #{Dir.pwd}/lib/"
36
- io.puts "Models-Path: #{Dir.pwd}/models"
37
+ w = Writer.new(io)
38
+ w.put "Load-Path", loadpath.to_a.join(':')
39
+ w.put "Lib-Path", "#{Dir.pwd}/lib/"
40
+ w.put "Models-Path", "#{Dir.pwd}/models"
37
41
  # Stapler expects view erb/haml scripts to be in the JVM ClassPath
38
- io.puts "Class-Path: #{Dir.pwd}/views" if File.exists?("#{Dir.pwd}/views")
42
+ w.put "Class-Path", "#{Dir.pwd}/views" if File.exists?("#{Dir.pwd}/views")
39
43
  # Directory for static images, javascript, css, etc. of this plugin.
40
44
  # The static resources are mapped under #CONTEXTPATH/plugin/SHORTNAME/
41
- io.puts "Resource-Path: #{Dir.pwd}/static"
45
+ w.put "Resource-Path", "#{Dir.pwd}/static"
46
+ end
47
+
48
+ class Writer
49
+
50
+ MAX_LENGTH = 72.to_i
51
+
52
+ def initialize(io)
53
+ @io = io
54
+ end
55
+
56
+ def put(key, value)
57
+ @io.puts "#{key}: #{manifest_truncate(value)}"
58
+ end
59
+
60
+ def manifest_truncate(message)
61
+ if message.length < MAX_LENGTH
62
+ return message
63
+ end
64
+
65
+ line = message[0 ... MAX_LENGTH] + "\n"
66
+ offset = MAX_LENGTH
42
67
 
68
+ while offset < message.length
69
+ line += " #{message[offset ... (offset + MAX_LENGTH - 1)]}\n"
70
+ offset += (MAX_LENGTH - 1)
71
+ end
72
+ return line
73
+ end
43
74
  end
44
75
  end
45
76
  end
46
77
  end
47
- end
78
+ end
@@ -1,5 +1,5 @@
1
1
  module Jenkins
2
2
  class Plugin
3
- VERSION = "0.1.11"
3
+ VERSION = "0.1.12"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jenkins-plugin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 11
10
- version: 0.1.11
9
+ - 12
10
+ version: 0.1.12
11
11
  platform: ruby
12
12
  authors:
13
13
  - Charles Lowell
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-01 00:00:00 -05:00
18
+ date: 2011-10-05 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -137,6 +137,9 @@ files:
137
137
  - Rakefile
138
138
  - bin/jpi
139
139
  - features/create-new-plugin.feature
140
+ - features/support/create_new_plugin_steps.rb
141
+ - features/support/directory_structure.rb
142
+ - features/support/work.rb
140
143
  - jenkins-plugin.gemspec
141
144
  - lib/jenkins/plugin/cli.rb
142
145
  - lib/jenkins/plugin/cli/formatting.rb
@@ -188,3 +191,6 @@ specification_version: 3
188
191
  summary: Tools for creating and building Jenkins Ruby plugins
189
192
  test_files:
190
193
  - features/create-new-plugin.feature
194
+ - features/support/create_new_plugin_steps.rb
195
+ - features/support/directory_structure.rb
196
+ - features/support/work.rb