# Tagz-5.0.1 -- processing instruction support

**URL:** <https://www.ruby-forum.com/t/tagz-5-0-1-processing-instruction-support/164174>\
**Category:** Ruby\
**Created:** [March 29, 2009, 12:49pm UTC](https://www.ruby-forum.com/t/tagz-5-0-1-processing-instruction-support/164174 "2009-03-29T12:49:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_SSTownley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@Andrew\_SSTownley](https://www.ruby-forum.com/u/Andrew_SSTownley)\
**Post date:** [March 29, 2009, 12:49pm UTC](https://www.ruby-forum.com/t/tagz-5-0-1-processing-instruction-support/164174/1 "2009-03-29T12:49:53Z")

</div>

Hi Ara,

I was actually working on another machine where I had to install tagz.  
I noticed this morning when I was trying to do a line-by-line  
comparison, that this machine had 5.0.1 instead of 5.0.0. It appears  
that the behavior is fixed by the change between 5.0.0 and 5.0.1.

Given this, I’ve re-patched 5.0.1 with the PI support (if anyone else  
cares), and included it below.

$ ruby a.rb  
hello  
worldhello  
world

Cheers,

ast

$ diff -u /usr/lib/ruby/gems/1.8/gems/tagz-5.0.1/lib/tagz.rb  
tagz-local.rb  
— /usr/lib/ruby/gems/1.8/gems/tagz-5.0.1/lib/tagz.rb 2009-03-28  
04:08:17.000000000 +0000  
+++ tagz-local.rb 2009-03-28 08:57:43.000000000 +0000  
@@ -5,7 +5,7 @@  
Tagz::VERSION = [  
Tagz::VERSION\_MAJOR = 5,  
Tagz::VERSION\_MINOR = 0,

- 

```
   Tagz::VERSION_TEENY = 1

```

- 

```
   Tagz::VERSION_TEENY = 0
 ].join('.')
 def Tagz.version() Tagz::VERSION end

```

end  
@@ -15,27 +15,7 @@
# open\_tag

# 
def tagz\_\_ name, \*argv, &block

- 

```
 options = argv.last.is_a?(Hash) ? argv.pop : {}

```

- 

```
 content = argv

```

- 
- 

```
 unless options.empty?

```

- 

```
   attributes = ' ' <<

```

- 

```
     options.map do |key, value|

```

- 

```
       key = XChar.escape key.to_s

```

- 

```
       value = XChar.escape value.to_s

```

- 

```
       if value =~ %r/"/

```

- 

```
         raise ArgumentError, value if value =~ %r/'/

```

- 

```
         value = "'#{ value }'"

```

- 

```
       else

```

- 

```
         raise ArgumentError, value if value =~ %r/"/

```

- 

```
         value = "\"#{ value }\""

```

- 

```
       end

```

- 

```
       [key, value].join('=')

```

- 

```
     end.join(' ')

```

- 

```
 else

```

- 

```
   attributes = ''

```

- 

```
 end

```

- 

- 

```
 attributes, content = process_attributes *argv, &block
 tagz.concat "<#{ name }#{ attributes }>"

 if content.empty?

```

## @@ -53,7 +33,6 @@ tagz \<\< value.to\_s unless(tagz.size \> size) tagz.concat “\</#{ name }\>” end

```
     end
   else
     tagz << content.join

```

@@ -74,6 +53,13 @@  
tagz.concat “\</#{ tag }\>”  
end

- 
# processing instruction
- 
# 
- def tagz\_? name, \*argv, &block
- 

```
 attributes, content = process_attributes *argv, &block

```

- 

```
 tagz.concat "<?#{ name }#{ attributes }?>"

```

- end
- 
# access tagz doc and enclose tagz operations

# 
def tagz document = nil, &block  
@@ -100,6 +86,8 @@  
def method\_missing m, \*a, &b  
strategy =  
case m.to\_s
- 

```
     when %r/^(.*[^?])_\?$/o

```

- 

```
       :processing_instruction
     when %r/^(.*[^_])_(!)?$/o
       :open_tag
     when %r/^_([^_].*)$/o

```

@@ -125,6 +113,9 @@  
m, bang = $1, $2  
b ||= lambda{} if bang  
tagz{ tagz\_\_(m, \*a, &b) }

- 

```
   when :processing_instruction

```

- 

```
     m = $1

```

- 

```
     tagz{ tagz_?(m, *a, &b) }
   when :close_tag
     m = $1
     tagz{ __tagz(m, *a, &b) }

```

@@ -141,6 +132,33 @@  
end  
end

- def process\_attributes \*argv, &block
- 

```
 options = argv.last.is_a?(Hash) ? argv.pop : {}

```

- 

```
 content = argv

```

- 
- 

```
 attributes = nil

```

- 
- 

```
 unless options.empty?

```

- 

```
   attributes = ' ' <<

```

- 

```
     options.map do |key, value|

```

- 

```
       key = XChar.escape key.to_s

```

- 

```
       value = XChar.escape value.to_s

```

- 

```
       if value =~ %r/"/

```

- 

```
         raise ArgumentError, value if value =~ %r/'/

```

- 

```
         value = "'#{ value }'"

```

- 

```
       else

```

- 

```
         raise ArgumentError, value if value =~ %r/"/

```

- 

```
         value = "\"#{ value }\""

```

- 

```
       end

```

- 

```
       [key, value].join('=')

```

- 

```
     end.join(' ')

```

- 

```
 else

```

- 

```
   attributes = ''

```

- 

```
 end

```

- 
- 

```
 [attributes, content]

```

- end
- class Document \< ::String  
def Document.for other  
Document === other ? other : Document.new(other.to\_s)

---

<div class="post-metadata">

**Author:** ![Andrew\_SSTownley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@Andrew\_SSTownley](https://www.ruby-forum.com/u/Andrew_SSTownley)\
**Post date:** [March 30, 2009, 7:01am UTC](https://www.ruby-forum.com/t/tagz-5-0-1-processing-instruction-support/164174/2 "2009-03-30T07:01:04Z")

</div>

On Mar 29, 5:48 am, “Andrew S. Townley” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi Ara,
> 
> I was actually working on another machine where I had to install tagz.  
> I noticed this morning when I was trying to do a line-by-line  
> comparison, that this machine had 5.0.1 instead of 5.0.0. It appears  
> that the behavior is fixed by the change between 5.0.0 and 5.0.1.
> 
> Given this, I’ve re-patched 5.0.1 with the PI support (if anyone else  
> cares), and included it below.

I love the beauty of open source as much as the next guy, but I’m  
thinking this is maybe not the best workflow for this type of  
collaboration. A few suggestions for better sharing of patches:

- Use the rubyforge tracker
- Get tagz set up on GitHub
- For god’s sake, send patches directly to Ara and only Ara, not to  
ruby-talk.
