inventory-rake 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,26 @@
1
+ Inventory-Rake
2
+
3
+ Inventory-Rake provides Rake tasks for your Inventory¹. This includes
4
+ cleaning tasks, gem generation, testing, installation, uninstallation, and
5
+ pushing, and inventory content checking.
6
+
7
+ ¹ Get information on Inventory at http://disu.se/software/inventory/
8
+
9
+ § Installation
10
+
11
+ Install Inventory-Rake with
12
+
13
+ % gem install inventory-rake
14
+
15
+ § Usage
16
+
17
+ Include the following code in your ‹Rakefile›, where ‹Package› is the
18
+ top-level module of your package:
19
+
20
+ require 'inventory/rake-3.0'
21
+
22
+ Inventory::Rake::Tasks.define Package::Version, :gem => proc{ |_, s|
23
+ s.author = 'Your Name'
24
+ s.email = 'your@email.com'
25
+ s.homepage = 'https://github.com/now/%s' % Package.name.downcase
26
+ }
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'lookout/rake-3.0'
4
+
5
+ $:.unshift File.expand_path('../lib', __FILE__)
6
+ require 'inventory/rake-1.0'
7
+
8
+ Inventory::Rake::Tasks.define Inventory::Rake::Version, :gem => proc{ |_, s|
9
+ s.author = 'Nikolai Weibull'
10
+ s.email = 'now@bitwi.se'
11
+ s.homepage = 'https://github.com/now/inventory-rake'
12
+ }
13
+ Lookout::Rake::Tasks::Test.new
@@ -0,0 +1,10 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Namespace for Inventory, see {http://disu.se/software/inventory}.
4
+ class Inventory; end
5
+
6
+ # Namespace for Rake integration of Inventory.
7
+ module Inventory::Rake
8
+ load File.expand_path('../rake/version.rb', __FILE__)
9
+ Version.load
10
+ end
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Namespace for Rake tasks.
4
+ module Inventory::Rake::Tasks
5
+ @mostlycleanfiles, @cleanfiles, @distcleanfiles = [], [], []
6
+
7
+ class << self
8
+ attr_accessor :inventory
9
+
10
+ attr_reader :mostlycleanfiles, :cleanfiles, :distcleanfiles
11
+
12
+ def define(inventory, options = {})
13
+ self.inventory = inventory
14
+ Clean.define
15
+ Inventory.new(:inventory => inventory)
16
+ Gem.new(:inventory => inventory, &(options.fetch(:gem, proc{ })))
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ desc 'Check that the package meets its expectations'
4
+ task :check
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ class Inventory::Rake::Tasks::Clean
4
+ include Rake::DSL
5
+
6
+ class << self
7
+ include Rake::DSL
8
+
9
+ def define
10
+ desc 'Delete targets built by rake that are often rebuilt'
11
+ new :mostlyclean, Inventory::Rake::Tasks.mostlycleanfiles
12
+
13
+ desc 'Delete targets built by rake'
14
+ new :clean, Inventory::Rake::Tasks.cleanfiles
15
+ task :clean => :mostlyclean
16
+
17
+ desc 'Delete targets built by extconf.rb'
18
+ new :distclean, Inventory::Rake::Tasks.distcleanfiles
19
+ task :distclean => :clean
20
+ end
21
+ end
22
+
23
+ def initialize(name, files = [])
24
+ @name, @files = name, files
25
+ define
26
+ end
27
+
28
+ def define
29
+ task name do
30
+ rm files, :force => true
31
+ end
32
+ end
33
+
34
+ attr_accessor :name, :files
35
+ end
@@ -0,0 +1,191 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ class Inventory::Rake::Tasks::Gem
4
+ include Rake::DSL
5
+
6
+ def initialize(options = {})
7
+ self.inventory = options.fetch(:inventory, Inventory::Rake::Tasks.inventory)
8
+ self.specification = options.fetch(:specification,
9
+ Gem::Specification.new{ |s|
10
+ next unless @inventory
11
+
12
+ s.name = @inventory.package
13
+ s.version = @inventory.to_s # TODO: We could probably skip #to_s
14
+
15
+ s.description = IO.read('README')
16
+ s.summary = s.description[/^.*?\./].lstrip
17
+
18
+ s.files = @inventory.files # TODO: We can skip #files and rely on #to_a
19
+
20
+ s.require_paths = @inventory.lib_directories
21
+
22
+ @inventory.dependencies.add_to_gem_specification s
23
+ })
24
+ yield self, @specification if block_given?
25
+ define
26
+ end
27
+
28
+ def define
29
+ desc 'Create specifications' unless Rake::Task.task_defined? :spec
30
+ task :spec => :'gem:spec'
31
+
32
+ gemspec = '%s.gemspec' % @specification.name
33
+ Inventory::Rake::Tasks.cleanfiles << gemspec
34
+
35
+ desc 'Create gem specification' unless Rake::Task.task_defined? :'gem:spec'
36
+ task :'gem:spec' => gemspec
37
+
38
+ file gemspec => %w'Rakefile README' + [@inventory.path] do |t|
39
+ tmp = '%s.tmp' % t.name
40
+ rm([t.name, tmp], :force => true)
41
+ rake_output_message 'gem specification --ruby %s > %s' %
42
+ [@specification.name, tmp] if verbose
43
+ File.open(tmp, 'wb') do |f|
44
+ f.write @specification.to_ruby
45
+ end
46
+ chmod File.stat(tmp).mode & ~0222, tmp
47
+ mv tmp, t.name
48
+ end
49
+
50
+ desc 'Create files for distribution' unless Rake::Task.task_defined? :dist
51
+ task :dist => :'gem:dist'
52
+
53
+ desc 'Create %s for distribution' % @specification.file_name
54
+ task :'gem:dist' => [:'inventory:check', @specification.file_name]
55
+ file @specification.file_name => @specification.files do
56
+ require 'rubygems' unless defined? Gem
57
+ rake_output_message 'gem build %s' % gemspec if verbose
58
+ Gem::Builder.new(@specification).build
59
+ end
60
+
61
+ desc 'Check files before distribution' unless
62
+ Rake::Task.task_defined? :'dist:check'
63
+ task :'dist:check' => [:dist, :'gem:dist:check']
64
+
65
+ desc 'Check %s before distribution' % @specification.file_name
66
+ task :'gem:dist:check' => :'gem:dist' do
67
+ require 'rubygems' unless defined? Gem
68
+ require 'rubygems/installer' unless defined? Gem::Installer
69
+ checkdir = @specification.full_name
70
+ rake_output_message 'gem unpack %s --target %s' %
71
+ [@specification.file_name, checkdir] if verbose
72
+ Gem::Installer.new(@specification.file_name, :unpack => true).
73
+ unpack File.expand_path(checkdir)
74
+ chdir checkdir do
75
+ sh '%s %sinventory:check check' %
76
+ [Rake.application.name, Rake.application.options.silent ? '-s ' : '']
77
+ end
78
+ rm_r checkdir
79
+ end
80
+
81
+ desc 'Install dependencies on the local system' unless
82
+ Rake::Task.task_defined? :'deps:install'
83
+ task :'deps:install' => :'gem:deps:install'
84
+
85
+ desc 'Install dependencies in ruby gem directory'
86
+ task :'gem:deps:install' do
87
+ require 'rubygems' unless defined? Gem
88
+ require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
89
+ @specification.dependencies.each do |dependency|
90
+ rake_output_message "gem install %s -v '%s'" % [dependency.name, dependency.requirement] if verbose
91
+ Gem::DependencyInstaller.new.install dependency.name, dependency.requirement
92
+ end
93
+ end
94
+
95
+ desc 'Install dependencies for the current user' unless
96
+ Rake::Task.task_defined? :'deps:install:user'
97
+ task :'deps:install:user' => :'gem:deps:install:user'
98
+
99
+ desc 'Install dependencies for the current user'
100
+ task :'gem:deps:install:user' do
101
+ require 'rubygems' unless defined? Gem
102
+ require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
103
+ @specification.dependencies.each do |dependency|
104
+ rake_output_message "gem install --user-install --bindir %s %s -v '%s'" %
105
+ [Gem.bindir(Gem.user_dir), dependency.name, dependency.requirement] if verbose
106
+ Gem::DependencyInstaller.
107
+ new(:user_install => true,
108
+ :bindir => Gem.bindir(Gem.user_dir)).
109
+ install dependency.name, dependency.requirement
110
+ end
111
+ end
112
+
113
+ desc 'Install distribution files on the local system' unless
114
+ Rake::Task.task_defined? :install
115
+ task :install => :'gem:install'
116
+
117
+ desc 'Install %s in ruby gem directory' %
118
+ @specification.file_name
119
+ task :'gem:install' => :'gem:dist' do |t|
120
+ require 'rubygems' unless defined? Gem
121
+ require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
122
+ rake_output_message 'gem install %s' % @specification.file_name if verbose
123
+ Gem::DependencyInstaller.
124
+ new(:ignore_dependencies => true).
125
+ install @specification.file_name
126
+ end
127
+
128
+ desc 'Install distribution files for the current user' unless
129
+ Rake::Task.task_defined? :'install:user'
130
+ task :'install:user' => :'gem:install:user'
131
+
132
+ desc 'Install %s in user gem directory' %
133
+ @specification.file_name
134
+ task :'gem:install:user' => :'gem:dist' do
135
+ require 'rubygems' unless defined? Gem
136
+ require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
137
+ rake_output_message 'gem install --user-install --bindir %s %s' %
138
+ [Gem.bindir(Gem.user_dir), @specification.file_name] if verbose
139
+ Gem::DependencyInstaller.
140
+ new(:ignore_dependencies => true,
141
+ :user_install => true,
142
+ :bindir => Gem.bindir(Gem.user_dir)).
143
+ install @specification.file_name
144
+ end
145
+
146
+ desc 'Delete all files installed on the local system' unless
147
+ Rake::Task.task_defined? :uninstall
148
+ task :uninstall => :'gem:uninstall'
149
+
150
+ desc 'Uninstall %s from ruby gem directory' % @specification.file_name
151
+ task :'gem:uninstall' do
152
+ require 'rubygems' unless defined? Gem
153
+ # TODO: I have absolutely no idea why this is needed, but it is.
154
+ require 'rubygems/user_interaction' unless defined? Gem::UserInteraction
155
+ require 'rubygems/uninstaller' unless defined? Gem::Uninstaller
156
+ rake_output_message 'gem uninstall --executables %s' % @specification.name if verbose
157
+ Gem::Uninstaller.new(@specification.name,
158
+ :executables => true,
159
+ :version => @specification.version).uninstall
160
+ end
161
+
162
+ desc 'Delete all files installed for current user' unless
163
+ Rake::Task.task_defined? :'uninstall:user'
164
+ task :'uninstall:user' => :'gem:uninstall:user'
165
+
166
+ desc 'Uninstall %s from user gem directory' % @specification.file_name
167
+ task :'gem:uninstall:user' do
168
+ require 'rubygems' unless defined? Gem
169
+ # TODO: I have absolutely no idea why this is needed, but it is.
170
+ require 'rubygems/user_interaction' unless defined? Gem::UserInteraction
171
+ require 'rubygems/uninstaller' unless defined? Gem::Uninstaller
172
+ rake_output_message 'gem uninstall --executables --install-dir %s %s' %
173
+ [Gem.user_dir, @specification.name] if verbose
174
+ Gem::Uninstaller.new(@specification.name,
175
+ :executables => true,
176
+ :install_dir => Gem.user_dir,
177
+ :version => @specification.version).uninstall
178
+ end
179
+
180
+ desc 'Push distribution files to distribution hubs' unless
181
+ Rake::Task.task_defined? :push
182
+ task :push => :'gem:push'
183
+
184
+ desc 'Push %s to rubygems.org' % @specification.file_name
185
+ task :'gem:push' => :'gem:dist:check' do
186
+ sh 'gem push -%s-verbose %s' % [verbose ? '' : '-no', @specification.file_name]
187
+ end
188
+ end
189
+
190
+ attr_writer :inventory, :specification
191
+ end
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ class Inventory::Rake::Tasks::Inventory
4
+ include Rake::DSL
5
+
6
+ def initialize(options = {})
7
+ self.inventory = options.fetch(:inventory, Inventory::Rake::Tasks.inventory)
8
+ yield self if block_given?
9
+ define
10
+ end
11
+
12
+ def define
13
+ desc 'Check that the inventory is correct'
14
+ task :'inventory:check' do
15
+ # TODO: Use directories from Inventory instead of hard-coding lib and
16
+ # test/unit. We want to check ext too?
17
+ diff = ((Dir['{lib,test/unit}/**/*.rb'] -
18
+ @inventory.lib_files -
19
+ @inventory.unit_test_files).map{ |e| 'file not listed in inventory: %s' % e } +
20
+ @inventory.files.reject{ |e| File.exist? e }.map{ |e| 'file listed in inventory does not exist: %s' % e })
21
+ fail diff.join("\n") unless diff.empty?
22
+ # TODO: puts 'inventory checks out' if verbose
23
+ end
24
+ end
25
+
26
+ attr_writer :inventory
27
+ end
@@ -0,0 +1,29 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'inventory-1.0'
4
+
5
+ module Inventory::Rake
6
+ Version = Inventory.new(1, 2, 0){
7
+ def dependencies
8
+ super + Inventory::Dependencies.new{
9
+ optional 'rake', 0, 9, 2
10
+ }
11
+ end
12
+
13
+ def requires
14
+ %w'
15
+ rake
16
+ '
17
+ end
18
+
19
+ def libs
20
+ %w'
21
+ inventory/rake/tasks.rb
22
+ inventory/rake/tasks/check.rb
23
+ inventory/rake/tasks/clean.rb
24
+ inventory/rake/tasks/gem.rb
25
+ inventory/rake/tasks/inventory.rb
26
+ '
27
+ end
28
+ }
29
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inventory-rake
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nikolai Weibull
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: inventory
16
+ requirement: &16233528 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *16233528
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &16231944 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.9.2
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *16231944
36
+ description: ! " Inventory-Rake\n\n Inventory-Rake
37
+ provides Rake tasks for your Inventory¹. This includes\n cleaning tasks, gem generation,
38
+ testing, installation, uninstallation, and\n pushing, and inventory content checking.\n\n¹
39
+ Get information on Inventory at http://disu.se/software/inventory/\n\n§ Installation\n\n
40
+ \ Install Inventory-Rake with\n\n % gem install inventory-rake\n\n§ Usage\n\n
41
+ \ Include the following code in your ‹Rakefile›, where ‹Package› is the\n top-level
42
+ module of your package:\n\n require 'inventory/rake-3.0'\n\n Inventory::Rake::Tasks.define
43
+ Package::Version, :gem => proc{ |_, s|\n s.author = 'Your Name'\n s.email
44
+ = 'your@email.com'\n s.homepage = 'https://github.com/now/%s' % Package.name.downcase\n
45
+ \ }\n"
46
+ email: now@bitwi.se
47
+ executables: []
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - lib/inventory/rake/tasks.rb
52
+ - lib/inventory/rake/tasks/check.rb
53
+ - lib/inventory/rake/tasks/clean.rb
54
+ - lib/inventory/rake/tasks/gem.rb
55
+ - lib/inventory/rake/tasks/inventory.rb
56
+ - lib/inventory/rake-1.0.rb
57
+ - lib/inventory/rake/version.rb
58
+ - test/unit/inventory/rake/tasks.rb
59
+ - test/unit/inventory/rake/tasks/check.rb
60
+ - test/unit/inventory/rake/tasks/clean.rb
61
+ - test/unit/inventory/rake/tasks/gem.rb
62
+ - test/unit/inventory/rake/tasks/inventory.rb
63
+ - test/unit/inventory/rake-1.0.rb
64
+ - test/unit/inventory/rake/version.rb
65
+ - README
66
+ - Rakefile
67
+ homepage: https://github.com/now/inventory-rake
68
+ licenses: []
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 1.8.10
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Inventory-Rake provides Rake tasks for your Inventory¹.
92
+ test_files: []