colour 0.1.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,4 +1,5 @@
1
- == 1.0.0 / 2008-03-22
1
+ == 0.3 / 2009-01-20
2
2
 
3
- * 1 major enhancement
4
- * Birthday!
3
+ * rSpec Testing
4
+ * removed tests
5
+ * now spec driven
data/Manifest.txt CHANGED
@@ -2,23 +2,10 @@ History.txt
2
2
  Manifest.txt
3
3
  README.txt
4
4
  Rakefile
5
- bin/colour
5
+ colour.gemspec
6
+ colour.rb
6
7
  lib/colour.rb
7
- lib/rgb.rb
8
8
  lib/hsv.rb
9
+ lib/rgb.rb
9
10
  lib/standard_colours.rb
10
- lib/cmyk.rb
11
- spec/colour_spec.rb
12
- spec/spec_helper.rb
13
- tasks/ann.rake
14
- tasks/annotations.rake
15
- tasks/bones.rake
16
- tasks/doc.rake
17
- tasks/gem.rake
18
- tasks/manifest.rake
19
- tasks/post_load.rake
20
- tasks/rubyforge.rake
21
- tasks/setup.rb
22
- tasks/spec.rake
23
- tasks/svn.rake
24
- test/test_colour.rb
11
+
data/Rakefile CHANGED
@@ -11,8 +11,8 @@ task :default => 'spec:run'
11
11
 
12
12
  PROJ.name = 'colour'
13
13
  PROJ.authors = 'Wes Devauld'
14
- PROJ.email = 'http://devauld.ca'
15
- PROJ.url = 'http://www.ihatework.ca/svn/colour/'
14
+ PROJ.email = 'wes@devauld.ca'
15
+ PROJ.url = 'http://code.devauld.ca/git/colour/'
16
16
  PROJ.rubyforge_name = 'colour'
17
-
18
- PROJ.spec_opts << '--color'
17
+ PROJ.version = '0.3'
18
+ PROJ.exclude = %w(.git)
data/colour.gemspec ADDED
Binary file
data/colour.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'lib/colour'
2
+ require 'lib/rgb'
3
+ require 'lib/cmyk'
4
+ require 'lib/hsv'
5
+ require 'lib/standard_colours'
data/lib/colour.rb CHANGED
@@ -9,10 +9,6 @@ module Colour
9
9
  self
10
10
  end
11
11
 
12
- def to_cmyk
13
- self
14
- end
15
-
16
12
  def to_hsv
17
13
  self
18
14
  end
@@ -35,7 +31,7 @@ module Colour
35
31
 
36
32
  # Return the complementary colour
37
33
  def complementary
38
- rotate_hue[180]
34
+ rotate_hue(180)
39
35
  end
40
36
 
41
37
  # Return two colours spread distance apart opposite
@@ -86,10 +82,39 @@ module Colour
86
82
  end
87
83
  end
88
84
 
85
+
86
+ def gradient_to(colour, steps=10)
87
+ c = self.class.name.downcase
88
+ origin = self.to_rgb
89
+ destination = colour.to_rgb
90
+ gradient = []
91
+
92
+ #TODO: *_range isn't really being used
93
+ red_range = destination.r - origin.r
94
+ red_increment = red_range / steps
95
+ green_range = destination.g - origin.g
96
+ green_increment = green_range / steps
97
+ blue_range = destination.b - origin.b
98
+ blue_increment = blue_range / steps
99
+
100
+ steps.times do |i|
101
+ intermediate = RGB.new(
102
+ origin.r + red_increment * i,
103
+ origin.g + green_increment * i,
104
+ origin.b + blue_increment * i
105
+ )
106
+ gradient << intermediate.send("to_" + c)
107
+ if block_given? then
108
+ yield intermediate.send("to_" + c)
109
+ end
110
+ end
111
+ gradient
112
+ end
113
+
89
114
  #Bones specific stuff
90
115
 
91
116
  # :stopdoc:
92
- VERSION = '0.1.0'
117
+ VERSION = '0.2.1'
93
118
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
94
119
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
95
120
  # :startdoc:
