active_text 0.0.6 → 0.0.7

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.6
1
+ 0.0.7
data/active_text.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active_text}
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ramon Tayag"]
12
- s.date = %q{2011-04-15}
12
+ s.date = %q{2011-04-16}
13
13
  s.description = %q{Aims to be able to read and replace "variables" in text in an active record manner. I don't claim that it behaves exactly like ActiveRecord - that is a much more complex beast than this will ever be.}
14
14
  s.email = %q{ramon@tayag.net}
15
15
  s.extra_rdoc_files = [
@@ -18,6 +18,7 @@ module ActiveText
18
18
  @text.scan(/^\${1}(.+): .+;/).flatten.each do |variable_name|
19
19
  if has_context?(variable_name)
20
20
  variable = ActiveText::Variable.new(variable_name, context_of(variable_name), @options[:comment])
21
+ #puts "Instantiating variable: :#{variable_name} => #{variable.value}"
21
22
  @variables.merge!({variable_name.to_sym => variable})
22
23
  end
23
24
  end
@@ -31,7 +32,7 @@ module ActiveText
31
32
  end
32
33
 
33
34
  # Used to update the text
34
- def render
35
+ def apply
35
36
  @variables.each do |key, var|
36
37
  @text.gsub!(/^\$#{key}: .+;/, %Q($#{key}: #{var.value};))
37
38
  end
@@ -39,13 +39,13 @@ $mbc2: "http://someurl.com/image.jpg";}
39
39
  @s.mbc2 = %Q("Another URL")
40
40
  @s.mbc2.should == %Q("Another URL")
41
41
 
42
- rendered_text = @s.render
42
+ rendered_text = @s.apply
43
43
  rendered_text.should_not match(/http:\/\/someurl\.com\/image\.jpg/)
44
44
  rendered_text.should match(/\$mbc2: "Another URL";/)
45
45
 
46
46
  @s.mbc2 = %Q("Some third URL")
47
47
  @s.mbc2.should == %Q("Some third URL")
48
- rendered_text = @s.render
48
+ rendered_text = @s.apply
49
49
  rendered_text.should_not match(/\$mbc2: "Another URL";/)
50
50
  rendered_text.should match(/\$mbc2: "Some third URL";/)
51
51
  end
@@ -61,7 +61,7 @@ $mbc2: "http://someurl.com/image.jpg";}
61
61
  $mbc2: "Another URL";}
62
62
  @s = ActiveText::Base.new(text_old)
63
63
  @s.mbc2 = %Q("Another URL")
64
- @s.render.should == text_new
64
+ @s.apply.should == text_new
65
65
  end
66
66
  end
67
67
 
@@ -113,6 +113,11 @@ $mbc: #555;}
113
113
  @s.update_attributes(:mbc2 => %Q("Another URL"), :mbc => nil)
114
114
  @s.mbc2.should == %Q("Another URL")
115
115
  @s.mbc.should == "#555"
116
+ # even after reinstantiation
117
+ @s = ActiveText::Base.new(text)
118
+ @s.update_attributes({"mbc" => "#444"})
119
+ @s.mbc2.should == %Q("http://someurl.com/image.jpg")
120
+ @s.mbc.should == "#444"
116
121
  end
117
122
 
118
123
  it "should have setter method for variables" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_text
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ramon Tayag
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-15 00:00:00 +08:00
18
+ date: 2011-04-16 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency