public
Description: I suppose it's a document database. Or a tuple store. But really, it's just data sloshing around, waiting to be used.
Clone URL: git://github.com/lazyatom/soup.git
Merged some of the changes from elliotcable's fork.
lazyatom (author)
Tue Apr 15 14:51:08 -0700 2008
commit  a5208f59f9bbe0507affa329366794df0a31f0a8
tree    1f93bfc9154e7a2d6d85fce515b6a5fd255609b0
parent  f151d7b9aa8eea291c4d4a5bef1a8325f4975b00
...
3
4
5
6
7
 
 
8
...
3
4
5
 
6
7
8
9
0
@@ -3,4 +3,5 @@ doc
0
 *.log
0
 *.db
0
 .DS_Store
0
-*~
0
\ No newline at end of file
0
+*~
0
+meta
0
\ No newline at end of file
...
1
2
3
4
 
 
 
 
5
 
6
7
8
 
 
9
10
...
 
 
 
 
1
2
3
4
5
6
7
8
 
9
10
11
 
0
@@ -1,10 +1,11 @@
0
-lib/active_record_tuple.rb
0
-lib/data_mapper_tuple.rb
0
-lib/sequel_tuple.rb
0
-lib/snip.rb
0
+lib/soup/snip.rb
0
+lib/soup/tuples/active_record_tuple.rb
0
+lib/soup/tuples/data_mapper_tuple.rb
0
+lib/soup/tuples/sequel_tuple.rb
0
 lib/soup.rb
0
+Manifest
0
 README
0
 spec/snip_spec.rb
0
-spec/soup_test.rb
0
+spec/soup_spec.rb
0
+spec/spec_helper.rb
0
 spec/spec_runner.rb
0
-Manifest
...
10
11
12
 
 
13
14
 
15
16
17
18
19
20
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
23
24
25
26
27
28
 
 
 
29
30
31
32
 
33
...
10
11
12
13
14
15
 
16
17
18
19
20
 
 
 
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 
 
 
 
 
41
42
43
44
45
 
46
47
48
1
@@ -10,22 +10,37 @@ begin
0
     soup.email = ["james@lazyatom.com"]
0
     soup.description = File.readlines("README").first
0
     soup.dependencies = ["activerecord >=2.0.2"]
0
+ soup.clean_pattern = ["*.db", "meta", "pkg"]
0
+ soup.ignore_pattern = [".git", "*.db", "meta"]
0
   end
0
-
0
+
0
 rescue LoadError
0
   puts "You need to install the echoe gem to perform meta operations on this gem"
0
 end
0
 
0
-desc "Open an irb session preloaded with this library"
0
-task :console do
0
- sh "irb -rubygems -r ./lib/soup.rb"
0
+begin
0
+ require 'spec'
0
+ require 'spec/rake/spectask'
0
+
0
+ Spec::Rake::SpecTask.new do |t|
0
+ t.spec_opts = ["--format", "specdoc", "--colour"]
0
+ t.spec_files = Dir['spec/**/*_spec.rb'].sort
0
+ t.libs = ['lib']
0
+ t.rcov = true
0
+ t.rcov_dir = 'meta/coverage'
0
+ end
0
+
0
+ task :show_rcov do
0
+ system 'open meta/coverage/index.html' if PLATFORM['darwin']
0
+ end
0
+
0
+rescue LoadError
0
+ puts "You need RSpec installed to run the spec (default) task on this gem"
0
 end
0
 
0
-# We have to run our own spec runner, because Snip will try to undefine
0
-# rspec's should methods using the default one
0
-task(:spec) do
0
- files = FileList['spec/**/*_spec.rb']
0
- system "ruby spec/spec_runner.rb #{files} --format specdoc --colour"
0
+desc "Open an irb session preloaded with this library"
0
+task :console do
0
+ sh "irb --prompt simple -rubygems -r ./lib/soup.rb"
0
 end
0
 
0
-task :default => :spec
0
\ No newline at end of file
0
+task :default => [:spec, :show_rcov]
0
\ No newline at end of file
...
1
2
3
4
 
5
6
7
...
35
36
37
38
 
39
40
 
41
42
 
43
44
45
46
47
48
 
49
50
51
52
53
54
55
56
57
58
59
60
61
62
 
 
63
64
 
 
 
65
66
67
68
 
 
 
 
69
70
71
72
73
74
 
 
 
 
 
 
 
75
76
77
...
1
2
3
 
4
5
6
7
...
35
36
37
 
38
39
 
40
41
 
42
43
44
45
46
47
 
48
49
50
51
 
 
 
 
 
 
 
 
 
 
 
52
53
54
 
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
0
@@ -1,7 +1,7 @@
0
 # Let us require stuff in lib without saying lib/ all the time
0
 $LOAD_PATH.unshift(File.dirname(__FILE__)).uniq!
0
 
0
-require 'snip'
0
+require 'soup/snip'
0
 
0
 module Soup
0
   VERSION = "0.2.0"
0
@@ -35,43 +35,47 @@ module Soup
0
   def self.tuple_class
0
     @tuple_class ||= case (@tuple_implementation || DEFAULT_TUPLE_IMPLEMENTATION)
0
     when "active_record_tuple", nil
