maestro-plugin-rake-tasks 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ pkg
8
+ rdoc
9
+ spec/reports
10
+ test/tmp
11
+ test/version_tmp
12
+ tmp
13
+ manifest.json
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use --create jruby-1.6.8@maestro-plugin-rake-tasks
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in maestro-plugin-rake_tasks-tasks.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ maestro-plugin-rake-tasks (1.0.0)
5
+ git
6
+ json (>= 1.4.6)
7
+ nokogiri
8
+ rake (~> 0.9.2)
9
+ zippy
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ bouncy-castle-java (1.5.0147)
15
+ diff-lcs (1.2.4)
16
+ git (1.2.5)
17
+ jruby-openssl (0.8.8)
18
+ bouncy-castle-java (>= 1.5.0147)
19
+ json (1.8.0-java)
20
+ nokogiri (1.5.9-java)
21
+ rake (0.9.6)
22
+ rspec (2.13.0)
23
+ rspec-core (~> 2.13.0)
24
+ rspec-expectations (~> 2.13.0)
25
+ rspec-mocks (~> 2.13.0)
26
+ rspec-core (2.13.1)
27
+ rspec-expectations (2.13.0)
28
+ diff-lcs (>= 1.1.3, < 2.0)
29
+ rspec-mocks (2.13.1)
30
+ rubyzip (0.9.9)
31
+ zippy (0.2.1)
32
+ rubyzip (>= 0.9.1)
33
+
34
+ PLATFORMS
35
+ java
36
+
37
+ DEPENDENCIES
38
+ jruby-openssl
39
+ maestro-plugin-rake-tasks!
40
+ rspec (~> 2.13.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # Maestro::Plugin::Rake::Tasks
2
+
3
+ This gem is used to help with the packaging of Maestro Ruby plugins. It provides tasks that can be instantiated and
4
+ used as part of a Rakefile.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'maestro-plugin-rake-tasks'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install maestro-plugin-rake-tasks
19
+
20
+ ## Usage
21
+
22
+ ### Bundle Task
23
+
24
+ This task is used to update the gem dependencies in the vendor/cache directory. It omits the development and test
25
+ dependency groups before calling the *bundle update* command. Groups to be omitted can be specified with the
26
+ without_groups parameter.
27
+
28
+ Default example:
29
+
30
+ ```
31
+ Maestro::Plugin::RakeTasks::BundleTask.new
32
+ ```
33
+
34
+ Invoke like so
35
+
36
+ $ rake bundle
37
+
38
+ Example overriding the dependency groups to be omitted:
39
+
40
+ ```
41
+ Maestro::Plugin::RakeTasks::BundleTask.new do |t|
42
+ t.without_groups= [ 'development' ]
43
+ end
44
+ ```
45
+
46
+ The following attributes can be configured:
47
+
48
+ * without_groups: an array of dependency groups to omit from the bundle. Defaults: development, test
49
+
50
+ ### Package Task
51
+
52
+ This task is used to package the plugin in a zip file. The basic usage assumes that you have a Maven POM file (pom.xml)
53
+ containing the plugin name (artifactId) and version. If you do not have a pom.xml, you can specify the values in the
54
+ Rakefile when configuring the PackageTask. You also must have a manifest template which contains a placeholder for the
55
+ version which will be replaced by the package task.
56
+
57
+ Example using all defaults and a pom.xml:
58
+
59
+ ```
60
+ Maestro::Plugin::RakeTasks::PackageTask.new
61
+ ```
62
+
63
+ Invoke like so:
64
+
65
+ $ rake package
66
+
67
+ Example overriding some values:
68
+
69
+ ```
70
+ Maestro::Plugin::RakeTasks::PackageTask.new do |t|
71
+ t.verbose=false
72
+ t.version='1.2.3'
73
+ t.plugin_name='my-fancy-maestro-plugin'
74
+ end
75
+ ```
76
+
77
+ The following attributes can be configured:
78
+
79
+ * verbose: enable/disable verbose output. Default: true
80
+ * directories: an array of directories to package. Defaults: src, vendor, images.
81
+ * files: an array of files to package. Defaults: manifest.json, README.md, LICENSE
82
+ * use_pom: read plugin name and version from the pom. Default: true
83
+ * pom_path: path to the pom file. Default: ./pom.xml
84
+ * manifest_template_path: path to the manifest template. Default: ./manifest.template.json
85
+ * version: the plugin version. Defaults to the value defined in the pom.xml. Required if you are not using a pom.xml.
86
+ * plugin_name: the plugin name. Defaults to the value defined in the pom.xml. Required if you are not using a pom.xml.
87
+ * dest_dir: the destination directory of the zip file. Default: .
88
+
89
+ ## Example Rakefile
90
+
91
+ The following is an example Rakefile that can be used to build and test most Maestro Ruby plugins.
92
+
93
+ ```
94
+ require 'rake/clean'
95
+ require 'maestro/plugin/rake_tasks'
96
+ require 'rspec/core/rake_task'
97
+
98
+ $:.push File.expand_path("../src", __FILE__)
99
+
100
+ CLEAN.include("manifest.json", "*-plugin-*.zip", "vendor", "package", "tmp", ".bundle")
101
+
102
+ task :default => :all
103
+ task :all => [:clean, :bundle, :spec, :package]
104
+
105
+ desc "Run specs"
106
+ RSpec::Core::RakeTask.new do |t|
107
+ t.rspec_opts = "--format p --color"
108
+ end
109
+
110
+ Maestro::Plugin::RakeTasks::BundleTask.new
111
+
112
+ Maestro::Plugin::RakeTasks::PackageTask.new
113
+ ```
114
+
115
+ ## Contributing
116
+
117
+ 1. Fork it
118
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
119
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
120
+ 4. Push to the branch (`git push origin my-new-feature`)
121
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+ require 'rake/clean'
4
+
5
+ CLEAN.include('pkg', 'manifest.json', '*.zip')
6
+ CLOBBER.include('.bundle', '.config', 'coverage', 'InstalledFiles', 'spec/reports', 'rdoc', 'test', 'tmp')
7
+
8
+ task :default => [:clean, :spec, :build]
9
+
10
+ RSpec::Core::RakeTask.new
11
+
12
+
@@ -0,0 +1,47 @@
1
+ module Maestro
2
+ module Plugin
3
+ module RakeTasks
4
+ class BundleTask < ::Rake::TaskLib
5
+ include ::Rake::DSL if defined?(::Rake::DSL)
6
+
7
+ # Depedency groups to omit
8
+ # default:
9
+ # [ 'development', 'test' ]
10
+ attr_accessor :without_groups
11
+
12
+ # Name of task.
13
+ #
14
+ # default:
15
+ # :bundle
16
+ attr_accessor :name
17
+
18
+ def initialize(*args, &task_block)
19
+ setup_ivars(args)
20
+
21
+ desc 'Update the dependencies' unless ::Rake.application.last_comment
22
+
23
+ task name, *args do |_, task_args|
24
+ RakeFileUtils.send(:verbose, verbose) do
25
+ task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block
26
+ run_task verbose
27
+ end
28
+ end
29
+ end
30
+
31
+ def setup_ivars(args)
32
+ @name = args.shift || :bundle
33
+ @without_groups = [ 'development', 'test' ]
34
+ end
35
+
36
+ def run_task(verbose)
37
+ sh "bundle install --without #{@without_groups.join(' ')}" do |ok, res|
38
+ raise 'Error bundling' if ! ok
39
+ end
40
+ sh 'bundle package' do |ok, res|
41
+ raise 'Error bundling' if ! ok
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,165 @@
1
+ require 'maestro/plugin/rake_tasks/version'
2
+ require 'rake'
3
+ require 'rake/tasklib'
4
+ require 'zippy'
5
+ require 'git'
6
+ require 'nokogiri'
7
+ require 'json'
8
+
9
+
10
+ module Maestro
11
+ module Plugin
12
+ module RakeTasks
13
+ class PackageTask < ::Rake::TaskLib
14
+ include ::Rake::DSL if defined?(::Rake::DSL)
15
+
16
+ # Use verbose output. If this is set to true, the task will print the
17
+ # progress output to stdout.
18
+ #
19
+ # default:
20
+ # true
21
+ attr_accessor :verbose
22
+
23
+ # List the directories to package
24
+ # default:
25
+ # [ 'src', 'vendor', 'images' ]
26
+ attr_accessor :directories
27
+
28
+ # List the files to package
29
+ # default:
30
+ # [ 'manifest.json', 'README.md', 'LICENSE' ]
31
+ attr_accessor :files
32
+
33
+ # Tells the task to read version and plugin name from a pom.xml file
34
+ # default:
35
+ # true
36
+ attr_accessor :use_pom
37
+
38
+ # The path to the pom.xml
39
+ # default:
40
+ # './pom.xml'
41
+ attr_accessor :pom_path
42
+
43
+ # The path to the manifest template
44
+ # default:
45
+ # './manifest.template.json'
46
+ attr_accessor :manifest_template_path
47
+
48
+ # The plugin version
49
+ # default read from pom.xml (version)
50
+ attr_accessor :version
51
+
52
+ # The plugin name
53
+ # default read from pom.xml (artifactId)
54
+ attr_accessor :plugin_name
55
+
56
+ # The destination directory
57
+ # default:
58
+ # .
59
+ attr_accessor :dest_dir
60
+
61
+ # Name of task.
62
+ #
63
+ # default:
64
+ # :package
65
+ attr_accessor :name
66
+
67
+ def initialize(*args, &task_block)
68
+ setup_ivars(args)
69
+
70
+ desc "Package a Maestro Ruby plugin into a Zip file" unless ::Rake.application.last_comment
71
+
72
+ task name, *args do |_, task_args|
73
+ RakeFileUtils.send(:verbose, verbose) do
74
+ task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block
75
+ run_task verbose
76
+ end
77
+ end
78
+ end
79
+
80
+ def setup_ivars(args)
81
+ @name = args.shift || :package
82
+ @verbose, @use_pom = true, true
83
+ @directories = [ 'src', 'vendor', 'images' ]
84
+ @files = [ 'manifest.json', 'README.md', 'LICENSE' ]
85
+ @version, @plugin_name = nil, nil
86
+ @dest_dir = '.'
87
+ @pom_path = './pom.xml'
88
+ @manifest_template_path = './manifest.template.json'
89
+ end
90
+
91
+ def run_task(verbose)
92
+ parse_pom if @use_pom
93
+
94
+ # Make sure we have a valid name and version
95
+ abort "ERROR: Plugin name is missing" unless @plugin_name
96
+ abort "ERROR: Plugin version is missing" unless @version
97
+
98
+ # Add the commit hash to the version if it's available
99
+ git_version! if File.exists?('.git')
100
+
101
+ # If we use a template, use it to create the manifest
102
+ update_manifest if File.exists?(@manifest_template_path)
103
+
104
+ # Create the zip file
105
+ create_zip_file("#{@plugin_name}-#{@version}.zip")
106
+
107
+ end
108
+
109
+ private
110
+
111
+ def parse_pom
112
+ pom = File.open(@pom_path)
113
+ doc = Nokogiri::XML(pom.read)
114
+ pom.close
115
+ @plugin_name ||= doc.at_xpath('/xmlns:project/xmlns:artifactId').text
116
+ @version ||= doc.at_xpath('/xmlns:project/xmlns:version').text
117
+ end
118
+
119
+ def git_version!
120
+ git = Git.open('.')
121
+ # check if there are modified files
122
+ if git.status.select { |s| s.type == 'M' }.empty?
123
+ commit = git.log.first.sha[0..5]
124
+ @version = "#{@version}-#{commit}"
125
+ else
126
+ warn "WARNING: There are modified files, not using commit hash in version"
127
+ end
128
+ @version
129
+ end
130
+
131
+ # update the version number in the manifest file.
132
+ def update_manifest
133
+ manifest = JSON.parse(IO.read(@manifest_template_path))
134
+ manifest.each { |m| m['version'] = @version }
135
+ File.open('manifest.json','w'){ |f| f.write(JSON.pretty_generate(manifest)) }
136
+ end
137
+
138
+ def create_zip_file(zip_file)
139
+ Zippy.create zip_file do |z|
140
+ @directories.each { |dir| add_dir z, dir }
141
+ @files.each { |file| add_file z, file }
142
+ end
143
+ end
144
+
145
+ # add a file to the zip file
146
+ def add_file( zippyfile, f )
147
+ puts "Writing #{f} at #{@dest_dir}" if verbose
148
+ zippyfile["#{@dest_dir}/#{f}"] = File.open(f)
149
+ end
150
+
151
+ # add a directory to the zip file
152
+ def add_dir( zippyfile, d )
153
+ glob = "#{d}/**/*"
154
+ FileList.new( glob ).each { |f|
155
+ if (File.file?(f))
156
+ add_file zippyfile, f
157
+ end
158
+ }
159
+ end
160
+
161
+ end
162
+
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,7 @@
1
+ module Maestro
2
+ module Plugin
3
+ module RakeTasks
4
+ VERSION = '1.0.0'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ require 'maestro/plugin/rake_tasks/package_task'
2
+ require 'maestro/plugin/rake_tasks/bundle_task'
3
+ require 'maestro/plugin/rake_tasks/version'
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'maestro/plugin/rake_tasks/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'maestro-plugin-rake-tasks'
8
+ spec.version = Maestro::Plugin::RakeTasks::VERSION
9
+ spec.authors = ['Etienne Pelletier']
10
+ spec.email = ['epelletier@maestrodev.com']
11
+ spec.description = %q{A collection of Rake tasks used to package Maetro Ruby plugins}
12
+ spec.summary = %q{A collection of Rake tasks used to package Maetro Ruby plugins}
13
+ spec.homepage = 'https://github.com/maestrodev/maestro-plugin-rake-tasks'
14
+ spec.license = 'Apache 2.0'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'rake', '~>0.9.2'
22
+ spec.add_dependency 'nokogiri'
23
+ spec.add_dependency 'git'
24
+ spec.add_dependency 'zippy'
25
+ spec.add_dependency 'json', '>= 1.4.6'
26
+
27
+ spec.add_development_dependency 'rspec', '~> 2.13.0'
28
+ spec.add_development_dependency 'jruby-openssl'
29
+ end
@@ -0,0 +1,100 @@
1
+ require 'spec_helper'
2
+
3
+ describe Maestro::Plugin::RakeTasks::PackageTask do
4
+
5
+ before(:each) do
6
+ @task = Maestro::Plugin::RakeTasks::PackageTask.new
7
+ @task.pom_path = File.dirname(__FILE__) + '/../../../pom.xml'
8
+ @task.manifest_template_path = File.dirname(__FILE__) + '/../../../manifest.template.json'
9
+ end
10
+
11
+ it 'should read version number and plugin name from a pom.xml' do
12
+
13
+ @task.stub(:git_version!)
14
+ @task.stub(:update_manifest)
15
+ @task.stub(:create_zip_file)
16
+ @task.run_task true
17
+ @task.version.should == 'X.Y.Z'
18
+ @task.plugin_name.should == 'maestro-test-plugin'
19
+
20
+ end
21
+
22
+ it 'should override the pom values' do
23
+ @task.stub(:git_version!)
24
+ @task.stub(:update_manifest)
25
+ @task.stub(:create_zip_file)
26
+ @task.version='1.2.3'
27
+ @task.plugin_name='test'
28
+ @task.run_task true
29
+ @task.version.should == '1.2.3'
30
+ @task.plugin_name.should == 'test'
31
+ end
32
+
33
+ it 'should fail if the version is not read from pom and not set' do
34
+ @task.stub(:git_version!)
35
+ @task.stub(:update_manifest)
36
+ @task.stub(:create_zip_file)
37
+ @task.plugin_name='test'
38
+ @task.use_pom=false
39
+
40
+ expect {
41
+ @task.run_task true
42
+ }.to raise_error( SystemExit )
43
+
44
+ end
45
+
46
+
47
+ it 'should fail if the plugin name is not read from pom and not set' do
48
+ @task.stub(:git_version!)
49
+ @task.stub(:update_manifest)
50
+ @task.stub(:create_zip_file)
51
+ @task.version='1.2.3'
52
+ @task.use_pom=false
53
+
54
+ expect {
55
+ @task.run_task true
56
+ }.to raise_error( SystemExit )
57
+
58
+ end
59
+
60
+ it 'should create an updated manifest file' do
61
+ @task.stub(:git_version!)
62
+ @task.stub(:create_zip_file)
63
+ @task.run_task true
64
+
65
+ manifest_path = File.dirname(__FILE__) + '/../../../../manifest.json'
66
+ File.exists?(manifest_path).should be_true
67
+ manifest = JSON.parse(IO.read(manifest_path))
68
+ manifest.first['version'].should == 'X.Y.Z'
69
+
70
+ end
71
+
72
+ it 'should name the zip file based on the plugin_name and version' do
73
+ @task.stub(:git_version!)
74
+ @task.stub(:update_manifest)
75
+ @task.should_receive(:create_zip_file).with('maestro-test-plugin-X.Y.Z.zip')
76
+ @task.run_task true
77
+ end
78
+
79
+ it 'should add default directories to the zip file' do
80
+ @task.stub(:git_version!)
81
+ @task.stub(:update_manifest)
82
+ @task.stub(:add_file)
83
+ @task.should_receive(:add_dir).with(anything(), 'src')
84
+ @task.should_receive(:add_dir).with(anything(), 'vendor')
85
+ @task.should_receive(:add_dir).with(anything(), 'images')
86
+ @task.run_task true
87
+ end
88
+
89
+ it 'should add default files to the zip file' do
90
+ @task.stub(:git_version!)
91
+ @task.stub(:update_manifest)
92
+ @task.stub(:add_dir)
93
+ @task.should_receive(:add_file).with(anything(), 'manifest.json')
94
+ @task.should_receive(:add_file).with(anything(), 'LICENSE')
95
+ @task.should_receive(:add_file).with(anything(), 'README.md')
96
+ @task.run_task true
97
+ end
98
+
99
+
100
+ end
@@ -0,0 +1,10 @@
1
+ [{
2
+ "name" : "test",
3
+ "description" : "test manifest",
4
+ "license" : "Apache 2.0",
5
+ "author": "Author",
6
+ "version": "updated at build time",
7
+ "class": "SomeClass",
8
+ "type":"ruby"
9
+ }
10
+ ]
data/spec/pom.xml ADDED
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
+ <modelVersion>4.0.0</modelVersion>
4
+
5
+ <groupId>com.maestrodev</groupId>
6
+ <artifactId>maestro-test-plugin</artifactId>
7
+ <version>X.Y.Z</version>
8
+ <name>maestro-test-plugin</name>
9
+ <packaging>pom</packaging>
10
+
11
+
12
+ </project>
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'rspec'
3
+
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') unless $LOAD_PATH.include?(File.dirname(__FILE__) + '/../lib')
5
+
6
+ require 'maestro/plugin/rake_tasks'
7
+
8
+ RSpec.configure do |config|
9
+
10
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: maestro-plugin-rake-tasks
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Etienne Pelletier
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2013-05-23 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ version_requirements: &id001 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 0.9.2
23
+ requirement: *id001
24
+ prerelease: false
25
+ type: :runtime
26
+ - !ruby/object:Gem::Dependency
27
+ name: nokogiri
28
+ version_requirements: &id002 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ requirement: *id002
35
+ prerelease: false
36
+ type: :runtime
37
+ - !ruby/object:Gem::Dependency
38
+ name: git
39
+ version_requirements: &id003 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ requirement: *id003
46
+ prerelease: false
47
+ type: :runtime
48
+ - !ruby/object:Gem::Dependency
49
+ name: zippy
50
+ version_requirements: &id004 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ requirement: *id004
57
+ prerelease: false
58
+ type: :runtime
59
+ - !ruby/object:Gem::Dependency
60
+ name: json
61
+ version_requirements: &id005 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 1.4.6
67
+ requirement: *id005
68
+ prerelease: false
69
+ type: :runtime
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ version_requirements: &id006 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.13.0
78
+ requirement: *id006
79
+ prerelease: false
80
+ type: :development
81
+ - !ruby/object:Gem::Dependency
82
+ name: jruby-openssl
83
+ version_requirements: &id007 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ requirement: *id007
90
+ prerelease: false
91
+ type: :development
92
+ description: A collection of Rake tasks used to package Maetro Ruby plugins
93
+ email:
94
+ - epelletier@maestrodev.com
95
+ executables: []
96
+
97
+ extensions: []
98
+
99
+ extra_rdoc_files: []
100
+
101
+ files:
102
+ - .gitignore
103
+ - .rvmrc
104
+ - Gemfile
105
+ - Gemfile.lock
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - lib/maestro/plugin/rake_tasks.rb
110
+ - lib/maestro/plugin/rake_tasks/bundle_task.rb
111
+ - lib/maestro/plugin/rake_tasks/package_task.rb
112
+ - lib/maestro/plugin/rake_tasks/version.rb
113
+ - maestro-plugin-rake-tasks.gemspec
114
+ - spec/maestro/plugin/rake_tasks/package_task_spec.rb
115
+ - spec/manifest.template.json
116
+ - spec/pom.xml
117
+ - spec/spec_helper.rb
118
+ homepage: https://github.com/maestrodev/maestro-plugin-rake-tasks
119
+ licenses:
120
+ - Apache 2.0
121
+ post_install_message:
122
+ rdoc_options: []
123
+
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ hash: 2
132
+ segments:
133
+ - 0
134
+ version: "0"
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ hash: 2
141
+ segments:
142
+ - 0
143
+ version: "0"
144
+ requirements: []
145
+
146
+ rubyforge_project:
147
+ rubygems_version: 1.8.24
148
+ signing_key:
149
+ specification_version: 3
150
+ summary: A collection of Rake tasks used to package Maetro Ruby plugins
151
+ test_files:
152
+ - spec/maestro/plugin/rake_tasks/package_task_spec.rb
153
+ - spec/manifest.template.json
154
+ - spec/pom.xml
155
+ - spec/spec_helper.rb