fabulator-xml 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -2,3 +2,10 @@
2
2
 
3
3
  * 1 major enhancement:
4
4
  * Initial release
5
+
6
+ === 0.0.2
7
+
8
+ * 2 minor enhancement:
9
+ * Noted dependence on fabulator gem
10
+ * Included fabulator-xml.rb so nothing complains about missing files
11
+ when being loaded.
data/Rakefile CHANGED
@@ -1,30 +1,56 @@
1
- $: << File.expand_path(File.dirname(__FILE__))+'/lib'
2
- $: << File.expand_path(File.dirname(__FILE__))+'/../fabulator/lib'
3
-
4
- require 'rubygems'
5
- gem 'hoe', '>= 2.1.0'
6
- require 'hoe'
7
- require 'fileutils'
8
- require 'fabulator'
9
- require './lib/fabulator/xml'
10
-
11
- Hoe.plugin :newgem
12
- # Hoe.plugin :website
13
- Hoe.plugin :cucumberfeatures
14
-
15
- # Generate all the Rake tasks
16
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
17
- $hoe = Hoe.spec 'fabulator-xml' do
18
- self.version = Fabulator::Xml::VERSION::STRING
19
- self.developer 'James Smith', 'jgsmith@tamu.edu'
20
- self.rubyforge_name = self.name # TODO this is default value
21
- # self.extra_deps = [['activesupport','>= 2.0.2']]
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gem|
4
+ gem.name = "fabulator-xml"
5
+ gem.summary = %Q{XML functions and types for the Fabulator engine.}
6
+ gem.description = %Q{XML functions and types for the Fabulator engine.}
7
+ gem.email = "jgsmith@tamu.edu"
8
+ gem.homepage = "http://github.com/jgsmith/ruby-fabulator-xml"
9
+ gem.authors = ["James Smith"]
10
+ gem.add_dependency('fabulator', '>= 0.0.1')
11
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
12
+ end
13
+ rescue LoadError
14
+ puts "Jeweler (or a dependency) not available. This is only required if you plan to package fabulator-exhibit as a gem."
15
+ end
16
+
17
+ require 'rake'
18
+ require 'rake/rdoctask'
19
+ require 'rake/testtask'
20
+
21
+ require 'cucumber'
22
+ require 'cucumber/rake/task'
23
+
24
+ task :features => 'spec:integration'
22
25
 
26
+ namespace :spec do
27
+
28
+ desc "Run the Cucumber features"
29
+ Cucumber::Rake::Task.new(:integration) do |t|
30
+ t.fork = true
31
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
32
+ # t.feature_pattern = "#{extension_root}/features/**/*.feature"
33
+ t.profile = "default"
34
+ end
35
+
36
+ end
37
+
38
+ desc 'Generate documentation for the fabulator exhibit extension.'
39
+ Rake::RDocTask.new(:rdoc) do |rdoc|
40
+ rdoc.rdoc_dir = 'rdoc'
41
+ rdoc.title = 'FabulatorExhibitExtension'
42
+ rdoc.options << '--line-numbers' << '--inline-source'
43
+ rdoc.rdoc_files.include('README')
44
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
45
  end
24
46
 
25
- require 'newgem/tasks'
26
- Dir['tasks/**/*.rake'].each { |t| load t }
47
+ # For extensions that are in transition
48
+ desc 'Test the fabulator exhibit extension.'
49
+ Rake::TestTask.new(:test) do |t|
50
+ t.libs << 'lib'
51
+ t.pattern = 'test/**/*_test.rb'
52
+ t.verbose = true
53
+ end
27
54
 
