fabulator-exhibit 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 ADDED
@@ -0,0 +1,14 @@
1
+ === 0.0.1 2010-03-01
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
5
+
6
+ === 0.0.2
7
+
8
+ * 1 major enhancement:
9
+ * <ex:item/> now takes @ex:mode with values 'add' or 'remove' in order
10
+ to add or remove items from a database. The default is 'add'. Only
11
+ an @ex:id is required if 'remove'ing.
12
+
13
+ * 1 minor enhancement:
14
+ * Document dependence on uuid gem in gem spec
data/README.rdoc CHANGED
@@ -35,7 +35,7 @@ This Fabulator extension provides to an Exhibit-style database, but does
35
35
  not provide actual storage. The embedding framework will need to define
36
36
  several functions:
37
37
 
38
- === Fabulator::Exhibit::Action::Lib.fetch_database(name)
38
+ === Fabulator::Exhibit::Actions::Lib.fetch_database(name)
39
39
 
40
40
  This function should return the Exhibit database. It needs to look like
41
41
  the following data structure:
@@ -46,7 +46,7 @@ the following data structure:
46
46
  :items => { }
47
47
  }
48
48
 
49
- === Fabulator::Exhibit::Action::Lib.store_database(name, data)
49
+ === Fabulator::Exhibit::Actions::Lib.store_database(name, data)
50
50
 
51
51
  This function should store the data for later retrieval. The data is provided
52
52
  in the same format it is returned by the fetch_database function.
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gem|
4
+ gem.name = "fabulator-exhibit"
5
+ gem.summary = %Q{Fabulator Extension providing Exhibit-style NoSQL databases.}
6
+ gem.description = %Q{Provides language extensions to manage Exhibit-style NoSQL databases.}
7
+ gem.email = "jgsmith@tamu.edu"
8
+ gem.homepage = "http://github.com/jgsmith/ruby-fabulator-exhibit"
9
+ gem.authors = ["James Smith"]
10
+ gem.add_dependency('fabulator', '>= 0.0.1')
11
+ gem.add_dependency('uuid', '>= 2.1.0')
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ end
14
+ rescue LoadError
15
+ puts "Jeweler (or a dependency) not available. This is only required if you plan to package fabulator-exhibit as a gem."
16
+ end
17
+
18
+ require 'rake'
19
+ require 'rake/rdoctask'
20
+ require 'rake/testtask'
21
+
22
+ require 'cucumber'
23
+ require 'cucumber/rake/task'
24
+
25
+ task :features => 'spec:integration'
26
+
27
+ namespace :spec do
28
+
29
+ desc "Run the Cucumber features"
30
+ Cucumber::Rake::Task.new(:integration) do |t|
31
+ t.fork = true
32
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
33
+ # t.feature_pattern = "#{extension_root}/features/**/*.feature"
34
+ t.profile = "default"
35
+ end
36
+
37
+ end
38
+
39
+ desc 'Generate documentation for the fabulator exhibit extension.'
40
+ Rake::RDocTask.new(:rdoc) do |rdoc|
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = 'FabulatorExhibitExtension'
43
+ rdoc.options << '--line-numbers' << '--inline-source'
44
+ rdoc.rdoc_files.include('README')
45
+ rdoc.rdoc_files.include('lib/**/*.rb')
46
+ end
47
+
48
+ # For extensions that are in transition
49
+ desc 'Test the fabulator exhibit extension.'
50
+ Rake::TestTask.new(:test) do |t|
51
+ t.libs << 'lib'
52
+ t.pattern = 'test/**/*_test.rb'
53
+ t.verbose = true
54
+ end
55
+
56
+ # Load any custom rakefiles for extension
57
+ Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -1,7 +1,9 @@
1
1
  Feature: Simple database items
2
2
 
3
3
  Scenario: simple database with one item
4
- Given the statemachine
4
+ Given a context
5
+ And the prefix f as "http://dh.tamu.edu/ns/fabulator/1.0#"
6
+ And the statemachine
5
7
  """
6
8
  <f:application xmlns:f="http://dh.tamu.edu/ns/fabulator/1.0#"
7
9
  xmlns:ex="http://dh.tamu.edu/ns/fabulator/exhibit/1.0#"
@@ -15,6 +17,7 @@ Feature: Simple database items
15
17
  <ex:database>
16
18
  <f:value f:path="/f" f:select="ex:item('foo')" />
17
19
  </ex:database>
20
+ <f:value f:path="/g" f:select="ex:items()" />
18
21
  </f:application>
19
22
  """
20
23
  And using the 'test' database
@@ -23,3 +26,4 @@ Feature: Simple database items
23
26
  And the item 'foo' should have the label 'fooLabel'
24
27
  And the item 'foo' should have the property 'bar' as 'baz'
25
28
  And the expression (/f/bar) should equal ['baz']
29
+ And the expression (/g/foo/bar) should equal ['baz']
@@ -96,6 +96,9 @@ Then /the (expression \(.*\)) should equal (\[.*\])/ do |x, y|
96
96
  b = y.run(@context)
97
97
  #puts YAML::dump(a)
98
98
  #puts YAML::dump(b)
99
+ #puts @parser.parse('f:dump(/)', @context).run(@context).first.to_s
100
+
101
+
99
102
  a.first.value.should == b.first.value