0
- ActiveRecordTuple
0
+ Soup::Tuples::ActiveRecordTuple
0
     when "data_mapper_tuple"
0
- DataMapperTuple
0
+ Soup::Tuples::DataMapperTuple
0
     when "sequel_tuple"
0
- SequelTuple
0
+ Soup::Tuples::SequelTuple
0
     end
0
   end
0
   
0
   # Get the soup ready!
0
   def self.prepare
0
- require @tuple_implementation || DEFAULT_TUPLE_IMPLEMENTATION
0
+ require "soup/tuples/#{@tuple_implementation || DEFAULT_TUPLE_IMPLEMENTATION}"
0
     tuple_class.prepare_database(DEFAULT_CONFIG.merge(@database_config || {}))
0
   end
0
   
0
- # ==============
0
- # The behaviour
0
- #
0
- # The idea is that the persistence layer implements these, but
0
- # Soup itself doesn't care. It shouldn't actually care that it's
0
- # returning Snips.
0
-
0
- # Finds bits in the soup with the given name
0
- def self.[](name)
0
- sieve(:name, "='#{name}'").first
0
- end
0
+ # The main interface
0
+ # ==================
0
   
0
- # Finds bits in the soup that make the given attribute hash
0
+ # Finds bits in the soup that make the given attribute hash.
0
+ # This method should eventually be delegated to the underlying persistence
0
+ # layers (i.e. Snips and Tuples, or another document database)
0
   def self.sieve(*args)
0
     Snip.sieve(*args)
0
   end
0
   
0
+ # Puts some data into the soup, and returns an object that contains
0
+ # that data. The object should respond to accessing and setting its
0
+ # attributes as if they were defined using attr_accessor on the object's
0
+ # class.
0
   def self.<<(attributes)
0
     s = Snip.new(attributes)
0
     s.save
0
     s
0
   end
0
   
0
+ # A shortcut to sieve by name attribute only
0
+ def self.[](name)
0
+ sieve(:name, "='#{name}'").first
0
+ end
0
+
0
+ # ==== (interface ends) =====
0
+
0
   # Save the current state of the soup into a YAML file.
0
   def self.preserve(filename='soup.yml')
0
     snips = {}
...
13
14
15
16
17
 
 
18
19
20
...
75
76
77
78
 
79
80
 
81
82
83
84
 
85
86
 
87
88
 
89
90
91
 
 
92
93
94
...
13
14
15
 
 
16
17
18
19
20
...
75
76
77
 
78
79
 
80
81
82
83
 
84
85
 
86
87
 
88
89
 
 
90
91
92
93
94
0
@@ -13,8 +13,8 @@ describe Soup do
0
   
0
     it "should use the default tuple implementation" do
0
       # No real idea how to mock the require, or use aught but Secret Knowledge that AR == Default
0
- Soup.tuple_class.should == ActiveRecordTuple
0
- ActiveRecordTuple.should_receive(:prepare_database)
0
+ Soup.tuple_class.should == Soup::Tuples::ActiveRecordTuple
0
+ Soup::Tuples::ActiveRecordTuple.should_receive(:prepare_database)
0
       Soup.prepare
0
     end
0
   
0
@@ -75,20 +75,20 @@ describe Soup do
0
     end
0
   
0
     it "should determine the tuple class based on the flavour" do
0
- require 'data_mapper_tuple'
0
+ require 'soup/tuples/data_mapper_tuple'
0
       Soup.flavour = :data_mapper
0
- Soup.tuple_class.should == DataMapperTuple
0
+ Soup.tuple_class.should == Soup::Tuples::DataMapperTuple
0
     end
0
   
0
     it "should allow the flavour to be set multiple times" do
0
- require 'data_mapper_tuple'
0
+ require 'soup/tuples/data_mapper_tuple'
0
       Soup.flavour = :data_mapper
0
- Soup.tuple_class.should == DataMapperTuple
0
+ Soup.tuple_class.should == Soup::Tuples::DataMapperTuple
0
     
0
- require 'sequel_tuple'
0
+ require 'soup/tuples/sequel_tuple'
0
       Soup.flavour = :sequel
0
- Soup.tuple_class.should_not == DataMapperTuple
0
- Soup.tuple_class.should == SequelTuple
0
+ Soup.tuple_class.should_not == Soup::Tuples::DataMapperTuple
0
+ Soup.tuple_class.should == Soup::Tuples::SequelTuple
0
     end
0
   
0
     it "should use have no tuple class if the flavour is unknowable" do
...
 
 
 
 
 
1
2
 
3
4
...
1
2
3
4
5
6
 
7
8
9
0
@@ -1,3 +1,8 @@
0
+$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w[.. lib]))
0
+
0
+require 'soup'
0
+require "soup/tuples/active_record_tuple"
0
+
0
 def clear_database
0
- ActiveRecordTuple.destroy_all
0
+ Soup::Tuples::ActiveRecordTuple.destroy_all
0
 end
0
\ No newline at end of file

Comments

  • elliottcable Tue Apr 15 22:37:47 -0700 2008 at Rakefile

    It’s fully up to you, of course, but see my replies to your comments on my commit on Rakefile.rb @ a0457ef (-;