map_by_method 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ == 0.8.2 2007-09-07
2
+
3
+ * Updated gem structure to use newgem's latest concepts - rubigen integration, and config folder instead of
4
+ large Rakefile
5
+ * respond_to? also tests respond_to?(callmethod) against the first element of the array, to protect against matching :each_pair etc
6
+
1
7
  == 0.8.1 2007-09-06
2
8
 
3
9
  * Ok ok ok, now it works in all places I've had it fail before
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007 Dr Nic Williams
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,15 +1,27 @@
1
1
  History.txt
2
+ License.txt
2
3
  Manifest.txt
3
4
  README.txt
4
5
  Rakefile
6
+ Rakefile.old
7
+ config/hoe.rb
8
+ config/requirements.rb
5
9
  install.rb
6
10
  lib/map_by_method.rb
7
11
  lib/map_by_method/version.rb
8
- scripts/txt2html
12
+ log/debug.log
13
+ script/destroy
14
+ script/generate
15
+ script/txt2html
16
+ setup.rb
17
+ tasks/deployment.rake
18
+ tasks/environment.rake
19
+ tasks/website.rake
9
20
  test/test_ar_association_proxy.rb
10
21
  test/test_helper.rb
11
22
  test/test_map_by_method.rb
12
23
  test/test_multiple_methods.rb
24
+ test/test_respond_to.rb
13
25
  website/index.html
14
26
  website/index.txt
15
27
  website/javascripts/rounded_corners_lite.inc.js
