inventory-rake 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 427df0935a6abb01a0c8d70412f8944533fa4371
4
+ data.tar.gz: 3baaf45912f54c59b4192ae5c2d79d8b58da9889
5
+ SHA512:
6
+ metadata.gz: df48e44bec0ee151e62278e5027359d686dc860725755125704a031dfa446da90621566d2ab86d7179f1d052757dcd6a5e64883ec794f333b4e6d60ddf6e502c
7
+ data.tar.gz: 641d02cd7e50060226b28d54a9c8c6d4a190a399cca87f7272b75372a7da82e2c3a2447f6bd7ff8a16390044d00014d877bbb2f433876bd4e43246d3fb505880
data/README CHANGED
@@ -1,10 +1,12 @@
1
1
  Inventory-Rake
2
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.
3
+ Inventory-Rake provides Rake¹ tasks for your Inventory². This includes tasks
4
+ for cleaning up our project, compiling extensions, installing dependencies,
5
+ installing and uninstalling the project itself, and creating and pushing
6
+ distribution files to distribution points.
6
7
 
7
- ¹ Get information on Inventory at http://disu.se/software/inventory/
8
+ ¹ See http://rake.rubyforge.org/
9
+ ² See http://disu.se/software/inventory/
8
10
 
9
11
  § Installation
10
12
 
@@ -15,12 +17,121 @@
15
17
  § Usage
16
18
 
17
19
  Include the following code in your ‹Rakefile›, where ‹Package› is the
18
- top-level module of your package:
20
+ top-level module of your project:
19
21
 
20
- require 'inventory/rake-3.0'
22
+ require 'inventory-rake-3.0'
23
+
24
+ load File.expand_path('../lib/package/version.rb', __FILE__)
21
25
 
22
26
  Inventory::Rake::Tasks.define Package::Version, :gem => proc{ |_, s|
23
27
  s.author = 'Your Name'
24
- s.email = 'your@email.com'
25
- s.homepage = 'https://github.com/now/%s' % Package.name.downcase
28
+ s.email = 'you@example.com'
29
+ s.homepage = 'http://example.com/'
26
30
  }
31
+
32
+ Inventory::Rake::Tasks.unless_installing_dependencies do
33
+ # Any additional tasks that your project’s dependencies provide
34
+ end
35
+
36
+ ‹Inventory::Rake::Tasks.define› does the heavy lifting. It takes our
37
+ inventory and sets up the tasks mentioned above. We also do some
38
+ additional customization of the gem specification.
39
+
40
+ As we want to be able to use our Rakefile to install our dependencies for
41
+ us, the rest of the Rakefile is inside the conditional
42
+ #unless_installing_dependencies, which, as the name certainly implies,
43
+ executes its block unless the task being run is the one that installs our
44
+ dependencies. This becomes relevant if we want to, for example, set up
45
+ Travis¹ integration. To do so, simply add
46
+
47
+ before_script:
48
+ - gem install inventory-rake -v '~> VERSION' --no-rdoc --no-ri
49
+ - rake gem:deps:install
50
+
51
+ to your ‹.travis.yml› file. This’ll make sure that Travis installs all
52
+ development, runtime, and optional dependencies that you’ve listed in your
53
+ inventory before running any tests.
54
+
55
+ There’s more information in the {API documentation}² that you’ll likely
56
+ want to read up on if anything is unclear.
57
+
58
+ ¹ See http://travis-ci.org/
59
+ ² See http://disu.se/software/inventory/api/inventory-rake/
60
+
61
+ § Tasks
62
+
63
+ The tasks that are created if you use Inventory-Rake are:
64
+
65
+ = check. = Check that the package meets its expectations.
66
+ = mostlyclean. = Delete targets built by rake that are ofter rebuilt.
67
+ = clean. = Delete targets built by rake; depends on mostlyclean.
68
+ = distclean. = Delete all files not meant for distribution; depends on clean.
69
+ = compile. = Compile all extensions; depends on each compile:name.
70
+ = compile:name. = Compile extension /name/; depends on
71
+ lib/path/so file.
72
+ = lib/path/so. = Installed dynamic library of extension /name/ inside
73
+ inventory path; depends on ext/name/so.
74
+ = ext/name/so. = Dynamic library of extension /name/; depends on
75
+ ext/name/Makefile and the source files of the extension.
76
+ = ext/name/Makefile. = Makefile for extension /name/; depends on inventory
77
+ path, ext/name/extconf.rb file, and ext/name/depend file.
78
+ = clean:name. = Clean files built for extension /name/; depended upon by
79
+ clean.
80
+ = spec. = Create specifications; depends on gem:spec.
81
+ = gem:spec. = Create gem specification; depends on gemspec.
82
+ = gemspec (file). = Gem specification file; depends on Rakefile, README, and
83
+ inventory path.
84
+ = dist. = Create files for distribution; depends on gem:dist.
85
+ = gem:dist. = Create gem for distribution; depends on inventory:check and gem
86
+ file.
87
+ = inventory:check. = Check that the inventory is correct by looking for files
88
+ not listed in the inventory that match the pattern and for files listed
89
+ in the inventory that don’t exist; depends on distclean.
90
+ = gem (file). = Gem file; depends on files included in gem.
91
+ = dist:check. = Check files before distribution; depends on dist and
92
+ gem:dist:check.
93
+ = gem:dist:check. = Check gem before distribution; depends on gem:dist.
94
+ = deps:install. = Install dependencies on the local system; depends on
95
+ gem:deps:install.
96
+ = gem:deps:install. = Install dependencies in ruby gem directory.
97
+ = deps:install:user. = Install dependencies for the current user; depends on
98
+ gem:deps:install:user.
99
+ = gem:deps:install:user. = Install dependencies in the user gem directory.
100
+ = install. = Install distribution files on the local system; depends on
101
+ gem:install.
102
+ = gem:install. = Install gem in ruby gem directory; depends on gem:dist.
103
+ = install:user. = Install distribution files for the current user; depends on
104
+ gem:install:user.
105
+ = gem:install:user. = Install gem in the user gem directory.
106
+ = uninstall. = Delete all files installed on the local system.
107
+ = gem:uninstall. = Uninstall gem from ruby gem directory.
108
+ = uninstall:user. = Delete all files installed for current user.
109
+ = gem:uninstall:user. = Uninstall gem from ruby gem directory.
110
+ = push. = Push distribution files to distribution hubs.
111
+ = gem:push. = Push gem to rubygems.org.
112
+
113
+ § Financing
114
+
115
+ Currently, most of my time is spent at my day job and in my rather busy
116
+ private life. Please motivate me to spend time on this piece of software
117
+ by donating some of your money to this project. Yeah, I realize that
118
+ requesting money to develop software is a bit, well, capitalistic of me.
119
+ But please realize that I live in a capitalistic society and I need money
120
+ to have other people give me the things that I need to continue living
121
+ under the rules of said society. So, if you feel that this piece of
122
+ software has helped you out enough to warrant a reward, please PayPal a
123
+ donation to now@disu.se¹. Thanks! Your support won’t go unnoticed!
124
+
125
+ ¹ Send a donation:
126
+ https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=now%40disu%2ese&item_name=Nikolai%20Weibull%20Software%20Services
127
+
128
+ § Reporting Bugs
129
+
130
+ Please report any bugs that you encounter to the {issue tracker}¹.
131
+
132
+ ¹ See https://github.com/now/inventory-rake/issues
133
+
134
+ § Authors
135
+
136
+ Nikolai Weibull wrote the code, the tests, the manual pages, and this
137
+ README.
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  $:.unshift File.expand_path('../lib', __FILE__)
4
- require 'inventory/rake-1.0'
4
+ require 'inventory-rake-1.0'
5
5
 