28
- # TODO - want other tests/tasks run by default? Add them to the list
29
- # remove_task :default
30
- # task :default => [:spec, :features]
55
+ # Load any custom rakefiles for extension
56
+ Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -0,0 +1,104 @@
1
+ require 'yaml'
2
+
3
+ Transform /^(expression|context) \((.*)\)$/ do |n, arg|
4
+ @namespaces ||= { }
5
+ @parser ||= Fabulator::Expr::Parser.new
6
+ @parser.parse(arg, @context)
7
+ end
8
+
9
+ Transform /^\[(.*)\]$/ do |arg|
10
+ @parser ||= Fabulator::Expr::Parser.new
11
+ @parser.parse(arg, @context)
12
+ end
13
+
14
+ Transform /^(\d+)$/ do |arg|
15
+ arg.to_i
16
+ end
17
+
18
+ Given 'a context' do
19
+ @roots ||= { }
20
+ @data ||= Fabulator::Expr::Node.new('data', @roots, nil, [])
21
+ @roots['data'] ||= @data
22
+ @context ||= Fabulator::Expr::Context.new
23
+ @context.root = @data
24
+ @parser ||= Fabulator::Expr::Parser.new
25
+ end
26
+
27
+ Given /the prefix (\S+) as "([^"]+)"/ do |p,h|
28
+ @context ||= Fabulator::Expr::Context.new
29
+ @context.set_ns(p, h)
30
+ end
31
+
32
+ Given /that (\[.*\]) is set to (\[.*\])/ do |l,r|
33
+ @context.set_value(l, r)
34
+ end
35
+
36
+ When /I run the (expression \(.*\)) in the (context \(.*\))/ do |exp, cp|
37
+ @expr = exp
38
+ if cp.nil? || cp == ''
39
+ @result = []
40
+ @cp = @context.root
41
+ else
42
+ @cp = cp.run(@context).first || @context.root
43
+ @result = @expr.run(@context.with_root(@cp))
44
+ end
45
+ end
46
+
47
+ When /I run the (expression \(.*\))/ do |exp|
48
+ ## assume '/' as the context here
49
+ @expr = exp
50
+ @cp = @data
51
+ #puts YAML::dump(@expr)
52
+ @result = @expr.run(@context.with_root(@cp))
53
+ #puts YAML::dump(@result)
54
+ end
55
+
56
+ When /I unify the types? (.*)/ do |ts|
57
+ types = ts.split(/\s*,\s*/)
58
+ typea = types.collect { |t|
59
+ pn = t.split(/:/, 2)
60
+ [ @context.get_ns(pn[0]), pn[1] ]
61
+ }
62
+ @type_result = Fabulator::ActionLib.unify_types(
63
+ types.collect { |t|
64
+ pn = t.split(/:/, 2)
65
+ [ @context.get_ns(pn[0]), pn[1] ]
66
+ }
67
+ )
68
+ end
69
+
70
+ Then /I should get the type (.*)/ do |t|
71
+ pn = t.split(/:/, 2)
72
+ @type_result[0].should == @context.get_ns(pn[0])
73
+ @type_result[1].should == pn[1]
74
+ end
75
+
76
+ Then /I should get (\d+) items?/ do |count|
77
+ @result.length.should == count
78
+ end
79
+
80
+ Then /item (\d+) should be (\[.*\])/ do |i,t|
81
+ test = t.run(@context.with_root(@cp)).first
82
+ #puts "Result: #{@result[i.to_i].to_s.class.to_s}"
83
+ @result[i.to_i].to_s.should == test.to_s
84
+ end
85
+
86
+ Then /item (\d+) should be false/ do |i|
87
+ (!!@result[i.to_i].value).should == false
88
+ end
89
+
90
+ Then /item (\d+) should be true/ do |i|
91
+ (!!@result[i.to_i].value).should == true
92
+ end
93
+
94
+ Then /the (expression \(.*\)) should equal (\[.*\])/ do |x, y|
95
+ a = x.run(@context)
96
+ b = y.run(@context)
97
+ #puts YAML::dump(a)
98
+ #puts YAML::dump(b)
99
+ a.first.value.should == b.first.value
100
+ end
101
+
102
+ Then /the (expression \(.*\)) should be nil/ do |x|
103
+ x.run(@context).first.should == nil
104
+ end
@@ -0,0 +1,31 @@
1
+ Given /the statemachine/ do |doc_xml|
2
+ doc = LibXML::XML::Document.string doc_xml
3
+
4
+ @roots ||= { }
5
+ @namespaces ||= { }
6
+ @data ||= Fabulator::Expr::Node.new('data', @roots, nil, [])
7
+ @roots['data'] ||= @data
8
+ @context ||= Fabulator::Expr::Context.new
9
+ @context.root = @data
10
+
11
+ @parser ||= Fabulator::Expr::Parser.new
12
+ if @sm.nil?
13
+ @sm = Fabulator::Core::StateMachine.new.compile_xml(doc) #, @context)
14
+ else
15
+ @sm.compile_xml(doc) #, @context)
16
+ end
17
+ @sm.init_context(@context)
18
+ end
19
+
20
+ When /I run it with the following params:/ do |param_table|
21
+ params = { }
22
+ param_table.hashes.each do |hash|
23
+ params[hash['key']] = hash['value']
24
+ end
25
+ @sm.run(params)
26
+ #puts YAML::dump(@sm)
27
+ end
28
+
29
+ Then /it should be in the '(.*)' state/ do |s|
30
+ @sm.state.should == s
31
+ end
@@ -0,0 +1,8 @@
1
+ # This file makes it possible to install RubyCAS-Client as a Rails plugin.
2
+
3
+ $: << File.expand_path(File.dirname(__FILE__))+'/../../lib'
4
+ $: << File.expand_path(File.dirname(__FILE__))+'/../../../fabulator/lib'
5
+
6
+ require 'fabulator'
7
+ require 'fabulator/xml'
8
+ require 'spec/expectations'
@@ -0,0 +1,33 @@
1
+ @types
2
+ Feature: Type unification
3
+
4
+ Scenario: A single type
5
+ Given the prefix f as "http://dh.tamu.edu/ns/fabulator/1.0#"
6
+ And the prefix x as "http://dh.tamu.edu/ns/fabulator/xml/1.0#"
7
+ When I unify the types f:string, x:document
8
+ Then I should get the type f:string
9
+
10
+ Scenario: Get the type of a parsed string value
11
+ Given a context
12
+ And the prefix f as "http://dh.tamu.edu/ns/fabulator/1.0#"
13
+ And the prefix x as "http://dh.tamu.edu/ns/fabulator/xml/1.0#"
14
+ When I run the expression (x:parse-string("<foo />")/@type)
15
+ Then I should get 1 item
16
+ And item 0 should be [f:uri-prefix('x') + 'document']
17
+
18
+ Scenario: Get the type of a parsed string value
19
+ Given a context
20
+ And the prefix f as "http://dh.tamu.edu/ns/fabulator/1.0#"
21
+ And the prefix x as "http://dh.tamu.edu/ns/fabulator/xml/1.0#"
22
+ When I run the expression (x:document("<foo />")/@type)
23
+ Then I should get 1 item
24
+ And item 0 should be [f:uri-prefix('x') + 'document']
25
+
26
+ Scenario: Get the value of an element
27
+ Given a context
28
+ And the prefix f as "http://dh.tamu.edu/ns/fabulator/1.0#"
29
+ And the prefix x as "http://dh.tamu.edu/ns/fabulator/xml/1.0#"
30
+ When I run the expression (x:path(x:parse-string("<foo><bar>baz</bar></foo>"), "/foo/bar")/@type)
31
+ Then I should get 1 item
32
+ And item 0 should be [f:uri-prefix('x') + 'node']
33
+
@@ -0,0 +1,35 @@
1
+ Feature: XPath evaluation
2
+
3
+ @1
4
+ Scenario: Get the value of an element
5
+ Given a context
6
+ And the prefix f as "http://dh.tamu.edu/ns/fabulator/1.0#"
7
+ And the prefix x as "http://dh.tamu.edu/ns/fabulator/xml/1.0#"
8
+ When I run the expression (x:path(x:parse-string("<foo><bar>baz</bar></foo>"), "/foo/bar"))
9
+ Then I should get 1 item
10
+ And item 0 should be ['baz']
11
+
12
+ Scenario: Get the value of an element without prior parsing
13
+ Given a context
14
+ And the prefix f as "http://dh.tamu.edu/ns/fabulator/1.0#"
15
+ And the prefix x as "http://dh.tamu.edu/ns/fabulator/xml/1.0#"
16
+ When I run the expression (x:path("<foo><bar>baz</bar></foo>", "/foo/bar"))
17
+ Then I should get 1 item
18
+ And item 0 should be ['baz']
19
+
20
+ Scenario: Get the value of an element without prior parsing
21
+ Given a context
22
+ And the prefix f as "http://dh.tamu.edu/ns/fabulator/1.0#"
23
+ And the prefix x as "http://dh.tamu.edu/ns/fabulator/xml/1.0#"
24
+ When I run the expression (let $d := x:document("<foo><bar>baz</bar></foo>"); x:path($d, "/foo/bar"))
25
+ Then I should get 1 item
26
+ And item 0 should be ['baz']
27
+
28
+ Scenario: Get the value of an element with namespaces
29
+ Given a context
30
+ And the prefix f as "http://dh.tamu.edu/ns/fabulator/1.0#"
31
+ And the prefix x as "http://dh.tamu.edu/ns/fabulator/xml/1.0#"
32
+ When I run the expression (x:path(x:parse-string("<g:foo xmlns:g='http://dh.tamu.edu/ns/fabulator/1.0#'><g:bar>baz</g:bar></g:foo>"), "/f:foo/f:bar"))
33
+ Then I should get 1 item
34
+ And item 0 should be ['baz']
35
+
File without changes
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: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Smith
@@ -15,59 +15,45 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-07 00:00:00 +00:00
18
+ date: 2010-08-10 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rubyforge
22
+ name: fabulator
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 7
29
+ hash: 29
30
30
  segments:
