spraypaint 1.0.1 → 1.0.2

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.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  $: << File.expand_path(File.join(File.dirname(__FILE__), "lib"))
2
2
 
3
- require 'spraypaint'
3
+ require 'spraypaint/version'
4
4
  require 'spec/rake/spectask' rescue nil
5
5
 
6
6
  namespace :spraypaint do
@@ -15,6 +15,8 @@ namespace :spraypaint do
15
15
  gemspec.homepage = "http://github.com/tomafro/spraypaint.git"
16
16
  gemspec.authors = ['Tom Ward']
17
17
  end
18
+
19
+ Jeweler::GemcutterTasks.new
18
20
  rescue LoadError
19
21
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
20
22
  end
data/lib/spraypaint.rb CHANGED
@@ -47,13 +47,6 @@
47
47
  #
48
48
 
49
49
  module Spraypaint
50
- module Version
51
- MAJOR = 1
52
- MINOR = 0
53
- PATCH = 1
54
- STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
55
- end
56
-
57
50
  def self.activate_plugin
58
51
  ActiveRecord::Base.extend(ClassMethods)
59
52
  end
@@ -5,7 +5,7 @@ module Spraypaint::Behaviour
5
5
 
6
6
  def self.included(base)
7
7
  self.included_modules.each do |m|
8
- m.__send__ :included, base
8
+ m.send :included, base
9
9
  end
10
10
  end
11
11
  end
@@ -61,7 +61,7 @@ module Spraypaint::Behaviour::Manipulation
61
61
 
62
62
  module ClassMethods
63
63
  def tag_sanitizer
64
- @tag_sanitizer ||= Spraypaint::DefaultSanitizer.new
64
+ @tag_sanitizer ||= Spraypaint::Sanitizer.new
65
65
  end
66
66
 
67
67
  def tag_sanitizer=(sanitizer)
@@ -1,11 +1,17 @@
1
- module Spraypaint::Sanitizer
1
+ class Spraypaint::Sanitizer
2
+ include Spraypaint::SanitizerSupport
2
3
 
3
- # Sanitizes an array of tags, passing each one through #sanitize_tag and removing
4
- # all nils and duplicates.
5
-
6
- def sanitize_array(array)
7
- array.collect do |tag|
8
- sanitize_tag(tag)
9
- end.compact.uniq
4
+ attr_accessor :allowed_characters
5
+
6
+ def initialize(allowed_characters = /[\w -]/)
7
+ self.allowed_characters = allowed_characters
8
+ end
9
+
10
+ def sanitize_tag(tag)
11
+ return nil if tag.nil?
12
+ string = tag.strip
13
+ string = string.mb_chars.normalize(:d).gsub(/[^\0-\x80]/, '')
14
+ string = string.scan(self.allowed_characters).join
15
+ string.empty? ? nil : string.to_s
10
16
  end
11
17
  end
@@ -0,0 +1,11 @@
1
+ module Spraypaint::SanitizerSupport
2
+
3
+ # Sanitizes an array of tags, passing each one through #sanitize_tag and removing
4
+ # all nils and duplicates.
5
+
6
+ def sanitize_array(array)
7
+ array.collect do |tag|
8
+ sanitize_tag(tag)
9
+ end.compact.uniq
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ module Spraypaint
2
+ module Version
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ PATCH = 2
6
+ STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
+ end
8
+ end
data/spraypaint.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{spraypaint}
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tom Ward"]
12
- s.date = %q{2009-11-04}
12
+ s.date = %q{2009-11-05}
13
13
  s.description = %q{Simple tagging in a can}
14
14
  s.email = %q{tom@popdog.net}
15
15
  s.files = [
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
18
18
  "MIT-LICENSE",
19
19
  "Rakefile",
20
20
  "TODO",
21
- "VERSION.yml",
22
21
  "about.yml",
23
22
  "generators/spraypaint_migration/spraypaint_migration_generator.rb",
24
23
  "generators/spraypaint_migration/templates/spraypaint_migration.rb",
@@ -27,10 +26,11 @@ Gem::Specification.new do |s|
27
26
  "lib/spraypaint/behaviour/discovery.rb",
28
27
  "lib/spraypaint/behaviour/manipulation.rb",
29
28
  "lib/spraypaint/behaviour/persistence.rb",
30
- "lib/spraypaint/default_sanitizer.rb",
31
29
  "lib/spraypaint/model/tag.rb",
32
30
  "lib/spraypaint/model/tagging.rb",
33
31
  "lib/spraypaint/sanitizer.rb",
32
+ "lib/spraypaint/sanitizer_support.rb",
33
+ "lib/spraypaint/version.rb",
34
34
  "rails/init.rb",
35
35
  "spraypaint.gemspec",
36
36
  "test/config/boot.rb",
@@ -38,14 +38,11 @@ Gem::Specification.new do |s|
38
38
  "test/config/environment.rb",
39
39
  "test/config/environments/test.rb",
40
40
  "test/db/schema.rb",
41
- "test/spec/default_sanitizer_spec.rb",
42
41
  "test/spec/models/tag_spec.rb",
43
42
  "test/spec/models/tagging_spec.rb",
43
+ "test/spec/sanitizer_spec.rb",
44
44
  "test/spec/spec_helper.rb",
45
- "test/spec/spraypaint_spec.rb",
46
- "vendor/penknife/lib/penknife.rb",
47
- "vendor/penknife/lib/penknife/rake.rb",
48
- "vendor/penknife/lib/penknife/rake/plugin_tasks.rb"
45
+ "test/spec/spraypaint_spec.rb"
49
46
  ]