6
6
  Inventory::Rake::Tasks.define Inventory::Rake::Version, :gem => proc{ |_, s|
7
7
  s.author = 'Nikolai Weibull'
@@ -10,6 +10,12 @@ Inventory::Rake::Tasks.define Inventory::Rake::Version, :gem => proc{ |_, s|
10
10
  }
11
11
 
12
12
  Inventory::Rake::Tasks.unless_installing_dependencies do
13
- require 'lookout/rake-3.0'
13
+ require 'lookout-rake-3.0'
14
14
  Lookout::Rake::Tasks::Test.new
15
+
16
+ require 'inventory-rake-tasks-yard-1.0'
17
+ Inventory::Rake::Tasks::YARD.new do |t|
18
+ t.options += %w'--plugin yard-heuristics-1.0'
19
+ t.globals[:source_code_url] = 'https://github.com/now/%s/blob/v%s/%%s#L%%d' % [t.inventory.package, t.inventory]
20
+ end
15
21
  end
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Namespace for [Inventory](http://disu.se/software/inventory/). The bulk of
4
+ # the library is in {Rake::Tasks}.
5
+ class Inventory; end
6
+
7
+ # Namespace for [Rake](http://rake.rubyforge.org/) integration of Inventory.
8
+ module Inventory::Rake
9
+ load File.expand_path('../inventory-rake-1.0/version.rb', __FILE__)
10
+ Version.load
11
+ end
@@ -0,0 +1,63 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Namespace for Rake tasks using an Inventory.
4
+ module Inventory::Rake::Tasks
5
+ @mostlycleanfiles, @cleanfiles, @distcleanfiles = [], [], []
6
+
7
+ class << self
8
+ # @param [Inventory] value
9
+ # @return [Inventory] The default inventory to use for tasks
10
+ attr_accessor :inventory
11
+
12
+ # @return [Array<String>] The files to clean when running the “mostlyclean”
13
+ # task
14
+ attr_reader :mostlycleanfiles
15
+
16
+ # @return [Array<String>] The files to clean when running the “clean” task
17
+ attr_reader :cleanfiles
18
+
19
+ # @return [Array<String>] The files to clean when running the “distclean”
20
+ # task
21
+ attr_reader :distcleanfiles
22
+
23
+ # Sets the default {.inventory} to INVENTORY, then defines {Clean},
24
+ # {Compile}, {Inventory}, and {Gem} tasks.
25
+ #
26
+ # A task named “check” will already have been created. This task is meant
27
+ # to depend on tasks that check the package before distribution.
28
+ #
29
+ # @param [Inventory] inventory
30
+ # @param [Hash] options
31
+ # @option options [#to_proc] :gem (proc{}) Block to pass to
32
+ # {Gem#initialize}
33
+ # @return [self]
34
+ def define(inventory, options = {})
35
+ self.inventory = inventory
36
+ Clean.define
37
+ Compile.new :inventory => inventory
38
+ Inventory.new :inventory => inventory
39
+ Gem.new(:inventory => inventory, &options.fetch(:gem, proc{}))
40
+ self
41
+ end
42
+
43
+ # Yields if the top-level tasks that Rake’s running don’t include any of
44
+ #
45
+ # * deps:install
46
+ # * deps:install:user
47
+ # * gem:deps:install
48
+ # * gem:deps:install:user
49
+ #
50
+ # that is, Rake’s not being run to install the inventory’s dependencies.
51
+ #
52
+ # @yield [?]
53
+ # @return [self]
54
+ def unless_installing_dependencies
55
+ yield if (%w'deps:install
56
+ deps:install:user
57
+ gem:deps:install
58
+ gem:deps:install:user' &
59
+ Rake.application.top_level_tasks).empty?
60
+ self
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,64 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Tasks for cleaning up a project directory.
4
+ class Inventory::Rake::Tasks::Clean
5
+ include Rake::DSL
6
+
7
+ class << self
8
+ include Rake::DSL
9
+
10
+ def define
11
+ # Defines the following tasks:
12
+ #
13
+ # <dl>
14
+ # <dt>mostlyclean</dt>
15
+ # <dd>Delete targets built by rake that are ofter rebuilt.</dd>
16
+ #
17
+ # <dt>clean</dt>
18
+ # <dd>Delete targets builty by rake; depends on mostlyclean.</dd>
19
+ #
20
+ # <dt>distclean</dt>
21
+ # <dd>Delete all files not meant for distribution; depends on
22
+ # clean.</dd>
23
+ # </dl>
24
+ desc 'Delete targets built by rake that are often rebuilt'
25
+ new :mostlyclean, Inventory::Rake::Tasks.mostlycleanfiles
26
+
27
+ desc 'Delete targets built by rake'
28
+ new :clean, Inventory::Rake::Tasks.cleanfiles
29
+ task :clean => :mostlyclean
30
+
31
+ desc 'Delete all files not meant for distribution'
32
+ new :distclean, Inventory::Rake::Tasks.distcleanfiles
33
+ task :distclean => :clean
34
+ end
35
+ end
36
+
37
+ # Sets up a cleaning task {#name} that’ll delete {#files}, optionally yields
38
+ # the task for further customization, then {#define}s the task.
39
+ #
40
+ # @param [Symbol] name
41
+ # @param [Array<String>] files
42
+ # @yield [?]
43
+ # @yieldparam [self] task
44
+ def initialize(name, files = [])
45
+ @name, @files = name, files
46
+ yield self if block_given?
47
+ define
48
+ end
49
+
50
+ # Defines the task {#name} that’ll delete {#files}.
51
+ def define
52
+ task name do
53
+ rm files, :force => true
54
+ end
55
+ end
56
+
57
+ # @param [Symbol] value
58
+ # @return [Symbol] The name of the task
59
+ attr_accessor :name
60
+
61
+ # @param [Array<String>] value
62
+ # @return [Array<String>] The files to delete
63
+ attr_accessor :files
64
+ end
@@ -0,0 +1,99 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Defines tasks for compiling and cleaning extensions.
4
+ class Inventory::Rake::Tasks::Compile
5
+ include Rake::DSL
6
+
7
+ # Sets up tasks based on INVENTORY, optionally yields the task object for
8
+ # further customization, then {#define}s the tasks.
9
+ #
10
+ # @param [Hash] options
11
+ # @option options [Inventory] :inventory (Inventory::Rake::Tasks.inventory)
12
+ # The inventory to use
13
+ # @yield [?]
14
+ # @yieldparam [self] task
15
+ def initialize(options = {})
16
+ self.inventory = options.fetch(:inventory, Inventory::Rake::Tasks.inventory)
17
+ yield self if block_given?
18
+ define
19
+ end
20
+
21
+ # Defines the following task:
22
+ #
23
+ # <dl>
24
+ # <dt>compile</dt>
25
+ # <dd>Compile all extensions; depends on each compile:<em>name</em>.</dd>
26
+ # </dl>
27
+ #
28
+ # Then, for each extension in the inventory, define the following tasks:
29
+ #
30
+ # <dl>
31
+ # <dt>compile:<em>name</em></dt>
32
+ # <dd>Compile extension <em>name</em>; depends on
33
+ # lib/<em>path</em>/<em>so</em> file.</dd>
34
+ #
35
+ # <dt>lib/<em>path</em>/<em>so</em></dt>
36
+ # <dd>Installed dynamic library of extension <em>name</em> inside inventory
37
+ # path; depends on ext/<em>name</em>/<em>so</em>.</dd>
38
+ #
39
+ # <dt>ext/<em>name</em>/<em>so</em></dt>
40
+ # <dd>Dynamic library of extension <em>name</em>; depends on
41
+ # ext/<em>name</em>/Makefile and the source files of the extension.</dd>
42
+ #
43
+ # <dt>ext/<em>name</em>/Makefile</dt>
44
+ # <dd>Makefile for extension <em>name</em>; depends on inventory path,
45
+ # ext/<em>name</em>/extconf.rb file, and ext/<em>name</em>/depend file.</dd>
46
+ #
47
+ # <dt>clean:<em>name</em></dt>
48
+ # <dd>Clean files built for extension <em>name</em>; depended upon by
49
+ # clean.</dd>
50
+ # </dl>
51
+ #
52
+ # Finally, if defined, the test task is set to depend on the compile task.
53
+ def define
54
+ desc 'Compile extensions' unless Rake::Task.task_defined? :compile
55
+ task :compile
56
+
57
+ @inventory.extensions.each do |extension|
58
+ name = :"compile:#{extension}"
59
+ makefile = '%s/Makefile' % extension.directory
60
+ ext_so = '%s/%s.%s' % [extension.directory,
61
+ extension.name.delete('-'),
62
+ RbConfig::CONFIG['DLEXT']]
63
+ lib_so = 'lib/%s/%s' % [@inventory.package_path, File.basename(ext_so)]
64
+
65
+ task :compile => name
66
+
67
+ task name => lib_so
68
+
69
+ file lib_so => ext_so do
70
+ install ext_so, lib_so
71
+ end
72
+
73
+ file ext_so => [makefile] + extension.source_files do
74
+ sh 'make -C %s' % extension.directory
75
+ end
76
+
77
+ file makefile => [@inventory.path, extension.extconf, extension.depend] do
78
+ Dir.chdir extension.directory do
79
+ ENV['CFLAGS'] = '-Werror' unless ENV['CFLAGS']
80
+ ruby File.basename(extension.extconf)
81
+ end
82
+ end
83
+
84
+ clean_name = :"clean:#{extension}"
85
+ desc 'Clean files built for extension %s' % extension
86
+ task clean_name do
87
+ sh 'make -C %s %s' % [extension.directory, rule]
88
+ end
89
+
90
+ task :clean => clean_name
91
+ end
92
+
93
+ task :test => :compile if Rake::Task.task_defined? :test
94
+ end
95
+
96
+ # @param [Inventory] value
97
+ # @return [Inventory] The inventory to use: VALUE
98
+ attr_writer :inventory
99
+ end
@@ -1,8 +1,30 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ # Defines [RubyGems](http://rubygems.org/)-related tasks. This includes tasks
4
+ # for generating a gem specification, creating a gem file, checking the gem
5
+ # file before distribution, installing gem dependencies, installing and
6
+ # uninstalling the gem locally, and pushing the gem to a distribution point.
3
7
  class Inventory::Rake::Tasks::Gem
4
8
  include Rake::DSL
5
9
 
10
+ # Sets up tasks based on INVENTORY and SPECIFICATION, optionally yields the
11
+ # task object and the gem specification for further customization, then
12
+ # {#define}s the tasks.
13
+ #
14
+ # The default for SPECIFICATION is to use the name, version, and files of the
15
+ # inventory, use all of `README` as the description, set the summary to the
16
+ # first sentence of the description, set the require paths to “lib”, add each
17
+ # extension of the inventory’s extconf to the extensions, and finally add
18
+ # inventory’s dependencies.
19
+ #
20
+ # @param [Hash] options
21
+ # @option options [Inventory] :inventory (Inventory::Rake::Tasks.inventory)
22
+ # The inventory to use
23
+ # @option options [Gem::Specification] :specification The specification to
24
+ # use
25
+ # @yield [?]
26
+ # @yieldparam [self] task
27
+ # @yieldparam [Gem::Specification] specification
6
28
  def initialize(options = {})
7
29
  self.inventory = options.fetch(:inventory, Inventory::Rake::Tasks.inventory)
8
30
  self.specification = options.fetch(:specification,
@@ -19,12 +41,94 @@ class Inventory::Rake::Tasks::Gem
19
41
 
20
42
  s.require_paths = @inventory.lib_directories
21
43
 
44
+ s.extensions = @inventory.extensions.map(&:extconf)
45
+
22
46
  @inventory.dependencies.add_to_gem_specification s
23
47
  })
24
48
  yield self, @specification if block_given?
25
49
  define
26
50
  end
27
51
 
52
+ # Defines the following tasks:
53
+ #
54
+ # <dl>
55
+ # <dt>spec</dt>
56
+ # <dd>Create specifications; depends on gem:spec.</dd>
57
+ #
58
+ # <dt>gem:spec</dt>
59
+ # <dd>Create gem specification; depends on <em>gemspec</em>.</dd>
60
+ #
61
+ # <dt>gemspec (file)</dt>
62
+ # <dd>Gem specification file; depends on Rakefile, README, and inventory
63
+ # path.</dd>
64
+ #
65
+ # <dt>dist</dt>
66
+ # <dd>Create files for distribution; depends on gem:dist.</dd>
67
+ #
68
+ # <dt>gem:dist</dt>
69
+ # <dd>Create gem for distribution; depends on inventory:check and
70
+ # <em>gem</em> file.</dd>
71
+ #
72
+ # <dt>gem (file)</dt>
73
+ # <dd>Gem file; depends on files included in gem.</dd>
74
+ #
75
+ # <dt>dist:check</dt>
76
+ # <dd>Check files before distribution; depends on dist and
77
+ # gem:dist:check.</dd>
78
+ #
79
+ # <dt>gem:dist:check</dt>
80
+ # <dd>Check gem before distribution; depends on gem:dist.</dd>
81
+ #
82
+ # <dt>deps:install</dt>
83
+ # <dd>Install dependencies on the local system; depends on
84
+ # gem:deps:install.</dd>
85
+ #
86
+ # <dt>gem:deps:install</dt>
87
+ # <dd>Install dependencies in ruby gem directory.</dd>
88
+ #
89
+ # <dt>deps:install:user</dt>
90
+ # <dd>Install dependencies for the current user; depends on
91
+ # gem:deps:install:user.</dd>
92
+ #
93
+ # <dt>gem:deps:install:user</dt>
94
+ # <dd>Install dependencies in the user gem directory.</dd>
95
+ #
96
+ # <dt>install</dt>
97
+ # <dd>Install distribution files on the local system; depends on
98
+ # gem:install.</dd>
99
+ #
100
+ # <dt>gem:install</dt>
101
+ # <dd>Install <em>gem</em> in ruby gem directory; depends on gem:dist.</dd>
102
+ #
103
+ # <dt>install:user</dt>
104
+ # <dd>Install distribution files for the current user; depends on
105
+ # gem:install:user.</dd>
106
+ #
107
+ # <dt>gem:install:user</dt>
108
+ # <dd>Install <em>gem</em> in the user gem directory.</dd>
109
+ #
110
+ # <dt>uninstall</dt>
111
+ # <dd>Delete all files installed on the local system.</dd>
112
+ #
113
+ # <dt>gem:uninstall</dt>
114
+ # <dd>Uninstall <em>gem</em> from ruby gem directory.</dd>
115
+ #
116
+ # <dt>uninstall:user</dt>
117
+ # <dd>Delete all files installed for current user.</dd>
118
+ #
119
+ # <dt>gem:uninstall:user</dt>
120
+ # <dd>Uninstall <em>gem</em> from ruby gem directory.</dd>
121
+ #
122
+ # <dt>push</dt>
123
+ # <dd>Push distribution files to distribution hubs.</dd>
124
+ #
125
+ # <dt>gem:push</dt>
126
+ # <dd>Push <em>gem</em> to rubygems.org.</dd>
127
+ # </dl>
128
+ #
129
+ # The gemspec will be added to {Inventory::Rake::Tasks.cleanfiles}.
130
+ #
131
+ # @return [self]
28
132
  def define
29
133
  desc 'Create specifications' unless Rake::Task.task_defined? :spec
30
134
  task :spec => :'gem:spec'
@@ -54,8 +158,9 @@ class Inventory::Rake::Tasks::Gem
54
158
  task :'gem:dist' => [:'inventory:check', @specification.file_name]
55
159
  file @specification.file_name => @specification.files do
56
160
  require 'rubygems' unless defined? Gem
161
+ require 'rubygems/package' unless defined? Gem::Package
57
162
  rake_output_message 'gem build %s' % gemspec if verbose
58
- Gem::Builder.new(@specification).build
163
+ Gem::Package.build @specification
59
164
  end
60
165
 
61
166
  desc 'Check files before distribution' unless
@@ -96,7 +201,7 @@ class Inventory::Rake::Tasks::Gem
96
201
  Rake::Task.task_defined? :'deps:install:user'
97
202
  task :'deps:install:user' => :'gem:deps:install:user'
98
203
 
99
- desc 'Install dependencies for the current user'
204
+ desc 'Install dependencies in the current user’s ruby gem directory'
100
205
  task :'gem:deps:install:user' do
101
206
  require 'rubygems' unless defined? Gem
102
207
  require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
@@ -185,7 +290,15 @@ class Inventory::Rake::Tasks::Gem
185
290
  task :'gem:push' => :'gem:dist:check' do
186
291
  sh 'gem push -%s-verbose %s' % [verbose ? '' : '-no', @specification.file_name]
187
292
  end
293
+
294
+ self
188
295
  end
189
296
 
190
- attr_writer :inventory, :specification
297
+ # @param [Inventory] value
298
+ # @return [Inventory] The inventory to use: VALUE
299
+ attr_writer :inventory
300
+
301
+ # @param [Gem::Specification] value
302
+ # @return [Gem::Specification] The specification to use: VALUE
303
+ attr_writer :specification
191
304
  end
@@ -0,0 +1,53 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Tasks related to the inventory.
4
+ class Inventory::Rake::Tasks::Inventory
5
+ include Rake::DSL
6
+
7
+ # Sets up tasks based on INVENTORY, optionally yields the task object for
8
+ # further customization, then {#define}s the tasks.
9
+ #
10
+ # @param [Hash] options
11
+ # @option options [Inventory] :inventory (Inventory::Rake::Tasks.inventory)
12
+ # The inventory to use
13
+ # @option options [String] :pattern
14
+ # ('{ext/**/*.{[ch],rb},{lib/test}/**/*.rb}') The pattern to use when
15
+ # looking for files not listed in inventory
16
+ # @yield [?]
17
+ # @yieldparam [self] task
18
+ def initialize(options = {})
19
+ self.inventory = options.fetch(:inventory, Inventory::Rake::Tasks.inventory)
20
+ self.pattern = options.fetch(:pattern, '{ext/**/*.{[ch],rb},{lib,test}/**/*.rb}')
21
+ yield self if block_given?
22
+ define
23
+ end
24
+
25
+ # Defines the following task:
26
+ #
27
+ # <dl>
28
+ # <dt>inventory:check</dt>
29
+ # <dd>Check that the inventory is correct by looking for files not listed
30
+ # in the inventory that match the pattern and for files listed in the
31
+ # inventory that don’t exist; depends on distclean.</dd>
32
+ # </dl>
33
+ def define
34
+ desc 'Check that the inventory is correct'
35
+ task :'inventory:check' => :distclean do
36
+ diff = ((Dir[@pattern] -
37
+ @inventory.extensions.map(&:source_files) -
38
+ @inventory.lib_files -
39
+ @inventory.unit_test_files).map{ |e| '%s: file not listed in inventory' % e } +
40
+ @inventory.files.reject{ |e| File.exist? e }.map{ |e| '%s: file listed in inventory does not exist' % e })
41
+ fail diff.join("\n") unless diff.empty?
42
+ # TODO: puts 'inventory checks out' if verbose
43
+ end
44
+ end
45
+
46
+ # @param [Inventory] value
47
+ # @return [Inventory] The inventory to use: VALUE
48
+ attr_writer :inventory
49
+
50
+ # @param [String] value
51
+ # @return [String] The pattern to use: VALUE
52
+ attr_writer :pattern
53
+ end
@@ -0,0 +1,34 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'inventory-1.0'
4
+
5
+ module Inventory::Rake
6
+ Version = Inventory.new(1, 4, 0){
7
+ def dependencies
8
+ super + Inventory::Dependencies.new{
9
+ development 'lookout', 3, 0, 0
10
+ development 'lookout-rake', 3, 0, 0
11
+ development 'yard', 0, 8, 0
12
+ development 'yard-heuristics', 1, 1, 0
13
+ runtime 'rake', 0, 9, 2, :feature => 'rake'
14
+ }
15
+ end
16
+
17
+ def package_libs
18
+ %w[tasks.rb
19
+ tasks/check.rb
20
+ tasks/clean.rb
21
+ tasks/compile.rb
22
+ tasks/gem.rb
23
+ tasks/inventory.rb]
24
+ end
25
+
26
+ def additional_libs
27
+ super + %w[inventory/rake-1.0.rb]
28
+ end
29
+
30
+ def unit_tests
31
+ super - %w[inventory/rake-1.0.rb]
32
+ end
33
+ }
34
+ end
@@ -1,10 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
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
3
+ warn "requiring 'inventory/rake-1.0' is deprecated; require 'inventory-rake-1.0' instead"
4
+ require 'inventory-rake-1.0'
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Expectations do
4
+ end
metadata CHANGED
@@ -1,89 +1,259 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inventory-rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
5
- prerelease:
4
+ version: 1.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Nikolai Weibull
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-04-27 00:00:00.000000000 Z
11
+ date: 2013-04-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: inventory
16
- requirement: &3960924 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '1.2'
19
+ version: '1.4'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *3960924
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: lookout
27
- requirement: &3960240 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ~>
31
32
  - !ruby/object:Gem::Version
32
33
  version: '3.0'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *3960240
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: lookout-rake
38
- requirement: &3959652 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
45
  - - ~>
42
46
  - !ruby/object:Gem::Version
43
47
  version: '3.0'
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *3959652
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.8.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.8.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard-heuristics
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.1'
47
83
  - !ruby/object:Gem::Dependency
48
84
  name: rake
49
- requirement: &3959232 !ruby/object:Gem::Requirement
50
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
51
86
  requirements:
52
87
  - - ~>
53
88
  - !ruby/object:Gem::Version
54
89
  version: 0.9.2
55
90
  type: :runtime
56
91
  prerelease: false
57
- version_requirements: *3959232
58
- description: ! " Inventory-Rake\n\n Inventory-Rake
59
- provides Rake tasks for your Inventory¹. This includes\n cleaning tasks, gem generation,
60
- testing, installation, uninstallation, and\n pushing, and inventory content checking.\n\n¹
61
- Get information on Inventory at http://disu.se/software/inventory/\n\n§ Installation\n\n
62
- \ Install Inventory-Rake with\n\n % gem install inventory-rake\n\n§ Usage\n\n
63
- \ Include the following code in your ‹Rakefile›, where ‹Package› is the\n top-level
64
- module of your package:\n\n require 'inventory/rake-3.0'\n\n Inventory::Rake::Tasks.define
65
- Package::Version, :gem => proc{ |_, s|\n s.author = 'Your Name'\n s.email
66
- = 'your@email.com'\n s.homepage = 'https://github.com/now/%s' % Package.name.downcase\n
67
- \ }\n"
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 0.9.2
97
+ description: |2
98
+ Inventory-Rake
99
+
100
+ Inventory-Rake provides Rake¹ tasks for your Inventory². This includes tasks
101
+ for cleaning up our project, compiling extensions, installing dependencies,
102
+ installing and uninstalling the project itself, and creating and pushing
103
+ distribution files to distribution points.
104
+
105
+ ¹ See http://rake.rubyforge.org/
106
+ ² See http://disu.se/software/inventory/
107
+
108
+ § Installation
109
+
110
+ Install Inventory-Rake with
111
+
112
+ % gem install inventory-rake
113
+
114
+ § Usage
115
+
116
+ Include the following code in your ‹Rakefile›, where ‹Package› is the
117
+ top-level module of your project:
118
+
119
+ require 'inventory-rake-3.0'
120
+
121
+ load File.expand_path('../lib/package/version.rb', __FILE__)
122
+
123
+ Inventory::Rake::Tasks.define Package::Version, :gem => proc{ |_, s|
124
+ s.author = 'Your Name'
125
+ s.email = 'you@example.com'
126
+ s.homepage = 'http://example.com/'
127
+ }
128
+
129
+ Inventory::Rake::Tasks.unless_installing_dependencies do
130
+ # Any additional tasks that your project’s dependencies provide
131
+ end
132
+
133
+ ‹Inventory::Rake::Tasks.define› does the heavy lifting. It takes our
134
+ inventory and sets up the tasks mentioned above. We also do some
135
+ additional customization of the gem specification.
136
+
137
+ As we want to be able to use our Rakefile to install our dependencies for
138
+ us, the rest of the Rakefile is inside the conditional
139
+ #unless_installing_dependencies, which, as the name certainly implies,
140
+ executes its block unless the task being run is the one that installs our
141
+ dependencies. This becomes relevant if we want to, for example, set up
142
+ Travis¹ integration. To do so, simply add
143
+
144
+ before_script:
145
+ - gem install inventory-rake -v '~> VERSION' --no-rdoc --no-ri
146
+ - rake gem:deps:install
147
+
148
+ to your ‹.travis.yml› file. This’ll make sure that Travis installs all
149
+ development, runtime, and optional dependencies that you’ve listed in your
150
+ inventory before running any tests.
151
+
152
+ There’s more information in the {API documentation}² that you’ll likely
153
+ want to read up on if anything is unclear.
154
+
155
+ ¹ See http://travis-ci.org/
156
+ ² See http://disu.se/software/inventory/api/inventory-rake/
157
+
158
+ § Tasks
159
+
160
+ The tasks that are created if you use Inventory-Rake are:
161
+
162
+ = check. = Check that the package meets its expectations.
163
+ = mostlyclean. = Delete targets built by rake that are ofter rebuilt.
164
+ = clean. = Delete targets built by rake; depends on mostlyclean.
165
+ = distclean. = Delete all files not meant for distribution; depends on clean.
166
+ = compile. = Compile all extensions; depends on each compile:name.
167
+ = compile:name. = Compile extension /name/; depends on
168
+ lib/path/so file.
169
+ = lib/path/so. = Installed dynamic library of extension /name/ inside
170
+ inventory path; depends on ext/name/so.
171
+ = ext/name/so. = Dynamic library of extension /name/; depends on
172
+ ext/name/Makefile and the source files of the extension.
173
+ = ext/name/Makefile. = Makefile for extension /name/; depends on inventory
174
+ path, ext/name/extconf.rb file, and ext/name/depend file.
175
+ = clean:name. = Clean files built for extension /name/; depended upon by
176
+ clean.
177
+ = spec. = Create specifications; depends on gem:spec.
178
+ = gem:spec. = Create gem specification; depends on gemspec.
179
+ = gemspec (file). = Gem specification file; depends on Rakefile, README, and
180
+ inventory path.
181
+ = dist. = Create files for distribution; depends on gem:dist.
182
+ = gem:dist. = Create gem for distribution; depends on inventory:check and gem
183
+ file.
184
+ = inventory:check. = Check that the inventory is correct by looking for files
185
+ not listed in the inventory that match the pattern and for files listed
186
+ in the inventory that don’t exist; depends on distclean.
187
+ = gem (file). = Gem file; depends on files included in gem.
188
+ = dist:check. = Check files before distribution; depends on dist and
189
+ gem:dist:check.
190
+ = gem:dist:check. = Check gem before distribution; depends on gem:dist.
191
+ = deps:install. = Install dependencies on the local system; depends on
192
+ gem:deps:install.
193
+ = gem:deps:install. = Install dependencies in ruby gem directory.
194
+ = deps:install:user. = Install dependencies for the current user; depends on
195
+ gem:deps:install:user.
196
+ = gem:deps:install:user. = Install dependencies in the user gem directory.
197
+ = install. = Install distribution files on the local system; depends on
198
+ gem:install.
199
+ = gem:install. = Install gem in ruby gem directory; depends on gem:dist.
200
+ = install:user. = Install distribution files for the current user; depends on
201
+ gem:install:user.
202
+ = gem:install:user. = Install gem in the user gem directory.
203
+ = uninstall. = Delete all files installed on the local system.
204
+ = gem:uninstall. = Uninstall gem from ruby gem directory.
205
+ = uninstall:user. = Delete all files installed for current user.
206
+ = gem:uninstall:user. = Uninstall gem from ruby gem directory.
207
+ = push. = Push distribution files to distribution hubs.
208
+ = gem:push. = Push gem to rubygems.org.
209
+
210
+ § Financing
211
+
212
+ Currently, most of my time is spent at my day job and in my rather busy
213
+ private life. Please motivate me to spend time on this piece of software
214
+ by donating some of your money to this project. Yeah, I realize that
215
+ requesting money to develop software is a bit, well, capitalistic of me.
216
+ But please realize that I live in a capitalistic society and I need money
217
+ to have other people give me the things that I need to continue living
218
+ under the rules of said society. So, if you feel that this piece of
219
+ software has helped you out enough to warrant a reward, please PayPal a
220
+ donation to now@disu.se¹. Thanks! Your support won’t go unnoticed!
221
+
222
+ ¹ Send a donation:
223
+ https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=now%40disu%2ese&item_name=Nikolai%20Weibull%20Software%20Services
224
+
225
+ § Reporting Bugs
226
+
227
+ Please report any bugs that you encounter to the {issue tracker}¹.
228
+
229
+ ¹ See https://github.com/now/inventory-rake/issues
230
+
231
+ § Authors
232
+
233
+ Nikolai Weibull wrote the code, the tests, the manual pages, and this
234
+ README.
68
235
  email: now@bitwi.se
69
236
  executables: []
70
237
  extensions: []
71
238
  extra_rdoc_files: []
72
239
  files:
73
- - lib/inventory/rake/tasks.rb
74
- - lib/inventory/rake/tasks/check.rb
75
- - lib/inventory/rake/tasks/clean.rb
76
- - lib/inventory/rake/tasks/gem.rb
77
- - lib/inventory/rake/tasks/inventory.rb
240
+ - lib/inventory-rake-1.0/tasks.rb
241
+ - lib/inventory-rake-1.0/tasks/check.rb
242
+ - lib/inventory-rake-1.0/tasks/clean.rb
243
+ - lib/inventory-rake-1.0/tasks/compile.rb
244
+ - lib/inventory-rake-1.0/tasks/gem.rb
245
+ - lib/inventory-rake-1.0/tasks/inventory.rb
246
+ - lib/inventory-rake-1.0.rb
247
+ - lib/inventory-rake-1.0/version.rb
78
248
  - lib/inventory/rake-1.0.rb
79
- - lib/inventory/rake/version.rb
80
- - test/unit/inventory/rake/tasks.rb
81
- - test/unit/inventory/rake/tasks/check.rb
82
- - test/unit/inventory/rake/tasks/clean.rb
83
- - test/unit/inventory/rake/tasks/gem.rb
84
- - test/unit/inventory/rake/tasks/inventory.rb
85
- - test/unit/inventory/rake-1.0.rb
86
- - test/unit/inventory/rake/version.rb
249
+ - test/unit/inventory-rake-1.0/tasks.rb
250
+ - test/unit/inventory-rake-1.0/tasks/check.rb
251
+ - test/unit/inventory-rake-1.0/tasks/clean.rb
252
+ - test/unit/inventory-rake-1.0/tasks/compile.rb
253
+ - test/unit/inventory-rake-1.0/tasks/gem.rb
254
+ - test/unit/inventory-rake-1.0/tasks/inventory.rb
255
+ - test/unit/inventory-rake-1.0.rb
256
+ - test/unit/inventory-rake-1.0/version.rb
87
257
  - README
88
258
  - Rakefile
89
259
  homepage: https://github.com/now/inventory-rake
@@ -94,21 +264,19 @@ rdoc_options: []
94
264
  require_paths:
95
265
  - lib
96
266
  required_ruby_version: !ruby/object:Gem::Requirement
97
- none: false
98
267
  requirements:
99
- - - ! '>='
268
+ - - '>='
100
269
  - !ruby/object:Gem::Version
101
270
  version: '0'
102
271
  required_rubygems_version: !ruby/object:Gem::Requirement
103
- none: false
104
272
  requirements:
105
- - - ! '>='
273
+ - - '>='
106
274
  - !ruby/object:Gem::Version
107
275
  version: '0'
108
276
  requirements: []
109
277
  rubyforge_project:
110
- rubygems_version: 1.8.10
278
+ rubygems_version: 2.0.0
111
279
  signing_key:
112
280
  specification_version: 4
113
- summary: Inventory-Rake provides Rake tasks for your Inventory¹.
281
+ summary: Inventory-Rake provides Rake¹ tasks for your Inventory².
114
282
  test_files: []
@@ -1,27 +0,0 @@
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
-
19
- def unless_installing_dependencies
20
- yield if (%w'deps:install
21
- deps:install:user
22
- gem:deps:install
23
- gem:deps:install:user' &
24
- Rake.application.top_level_tasks).empty?
25
- end
26
- end
27
- end
@@ -1,35 +0,0 @@
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
@@ -1,27 +0,0 @@
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
@@ -1,31 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'inventory-1.0'
4
-
5
- module Inventory::Rake
6
- Version = Inventory.new(1, 3, 0){
7
- def dependencies
8
- super + Inventory::Dependencies.new{
9
- development 'lookout', 3, 0, 0
10
- development 'lookout-rake', 3, 0, 0
11
- optional 'rake', 0, 9, 2
12
- }
13
- end
14
-
15
- def requires
16
- %w'
17
- rake
18
- '
19
- end
20
-
21
- def libs
22
- %w'
23
- inventory/rake/tasks.rb
24
- inventory/rake/tasks/check.rb
25
- inventory/rake/tasks/clean.rb
26
- inventory/rake/tasks/gem.rb
27
- inventory/rake/tasks/inventory.rb
28
- '
29
- end
30
- }
31
- end