rid 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rid/makros.rb CHANGED
@@ -73,24 +73,28 @@ module Rid
73
73
  # injects a makro and yields block with the filenames for found makros
74
74
  #
75
75
  def inject_makro!(makro, &block)
76
+ matcher = /\/\/\s*!#{makro}\s+[\S]+$/
77
+
76
78
  hash.flatten.each do |key, value|
77
79
  next unless value.is_a?(String)
78
80
 
79
81
  # do not try to inject makros in attachments, libs and injections array
80
82
  next if key =~ /^_attachments|libs|injections/
81
83
 
82
- new_value = value.gsub(/\/\/\s*!#{makro}\s+[\S]+$/) do |match|
83
- start = Regexp.last_match.begin(0)
84
- filename = match.sub(/^.*!#{makro}\s*(\S+).*$/, '\1')
84
+ while value =~ matcher do
85
+ value = value.sub(matcher) do |match|
86
+ start = Regexp.last_match.begin(0)
87
+ filename = match.sub(/^.*!#{makro}\s*(\S+).*$/, '\1')
85
88
 
86
- value = block.call(filename)
89
+ value = block.call(filename)
87
90
 
88
- store_injection makro, key, filename, start, value.size
91
+ store_injection makro, key, filename, start, value.size
89
92
 
90
- value
93
+ value
94
+ end
91
95
  end
92
96
 
93
- self.hash.update_at key, new_value
97
+ self.hash.update_at key, value
94
98
  end
95
99
  end
96
100
 
data/lib/rid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rid
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
data/rid.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rid}
8
- s.version = "0.5.1"
8
+ s.version = "0.5.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Johannes J. Schmidt"]
12
- s.date = %q{2010-03-16}
12
+ s.date = %q{2010-03-17}
13
13
  s.default_executable = %q{rid}
14
14
  s.description = %q{With Couch you can easy build a standalone CouchDB application. Couch aims to bring some of the Rails beauty to CouchDB. Currently Couch supports Rails style Generators you will love, using the same awesome Thor library used in Rails3.}
15
15
  s.email = %q{schmidt@netzmerk.com}
@@ -80,5 +80,15 @@ describe "Makros" do
80
80
  @doc.hash["key"].should == "// !json hash/json.json"
81
81
  end
82
82
  end
83
+
84
+ describe "many makros" do
85
+ it "should reject properly" do
86
+ @doc.hash = { "lib" => { "code.js" => "value", "other.js" => "value" }, "key" => "// !code code.js\n// !code other.js" }
87
+ @doc.inject_makros!
88
+ @doc.hash["injections"].should == [{"makro"=>"code", "size"=>5, "lib"=>"code.js", "start"=>0, "target"=>"key"}, {"makro"=>"code", "size"=>5, "lib"=>"other.js", "start"=>6, "target"=>"key"}]
89
+ @doc.reject_makros!
90
+ @doc.hash["key"].should == "// !code code.js\n// !code other.js"
91
+ end
92
+ end
83
93
  end
84
94
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 1
9
- version: 0.5.1
8
+ - 2
9
+ version: 0.5.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Johannes J. Schmidt
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-16 00:00:00 +01:00
17
+ date: 2010-03-17 00:00:00 +01:00
18
18
  default_executable: rid
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency