rocket_tag 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -12,6 +12,24 @@ module RocketTag
12
12
  attr_writer :contexts
13
13
  attr_reader :klass
14
14
 
15
+ def self.parse_tags list
16
+ require 'csv'
17
+ if list.kind_of? String
18
+ # for some reason CSV parser cannot handle
19
+ #
20
+ # hello, "foo"
21
+ #
22
+ # but must be
23
+ #
24
+ # hello,"foo"
25
+
26
+ list = list.gsub /,\s+"/, ',"'
27
+ list = list.parse_csv.map &:strip
28
+ else
29
+ list
30
+ end
31
+ end
32
+
15
33
  def initialize klass
16
34
  @klass = klass
17
35
  @contexts = Set.new
@@ -168,6 +186,7 @@ module RocketTag
168
186
 
169
187
 
170
188
  define_method "#{context}=" do |list|
189
+ list = Manager.parse_tags list
171
190
 
172
191
  # Ensure the tags are loaded
173
192
  cache_tags
data/rocket_tag.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rocket_tag}
8
- s.version = "0.0.1"
8
+ s.version = "0.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 = [%q{Brad Phelan}]
@@ -6,6 +6,16 @@ describe TaggableModel do
6
6
  @model = TaggableModel.create
7
7
  end
8
8
 
9
+ describe "parsing" do
10
+ it "converts strings to arrays using ruby core lib CSV" do
11
+ m = TaggableModel.new :skills => %q%hello, is it me, you are looking for, cat%
12
+ m.skills.should == ["hello", "is it me", "you are looking for", "cat"]
13
+
14
+ m = TaggableModel.new :skills => %q%hello, "is it me, you are looking for", cat%
15
+ m.skills.should == ["hello", "is it me, you are looking for", "cat"]
16
+ end
17
+ end
18
+
9
19
  describe "#save" do
10
20
  it "persists the tags cache to the database" do
11
21
  @model.languages = ["a", "b", "c"]
@@ -22,9 +32,6 @@ describe TaggableModel do
22
32
  it "validates the model wrt to the context" do
23
33
  @model.languages = 100
24
34
  @model.save.should == false
25
- pp @model.errors.messages
26
-
27
-
28
35
  end
29
36
  end
30
37
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rocket_tag
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brad Phelan
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - ">="
145
145
  - !ruby/object:Gem::Version
146
- hash: 198466425924794403
146
+ hash: -3759555627206033387
147
147
  segments:
148
148
  - 0
149
149
  version: "0"