@@ -132,7 +157,6 @@ end # module Colour
132
157
 
133
158
  Colour.require_all_libs_relative_to __FILE__
134
159
  require 'rgb'
135
- require 'cmyk'
136
160
  require 'standard_colours'
137
161
  require 'hsv'
138
162
 
data/lib/rgb.rb CHANGED
@@ -11,18 +11,6 @@ class RGB
11
11
  @b = b.abs.to_f
12
12
  end
13
13
 
14
- def to_cmyk
15
- min = [@r, @g, @b].min
16
- if(min == 1) then
17
- CMYK.new(0,0,0,1)
18
- else
19
- CMYK.new(((1-@r) - min)/(1-min),
20
- ((1-@g) - min)/(1-min),
21
- ((1-@b) - min)/(1-min),
22
- min)
23
- end
24
- end
25
-
26
14
  def to_hsv
27
15
  min = [@r, @g, @b].min
28
16
  max = [@r, @g, @b].max
@@ -1,4 +1,6 @@
1
1
  module StandardColoursRGB
2
+
3
+ # Using the definitions from http://en.wikipedia.org/wiki/List_of_colors
2
4
  def alice_blue
3
5
  RGB.new(0.941176, 0.972549, 1.000000)
4
6
  end
@@ -8,6 +10,9 @@ module StandardColoursRGB
8
10
  def amaranth
9
11
  RGB.new(0.898039, 0.168627, 0.313725)
10
12
  end
13
+ def amaranth_pink
14
+ RGB.new(0.945098, 0.611764, 0.733333)
15
+ end
11
16
  def amber
12
17
  RGB.new(1.000000, 0.749020, 0.000000)
13
18
  end
@@ -23,9 +28,15 @@ module StandardColoursRGB
23
28
  def aquamarine
24
29
  RGB.new(0.498039, 1.000000, 0.831373)
25
30
  end
31
+ def army_green
32
+ RGB.new(0.294117, 0.325490, 0.125490)
33
+ end
26
34
  def asparagus
27
35
  RGB.new(0.482353, 0.627451, 0.356863)
28
36
  end
37
+ def atomic_tangerine
38
+ RGB.new(1.000000, 0.600000, 0.400000)
39
+ end
29
40
  def auburn
30
41
  RGB.new(0.435294, 0.207843, 0.101961)
31
42
  end
metadata CHANGED
@@ -1,72 +1,75 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: colour
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.1.2
7
- date: 2008-04-11 00:00:00 -06:00
8
- summary: A library to convert between various representation of colour (RGB, CMYK and HSV), as well as generate swatches based on some colour theory
9
- require_paths:
10
- - lib
11
- email: http://devauld.ca
12
- homepage: http://www.ihatework.ca/svn/colour/
13
- rubyforge_project: colour
14
- description: A library to convert between various representation of colour (RGB, CMYK and HSV), as well as generate swatches based on some colour theory
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: "0.3"
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Wes Devauld
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-13 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bones
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.2.0
24
+ version:
25
+ description: A library to convert between various representation of colour (RGB, CMYK and HSV), as well as generate swatches based on some colour theory
26
+ email: wes@devauld.ca
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - History.txt
33
+ - README.txt
31
34
  files:
32
35
  - History.txt
33
36
  - Manifest.txt
34
37
  - README.txt
35
38
  - Rakefile
36
- - bin/colour
39
+ - colour.gemspec
40
+ - colour.rb
37
41
  - lib/colour.rb
38
- - lib/rgb.rb
39
42
  - lib/hsv.rb
43
+ - lib/rgb.rb
40
44
  - lib/standard_colours.rb
