rake-namespace_group 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 79aba341e59bbcf655d1a368237412972347098b
4
+ data.tar.gz: 50ddecb6530fbe868d75e3d621083264d389084b
5
+ SHA512:
6
+ metadata.gz: 83e685abec24b02b412558811579a5930b8530e61975266b16240c89915a621db9383fb62de9e38c55fee08324b3a2433a6df90a77d2d431715ee8a6b83cad54
7
+ data.tar.gz: faa0c025cad5fe5d55ebcaac51917dc42a1e61326f61e18723cf987043a0a25ad10c78e2a0bc405bc2c7e3fff7c16590a873e0a5383fb1510acd74f0c94575bc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rake-namespace_group.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Jan Vansteenkiste
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Rake::NamespaceGroup
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rake-namespace_group'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rake-namespace_group
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/rake-namespace_group/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,40 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rake/namespace_group'
4
+
5
+ RSpec::Core::RakeTask.new(:spec) do |t|
6
+ t.rspec_opts = '--format documentation --colour --backtrace --tty'
7
+ end
8
+
9
+ namespace_group :default, :all => true
10
+ namespace :default do
11
+ desc "Namespace 'default' task 'foo'"
12
+ task :foo do
13
+ puts "Namespace 'default' task 'foo'"
14
+ end
15
+ desc "Namespace 'default' task 'bar'"
16
+ task :bar do
17
+ puts "Namespace 'default' task 'bar'"
18
+ end
19
+ end
20
+
21
+ namespace :original do
22
+ desc "Namespace 'original' do task 'regular'"
23
+ task :regular do
24
+ puts "Namespace 'original' task 'regular'"
25
+ end
26
+ end
27
+
28
+ namespace_group :original do
29
+ desc "Namespace 'original' task 'foo'"
30
+ task :foo do
31
+ puts "Namespace 'original' task 'foo'"
32
+ end
33
+ end
34
+
35
+ namespace_group :original do
36
+ desc "Namespace 'original' task 'bar'"
37
+ task :bar do
38
+ puts "Namespace 'original' task 'bar'"
39
+ end
40
+ end
@@ -0,0 +1,8 @@
1
+ require "rake/namespace_group/version"
2
+ require "rake/namespace_group/dsl"
3
+
4
+ module Rake
5
+ module NamespaceGroup
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,46 @@
1
+ require 'rake/namespace_group/group_task'
2
+
3
+ module Rake
4
+ module DSL
5
+ private
6
+
7
+ alias_method :orig_task, :task
8
+
9
+ def group_task(*args, &block)
10
+ Rake::GroupTask.define_task(*args, &block)
11
+ end
12
+
13
+ # Create a new rake namespace and use it for evaluating the given
14
+ # block. Returns a NameSpace object that can be used to lookup
15
+ # tasks defined in the namespace. It also creates a parent level
16
+ # task to execute all tasks defined in this namespace.
17
+ #
18
+ # Example:
19
+ #
20
+ #
21
+ #
22
+ #
23
+ #
24
+ def namespace_group(name=nil, options={}, &block)
25
+ ns_name = options[:namespace] || name
26
+ ns = namespace(ns_name) do
27
+ if block_given?
28
+ (class << self; self; end).send :alias_method, :task, :group_task
29
+ yield
30
+ (class << self; self; end).send :alias_method, :task, :orig_task
31
+ end
32
+ end
33
+ scope = ns.scope
34
+
35
+ desc options[:desc] || "Execute all tasks in group #{ns_name}"
36
+ task ns_name, (options[:arguments] || []) do |_self, args|
37
+ tasklist = Rake.application.tasks_in_scope(scope)
38
+ tasklist.each do |task|
39
+ if options[:all] or task.is_a?(Rake::GroupTask)
40
+ task.invoke(args)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,5 @@
1
+ require 'rake/task'
2
+ module Rake
3
+ class GroupTask < Rake::Task
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Rake
2
+ module NamespaceGroup
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rake/namespace_group/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rake-namespace_group"
8
+ spec.version = Rake::NamespaceGroup::VERSION
9
+ spec.authors = ["Jan Vansteenkiste"]
10
+ spec.email = ["jan@vstone.eu"]
11
+ spec.summary = %q{Provide an wrapper task for namespaces that executes all tasks.}
12
+ spec.description = %q{A namespace_group creates a task that loops over all tasks in the namespace.}
13
+ spec.homepage = "https://github.com/vStone/rake-namespace_group"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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', '~> 10.0'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.7'
24
+ spec.add_development_dependency 'rspec', '~> 3.2'
25
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Rakefile' do
4
+
5
+ context "namespace default with :all => true" do
6
+ it 'defines a top level task ' do
7
+ expect(Rake::Task[:default]).to be_an_instance_of(Rake::Task)
8
+ end
9
+
10
+ it 'executes all regular tasks' do
11
+ expect($stdout).to receive(:puts).with("Namespace 'default' task 'foo'")
12
+ expect($stdout).to receive(:puts).with("Namespace 'default' task 'bar'")
13
+ Rake::Task[:default].invoke()
14
+ end
15
+ end
16
+
17
+ context "namespace original" do
18
+ it 'defines a top level task' do
19
+ expect(Rake::Task[:original]).to be_an_instance_of(Rake::Task)
20
+ end
21
+
22
+ it 'executes only group tasks' do
23
+ expect($stdout).to receive(:puts).with("Namespace 'original' task 'foo'")
24
+ expect($stdout).to receive(:puts).with("Namespace 'original' task 'bar'")
25
+ expect($stdout).to_not receive(:puts).with("Namespace 'original' task 'regular'")
26
+ Rake::Task[:original].invoke()
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ require 'rake'
2
+ require 'rake/namespace_group'
3
+
4
+ load 'Rakefile'
5
+
6
+ RSpec.configure do |config|
7
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rake-namespace_group
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jan Vansteenkiste
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '10.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '10.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
55
+ description: A namespace_group creates a task that loops over all tasks in the namespace.
56
+ email:
57
+ - jan@vstone.eu
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - Gemfile
63
+ - LICENSE.txt
64
+ - README.md
65
+ - Rakefile
66
+ - lib/rake/namespace_group.rb
67
+ - lib/rake/namespace_group/dsl.rb
68
+ - lib/rake/namespace_group/group_task.rb
69
+ - lib/rake/namespace_group/version.rb
70
+ - rake-namespace_group.gemspec
71
+ - spec/rakefile_spec.rb
72
+ - spec/spec_helper.rb
73
+ homepage: https://github.com/vStone/rake-namespace_group
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.4.5
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Provide an wrapper task for namespaces that executes all tasks.
97
+ test_files:
98
+ - spec/rakefile_spec.rb
99
+ - spec/spec_helper.rb