casttv-rakeutil 1.0.0

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.
Files changed (4) hide show
  1. data/INSTALL +2 -0
  2. data/README +25 -0
  3. data/lib/rakeutil.rb +71 -0
  4. metadata +55 -0
data/INSTALL ADDED
@@ -0,0 +1,2 @@
1
+ sudo gem sources -a http://gems.github.com
2
+ sudo gem install casttv-rakeutil
data/README ADDED
@@ -0,0 +1,25 @@
1
+ RakeUtil
2
+ ===============================================================================
3
+
4
+ Features:
5
+
6
+ - include FileUtils::Verbose
7
+ - makes Kernel#system a verbose call
8
+ - defines Kernel#system?, which exits on failure
9
+ - defines Kernel#jx(*args), which is basically:
10
+ system "java <inferred options and classpath> arg1 arg2 ..."
11
+ - defines Kernel#const, which allows ENV variables to override constants. i.e.
12
+
13
+ const :RAKE_CLASSPATH, (Dir["**/*.jar"] << "bin").join(":")
14
+ const :RAKE_JAVA_OPTS, " -d64 -Xmx14g "
15
+
16
+ - defines Hash#to_os, which makes the hash into an OpenStruct
17
+
18
+
19
+ Tasks:
20
+
21
+ - util:readme -- cat rakeutil's README
22
+ - util:dry -- Make system, FileUtils#*, and any other $dry respecting commands
23
+ into no-ops (that still are verbose). You should make your own commands
24
+ respect the $dry gloabal variable.
25
+ - util:constants -- Pretty-print all rakeutil constants
data/lib/rakeutil.rb ADDED
@@ -0,0 +1,71 @@
1
+ require "fileutils"
2
+ include FileUtils::Verbose
3
+ require "rubygems"
4
+ require "ostruct"
5
+
6
+ def const(k, v)
7
+ k = k.to_s
8
+ $rake_consts ||= []
9
+ $rake_consts << k
10
+ Kernel.const_set(k, ENV[k] || v)
11
+ end
12
+
13
+ def system?(cmd)
14
+ puts cmd
15
+ Kernel.system(cmd) or exit unless $dry
16
+ end
17
+
18
+ def system(cmd)
19
+ puts cmd
20
+ Kernel.system(cmd) unless $dry
21
+ end
22
+
23
+ def jx(*args)
24
+ system "java -cp #{RAKE_CLASSPATH} #{RAKE_JAVA_OPTS} #{args.join(" ")}"
25
+ end
26
+
27
+ const :RAKE_CLASSPATH, (Dir["**/*.jar"] << "bin").join(":")
28
+ const :RAKE_JAVA_OPTS, " -Xmx1g "
29
+
30
+ class Object
31
+ def to_os
32
+ self
33
+ end
34
+ end
35
+
36
+ class Hash
37
+ def to_os
38
+ inject({}){ |memo, (k, v)| memo[k] = v.to_os; memo }
39
+ end
40
+ end
41
+
42
+ class Array
43
+ def to_os
44
+ map{|e| e.to_os }
45
+ end
46
+ end
47
+
48
+
49
+ namespace :util do
50
+
51
+ desc "cat rakeutil's README"
52
+ task :readme do
53
+ puts File.dirname(__FILE__) + "/../README"
54
+ end
55
+
56
+ desc "Don't let fileutils and compatible commands affect the fs"
57
+ task :dry => :dry_run do
58
+ end
59
+
60
+ desc "Don't let fileutils and compatible commands affect the fs"
61
+ task :dry_run do
62
+ include FileUtils::DryRun
63
+ $dry = true
64
+ end
65
+
66
+ desc "Pretty-print all rakeutil constants"
67
+ task :constants do
68
+ $rake_consts.sort.each {|c| puts c + "\t" + const_get(c).inspect }
69
+ end
70
+
71
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: casttv-rakeutil
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - CastTV
8
+ autorequire: rakeutil
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-13 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Making my life easier
17
+ email: kyle@casttv.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - README
26
+ - INSTALL
27
+ - lib/rakeutil.rb
28
+ has_rdoc: false
29
+ homepage: http://www.casttv.com/
30
+ post_install_message:
31
+ rdoc_options: []
32
+
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: "0"
40
+ version:
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ requirements: []
48
+
49
+ rubyforge_project:
50
+ rubygems_version: 1.2.0
51
+ signing_key:
52
+ specification_version: 2
53
+ summary: Rake Utilities
54
+ test_files: []
55
+