data/Rakefile CHANGED
@@ -1,125 +1,4 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'rake/clean'
4
- require 'rake/testtask'
5
- require 'rake/packagetask'
6
- require 'rake/gempackagetask'
7
- require 'rake/rdoctask'
8
- require 'rake/contrib/rubyforgepublisher'
9
- require 'fileutils'
10
- require 'hoe'
11
-
12
- include FileUtils
13
- require File.join(File.dirname(__FILE__), 'lib', 'map_by_method', 'version')
14
-
15
- AUTHOR = "Dr Nic Williams"
16
- EMAIL = "drnicwilliams@gmail.com"
17
- DESCRIPTION = <<-EOS
18
- Replacement for map {|obj| obj.action} and Symbol.to_proc which is much cleaner and prettier
19
- NOW WORKS with ActiveRecord Associations!!
20
- EOS
21
- GEM_NAME = "map_by_method"
22
-
23
- @config_file = "~/.rubyforge/user-config.yml"
24
- @config = nil
25
- def rubyforge_username
26
- unless @config
27
- begin
28
- @config = YAML.load(File.read(File.expand_path(@config_file)))
29
- rescue
30
- puts <<-EOS
31
- ERROR: No rubyforge config file found: #{@config_file}"
32
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
33
- - See http://newgem.rubyforge.org/rubyforge.html for more details
34
- EOS
35
- exit
36
- end
37
- end
38
- @rubyforge_username ||= @config["username"]
39
- end
40
-
41
- RUBYFORGE_PROJECT = 'drnicutilities' # The unix name for your project
42
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
43
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
44
-
45
- REV = nil
46
- # UNCOMMENT IF REQUIRED:
47
- # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
48
- VERS = MapByMethod::VERSION::STRING + (REV ? ".#{REV}" : "")
49
- CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
50
- RDOC_OPTS = ['--quiet', '--title', 'find_gem documentation',
51
- "--opname", "index.html",
52
- "--line-numbers",
53
- "--main", "README",
54
- "--inline-source"]
55
-
56
- class Hoe
57
- def extra_deps
58
- @extra_deps.reject { |x| Array(x).first == 'hoe' }
59
- end
60
- end
61
-
62
- # Generate all the Rake tasks
63
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
64
- hoe = Hoe.new(GEM_NAME, VERS) do |p|
65
- p.author = AUTHOR
66
- p.description = DESCRIPTION
67
- p.email = EMAIL
68
- p.summary = DESCRIPTION
69
- p.url = HOMEPATH
70
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
71
- p.test_globs = ["test/**/test_*.rb"]
72
- p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
73
-
74
- # == Optional
75
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
76
- #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
77
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
78
- end
79
-
80
- CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
81
- PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
82
- hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
83
-
84
- desc 'Generate website files'
85
- task :website_generate do
86
- Dir['website/**/*.txt'].each do |txt|
87
- sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
88
- end
89
- end
90
-
91
- desc 'Upload website files to rubyforge'
92
- task :website_upload do
93
- host = "#{rubyforge_username}@rubyforge.org"
94
- remote_dir = "/var/www/gforge-projects/#{PATH}/"
95
- local_dir = 'website'
96
- sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
97
- end
98
-
99
- desc 'Generate and upload website files'
100
- task :website => [:website_generate, :website_upload]
101
-
102
- desc 'Release the website and new gem version'
103
- task :deploy => [:check_version, :website, :release] do
104
- puts "Remember to create SVN tag:"
105
- puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
106
- "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
107
- puts "Suggested comment:"
108
- puts "Tagging release #{CHANGES}"
109
- end
110
-
111
- desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
112
- task :local_deploy => [:website_generate, :install_gem]
113
-
114
- task :check_version do
115
- unless ENV['VERSION']
116
- puts 'Must pass a VERSION=x.y.z release version'
117
- exit
118
- end
119
- unless ENV['VERSION'] == VERS
120
- puts "Please update your version.rb to match the release version, currently #{VERS}"
121
- exit
122
- end
123
- end
124
-
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
125
3
 
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
@@ -0,0 +1,125 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/rdoctask'
8
+ require 'rake/contrib/rubyforgepublisher'
9
+ require 'fileutils'
10
+ require 'hoe'
11
+
12
+ include FileUtils
13
+ require File.join(File.dirname(__FILE__), 'lib', 'map_by_method', 'version')
14
+
15
+ AUTHOR = "Dr Nic Williams"
16
+ EMAIL = "drnicwilliams@gmail.com"
17
+ DESCRIPTION = <<-EOS
18
+ Replacement for map {|obj| obj.action} and Symbol.to_proc which is much cleaner and prettier
19
+ NOW WORKS with ActiveRecord Associations!!
20
+ EOS
21
+ GEM_NAME = "map_by_method"
22
+
23
+ @config_file = "~/.rubyforge/user-config.yml"
24
+ @config = nil
25
+ def rubyforge_username
26
+ unless @config
27
+ begin
28
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
29
+ rescue
30
+ puts <<-EOS
31
+ ERROR: No rubyforge config file found: #{@config_file}"
32
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
33
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
34
+ EOS
35
+ exit
36
+ end
37
+ end
38
+ @rubyforge_username ||= @config["username"]
39
+ end
40
+
41
+ RUBYFORGE_PROJECT = 'drnicutilities' # The unix name for your project
42
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
43
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
44
+
45
+ REV = nil
46
+ # UNCOMMENT IF REQUIRED:
47
+ # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
48
+ VERS = MapByMethod::VERSION::STRING + (REV ? ".#{REV}" : "")
49
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
50
+ RDOC_OPTS = ['--quiet', '--title', 'find_gem documentation',
51
+ "--opname", "index.html",
52
+ "--line-numbers",
53
+ "--main", "README",
54
+ "--inline-source"]
55
+
56
+ class Hoe
57
+ def extra_deps
58
+ @extra_deps.reject { |x| Array(x).first == 'hoe' }
59
+ end
60
+ end
61
+
62
+ # Generate all the Rake tasks
63
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
64
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
65
+ p.author = AUTHOR
66
+ p.description = DESCRIPTION
67
+ p.email = EMAIL
68
+ p.summary = DESCRIPTION
69
+ p.url = HOMEPATH
70
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
71
+ p.test_globs = ["test/**/test_*.rb"]
72
+ p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
73
+
74
+ # == Optional
75
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
76
+ #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
77
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
78
+ end
79
+
80
+ CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
81
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
82
+ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
83
+
84
+ desc 'Generate website files'
85
+ task :website_generate do
86
+ Dir['website/**/*.txt'].each do |txt|
87
+ sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
88
+ end
89
+ end
90
+
91
+ desc 'Upload website files to rubyforge'
92
+ task :website_upload do
93
+ host = "#{rubyforge_username}@rubyforge.org"
94
+ remote_dir = "/var/www/gforge-projects/#{PATH}/"
95
+ local_dir = 'website'
96
+ sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
97
+ end
98
+
99
+ desc 'Generate and upload website files'
100
+ task :website => [:website_generate, :website_upload]
101
+
102
+ desc 'Release the website and new gem version'
103
+ task :deploy => [:check_version, :website, :release] do
104
+ puts "Remember to create SVN tag:"
105
+ puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
106
+ "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
107
+ puts "Suggested comment:"
108
+ puts "Tagging release #{CHANGES}"
109
+ end
110
+
111
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
112
+ task :local_deploy => [:website_generate, :install_gem]
113
+
114
+ task :check_version do
115
+ unless ENV['VERSION']
116
+ puts 'Must pass a VERSION=x.y.z release version'
117
+ exit
118
+ end
119
+ unless ENV['VERSION'] == VERS
120
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
121
+ exit
122
+ end
123
+ end
124
+
125
+
@@ -0,0 +1,73 @@
1
+ require 'map_by_method/version'
2
+
3
+ AUTHOR = 'Dr Nic Williams' # can also be an array of Authors
4
+ EMAIL = "drnicwilliams@gmail.com"
5
+ DESCRIPTION = <<-EOS
6
+ Replacement for map {|obj| obj.action} and Symbol.to_proc which is much cleaner and prettier
7
+ NOW WORKS with ActiveRecord Associations!!
8
+ EOS
9
+ GEM_NAME = 'map_by_method' # what ppl will type to install your gem
10
+ RUBYFORGE_PROJECT = 'drnicutilities' # The unix name for your project
11
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
12
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
13
+
14
+ @config_file = "~/.rubyforge/user-config.yml"
15
+ @config = nil
16
+ RUBYFORGE_USERNAME = "unknown"
17
+ def rubyforge_username
18
+ unless @config
19
+ begin
20
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
21
+ rescue
22
+ puts <<-EOS
23
+ ERROR: No rubyforge config file found: #{@config_file}"
24
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
26
+ EOS
27
+ exit
28
+ end
29
+ end
30
+ RUBYFORGE_USERNAME.replace @config["username"]
31
+ end
32
+
33
+
34
+ REV = nil
35
+ # UNCOMMENT IF REQUIRED:
36
+ # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
37
+ VERS = MapByMethod::VERSION::STRING + (REV ? ".#{REV}" : "")
38
+ RDOC_OPTS = ['--quiet', '--title', 'map_by_method documentation',
39
+ "--opname", "index.html",
40
+ "--line-numbers",
41
+ "--main", "README",
42
+ "--inline-source"]
43
+
44
+ class Hoe
45
+ def extra_deps
46
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
47
+ @extra_deps
48
+ end
49
+ end
50
+
51
+ # Generate all the Rake tasks
52
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
+ p.author = AUTHOR
55
+ p.description = DESCRIPTION
56
+ p.email = EMAIL
57
+ p.summary = DESCRIPTION
58
+ p.url = HOMEPATH
59
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
60
+ p.test_globs = ["test/**/test_*.rb"]
61
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
62
+
63
+ # == Optional
64
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\\n\\n")
65
+ #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
66
+
67
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
68
+
69
+ end
70
+
71
+ CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
72
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
73
+ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
@@ -0,0 +1,17 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
16
+
17
+ require 'map_by_method'
@@ -7,13 +7,17 @@ module MapByMethod
7
7
  # Support for include_priv due to ActiveRecord's AssociationProxy expecting it;
8
8
  # Support degrades to normal single argument respond_to?
9
9
  def respond_to?(method, include_priv = false)
10
- if include_priv
11
- respond_to_before_map_by_method?(method, include_priv) or
12
- !!method.to_s.match(MAP_BY_METHOD_FORMAT)
13
- else
14
- respond_to_before_map_by_method?(method) or
15
- !!method.to_s.match(MAP_BY_METHOD_FORMAT)
10
+ respond_to = (include_priv ?
11
+ respond_to_before_map_by_method?(method, include_priv) :
12
+ respond_to_before_map_by_method?(method))
13
+ unless respond_to
14
+ matches = method.to_s.match(MAP_BY_METHOD_FORMAT)
15
+ if (respond_to = !!(matches)) && self.size > 0
16
+ iterator, callmethod = matches[1..2]
17
+ respond_to = self.first.respond_to?(callmethod)
18
+ end
16
19
  end
20
+ respond_to
17
21
  end
18
22
 
19
23
  protected
@@ -2,7 +2,7 @@ module MapByMethod #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 8
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
File without changes
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)