41
- - lib/cmyk.rb
42
- - spec/colour_spec.rb
43
- - spec/spec_helper.rb
44
- - tasks/ann.rake
45
- - tasks/annotations.rake
46
- - tasks/bones.rake
47
- - tasks/doc.rake
48
- - tasks/gem.rake
49
- - tasks/manifest.rake
50
- - tasks/post_load.rake
51
- - tasks/rubyforge.rake
52
- - tasks/setup.rb
53
- - tasks/spec.rake
54
- - tasks/svn.rake
55
- - test/test_colour.rb
56
- test_files:
57
- - test/test_colour.rb
45
+ has_rdoc: true
46
+ homepage: http://code.devauld.ca/git/colour/
47
+ post_install_message:
58
48
  rdoc_options:
59
49
  - --main
60
50
  - README.txt
61
- extra_rdoc_files:
62
- - History.txt
63
- - README.txt
64
- - bin/colour
65
- executables:
66
- - colour
67
- extensions: []
68
-
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
69
65
  requirements: []
70
66
 
71
- dependencies: []
67
+ rubyforge_project: !binary |
68
+ AA==
69
+
70
+ rubygems_version: 1.2.0
71
+ signing_key:
72
+ specification_version: 2
73
+ summary: A library to convert between various representation of colour (RGB, CMYK and HSV), as well as generate swatches based on some colour theory
74
+ test_files: []
72
75
 
