podoy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +35 -0
  4. data/Rakefile +4 -0
  5. data/lib/podoy/version.rb +5 -0
  6. data/lib/podoy.rb +8 -0
  7. data/sig/podoy.rbs +4 -0
  8. data/vendor/bundle/ruby/3.3.0+0/bin/rake +29 -0
  9. data/vendor/bundle/ruby/3.3.0+0/cache/rake-13.1.0.gem +0 -0
  10. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/History.rdoc +2403 -0
  11. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/MIT-LICENSE +21 -0
  12. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/README.rdoc +155 -0
  13. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/command_line_usage.rdoc +158 -0
  14. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/example/Rakefile1 +38 -0
  15. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/example/Rakefile2 +35 -0
  16. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/example/a.c +6 -0
  17. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/example/b.c +6 -0
  18. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/example/main.c +11 -0
  19. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/glossary.rdoc +42 -0
  20. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/jamis.rb +592 -0
  21. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/proto_rake.rdoc +127 -0
  22. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/rake.1 +156 -0
  23. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/rakefile.rdoc +622 -0
  24. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/rational.rdoc +151 -0
  25. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/exe/rake +27 -0
  26. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/application.rb +855 -0
  27. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/backtrace.rb +24 -0
  28. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/clean.rb +78 -0
  29. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/cloneable.rb +17 -0
  30. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/cpu_counter.rb +107 -0
  31. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/default_loader.rb +15 -0
  32. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/dsl_definition.rb +195 -0
  33. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/early_time.rb +22 -0
  34. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/ext/core.rb +26 -0
  35. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/ext/string.rb +176 -0
  36. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/file_creation_task.rb +25 -0
  37. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/file_list.rb +435 -0
  38. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/file_task.rb +58 -0
  39. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/file_utils.rb +132 -0
  40. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/file_utils_ext.rb +134 -0
  41. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/invocation_chain.rb +57 -0
  42. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/invocation_exception_mixin.rb +17 -0
  43. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/late_time.rb +18 -0
  44. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/linked_list.rb +112 -0
  45. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/loaders/makefile.rb +54 -0
  46. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/multi_task.rb +14 -0
  47. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/name_space.rb +38 -0
  48. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/packagetask.rb +222 -0
  49. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/phony.rb +16 -0
  50. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/private_reader.rb +21 -0
  51. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/promise.rb +100 -0
  52. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/pseudo_status.rb +30 -0
  53. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/rake_module.rb +67 -0
  54. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/rake_test_loader.rb +27 -0
  55. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/rule_recursion_overflow_error.rb +20 -0
  56. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/scope.rb +43 -0
  57. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/task.rb +434 -0
  58. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/task_argument_error.rb +8 -0
  59. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/task_arguments.rb +109 -0
  60. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/task_manager.rb +331 -0
  61. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/tasklib.rb +12 -0
  62. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/testtask.rb +189 -0
  63. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/thread_history_display.rb +49 -0
  64. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/thread_pool.rb +163 -0
  65. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/trace_output.rb +23 -0
  66. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/version.rb +10 -0
  67. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/win32.rb +51 -0
  68. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake.rb +71 -0
  69. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/rake.gemspec +101 -0
  70. data/vendor/bundle/ruby/3.3.0+0/specifications/rake-13.1.0.gemspec +26 -0
  71. metadata +117 -0
