fabulator-xml 0.0.4 → 0.0.5

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/History.txt CHANGED
@@ -3,6 +3,7 @@
3
3
  * 1 minor enhancement
4
4
  * Bump minimum version of Fabulator
5
5
  * ActionLib => TagLib
6
+ * register_type => has_type
6
7
 
7
8
  === 0.0.3 2010-08-16
8
9
 
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ begin
7
7
  gem.email = "jgsmith@tamu.edu"
8
8
  gem.homepage = "http://github.com/jgsmith/ruby-fabulator-xml"
9
9
  gem.authors = ["James Smith"]
10
- gem.add_dependency('fabulator', '>= 0.0.7')
10
+ gem.add_dependency('fabulator', '>= 0.0.9')
11
11
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
12
12
  end
13
13
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -13,7 +13,7 @@ Feature: Type unification
13
13
  And the prefix x as "http://dh.tamu.edu/ns/fabulator/xml/1.0#"
14
14
  When I run the expression (x:parse-string("<foo />")/@type)
15
15
  Then I should get 1 item
16
- And item 0 should be [f:uri-prefix('x') + 'document']
16
+ And item 0 should be [f:uri('x:document')]
17
17
 
18
18
  Scenario: Get the type of a parsed string value
19
19
  Given a context
@@ -21,7 +21,7 @@ Feature: Type unification
21
21
  And the prefix x as "http://dh.tamu.edu/ns/fabulator/xml/1.0#"
22
22
  When I run the expression (x:document("<foo />")/@type)
23
23
  Then I should get 1 item
24
- And item 0 should be [f:uri-prefix('x') + 'document']
24
+ And item 0 should be [f:uri('x:document')]
25
25
 
26
26
  Scenario: Get the value of an element
27
27
  Given a context
@@ -29,5 +29,5 @@ Feature: Type unification
29
29
  And the prefix x as "http://dh.tamu.edu/ns/fabulator/xml/1.0#"
30
30
  When I run the expression (x:path(x:parse-string("<foo><bar>baz</bar></foo>"), "/foo/bar")/@type)
31
31
  Then I should get 1 item
32
- And item 0 should be [f:uri-prefix('x') + 'node']
32
+ And item 0 should be [f:uri('x:node')]
33
33
 
@@ -8,37 +8,36 @@ module Fabulator
8
8
 
9
9
  namespace XML_NS
10
10
 
11
- register_type 'document', {
12
- :to => [
13
- { :type => [ FAB_NS, 'string' ],
14
- :weight => 1.0,
15
- :convert => lambda { |x| x.anon_node(x.value.to_s, [ FAB_NS, 'string' ]) }
16
- }
17
- ],
18
- :from => [
19
- { :type => [ FAB_NS, 'string' ],
20
- :weight => 1.0,
21
- :convert => lambda { |x| (x.anon_node(LibXML::XML::Document.string(x.value), [ XML_NS, 'document' ]) rescue nil) }
22
- }
23
- ]
24
- }
11
+ has_type :document do
12
+ going_to [ FAB_NS, 'string' ] do
13
+ weight 1.0
14
+ converting do |x|
15
+ x.root.value.to_s
16
+ end
17
+ end
18
+
19
+ coming_from [ FAB_NS, 'string' ] do
20
+ weight 1.0
21
+ converting do |x|
22
+ (x.root.anon_node(LibXML::XML::Document.string(x.root.value), [ XML_NS, 'document' ]) rescue nil)
23
+ end
24
+ end
25
+ end
25
26
 
26
- register_type 'node', {
27
- :to => [
28
- { :type => [ FAB_NS, 'string' ],
29
- :weight => 1.0,
30
- :convert => lambda { |x|
31
- x.anon_node(
32
- (
33
- x.value.is_a?(LibXML::XML::Node) ? x.value.content :
34
- x.value.is_a?(LibXML::XML::Attr) ? x.value.value :
35
- x.value.to_s
36
- ), [ FAB_NS, 'string' ]
37
- )
38
- }
39
- }
40
- ]
41
- }
27
+ has_type :node do
28
+ going_to [ FAB_NS, 'string' ] do
29
+ weight 1.0
30
+ converting do |x|
31
+ x.root.anon_node(
32
+ (
33
+ x.root.value.is_a?(LibXML::XML::Node) ? x.root.value.content :
34
+ x.root.value.is_a?(LibXML::XML::Attr) ? x.root.value.value :
35
+ x.root.value.to_s
36
+ ), [ FAB_NS, 'string' ]
37
+ )
38
+ end
39
+ end
40
+ end
42
41
 
43
42
  function 'parse-string', [ XML_NS, 'document' ] do |ctx, args|
44
43
  args[0].collect { |a|
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/fabulator-xml.rb'}"
9
+ puts "Loading fabulator-xml gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fabulator-xml
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Smith
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-07 00:00:00 +00:00
18
+ date: 2010-10-26 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 17
29
+ hash: 13
30
30
  segments:
31
31
  - 0
32
32
  - 0
33
- - 7
34
- version: 0.0.7
33
+ - 9
34
+ version: 0.0.9
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  description: XML functions and types for the Fabulator engine.
@@ -58,6 +58,9 @@ files:
58
58
  - lib/fabulator/xml.rb
59
59
  - lib/fabulator/xml/actions.rb
60
60
  - lib/fabulator/xml/version.rb
61
+ - script/console
62
+ - script/destroy
63
+ - script/generate
61
64
  - test/test_fabulator-xml.rb
62
65
  - test/test_helper.rb
63
66
  has_rdoc: true