50
47
  s.homepage = %q{http://github.com/tomafro/spraypaint.git}
51
48
  s.rdoc_options = ["--charset=UTF-8"]
@@ -57,9 +54,9 @@ Gem::Specification.new do |s|
57
54
  "test/config/environment.rb",
58
55
  "test/config/environments/test.rb",
59
56
  "test/db/schema.rb",
60
- "test/spec/default_sanitizer_spec.rb",
61
57
  "test/spec/models/tag_spec.rb",
62
58
  "test/spec/models/tagging_spec.rb",
59
+ "test/spec/sanitizer_spec.rb",
63
60
  "test/spec/spec_helper.rb",
64
61
  "test/spec/spraypaint_spec.rb"
65
62
  ]
@@ -1,9 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Spraypaint::DefaultSanitizer do
3
+ describe Spraypaint::Sanitizer do
4
4
  describe '(with no arguments passed to constructor)' do
5
5
  before(:each) do
6
- @it = Spraypaint::DefaultSanitizer.new
6
+ @it = Spraypaint::Sanitizer.new
7
7
  end
8
8
 
9
9
  it "should strip surrounding whitespace from tag" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spraypaint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Ward
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-04 00:00:00 +00:00
12
+ date: 2009-11-05 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -27,7 +27,6 @@ files:
27
27
  - MIT-LICENSE
28
28
  - Rakefile
29
29
  - TODO
30
- - VERSION.yml
31
30
  - about.yml
32
31
  - generators/spraypaint_migration/spraypaint_migration_generator.rb
33
32
  - generators/spraypaint_migration/templates/spraypaint_migration.rb
@@ -36,10 +35,11 @@ files:
36
35
  - lib/spraypaint/behaviour/discovery.rb
37
36
  - lib/spraypaint/behaviour/manipulation.rb
38
37
  - lib/spraypaint/behaviour/persistence.rb
39
- - lib/spraypaint/default_sanitizer.rb
40
38
  - lib/spraypaint/model/tag.rb
41
39
  - lib/spraypaint/model/tagging.rb
42
40
  - lib/spraypaint/sanitizer.rb
41
+ - lib/spraypaint/sanitizer_support.rb
42
+ - lib/spraypaint/version.rb
43
43
  - rails/init.rb
44
44
  - spraypaint.gemspec
45
45
  - test/config/boot.rb
@@ -47,9 +47,9 @@ files:
47
47
  - test/config/environment.rb
48
48
  - test/config/environments/test.rb
49
49
  - test/db/schema.rb
50
- - test/spec/default_sanitizer_spec.rb
51
50
  - test/spec/models/tag_spec.rb
52
51
  - test/spec/models/tagging_spec.rb
52
+ - test/spec/sanitizer_spec.rb
53
53
  - test/spec/spec_helper.rb
54
54
  - test/spec/spraypaint_spec.rb
55
55
  has_rdoc: true
@@ -85,8 +85,8 @@ test_files:
85
85
  - test/config/environment.rb
86
86
  - test/config/environments/test.rb
87
87
  - test/db/schema.rb
88
- - test/spec/default_sanitizer_spec.rb
89
88
  - test/spec/models/tag_spec.rb
90
89
  - test/spec/models/tagging_spec.rb
90
+ - test/spec/sanitizer_spec.rb
91
91
  - test/spec/spec_helper.rb
92
92
  - test/spec/spraypaint_spec.rb
data/VERSION.yml DELETED
@@ -1,4 +0,0 @@
1
- ---
2
- :patch: 0
3
- :major: 1
4
- :minor: 0
@@ -1,17 +0,0 @@
1
- class Spraypaint::DefaultSanitizer
2
- include Spraypaint::Sanitizer
3
-
4
- attr_accessor :allowed_characters
5
-
6
- def initialize(allowed_characters = /[\w -]/)
7
- self.allowed_characters = allowed_characters
8
- end
9
-
10
- def sanitize_tag(tag)
11
- return nil if tag.nil?
12
- string = tag.strip
13
- string = string.mb_chars.normalize(:d).gsub(/[^\0-\x80]/, '')
14
- string = string.scan(self.allowed_characters).join
15
- string.empty? ? nil : string.to_s
16
- end
17
- end