@@ -0,0 +1,134 @@
1
+ # frozen_string_literal: true
2
+ require "rake/file_utils"
3
+
4
+ module Rake
5
+ #
6
+ # FileUtilsExt provides a custom version of the FileUtils methods
7
+ # that respond to the <tt>verbose</tt> and <tt>nowrite</tt>
8
+ # commands.
9
+ #
10
+ module FileUtilsExt
11
+ include FileUtils
12
+
13
+ class << self
14
+ attr_accessor :verbose_flag, :nowrite_flag
15
+ end
16
+
17
+ DEFAULT = Object.new
18
+
19
+ FileUtilsExt.verbose_flag = DEFAULT
20
+ FileUtilsExt.nowrite_flag = false
21
+
22
+ FileUtils.commands.each do |name|
23
+ opts = FileUtils.options_of name
24
+ default_options = []
25
+ if opts.include?("verbose")
26
+ default_options << "verbose: FileUtilsExt.verbose_flag"
27
+ end
28
+ if opts.include?("noop")
29
+ default_options << "noop: FileUtilsExt.nowrite_flag"
30
+ end
31
+
32
+ next if default_options.empty?
33
+ module_eval(<<-EOS, __FILE__, __LINE__ + 1)
34
+ def #{name}(*args, **options, &block)
35
+ super(*args,
36
+ #{default_options.join(', ')},
37
+ **options, &block)
38
+ end
39
+ EOS
40
+ end
41
+
42
+ # Get/set the verbose flag controlling output from the FileUtils
43
+ # utilities. If verbose is true, then the utility method is
44
+ # echoed to standard output.
45
+ #
46
+ # Examples:
47
+ # verbose # return the current value of the
48
+ # # verbose flag
49
+ # verbose(v) # set the verbose flag to _v_.
50
+ # verbose(v) { code } # Execute code with the verbose flag set
51
+ # # temporarily to _v_. Return to the
52
+ # # original value when code is done.
53
+ def verbose(value=nil)
54
+ oldvalue = FileUtilsExt.verbose_flag
55
+ FileUtilsExt.verbose_flag = value unless value.nil?
56
+ if block_given?
57
+ begin
58
+ yield
59
+ ensure
60
+ FileUtilsExt.verbose_flag = oldvalue
61
+ end
62
+ end
63
+ FileUtilsExt.verbose_flag
64
+ end
65
+
66
+ # Get/set the nowrite flag controlling output from the FileUtils
67
+ # utilities. If verbose is true, then the utility method is
68
+ # echoed to standard output.
69
+ #
70
+ # Examples:
71
+ # nowrite # return the current value of the
72
+ # # nowrite flag
73
+ # nowrite(v) # set the nowrite flag to _v_.
74
+ # nowrite(v) { code } # Execute code with the nowrite flag set
75
+ # # temporarily to _v_. Return to the
76
+ # # original value when code is done.
77
+ def nowrite(value=nil)
78
+ oldvalue = FileUtilsExt.nowrite_flag
79
+ FileUtilsExt.nowrite_flag = value unless value.nil?
80
+ if block_given?
81
+ begin
82
+ yield
83
+ ensure
84
+ FileUtilsExt.nowrite_flag = oldvalue
85
+ end
86
+ end
87
+ oldvalue
88
+ end
89
+
90
+ # Use this function to prevent potentially destructive ruby code
91
+ # from running when the :nowrite flag is set.
92
+ #
93
+ # Example:
94
+ #
95
+ # when_writing("Building Project") do
96
+ # project.build
97
+ # end
98
+ #
99
+ # The following code will build the project under normal
100
+ # conditions. If the nowrite(true) flag is set, then the example
101
+ # will print:
102
+ #
103
+ # DRYRUN: Building Project
104
+ #
105
+ # instead of actually building the project.
106
+ #
107
+ def when_writing(msg=nil)
108
+ if FileUtilsExt.nowrite_flag
109
+ $stderr.puts "DRYRUN: #{msg}" if msg
110
+ else
111
+ yield
112
+ end
113
+ end
114
+
115
+ # Send the message to the default rake output (which is $stderr).
116
+ def rake_output_message(message)
117
+ $stderr.puts(message)
118
+ end
119
+
120
+ # Check that the options do not contain options not listed in
121
+ # +optdecl+. An ArgumentError exception is thrown if non-declared
122
+ # options are found.
123
+ def rake_check_options(options, *optdecl)
124
+ h = options.dup
125
+ optdecl.each do |name|
126
+ h.delete name
127
+ end
128
+ raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless
129
+ h.empty?
130
+ end
131
+
132
+ extend self
133
+ end
134
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+
4
+ # InvocationChain tracks the chain of task invocations to detect
5
+ # circular dependencies.
6
+ class InvocationChain < LinkedList
7
+
8
+ # Is the invocation already in the chain?
9
+ def member?(invocation)
10
+ head == invocation || tail.member?(invocation)
11
+ end
12
+
13
+ # Append an invocation to the chain of invocations. It is an error
14
+ # if the invocation already listed.
15
+ def append(invocation)
16
+ if member?(invocation)
17
+ fail RuntimeError, "Circular dependency detected: #{to_s} => #{invocation}"
18
+ end
19
+ conj(invocation)
20
+ end
21
+
22
+ # Convert to string, ie: TOP => invocation => invocation
23
+ def to_s
24
+ "#{prefix}#{head}"
25
+ end
26
+
27
+ # Class level append.
28
+ def self.append(invocation, chain)
29
+ chain.append(invocation)
30
+ end
31
+
32
+ private
33
+
34
+ def prefix
35
+ "#{tail} => "
36
+ end
37
+
38
+ # Null object for an empty chain.
39
+ class EmptyInvocationChain < LinkedList::EmptyLinkedList
40
+ @parent = InvocationChain
41
+
42
+ def member?(obj)
43
+ false
44
+ end
45
+
46
+ def append(invocation)
47
+ conj(invocation)
48
+ end
49
+
50
+ def to_s
51
+ "TOP"
52
+ end
53
+ end
54
+
55
+ EMPTY = EmptyInvocationChain.new
56
+ end
57
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+ module InvocationExceptionMixin
4
+ # Return the invocation chain (list of Rake tasks) that were in
5
+ # effect when this exception was detected by rake. May be null if
6
+ # no tasks were active.
7
+ def chain
8
+ @rake_invocation_chain ||= nil
9
+ end
10
+
11
+ # Set the invocation chain in effect when this exception was
12
+ # detected.
13
+ def chain=(value)
14
+ @rake_invocation_chain = value
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+ # LateTime is a fake timestamp that occurs _after_ any other time value.
4
+ class LateTime
5
+ include Comparable
6
+ include Singleton
7
+
8
+ def <=>(other)
9
+ 1
10
+ end
11
+
12
+ def to_s
13
+ "<LATE TIME>"
14
+ end
15
+ end
16
+
17
+ LATE = LateTime.instance
18
+ end
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+
4
+ # Polylithic linked list structure used to implement several data
5
+ # structures in Rake.
6
+ class LinkedList
7
+ include Enumerable
8
+ attr_reader :head, :tail
9
+
10
+ # Polymorphically add a new element to the head of a list. The
11
+ # type of head node will be the same list type as the tail.
12
+ def conj(item)
13
+ self.class.cons(item, self)
14
+ end
15
+
16
+ # Is the list empty?
17
+ # .make guards against a list being empty making any instantiated LinkedList
18
+ # object not empty by default
19
+ # You should consider overriding this method if you implement your own .make method
20
+ def empty?
21
+ false
22
+ end
23
+
24
+ # Lists are structurally equivalent.
25
+ def ==(other)
26
+ current = self
27
+ while !current.empty? && !other.empty?
28
+ return false if current.head != other.head
29
+ current = current.tail
30
+ other = other.tail
31
+ end
32
+ current.empty? && other.empty?
33
+ end
34
+
35
+ # Convert to string: LL(item, item...)
36
+ def to_s
37
+ items = map(&:to_s).join(", ")
38
+ "LL(#{items})"
39
+ end
40
+
41
+ # Same as +to_s+, but with inspected items.
42
+ def inspect
43
+ items = map(&:inspect).join(", ")
44
+ "LL(#{items})"
45
+ end
46
+
47
+ # For each item in the list.
48
+ def each
49
+ current = self
50
+ while !current.empty?
51
+ yield(current.head)
52
+ current = current.tail
53
+ end
54
+ self
55
+ end
56
+
57
+ # Make a list out of the given arguments. This method is
58
+ # polymorphic
59
+ def self.make(*args)
60
+ # return an EmptyLinkedList if there are no arguments
61
+ return empty if !args || args.empty?
62
+
63
+ # build a LinkedList by starting at the tail and iterating
64
+ # through each argument
65
+ # inject takes an EmptyLinkedList to start
66
+ args.reverse.inject(empty) do |list, item|
67
+ list = cons(item, list)
68
+ list # return the newly created list for each item in the block
69
+ end
70
+ end
71
+
72
+ # Cons a new head onto the tail list.
73
+ def self.cons(head, tail)
74
+ new(head, tail)
75
+ end
76
+
77
+ # The standard empty list class for the given LinkedList class.
78
+ def self.empty
79
+ self::EMPTY
80
+ end
81
+
82
+ protected
83
+
84
+ def initialize(head, tail=EMPTY)
85
+ @head = head
86
+ @tail = tail
87
+ end
88
+
89
+ # Represent an empty list, using the Null Object Pattern.
90
+ #
91
+ # When inheriting from the LinkedList class, you should implement
92
+ # a type specific Empty class as well. Make sure you set the class
93
+ # instance variable @parent to the associated list class (this
94
+ # allows conj, cons and make to work polymorphically).
95
+ class EmptyLinkedList < LinkedList
96
+ @parent = LinkedList
97
+
98
+ def initialize
99
+ end
100
+
101
+ def empty?
102
+ true
103
+ end
104
+
105
+ def self.cons(head, tail)
106
+ @parent.cons(head, tail)
107
+ end
108
+ end
109
+
110
+ EMPTY = EmptyLinkedList.new
111
+ end
112
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+
4
+ # Makefile loader to be used with the import file loader. Use this to
5
+ # import dependencies from make dependency tools:
6
+ #
7
+ # require 'rake/loaders/makefile'
8
+ #
9
+ # file ".depends.mf" => [SRC_LIST] do |t|
10
+ # sh "makedepend -f- -- #{CFLAGS} -- #{t.prerequisites} > #{t.name}"
11
+ # end
12
+ #
13
+ # import ".depends.mf"
14
+ #
15
+ # See {Importing Dependencies}[link:doc/rakefile_rdoc.html#label-Importing+Dependencies]
16
+ # for further details.
17
+
18
+ class MakefileLoader
19
+ include Rake::DSL
20
+
21
+ SPACE_MARK = "\0" # :nodoc:
22
+
23
+ # Load the makefile dependencies in +fn+.
24
+ def load(fn) # :nodoc:
25
+ lines = File.read fn
26
+ lines.gsub!(/\\ /, SPACE_MARK)
27
+ lines.gsub!(/#[^\n]*\n/m, "")
28
+ lines.gsub!(/\\\n/, " ")
29
+ lines.each_line do |line|
30
+ process_line(line)
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ # Process one logical line of makefile data.
37
+ def process_line(line) # :nodoc:
38
+ file_tasks, args = line.split(":", 2)
39
+ return if args.nil?
40
+ dependents = args.split.map { |d| respace(d) }
41
+ file_tasks.scan(/\S+/) do |file_task|
42
+ file_task = respace(file_task)
43
+ file file_task => dependents
44
+ end
45
+ end
46
+
47
+ def respace(str) # :nodoc:
48
+ str.tr SPACE_MARK, " "
49
+ end
50
+ end
51
+
52
+ # Install the handler
53
+ Rake.application.add_loader("mf", MakefileLoader.new)
54
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+
4
+ # Same as a regular task, but the immediate prerequisites are done in
5
+ # parallel using Ruby threads.
6
+ #
7
+ class MultiTask < Task
8
+ private
9
+
10
+ def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
11
+ invoke_prerequisites_concurrently(task_args, invocation_chain)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # The NameSpace class will lookup task names in the scope defined by a
4
+ # +namespace+ command.
5
+
6
+ class Rake::NameSpace
7
+
8
+ ##
9
+ # Create a namespace lookup object using the given task manager
10
+ # and the list of scopes.
11
+
12
+ def initialize(task_manager, scope_list)
13
+ @task_manager = task_manager
14
+ @scope = scope_list.dup
15
+ end
16
+
17
+ ##
18
+ # Lookup a task named +name+ in the namespace.
19
+
20
+ def [](name)
21
+ @task_manager.lookup(name, @scope)
22
+ end
23
+
24
+ ##
25
+ # The scope of the namespace (a LinkedList)
26
+
27
+ def scope
28
+ @scope.dup
29
+ end
30
+
31
+ ##
32
+ # Return the list of tasks defined in this and nested namespaces.
33
+
34
+ def tasks
35
+ @task_manager.tasks_in_scope(@scope)
36
+ end
37
+
38
+ end
@@ -0,0 +1,222 @@
1
+ # frozen_string_literal: true
2
+ # Define a package task library to aid in the definition of
3
+ # redistributable package files.
4
+
5
+ require "rake"
6
+ require "rake/tasklib"
7
+
8
+ module Rake
9
+
10
+ # Create a packaging task that will package the project into
11
+ # distributable files (e.g zip archive or tar files).
12
+ #
13
+ # The PackageTask will create the following targets:
14
+ #
15
+ # +:package+ ::
16
+ # Create all the requested package files.
17
+ #
18
+ # +:clobber_package+ ::
19
+ # Delete all the package files. This target is automatically
20
+ # added to the main clobber target.
21
+ #
22
+ # +:repackage+ ::
23
+ # Rebuild the package files from scratch, even if they are not out
24
+ # of date.
25
+ #
26
+ # <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tgz"</tt> ::
27
+ # Create a gzipped tar package (if <em>need_tar</em> is true).
28
+ #
29
+ # <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.gz"</tt> ::
30
+ # Create a gzipped tar package (if <em>need_tar_gz</em> is true).
31
+ #
32
+ # <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.bz2"</tt> ::
33
+ # Create a bzip2'd tar package (if <em>need_tar_bz2</em> is true).
34
+ #
35
+ # <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.zip"</tt> ::
36
+ # Create a zip package archive (if <em>need_zip</em> is true).
37
+ #
38
+ # Example:
39
+ #
40
+ # Rake::PackageTask.new("rake", "1.2.3") do |p|
41
+ # p.need_tar = true
42
+ # p.package_files.include("lib/**/*.rb")
43
+ # end
44
+ #
45
+ class PackageTask < TaskLib
46
+ # Name of the package (from the GEM Spec).
47
+ attr_accessor :name
48
+
49
+ # Version of the package (e.g. '1.3.2').
50
+ attr_accessor :version
51
+
52
+ # Directory used to store the package files (default is 'pkg').
53
+ attr_accessor :package_dir
54
+
55
+ # True if a gzipped tar file (tgz) should be produced (default is
56
+ # false).
57
+ attr_accessor :need_tar
58
+
59
+ # True if a gzipped tar file (tar.gz) should be produced (default
60
+ # is false).
61
+ attr_accessor :need_tar_gz
62
+
63
+ # True if a bzip2'd tar file (tar.bz2) should be produced (default
64
+ # is false).
65
+ attr_accessor :need_tar_bz2
66
+
67
+ # True if a xz'd tar file (tar.xz) should be produced (default is false)
68
+ attr_accessor :need_tar_xz
69
+
70
+ # True if a zip file should be produced (default is false)
71
+ attr_accessor :need_zip
72
+
73
+ # List of files to be included in the package.
74
+ attr_accessor :package_files
75
+
76
+ # Tar command for gzipped or bzip2ed archives. The default is 'tar'.
77
+ attr_accessor :tar_command
78
+
79
+ # Zip command for zipped archives. The default is 'zip'.
80
+ attr_accessor :zip_command
81
+
82
+ # True if parent directory should be omitted (default is false)
83
+ attr_accessor :without_parent_dir
84
+
85
+ # Create a Package Task with the given name and version. Use +:noversion+
86
+ # as the version to build a package without a version or to provide a
87
+ # fully-versioned package name.
88
+
89
+ def initialize(name=nil, version=nil)
90
+ init(name, version)
91
+ yield self if block_given?
92
+ define unless name.nil?
93
+ end
94
+
95
+ # Initialization that bypasses the "yield self" and "define" step.
96
+ def init(name, version)
97
+ @name = name
98
+ @version = version
99
+ @package_files = Rake::FileList.new
100
+ @package_dir = "pkg"
101
+ @need_tar = false
102
+ @need_tar_gz = false
103
+ @need_tar_bz2 = false
104
+ @need_tar_xz = false
105
+ @need_zip = false
106
+ @tar_command = "tar"
107
+ @zip_command = "zip"
108
+ @without_parent_dir = false
109
+ end
110
+
111
+ # Create the tasks defined by this task library.
112
+ def define
113
+ fail "Version required (or :noversion)" if @version.nil?
114
+ @version = nil if :noversion == @version
115
+
116
+ desc "Build all the packages"
117
+ task :package
118
+
119
+ desc "Force a rebuild of the package files"
120
+ task repackage: [:clobber_package, :package]
121
+
122
+ desc "Remove package products"
123
+ task :clobber_package do
124
+ rm_r package_dir rescue nil
125
+ end
126
+
127
+ task clobber: [:clobber_package]
128
+
129
+ [
130
+ [need_tar, tgz_file, "z"],
131
+ [need_tar_gz, tar_gz_file, "z"],
132
+ [need_tar_bz2, tar_bz2_file, "j"],
133
+ [need_tar_xz, tar_xz_file, "J"]
134
+ ].each do |need, file, flag|
135
+ if need
136
+ task package: ["#{package_dir}/#{file}"]
137
+ file "#{package_dir}/#{file}" =>
138
+ [package_dir_path] + package_files do
139
+ chdir(working_dir) { sh @tar_command, "#{flag}cvf", file, target_dir }
140
+ mv "#{package_dir_path}/#{target_dir}", package_dir if without_parent_dir
141
+ end
142
+ end
143
+ end
144
+
145
+ if need_zip
146
+ task package: ["#{package_dir}/#{zip_file}"]
147
+ file "#{package_dir}/#{zip_file}" =>
148
+ [package_dir_path] + package_files do
149
+ chdir(working_dir) { sh @zip_command, "-r", zip_file, target_dir }
150
+ mv "#{package_dir_path}/#{zip_file}", package_dir if without_parent_dir
151
+ end
152
+ end
153
+
154
+ directory package_dir_path => @package_files do
155
+ @package_files.each do |fn|
156
+ f = File.join(package_dir_path, fn)
157
+ fdir = File.dirname(f)
158
+ mkdir_p(fdir) unless File.exist?(fdir)
159
+ if File.directory?(fn)
160
+ mkdir_p(f)
161
+ else
162
+ rm_f f
163
+ safe_ln(fn, f)
164
+ end
165
+ end
166
+ end
167
+ self
168
+ end
169
+
170
+ # The name of this package
171
+
172
+ def package_name
173
+ @version ? "#{@name}-#{@version}" : @name
174
+ end
175
+
176
+ # The directory this package will be built in
177
+
178
+ def package_dir_path
179
+ "#{package_dir}/#{package_name}"
180
+ end
181
+
182
+ # The package name with .tgz added
183
+
184
+ def tgz_file
185
+ "#{package_name}.tgz"
186
+ end
187
+
188
+ # The package name with .tar.gz added
189
+
190
+ def tar_gz_file
191
+ "#{package_name}.tar.gz"
192
+ end
193
+
194
+ # The package name with .tar.bz2 added
195
+
196
+ def tar_bz2_file
197
+ "#{package_name}.tar.bz2"
198
+ end
199
+
200
+ # The package name with .tar.xz added
201
+
202
+ def tar_xz_file
203
+ "#{package_name}.tar.xz"
204
+ end
205
+
206
+ # The package name with .zip added
207
+
208
+ def zip_file
209
+ "#{package_name}.zip"
210
+ end
211
+
212
+ def working_dir
213
+ without_parent_dir ? package_dir_path : package_dir
214
+ end
215
+
216
+ # target directory relative to working_dir
217
+ def target_dir
218
+ without_parent_dir ? "." : package_name
219
+ end
220
+ end
221
+
222
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ # Defines a :phony task that you can use as a dependency. This allows
3
+ # file-based tasks to use non-file-based tasks as prerequisites
4
+ # without forcing them to rebuild.
5
+ #
6
+ # See FileTask#out_of_date? and Task#timestamp for more info.
7
+
8
+ require "rake"
9
+
10
+ task :phony
11
+
12
+ Rake::Task[:phony].tap do |task|
13
+ def task.timestamp # :nodoc:
14
+ Time.at 0
15
+ end
16
+ end