Peeja-rubot 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,227 @@
1
+ # $Id$
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+ require 'rake/clean'
6
+ require 'fileutils'
7
+ require 'ostruct'
8
+
9
+ PROJ = OpenStruct.new
10
+
11
+ PROJ.name = nil
12
+ PROJ.summary = nil
13
+ PROJ.description = nil
14
+ PROJ.changes = nil
15
+ PROJ.authors = nil
16
+ PROJ.email = nil
17
+ PROJ.url = nil
18
+ PROJ.version = ENV['VERSION'] || '0.0.0'
19
+ PROJ.rubyforge_name = nil
20
+ PROJ.exclude = %w(tmp$ bak$ ~$ CVS .svn/ ^pkg/ ^doc/)
21
+ PROJ.release_name = ENV['RELEASE']
22
+ PROJ.history_file = 'History.txt'
23
+ PROJ.manifest_file = 'Manifest.txt'
24
+ PROJ.readme_file = 'README.txt'
25
+
26
+ # Rspec
27
+ PROJ.specs = FileList['spec/**/*_spec.rb']
28
+ PROJ.spec_opts = []
29
+
30
+ # Test::Unit
31
+ PROJ.tests = FileList['test/**/test_*.rb']
32
+ PROJ.test_file = 'test/all.rb'
33
+ PROJ.test_opts = []
34
+
35
+ # Rcov
36
+ PROJ.rcov_dir = 'coverage'
37
+ PROJ.rcov_opts = ['--sort', 'coverage', '-T']
38
+ PROJ.rcov_threshold = 90.0
39
+ PROJ.rcov_threshold_exact = false
40
+
41
+ # Rdoc
42
+ PROJ.rdoc_opts = []
43
+ PROJ.rdoc_include = %w(^lib/ ^bin/ ^ext/ .txt$)
44
+ PROJ.rdoc_exclude = %w(extconf.rb$)
45
+ PROJ.rdoc_main = nil
46
+ PROJ.rdoc_dir = 'doc'
47
+ PROJ.rdoc_remote_dir = nil
48
+
49
+ # Extensions
50
+ PROJ.extensions = FileList['ext/**/extconf.rb']
51
+ PROJ.ruby_opts = %w(-w)
52
+ PROJ.libs = []
53
+ %w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
54
+
55
+ # Gem Packaging
56
+ PROJ.files = nil
57
+ PROJ.executables = nil
58
+ PROJ.dependencies = []
59
+ PROJ.need_tar = true
60
+ PROJ.need_zip = false
61
+ PROJ.post_install_message = nil
62
+
63
+ # File Annotations
64
+ PROJ.annotation_exclude = %w(^tasks/setup.rb$)
65
+ PROJ.annotation_extensions = %w(.txt .rb .erb) << ''
66
+ PROJ.annotation_tags = %w(FIXME OPTIMIZE TODO)
67
+
68
+ # Subversion Repository
69
+ PROJ.svn = false
70
+ PROJ.svn_root = nil
71
+ PROJ.svn_trunk = 'trunk'
72
+ PROJ.svn_tags = 'tags'
73
+ PROJ.svn_branches = 'branches'
74
+
75
+ # Announce
76
+ PROJ.ann_file = 'announcement.txt'
77
+ PROJ.ann_text = nil
78
+ PROJ.ann_paragraphs = []
79
+ PROJ.ann_email = {
80
+ :from => nil,
81
+ :to => %w(ruby-talk@ruby-lang.org),
82
+ :server => 'localhost',
83
+ :port => 25,
84
+ :domain => ENV['HOSTNAME'],
85
+ :acct => nil,
86
+ :passwd => nil,
87
+ :authtype => :plain
88
+ }
89
+
90
+ # Load the other rake files in the tasks folder
91
+ rakefiles = Dir.glob('tasks/*.rake').sort
92
+ rakefiles.unshift(rakefiles.delete('tasks/post_load.rake')).compact!
93
+ import(*rakefiles)
94
+
95
+ # Setup some constants
96
+ WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32
97
+
98
+ DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
99
+
100
+ def quiet( &block )
101
+ io = [STDOUT.dup, STDERR.dup]
102
+ STDOUT.reopen DEV_NULL
103
+ STDERR.reopen DEV_NULL
104
+ block.call
105
+ ensure
106
+ STDOUT.reopen io.first
107
+ STDERR.reopen io.last
108
+ end
109
+
110
+ DIFF = if WIN32 then 'diff.exe'
111
+ else
112
+ if quiet {system "gdiff", __FILE__, __FILE__} then 'gdiff'
113
+ else 'diff' end
114
+ end unless defined? DIFF
115
+
116
+ SUDO = if WIN32 then ''
117
+ else
118
+ if quiet {system 'which sudo'} then 'sudo'
119
+ else '' end
120
+ end
121
+
122
+ RCOV = WIN32 ? 'rcov.bat' : 'rcov'
123
+ GEM = WIN32 ? 'gem.bat' : 'gem'
124
+
125
+ %w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib|
126
+ begin
127
+ require lib
128
+ Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", true}
129
+ rescue LoadError
130
+ Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", false}
131
+ end
132
+ end
133
+
134
+ # Reads a file at +path+ and spits out an array of the +paragraphs+
135
+ # specified.
136
+ #
137
+ # changes = paragraphs_of('History.txt', 0..1).join("\n\n")
138
+ # summary, *description = paragraphs_of('README.txt', 3, 3..8)
139
+ #
140
+ def paragraphs_of( path, *paragraphs )
141
+ title = String === paragraphs.first ? paragraphs.shift : nil
142
+ ary = File.read(path).delete("\r").split(/\n\n+/)
143
+
144
+ result = if title
145
+ tmp, matching = [], false
146
+ rgxp = %r/^=+\s*#{Regexp.escape(title)}/i
147
+ paragraphs << (0..-1) if paragraphs.empty?
148
+
149
+ ary.each do |val|
150
+ if val =~ rgxp
151
+ break if matching
152
+ matching = true
153
+ rgxp = %r/^=+/i
154
+ elsif matching
155
+ tmp << val
156
+ end
157
+ end
158
+ tmp
159
+ else ary end
160
+
161
+ result.values_at(*paragraphs)
162
+ end
163
+
164
+ # Adds the given gem _name_ to the current project's dependency list. An
165
+ # optional gem _version_ can be given. If omitted, the newest gem version
166
+ # will be used.
167
+ #
168
+ def depend_on( name, version = nil )
169
+ spec = Gem.source_index.find_name(name).last
170
+ version = spec.version.to_s if version.nil? and !spec.nil?
171
+
172
+ PROJ.dependencies << case version
173
+ when nil; [name]
174
+ when %r/^\d/; [name, ">= #{version}"]
175
+ else [name, version] end
176
+ end
177
+
178
+ # Adds the given arguments to the include path if they are not already there
179
+ #
180
+ def ensure_in_path( *args )
181
+ args.each do |path|
182
+ path = File.expand_path(path)
183
+ $:.unshift(path) if test(?d, path) and not $:.include?(path)
184
+ end
185
+ end
186
+
187
+ # Find a rake task using the task name and remove any description text. This
188
+ # will prevent the task from being displayed in the list of available tasks.
189
+ #
190
+ def remove_desc_for_task( names )
191
+ Array(names).each do |task_name|
192
+ task = Rake.application.tasks.find {|t| t.name == task_name}
193
+ next if task.nil?
194
+ task.instance_variable_set :@comment, nil
195
+ end
196
+ end
197
+
198
+ # Change working directories to _dir_, call the _block_ of code, and then
199
+ # change back to the original working directory (the current directory when
200
+ # this method was called).
201
+ #
202
+ def in_directory( dir, &block )
203
+ curdir = pwd
204
+ begin
205
+ cd dir
206
+ return block.call
207
+ ensure
208
+ cd curdir
209
+ end
210
+ end
211
+
212
+ # Scans the current working directory and creates a list of files that are
213
+ # candidates to be in the manifest.
214
+ #
215
+ def manifest_files
216
+ files = []
217
+ exclude = Regexp.new(PROJ.exclude.join('|'))
218
+ Find.find '.' do |path|
219
+ path.sub! %r/^(\.\/|\/)/o, ''
220
+ next unless test ?f, path
221
+ next if path =~ exclude
222
+ files << path
223
+ end
224
+ files.sort!
225
+ end
226
+
227
+ # EOF
@@ -0,0 +1,54 @@
1
+ # $Id$
2
+
3
+ if HAVE_SPEC_RAKE_SPECTASK
4
+ require 'spec/rake/verify_rcov'
5
+
6
+ namespace :spec do
7
+
8
+ desc 'Run all specs with basic output'
9
+ Spec::Rake::SpecTask.new(:run) do |t|
10
+ t.ruby_opts = PROJ.ruby_opts
11
+ t.spec_opts = PROJ.spec_opts
12
+ t.spec_files = PROJ.specs
13
+ t.libs += PROJ.libs
14
+ end
15
+
16
+ desc 'Run all specs with text output'
17
+ Spec::Rake::SpecTask.new(:specdoc) do |t|
18
+ t.ruby_opts = PROJ.ruby_opts
19
+ t.spec_opts = PROJ.spec_opts + ['--format', 'specdoc']
20
+ t.spec_files = PROJ.specs
21
+ t.libs += PROJ.libs
22
+ end
23
+
24
+ if HAVE_RCOV
25
+ desc 'Run all specs with RCov'
26
+ Spec::Rake::SpecTask.new(:rcov) do |t|
27
+ t.ruby_opts = PROJ.ruby_opts
28
+ t.spec_opts = PROJ.spec_opts
29
+ t.spec_files = PROJ.specs
30
+ t.libs += PROJ.libs
31
+ t.rcov = true
32
+ t.rcov_dir = PROJ.rcov_dir
33
+ t.rcov_opts = PROJ.rcov_opts + ['--exclude', 'spec']
34
+ end
35
+
36
+ RCov::VerifyTask.new(:verify) do |t|
37
+ t.threshold = PROJ.rcov_threshold
38
+ t.index_html = File.join(PROJ.rcov_dir, 'index.html')
39
+ t.require_exact_threshold = PROJ.rcov_threshold_exact
40
+ end
41
+ end
42
+
43
+ end # namespace :spec
44
+
45
+ desc 'Alias to spec:run'
46
+ task :spec => 'spec:run'
47
+
48
+ task :clobber => 'spec:clobber_rcov' if HAVE_RCOV
49
+
50
+ remove_desc_for_task %w(spec:clobber_rcov)
51
+
52
+ end # if HAVE_SPEC_RAKE_SPECTASK
53
+
54
+ # EOF
@@ -0,0 +1,44 @@
1
+ # $Id$
2
+
3
+
4
+ if PROJ.svn and system("svn --version 2>&1 > #{DEV_NULL}")
5
+
6
+ unless PROJ.svn_root
7
+ info = %x/svn info ./
8
+ m = %r/^Repository Root:\s+(.*)$/.match(info)
9
+ PROJ.svn_root = (m.nil? ? '' : m[1])
10
+ end
11
+ PROJ.svn_root = File.join(PROJ.svn_root, PROJ.svn) if String === PROJ.svn
12
+
13
+ namespace :svn do
14
+
15
+ desc 'Show tags from the SVN repository'
16
+ task :show_tags do |t|
17
+ tags = %x/svn list #{File.join(PROJ.svn_root, PROJ.svn_tags)}/
18
+ tags.gsub!(%r/\/$/, '')
19
+ puts tags
20
+ end
21
+
22
+ desc 'Create a new tag in the SVN repository'
23
+ task :create_tag do |t|
24
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
25
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
26
+
27
+ trunk = File.join(PROJ.svn_root, PROJ.svn_trunk)
28
+ tag = "%s-%s" % [PROJ.name, PROJ.version]
29
+ tag = File.join(PROJ.svn_root, PROJ.svn_tags, tag)
30
+ msg = "Creating tag for #{PROJ.name} version #{PROJ.version}"
31
+
32
+ puts "Creating SVN tag '#{tag}'"
33
+ unless system "svn cp -m '#{msg}' #{trunk} #{tag}"
34
+ abort "Tag creation failed"
35
+ end
36
+ end
37
+
38
+ end # namespace :svn
39
+
40
+ task 'gem:release' => 'svn:create_tag'
41
+
42
+ end # if PROJ.svn
43
+
44
+ # EOF
@@ -0,0 +1,38 @@
1
+ # $Id$
2
+
3
+ require 'rake/testtask'
4
+
5
+ namespace :test do
6
+
7
+ Rake::TestTask.new(:run) do |t|
8
+ t.libs = PROJ.libs
9
+ t.test_files = if test(?f, PROJ.test_file) then [PROJ.test_file]
10
+ else PROJ.tests end
11
+ t.ruby_opts += PROJ.ruby_opts
12
+ t.ruby_opts += PROJ.test_opts
13
+ end
14
+
15
+ if HAVE_RCOV
16
+ desc 'Run rcov on the unit tests'
17
+ task :rcov => :clobber_rcov do
18
+ opts = PROJ.rcov_opts.dup << '-o' << PROJ.rcov_dir
19
+ opts = opts.join(' ')
20
+ files = if test(?f, PROJ.test_file) then [PROJ.test_file]
21
+ else PROJ.tests end
22
+ files = files.join(' ')
23
+ sh "#{RCOV} #{files} #{opts}"
24
+ end
25
+
26
+ task :clobber_rcov do
27
+ rm_r 'coverage' rescue nil
28
+ end
29
+ end
30
+
31
+ end # namespace :test
32
+
33
+ desc 'Alias to test:run'
34
+ task :test => 'test:run'
35
+
36
+ task :clobber => 'test:clobber_rcov' if HAVE_RCOV
37
+
38
+ # EOF
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Peeja-rubot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Peter Jaros (Peeja)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-04-30 00:00:00 -07:00
13
+ default_executable: rubot
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rice
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.1
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: facets
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 2.3.0
32
+ version:
33
+ description: FIXME (describe your package)
34
+ email: peter.a.jaros@gmail.com
35
+ executables:
36
+ - rubot
37
+ extensions:
38
+ - ext/rubot_aria/extconf.rb
39
+ extra_rdoc_files:
40
+ - Adapters.txt
41
+ - History.txt
42
+ - README.txt
43
+ - bin/rubot
44
+ files:
45
+ - .autotest
46
+ - Adapters.txt
47
+ - History.txt
48
+ - Manifest.txt
49
+ - README.txt
50
+ - Rakefile
51
+ - bin/rubot
52
+ - examples/navigate.rbt
53
+ - ext/rubot_aria/Makefile
54
+ - ext/rubot_aria/RAGenericAction.cpp
55
+ - ext/rubot_aria/RAGenericAction.h
56
+ - ext/rubot_aria/RAGenericAction.o
57
+ - ext/rubot_aria/RARobotManager.cpp
58
+ - ext/rubot_aria/RARobotManager.h
59
+ - ext/rubot_aria/RARobotManager.o
60
+ - ext/rubot_aria/extconf.rb
61
+ - ext/rubot_aria/rubot_aria.cpp
62
+ - ext/rubot_aria/rubot_aria.o
63
+ - ext/rubot_aria/rubot_aria.so
64
+ - lib/rubot.rb
65
+ - lib/rubot/adapters.rb
66
+ - lib/rubot/adapters/aria.rb
67
+ - lib/rubot/adapters/aria/action_desired.rb
68
+ - lib/rubot/adapters/aria/robot.rb
69
+ - lib/rubot/adapters/asimov.rb
70
+ - lib/rubot/dsl.rb
71
+ - lib/rubot/meta.rb
72
+ - spec/load_paths.rb
73
+ - spec/rubot/adapters/aria/robot_manager_spec.rb
74
+ - spec/rubot/adapters/aria/robot_spec.rb
75
+ - spec/rubot/adapters/aria_spec.rb
76
+ - spec/rubot/adapters/spec_helper.rb
77
+ - spec/rubot/dsl_spec.rb
78
+ - spec/rubot_spec.rb
79
+ - spec/spec.opts
80
+ - spec/spec_helper.rb
81
+ - tasks/ann.rake
82
+ - tasks/annotations.rake
83
+ - tasks/doc.rake
84
+ - tasks/gem.rake
85
+ - tasks/manifest.rake
86
+ - tasks/post_load.rake
87
+ - tasks/rubyforge.rake
88
+ - tasks/setup.rb
89
+ - tasks/spec.rake
90
+ - tasks/svn.rake
91
+ - tasks/test.rake
92
+ has_rdoc: true
93
+ homepage: http://rubot.org/
94
+ post_install_message:
95
+ rdoc_options:
96
+ - --main
97
+ - README.txt
98
+ require_paths:
99
+ - lib
100
+ - ext
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: "0"
106
+ version:
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: "0"
112
+ version:
113
+ requirements: []
114
+
115
+ rubyforge_project:
116
+ rubygems_version: 1.0.1
117
+ signing_key:
118
+ specification_version: 2
119
+ summary: FIXME (describe your package)
120
+ test_files: []
121
+