data/bin/colour DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.expand_path(
4
- File.join(File.dirname(__FILE__), '..', 'lib', 'colour'))
5
-
6
- # Put your code here
7
-
8
- # EOF
data/lib/cmyk.rb DELETED
@@ -1,21 +0,0 @@
1
- class CMYK
2
- attr_accessor :c, :m, :y, :k
3
- include Colour
4
- def initialize(c=0.0,m=0.0,y=0.0,k=0.0)
5
- @c = c.abs.to_f
6
- @m = m.abs.to_f
7
- @y = y.abs.to_f
8
- @k = k.abs.to_f
9
- end
10
-
11
- def to_rgb
12
- RGB.new(
13
- 1 - (@c * (1 - @k) + @k),
14
- 1 - (@m * (1 - @k) + @k),
15
- 1 - (@y * (1 - @k) + @k))
16
- end
17
-
18
- def to_hsv
19
- self.to_rgb.to_hsv
20
- end
21
- end
data/spec/colour_spec.rb DELETED
@@ -1,8 +0,0 @@
1
- # $Id$
2
-
3
- require File.join(File.dirname(__FILE__), %w[spec_helper])
4
-
5
- describe Colour do
6
- end
7
-
8
- # EOF
data/spec/spec_helper.rb DELETED
@@ -1,17 +0,0 @@
1
- # $Id$
2
-
3
- require File.expand_path(
4
- File.join(File.dirname(__FILE__), %w[.. lib colour]))
5
-
6
- Spec::Runner.configure do |config|
7
- # == Mock Framework
8
- #
9
- # RSpec uses it's own mocking framework by default. If you prefer to
10
- # use mocha, flexmock or RR, uncomment the appropriate line:
11
- #
12
- # config.mock_with :mocha
13
- # config.mock_with :flexmock
14
- # config.mock_with :rr
15
- end
16
-
17
- # EOF
data/tasks/ann.rake DELETED
@@ -1,76 +0,0 @@
1
- # $Id$
2
-
3
- begin
4
- require 'bones/smtp_tls'
5
- rescue LoadError
6
- require 'net/smtp'
7
- end
8
- require 'time'
9
-
10
- namespace :ann do
11
-
12
- file PROJ.ann_file do
13
- puts "Generating #{PROJ.ann_file}"
14
- File.open(PROJ.ann_file,'w') do |fd|
15
- fd.puts("#{PROJ.name} version #{PROJ.version}")
16
- fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
17
- fd.puts(" #{PROJ.url}") if PROJ.url
18
- fd.puts(" (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
19
- fd.puts
20
- fd.puts("== DESCRIPTION")
21
- fd.puts
22
- fd.puts(PROJ.description)
23
- fd.puts
24
- fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
25
- fd.puts
26
- PROJ.ann_paragraphs.each do |p|
27
- fd.puts "== #{p.upcase}"
28
- fd.puts
29
- fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
30
- fd.puts
31
- end
32
- fd.puts PROJ.ann_text if PROJ.ann_text
33
- end
34
- end
35
-
36
- desc "Create an announcement file"
37
- task :announcement => PROJ.ann_file
38
-
39
- desc "Send an email announcement"
40
- task :email => PROJ.ann_file do
41
- from = PROJ.ann_email[:from] || PROJ.email
42
- to = Array(PROJ.ann_email[:to])
43
-
44
- ### build a mail header for RFC 822
45
- rfc822msg = "From: #{from}\n"
46
- rfc822msg << "To: #{to.join(',')}\n"
47
- rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
48
- rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
49
- rfc822msg << "\n"
50
- rfc822msg << "Date: #{Time.new.rfc822}\n"
51
- rfc822msg << "Message-Id: "
52
- rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{PROJ.ann_email[:domain]}>\n\n"
53
- rfc822msg << File.read(PROJ.ann_file)
54
-
55
- params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
56
- PROJ.ann_email[key]
57
- end
58
-
59
- params[3] = PROJ.email if params[3].nil?
60
-
61
- if params[4].nil?
62
- STDOUT.write "Please enter your e-mail password (#{params[3]}): "
63
- params[4] = STDIN.gets.chomp
64
- end
65
-
66
- ### send email
67
- Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
68
- end
69
- end # namespace :ann
70
-
71
- desc 'Alias to ann:announcement'
72
- task :ann => 'ann:announcement'
73
-
74
- CLOBBER << PROJ.ann_file
75
-
76
- # EOF
@@ -1,22 +0,0 @@
1
- # $Id$
2
-
3
- if HAVE_BONES
4
-
5
- desc "Enumerate all annotations"
6
- task :notes do
7
- Bones::AnnotationExtractor.enumerate(
8
- PROJ, PROJ.annotation_tags.join('|'), :tag => true)
9
- end
10
-
11
- namespace :notes do
12
- PROJ.annotation_tags.each do |tag|
13
- desc "Enumerate all #{tag} annotations"
14
- task tag.downcase.to_sym do
15
- Bones::AnnotationExtractor.enumerate(PROJ, tag)
16
- end
17
- end
18
- end
19
-
20
- end # if HAVE_BONES
21
-
22
- # EOF
data/tasks/bones.rake DELETED
@@ -1,40 +0,0 @@
1
- # $Id$
2
-
3
- require 'pp'
4
- require 'stringio'
5
-
6
- namespace :bones do
7
-
8
- desc 'Show the PROJ open struct'
9
- task :debug do |t|
10
- atr = if ARGV.length == 2
11
- t.application.top_level_tasks.pop
12
- end
13
- sio = StringIO.new
14
- sep = "\n" + ' '*27
15
- fmt = "%23s => %s"
16
-
17
- if atr
18
- PP.pp(PROJ.send(atr.to_sym), sio, 49)
19
- sio.seek 0
20
- val = sio.read
21
- val = val.split("\n").join(sep)
22
-
23
- puts fmt % [atr, val]
24
- else
25
- h = PROJ.instance_variable_get(:@table)
26
- h.keys.map {|k| k.to_s}.sort.each do |k|
27
- sio.truncate 0
28
- PP.pp(h[k.to_sym], sio, 49)
29
- sio.seek 0
30
- val = sio.read
31
- val = val.split("\n").join(sep)
32
-
33
- puts fmt % [k, val]
34
- end
35
- end
36
- end
37
-
38
- end # namespace :bones
39
-
40
- # EOF
data/tasks/doc.rake DELETED
@@ -1,48 +0,0 @@
1
- # $Id$
2
-
3
- require 'rake/rdoctask'
4
-
5
- namespace :doc do
6
-
7
- desc 'Generate RDoc documentation'
8
- Rake::RDocTask.new do |rd|
9
- rd.main = PROJ.rdoc_main
10
- rd.rdoc_dir = PROJ.rdoc_dir
11
-
12
- incl = Regexp.new(PROJ.rdoc_include.join('|'))
13
- excl = Regexp.new(PROJ.rdoc_exclude.join('|'))
14
- files = PROJ.files.find_all do |fn|
15
- case fn
16
- when excl; false
17
- when incl; true
18
- else false end
19
- end
20
- rd.rdoc_files.push(*files)
21
-
22
- title = "#{PROJ.name}-#{PROJ.version} Documentation"
23
- title = "#{PROJ.rubyforge_name}'s " + title if PROJ.rubyforge_name != title
24
-
25
- rd.options << "-t #{title}"
26
- rd.options.concat(PROJ.rdoc_opts)
27
- end
28
-
29
- desc 'Generate ri locally for testing'
30
- task :ri => :clobber_ri do
31
- sh "#{RDOC} --ri -o ri ."
32
- end
33
-
34
- task :clobber_ri do
35
- rm_r 'ri' rescue nil
36
- end
37
-
38
- end # namespace :doc
39
-
40
- desc 'Alias to doc:rdoc'
41
- task :doc => 'doc:rdoc'
42
-
43
- desc 'Remove all build products'
44
- task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)
45
-
46
- remove_desc_for_task %w(doc:clobber_rdoc)
47
-
48
- # EOF
data/tasks/gem.rake DELETED
@@ -1,116 +0,0 @@
1
- # $Id$
2
-
3
- require 'rake/gempackagetask'
4
-
5
- namespace :gem do
6
-
7
- PROJ.spec = Gem::Specification.new do |s|
8
- s.name = PROJ.name
9
- s.version = PROJ.version
10
- s.summary = PROJ.summary
11
- s.authors = Array(PROJ.authors)
12
- s.email = PROJ.email
13
- s.homepage = Array(PROJ.url).first
14
- s.rubyforge_project = PROJ.rubyforge_name
15
- s.post_install_message = PROJ.post_install_message
16
-
17
- s.description = PROJ.description
18
-
19
- PROJ.dependencies.each do |dep|
20
- s.add_dependency(*dep)
21
- end
22
-
23
- s.files = PROJ.files
24
- s.executables = PROJ.executables.map {|fn| File.basename(fn)}
25
- s.extensions = PROJ.files.grep %r/extconf\.rb$/
26
-
27
- s.bindir = 'bin'
28
- dirs = Dir["{#{PROJ.libs.join(',')}}"]
29
- s.require_paths = dirs unless dirs.empty?
30
-
31
- incl = Regexp.new(PROJ.rdoc_include.join('|'))
32
- excl = PROJ.rdoc_exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
33
- excl = Regexp.new(excl.join('|'))
34
- rdoc_files = PROJ.files.find_all do |fn|
35
- case fn
36
- when excl; false
37
- when incl; true
38
- else false end
39
- end
40
- s.rdoc_options = PROJ.rdoc_opts + ['--main', PROJ.rdoc_main]
41
- s.extra_rdoc_files = rdoc_files
42
- s.has_rdoc = true
43
-
44
- if test ?f, PROJ.test_file
45
- s.test_file = PROJ.test_file
46
- else
47
- s.test_files = PROJ.tests.to_a
48
- end
49
-
50
- # Do any extra stuff the user wants
51
- # spec_extras.each do |msg, val|
52
- # case val
53
- # when Proc
54
- # val.call(s.send(msg))
55
- # else
56
- # s.send "#{msg}=", val
57
- # end
58
- # end
59
- end
60
-
61
- desc 'Show information about the gem'
62
- task :debug do
63
- puts PROJ.spec.to_ruby
64
- end
65
-
66
- pkg = Rake::PackageTask.new(PROJ.name, PROJ.version) do |pkg|
67
- pkg.need_tar = PROJ.need_tar
68
- pkg.need_zip = PROJ.need_zip
69
- pkg.package_files += PROJ.spec.files
70
- end
71
- Rake::Task['gem:package'].instance_variable_set(:@full_comment, nil)
72
-
73
- gem_file = if PROJ.spec.platform == Gem::Platform::RUBY
74
- "#{pkg.package_name}.gem"
75
- else
76
- "#{pkg.package_name}-#{PROJ.spec.platform}.gem"
77
- end
78
-
79
- desc "Build the gem file #{gem_file}"
80
- task :package => "#{pkg.package_dir}/#{gem_file}"
81
-
82
- file "#{pkg.package_dir}/#{gem_file}" => [pkg.package_dir] + PROJ.spec.files do
83
- when_writing("Creating GEM") {
84
- Gem::Builder.new(PROJ.spec).build
85
- verbose(true) {
86
- mv gem_file, "#{pkg.package_dir}/#{gem_file}"
87
- }
88
- }
89
- end
90
-
91
- desc 'Install the gem'
92
- task :install => [:clobber, :package] do
93
- sh "#{SUDO} #{GEM} install pkg/#{PROJ.spec.full_name}"
94
- end
95
-
96
- desc 'Uninstall the gem'
97
- task :uninstall do
98
- installed_list = Gem.source_index.find_name(PROJ.name)
99
- if installed_list and installed_list.collect { |s| s.version.to_s}.include?(PROJ.version) then
100
- sh "#{SUDO} #{GEM} uninstall -v '#{PROJ.version}' -i -x #{PROJ.name}"
101
- end
102
- end
103
-
104
- desc 'Reinstall the gem'
105
- task :reinstall => [:uninstall, :install]
106
-
107
- end # namespace :gem
108
-
109
- desc 'Alias to gem:package'
110
- task :gem => 'gem:package'
111
-
112
- task :clobber => 'gem:clobber_package'
113
-
114
- remove_desc_for_task %w(gem:clobber_package)
115
-
116
- # EOF
data/tasks/manifest.rake DELETED
@@ -1,49 +0,0 @@
1
- # $Id$
2
-
3
- require 'find'
4
-
5
- namespace :manifest do
6
-
7
- desc 'Verify the manifest'
8
- task :check do
9
- fn = PROJ.manifest_file + '.tmp'
10
- files = manifest_files
11
-
12
- File.open(fn, 'w') {|fp| fp.puts files}
13
- lines = %x(#{DIFF} -du #{PROJ.manifest_file} #{fn}).split("\n")
14
- if HAVE_FACETS_ANSICODE and ENV.has_key?('TERM')
15
- lines.map! do |line|
16
- case line
17
- when %r/^(-{3}|\+{3})/; nil
18
- when %r/^@/; Console::ANSICode.blue line
19
- when %r/^\+/; Console::ANSICode.green line
20
- when %r/^\-/; Console::ANSICode.red line
21
- else line end
22
- end
23
- end
24
- puts lines.compact
25
- rm fn rescue nil
26
- end
27
-
28
- desc 'Create a new manifest'
29
- task :create do
30
- files = manifest_files
31
- unless test(?f, PROJ.manifest_file)
32
- files << PROJ.manifest_file
33
- files.sort!
34
- end
35
- File.open(PROJ.manifest_file, 'w') {|fp| fp.puts files}
36
- end
37
-
38
- task :assert do
39
- files = manifest_files
40
- manifest = File.read(PROJ.manifest_file).split($/)
41
- raise "ERROR: #{PROJ.manifest_file} is out of date" unless files == manifest
42
- end
43
-
44
- end # namespace :manifest
45
-
46
- desc 'Alias to manifest:check'
47
- task :manifest => 'manifest:check'
48
-
49
- # EOF
data/tasks/post_load.rake DELETED
@@ -1,32 +0,0 @@
1
- # $Id$
2
-
3
- # This file does not define any rake tasks. It is used to load some project
4
- # settings if they are not defined by the user.
5
-
6
- PROJ.rdoc_exclude << "^#{Regexp.escape(PROJ.manifest_file)}$"
7
- PROJ.exclude << "^#{Regexp.escape(PROJ.ann_file)}$"
8
-
9
- PROJ.instance_variable_get(:@table).each do |key,val|
10
- next unless val.instance_of? Array
11
- next if key == :dependencies
12
- val.flatten!
13
- end
14
-
15
- PROJ.changes ||= paragraphs_of(PROJ.history_file, 0..1).join("\n\n")
16
-
17
- PROJ.description ||= paragraphs_of(PROJ.readme_file, 'description').join("\n\n")
18
-
19
- PROJ.summary ||= PROJ.description.split('.').first
20
-
21
- PROJ.files ||=
22
- if test(?f, PROJ.manifest_file)
23
- files = File.readlines(PROJ.manifest_file).map {|fn| fn.chomp.strip}
24
- files.delete ''
25
- files
26
- else [] end
27
-
28
- PROJ.executables ||= PROJ.files.find_all {|fn| fn =~ %r/^bin/}
29
-
30
- PROJ.rdoc_main ||= PROJ.readme_file
31
-
32
- # EOF
data/tasks/rubyforge.rake DELETED
@@ -1,57 +0,0 @@
1
- # $Id$
2
-
3
- if PROJ.rubyforge_name && HAVE_RUBYFORGE
4
-
5
- require 'rubyforge'
6
- require 'rake/contrib/sshpublisher'
7
-
8
- namespace :gem do
9
- desc 'Package and upload to RubyForge'
10
- task :release => [:clobber, :package] do |t|
11
- v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
12
- abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
13
- pkg = "pkg/#{PROJ.spec.full_name}"
14
-
15
- if $DEBUG then
16
- puts "release_id = rf.add_release #{PROJ.rubyforge_name.inspect}, #{PROJ.name.inspect}, #{PROJ.version.inspect}, \"#{pkg}.tgz\""
17
- puts "rf.add_file #{PROJ.rubyforge_name.inspect}, #{PROJ.name.inspect}, release_id, \"#{pkg}.gem\""
18
- end
19
-
20
- rf = RubyForge.new
21
- puts 'Logging in'
22
- rf.login
23
-
24
- c = rf.userconfig
25
- c['release_notes'] = PROJ.description if PROJ.description
26
- c['release_changes'] = PROJ.changes if PROJ.changes
27
- c['preformatted'] = true
28
-
29
- files = [(PROJ.need_tar ? "#{pkg}.tgz" : nil),
30
- (PROJ.need_zip ? "#{pkg}.zip" : nil),
31
- "#{pkg}.gem"].compact
32
-
33
- puts "Releasing #{PROJ.name} v. #{PROJ.version}"
34
- rf.add_release PROJ.rubyforge_name, PROJ.name, PROJ.version, *files
35
- end
36
- end # namespace :gem
37
-
38
-
39
- namespace :doc do
40
- desc "Publish RDoc to RubyForge"
41
- task :release => %w(doc:clobber_rdoc doc:rdoc) do
42
- config = YAML.load(
43
- File.read(File.expand_path('~/.rubyforge/user-config.yml'))
44
- )
45
-
46
- host = "#{config['username']}@rubyforge.org"
47
- remote_dir = "/var/www/gforge-projects/#{PROJ.rubyforge_name}/"
48
- remote_dir << PROJ.rdoc_remote_dir if PROJ.rdoc_remote_dir
49
- local_dir = PROJ.rdoc_dir
50
-
51
- Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
52
- end
53
- end # namespace :doc
54
-
55
- end # if HAVE_RUBYFORGE
56
-
57
- # EOF
data/tasks/setup.rb DELETED
@@ -1,227 +0,0 @@
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 = %w[--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
data/tasks/spec.rake DELETED
@@ -1,56 +0,0 @@
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
-
42
- task :verify => :rcov
43
- end
44
-
45
- end # namespace :spec
46
-
47
- desc 'Alias to spec:run'
48
- task :spec => 'spec:run'
49
-
50
- task :clobber => 'spec:clobber_rcov' if HAVE_RCOV
51
-
52
- remove_desc_for_task %w(spec:clobber_rcov)
53
-
54
- end # if HAVE_SPEC_RAKE_SPECTASK
55
-
56
- # EOF
data/tasks/svn.rake DELETED
@@ -1,44 +0,0 @@
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
data/test/test_colour.rb DELETED
File without changes