31
- - 2
32
31
  - 0
33
- - 4
34
- version: 2.0.4
35
- type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: hoe
39
- prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 21
46
- segments:
47
- - 2
48
- - 6
32
+ - 0
49
33
  - 1
50
- version: 2.6.1
51
- type: :development
52
- version_requirements: *id002
53
- description: |-
54
- XML functions and types for the Fabulator engine.
55
-
56
- Namespace: http://dh.tamu.edu/ns/fabulator/xml/1.0#
57
- email:
58
- - jgsmith@tamu.edu
34
+ version: 0.0.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: XML functions and types for the Fabulator engine.
38
+ email: jgsmith@tamu.edu
59
39
  executables: []
60
40
 
61
41
  extensions: []
62
42
 
63
43
  extra_rdoc_files:
64
- - History.txt
65
- - Manifest.txt
44
+ - README.rdoc
66
45
  files:
67
46
  - History.txt
68
47
  - Manifest.txt
69
48
  - README.rdoc
70
49
  - Rakefile
50
+ - VERSION
51
+ - features/step_definitions/expression_steps.rb
52
+ - features/step_definitions/xml_steps.rb
53
+ - features/support/env.rb
54
+ - features/types.feature
55
+ - features/xpath.feature
56
+ - lib/fabulator-xml.rb
71
57
  - lib/fabulator/xml.rb
72
58
  - lib/fabulator/xml/actions.rb
73
59
  - lib/fabulator/xml/version.rb
@@ -79,8 +65,7 @@ licenses: []
79
65
 
80
66
  post_install_message:
81
67
  rdoc_options:
82
- - --main
83
- - README.rdoc
68
+ - --charset=UTF-8
84
69
  require_paths:
85
70
  - lib
86
71
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -103,11 +88,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
88
  version: "0"
104
89
  requirements: []
105
90
 
106
- rubyforge_project: fabulator-xml
91
+ rubyforge_project:
107
92
  rubygems_version: 1.3.7
108
93
  signing_key:
109
94
  specification_version: 3
110
- summary: XML functions and types for the Fabulator engine
95
+ summary: XML functions and types for the Fabulator engine.
111
96
  test_files:
112
97
  - test/test_fabulator-xml.rb
113
98
  - test/test_helper.rb