100
103
  end
101
104
 
@@ -9,6 +9,7 @@ module Fabulator
9
9
  attribute :id, :eval => true, :static => false
10
10
  attribute :type, :static => false, :inherited => true
11
11
  attribute :label, :eval => true, :static => false
12
+ attribute :mode, :static => true, :default => 'add'
12
13
 
13
14
  has_select
14
15
  has_actions
@@ -18,19 +19,23 @@ module Fabulator
18
19
  items = @select.run(ctx)
19
20
 
20
21
  db = @database.run(ctx).first.to_s
21
-
22
+
22
23
  items.each do |item|
23
24
  info = Fabulator::Exhibit::Actions::Lib.accumulate_item_info do
24
25
  @actions.run(ctx.with_root(item))
25
26
  end
26
27
  info['id'] = (@id.run(ctx.with_root(item)).first.to_s rescue nil)
27
- if info['id'].nil?
28
- @@uuid ||= UUID.new
29
- info['id'] = @@uuid.generate(:compact)
28
+ if @mode == 'add'
29
+ if info['id'].nil?
30
+ @@uuid ||= UUID.new
31
+ info['id'] = @@uuid.generate(:compact)
32
+ end
33
+ info['type'] = @type.run(ctx.with_root(item)).first.to_s
34
+ info['label'] = @label.run(ctx.with_root(item)).first.to_s
35
+ Fabulator::Exhibit::Actions::Lib.add_info(db, :items, info)
36
+ elsif @mode == 'remove' && !info['id'].nil?
37
+ Fabulator::Exhibit::Actions::Lib.remove_info(db, :items, info['id'])
30
38
  end
31
- info['type'] = @type.run(ctx.with_root(item)).first.to_s
32
- info['label'] = @label.run(ctx.with_root(item)).first.to_s
33
- Fabulator::Exhibit::Actions::Lib.add_info(db, :items, info)
34
39
  end
35
40
  end
36
41
  end
@@ -90,7 +90,7 @@ require 'fabulator/exhibit/actions/value'
90
90
  args.collect{ |a|
91
91
  id = a.to_s
92
92
  i = db[:items][id]
93
- r = ctx.root.anon_node(id)
93
+ r = ctx.root.anon_node(nil)
94
94
  r.name = id
95
95
  i.each_pair do |k,v|
96
96
  next if k == "id"
@@ -103,11 +103,13 @@ require 'fabulator/exhibit/actions/value'
103
103
  }
104
104
  end
105
105
 
106
+ ## need to make this an iterator
106
107
  function 'items' do |ctx, args|
107
- db = Fabulator::Exhibit::Actions::Lib.get_database(args.first.to_s)
108
- db[:items].collect{ |item|
109
- i = ctx.anon_node(item["id"])
110
- i.name = item["id"]
108
+ nom = ctx.attribute(EXHIBIT_NS, 'database', { :inherited => true, :static => true })
109
+ db = Fabulator::Exhibit::Actions::Lib.get_database(nom)
110
+ ret = ctx.root.anon_node(nil)
111
+ db[:items].each_pair{ |id, item|
112
+ i = ret.create_child(id, nil)
111
113
  item.each_pair do |k,v|
112
114
  next if k == "id"
113
115
  v = [ v ] unless v.is_a?(Array)
@@ -115,8 +117,8 @@ require 'fabulator/exhibit/actions/value'
115
117
  i.create_child(k,vv)
116
118
  end
117
119
  end
118
- i
119
120
  }
121
+ [ ret ]
120
122
  end
121
123
  end
122
124
  end
@@ -0,0 +1 @@
1
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fabulator-exhibit
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,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-08 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
@@ -34,6 +34,22 @@ dependencies:
34
34
  version: 0.0.1
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: uuid
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 11
46
+ segments:
47
+ - 2
48
+ - 1
49
+ - 0
50
+ version: 2.1.0
51
+ type: :runtime
52
+ version_requirements: *id002
37
53
  description: Provides language extensions to manage Exhibit-style NoSQL databases.
38
54
  email: jgsmith@tamu.edu
39
55
  executables: []
@@ -43,13 +59,16 @@ extensions: []
43
59
  extra_rdoc_files:
44
60
  - README.rdoc
45
61
  files:
62
+ - History.txt
46
63
  - README.rdoc
64
+ - Rakefile
47
65
  - VERSION
48
66
  - features/simple-database.feature
49
67
  - features/step_definitions/exhibit_steps.rb
50
68
  - features/step_definitions/expression_steps.rb
51
69
  - features/step_definitions/xml_steps.rb
52
70
  - features/support/env.rb
71
+ - lib/fabulator-exhibit.rb
53
72
  - lib/fabulator/exhibit.rb
54
73
  - lib/fabulator/exhibit/actions.rb
55
74
  - lib/fabulator/exhibit/actions/item.rb
@@ -60,7 +79,7 @@ files:
60
79
  - test/test_helper.rb
61
80
  - test/test_fabulator-xml.rb
62
81
  has_rdoc: true
63
- homepage: http://github.com/jgsmith/fabulator-exhibit
82
+ homepage: http://github.com/jgsmith/ruby-fabulator-exhibit
64
83
  licenses: []
65
84
 
66
85
  post_install_message: