soup 0.1.1 → 0.1.2

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/README ADDED
@@ -0,0 +1,168 @@
1
+ Soup is a bit of everything, summoned from nothing. Soup is like an imaginary friend - comforting,
2
+ and will often talk to you, but when you look closely, they don't exist.
3
+
4
+ Terrifying. And so:
5
+
6
+ require 'soup'
7
+ Soup.prepare
8
+
9
+ s = Snip.new
10
+ s.name = "James"
11
+ s.skills = "Bowstaff, nunchuck"
12
+ s.save
13
+
14
+ # ...much later...
15
+
16
+ s = Snip['james']
17
+ s.skills # => "Bowstaff, nunchuck"
18
+
19
+ x = Snip.new
20
+ x.mane = "Lush and thick"
21
+ x.teeth = "Sharp and ready"
22
+ x.position = "Above my bed!!!"
23
+ x.save
24
+
25
+ The point is that you can set any attribute on a Snip, and it will be persisted without care.
26
+ With reckless abandon, really.
27
+
28
+ The data can be stored using anything - Snip doesn't really care much about the underlying
29
+ persistence layer. I've written implementations using DataMapper, ActiveRecord and Sequel...
30
+ there are other implementations of course. Unknowable implementations.
31
+ Terrifying implementations. You Fool! Warren is Dead!
32
+
33
+
34
+
35
+ (c) 2008 James Adam, MIT LICENSE. Yeah.
36
+
37
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXP
38
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXY?""" .
39
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXY?"" ,;ciCCC
40
+ "?YXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXYYY??"" .,;iCCCCCCCCCC
41
+ .,. `""""""???YYYYYYYYYYXXXXXXXYYYYY???""""""" ..,;ciiCCCCCCCCCCC''`
42
+ ```'`CCiiicccccccccc;;,,. .,..,..,;cccciiiCCCCCCC????>''````` .;ciCCC
43
+ Cic;,. `''<<????CCCCCCCCCCCC?????''''''''`````' ..,;;;ccciiiCCCCCCCCCC
44
+ CCCCCCCCCCCCcc;;;,,. .,..,..,..,;;cciiiiCCCCCCCCCCCCCCCCCCCCC??>'`
45
+ ``''?CCCCCCCCCC"'```''CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC??""''`` _.,;cciCC
46
+ ic;;,. ````'<?Ciiccc;,,. ````'''`CCCCCC''''''''`' .,;cciiiCCCCCCCCCC?"'`
47
+ CCCCCCCCCiic;._ ```''"<?CCC;;;,,,.,..,...,;;;;;;C777???CC'''''``' _,xiXX
48
+ . ```'''`CCCCCCCiicc;,,,,,.. ```````' .,,,xiiXXXXXXXXXX
49
+ XXXXXxXx,,,. ``````````````````` .,..,..,.xiXiiXiiXXXXXXXXXXXXXXXXXXXX
50
+ XXXXXXXXXXXXXXXXXXxXxxXxXXXXXxxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
51
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
52
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
53
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXY??"""
54
+ """?YXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXYY???"""
55
+ = """""???YYXXXXXXXXXXXXXXXXXXXXXXXXXXYYY???"" ,;
56
+ -;ccccc;;,.,.. """""""""" ,;ciCC'``'
57
+ ;;, ```'???CCCCC `''--;CCicc;;, .,;;,,,. .. .,;ciCCCCCCCicc;-
58
+ C'```CCiiiiiCCCCtCiicc;,. ```' . .,;;iCCCCC'' .,;;cccc-''`CCCCCCCCCCCCC;;
59
+ CCCCc;,,.,;CCCcc,,,,..'' .;CC'`'CCCCCCCCCC'' ``' .,;;;cc===`CC''````````'
60
+ .,...```' .C.,.`""""?CCCCC'`CCC''''``' .,.,;ciCCCCCC..,;cciiCtttCCCCCCCtt
61
+ ```' `'`CCCCCCCCCCC' . `' ```' .,. ```CCC''''`CCCCCCCCCCCCC?"''
62
+ .. ``' ```'
63
+ $$$$$$$$$$$$ccc$$$$$$$$"?hccc=Jcc$$hccccccc$$$$$$$$$$$$$cccccc,,,,,ccc,,..
64
+ $$$??hcccci???CCCCCC$$L ,$$$$c $$hcccccJ???LcccccccccJCCC???????CCCC??????
65
+ $$F `?$$$$$$$$$$$$$$$$. ,$$"$$.?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
66
+ $$,. ,$$$$$$$$$$$$$$$$. ,$$ $$h $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$??????????$$
67
+ $$$h $$$$$$$$$$$$$$$$$$ $$$ ?$h ?$$$$$$$$$$$$$$$$$$$$$$$???izc?????????i??
68
+ ???" ?????$$$$$$$"""""" "" ?"" `"?"""$$$$$$$$??<Lr??cr?="" . . .
69
+ ,,,,,,,,,J$$$$$$$$,.,,,,,,,,.. ,$$$$$$P>JP" .,;;,.!!;,.!!!!!!!
70
+ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$C3$$ -' --''`!!!!'`' .. `!
71
+ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Ci??c,,,.,..,. `````
72
+ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$JJCCCC????????$$????rrrcccc,
73
+ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$C<<$$$$$PF<$$$$
74
+ $$$$$cizccCCCCCCCCCcccc$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$?????)>>J$CLccc$??""
75
+ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$????ii?iiJJJ$$??"""
76
+ $$$$$$$$$$$$$??$$$$????P$$$???iiiiicccccc<<????)Cicc$P"" .. .,;;!!!
77
+ $$$$$CCCCCCC>>J>>>>cccccc>>>??C????CC>cccJ$??""""" -``!!;!' .!!!'
78
+ $$$$$??CCCCCCCCCCCff>>>>>J$$$P"""""""" ..,;;;;;;;!'`.,;;!'''
79
+ ??????????????"""""'' `' .,..,;;;;!!!'```..```' .,.,;;;- `,;'
80
+ .,. ,;;----'''''''```````' `''`,;;!!'''`..,;;'' ,;
81
+ ---;;;;;;;-----'''''''''``' --- `' .,,ccc$$hcccccc,. `' ,;;!!!'``,;;!!'
82
+ ;;;;,,.,;-------''''''' ,;;!!- .zJ$$$$$$$$$$$$$$$$$$$c,. `' ,;;!!!!' ,;
83
+ ```' -;;;!'''''- `.,.. .zJ$$$$$$$$$$$$$$$$$$$$$$$$$$c, `!!'' ,;!!'
84
+ !!- ' `,;;;;;;;;;;'''''```' ,c$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$c, ;!!'' ,;
85
+ ,;;;!!!!!!!!''``.,;;;;!'`' z$$$$$$$$???"""""'.,,.`"?$$$$$$$$$$$ ``,;;!!!
86
+ ;;.. --''```_..,;;! J$$$$$$??,zcd$$$$$$$$$$$$$$$$$$$$$$$$h ``'``'
87
+ ```''' ,;;''``.,.,;;, ,$$$$$$F,z$$$$$$$$$$$$$$$$$$$c,`""?$$$$$h
88
+ !!!!;;;;, --`!''''''' $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$h.`"$$$$h .
89
+ `'''``.,;;;!;;;--;; zF,$$$$$$$$$$?????$$$$$$$$$$$$$?????$$r ;?$$$ $.
90
+ !;.,..,.````.,;;;; ,$P'J"$$$$$$P" .,c,,.J$$$$$$$$$"',cc,_`?h.`$$$$ $L
91
+ '``````' .,.. ,$$". $ $$$$P",c$$$$$$$$$$$$$$$$',$$$$$$$$$$ $$$$ $$c,
92
+ !!!!!!!!!!!!!''' J$',$ $.`$$P c$$$$$$$$$$$$$$$$$$,$$$$$$$$$$$ $$$$ $$$$C
93
+ `` J$ ,$P $$ ?$',$$$$???$$$$$$$$$$$$$$$??"""?$$$ <$$$ $$$$$
94
+ c ;, z$F,$$ `$$ $ ?$" "$$$.?$$$ $$$P c??c, ?$.<$$',$$$$$F
95
+ $$h. -!> (' $" $F ,F ?$ $ F ,="?$$c,`$$F $$"z$$',$' ,$$P $h.`$ ?$$$$$r
96
+ $$$$$hc,. ``' J$ $P J$ . $$F L ",,J$$$F <$hc$$ "$L,`??????,J$$$.` z$$$$$
97
+ $$$$$$$$$$c,'' ?F,$',$F.: $$ c$c,,,,,c,,J$$$$$$$ ?$$$c,,,c$$$$$$F. $$$$$$
98
+ `"$$$$$$$$$$$c, $$',$$ :: $$$$$$$$F"',$$$$$$$$$$h ?$$$L;;$$$??$$$$ $$$$$$
99
+ "?$$$$$$$$$$ $$$$$$ : .`F"$$$$$$$$$$$$""""?"""h $$$$$$$"$,J$$$$ $$$$$'
100
+ "?$$$$$$$ $$$$$$.`.` h `$$$$$$$$$$$cccc$$c,zJ$$$$$P' $$$$$P',$$$$P
101
+ $. `""?$$ $$$$$$$ ` "$c "?$$$$$$$$$$$$??$$$$$$$$" ,J$$$P",J$$$$P
102
+ .. `" ?$$$$$$h ?$$c.`?$$$$$$$$$' . <$$$$$' ,$$$" ,$$$$$"
103
+ !!>. . `$$$$$$$h . "$$$c,"$$$$$$$' `' `$$$P ,$$$' ,c$$$$$' ;!
104
+ ```<!!!> `$$$$$$$c "$$$c`?$$$$$ : : $$$ ,$$P' z$$$$$$' ;!!
105
+ $hc ```' ; `$$$$$$$. ?$$c ?$$$$ .: : $$$ $$F ,J$$$$$$' ;!!
106
+ .,.. ' `$$$$$$$ "$$h`$$$$ .' ' $$$ ,$$ ,J$$$$$$' !!!
107
+ ????P `$$$$$$L $$$ $$$F :.: J$$P J$F J$$$$$P ;!!
108
+ -=< ?$$."$$ `$$ ?$$' `' z$$$F $P $$$$$$' !!'
109
+ cc `$$$c`? ?$.`$$hc, cd$$F ,$' $$$$$$ ;!!
110
+ $$$$c `$$c$$$$$$$$$",c$' $$$$$$ `!!
111
+ $$$$$ `?$$$$$$$$$$$$P' $$$$$$> ..
112
+ $$$$$ `"?$$$$$$$P" $$$$$$L $$c,
113
+ !! <$$$$$ zc,`"""', <$$$$$$.`$$$$cc,
114
+ !! J$$$$P `$$$$$$$' !' $$$$$$L `$$$$$$h
115
+ ;, $$$$$L `! J$$$$$',!! $$$$$$$ `$$$$$$
116
+ ' <$$$$$. ! $$$$$$ !! ?$$$$$$ `$$$$$
117
+ ,$$$$$$$c `,`???? ;' c,?$$$$' `?$$$
118
+ $$$$$$$?? `!;;;;! . `h."?$P `$$$
119
+ ,$$$$$$$h. `''' `' `$$$P `?$
120
+ $$$$$$$$h `!' `"' `
121
+ `$$$$$$$$F !; ! ;,
122
+ `$$$$$$$' `!!> `!
123
+ c, ;, `?$$$$P !!> .
124
+ $F !!> `""' `!! ;!> <-
125
+ $F `!!' ;!; ' `! <!> ;
126
+ $F `' <! !!! !!> !!
127
+ ?' `' !!! !!! !!> !!
128
+ !!' <!! ;!!! `' ;
129
+ ;!! !! !!!! !'
130
+ !!! `' !!! ' ;
131
+ !! ;!!' !
132
+ !!! ;! !
133
+ <!!! )' `!
134
+ ,;;> ;!!! `!
135
+ `'' ;!!! ! `!
136
+ ;! ;!!! ,$$c, `
137
+ !'' ;!!! ' ,c$$$$$$c.
138
+ > ; !!! ?$$$$$$$$$
139
+ !!> ;!! .!!! .!> "?$$$$$$$
140
+ <! `! ,; ;!! !!!! !! `"?$$$$
141
+ . ' ' ;!!! .!!!! !! . `"?$
142
+ `' <!!' .!!!!!! !!!' ! > `
143
+ .!!! <!!'`!!! .!!!!; !!>
144
+ !!! <!!' !! ;!!!!!! (' ;,
145
+ <!! !!!' !!! !!!'!!! !> `!
146
+ !!' !!!' `!!';!> !! <! `' `! !>.
147
+ ' ;<!!' .!!! !!' <!' ; `!! ; `! !!!>
148
+ .<!>;!!!' !!! `!! <!! .. ' ' !!!' ;,
149
+ <!!! <!! ; !!! !!>;!!''! J$$c `!!; !!>
150
+ ;!!! ;!! <! !!> !! `!! !' J$$$$hr `'' !!!,;;
151
+ ;!!! !! <!! <!! !' ;!! ' <$$$$$$$. <!!!'!
152
+ !!! !;<!!' !!! ;! !!> $$$$$$$$$$. `' !
153
+ `!!! !!!!!' !!! !! `!!! ?$$$$$$$??$c !!>;
154
+ ;!! ;!!!!! ;!!> !! <!!> ?$$$$$$c,`$$. `!!!
155
+ !!! !!! !' `!!> !! !!! "?$$$$$$ "?$c `<!
156
+ ;!! !! ;! !!!> ! ;!!!, "$$$$$$c,"?$c,
157
+ ;!! !! ;! !!!! ! `!!!! "$$$$$$c ?$$h.
158
+ !!!> !! !! !!!! !!! "?$$$$c "$$$c,
159
+ !!!' ' !! `!!! `! "$$$$h.`?$$$c,
160
+ <!!!> <!! `!!! !> ?$$$$$c ?$$$$h.
161
+ `!!! `!! !!! `' "?$$$$h.`?$$$$
162
+ `!!> !! `!! `?$$$$$$$$$$
163
+ `!' !! `' "$$$$$$$$$
164
+ `!> ?$$$$$$$
165
+ `! `"?$$$$
166
+ `- ;! `"$$
167
+ `?
168
+ (http://www.edvard-munch.com/Paintings/other_artists/scream_ascii_3.htm)
@@ -1,8 +1,10 @@
1
1
  require 'rubygems'
2
- require 'active_record'
2
+ require 'activerecord'
3
3
 
4
4
  class Tuple < ActiveRecord::Base
5
- def self.prepare_database
5
+ def self.prepare_database(config)
6
+ ActiveRecord::Base.establish_connection(config)
7
+ return if connection.tables.include?("tuples")
6
8
  ActiveRecord::Migration.create_table :tuples, :force => true do |t|
7
9
  t.column :snip_id, :integer
8
10
  t.column :name, :string
@@ -1,11 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'data_mapper'
3
3
 
4
- DataMapper::Database.setup({
5
- :adapter => 'sqlite3',
6
- :database => 'soup_development.db'
7
- })
8
-
9
4
  # This tuple implementation is broken - there's a weird interaction
10
5
  # where values are not set within the web application.
11
6
  #
@@ -19,8 +14,9 @@ class Tuple < DataMapper::Base
19
14
  property :created_at, :datetime
20
15
  property :updated_at, :datetime
21
16
 
22
- def self.prepare_database
23
- DataMapper::Persistence.auto_migrate!
17
+ def self.prepare_database(config)
18
+ DataMapper::Database.setup(config)
19
+ DataMapper::Persistence.auto_migrate! # TODO: detect if the table exists
24
20
  end
25
21
 
26
22
  def self.for_snip(id)
@@ -13,17 +13,17 @@ class Tuple < Sequel::Model(:tuples)
13
13
  datetime :updated_at
14
14
  end
15
15
 
16
+ def self.prepare_database(config)
17
+ # ummm... how to connect?
18
+ create_table # TODO: detect if the table already exists
19
+ end
20
+
16
21
  def self.for_snip(id)
17
- Tuple.filter(:snip_id => id).to_a
22
+ filter(:snip_id => id).to_a
18
23
  end
19
24
 
20
25
  # TODO: *totally* not threadsafe.
21
26
  def self.next_snip_id
22
27
  max(:snip_id) + 1
23
28
  end
24
- end
25
-
26
-
27
- # Create the table with this:
28
- #
29
- # Tuple.create_table
29
+ end
@@ -1,5 +1,9 @@
1
1
  require 'rubygems'
2
- require 'blankslate'
2
+
3
+ # Based on Builder's BlankSlate object
4
+ class EmptyClass
5
+ instance_methods.each { |m| undef_method(m) unless m =~ /^(__|instance_eval)/ }
6
+ end
3
7
 
4
8
  # methods called on Tuple:
5
9
  # Tuple.for_snip(id)
@@ -11,7 +15,7 @@ require 'blankslate'
11
15
  # Tuple#value
12
16
  # Tuple#destroy
13
17
 
14
- class Snip < BlankSlate
18
+ class Snip < EmptyClass
15
19
 
16
20
  # Returns the snip with the given name (i.e. the snip with the tuple of "name" -> name)
17
21
  #
@@ -1,7 +1,35 @@
1
- # require 'data_mapper_tuple'
2
- # or
3
- require 'active_record_tuple'
4
- # or
5
- # require 'sequel_tuple'
1
+ require 'snip'
6
2
 
7
- require 'snip'
3
+ module Soup
4
+ VERSION = "0.1.2"
5
+
6
+ DEFAULT_CONFIG = {
7
+ :adapter => 'sqlite3',
8
+ :database => 'soup.db'
9
+ }
10
+
11
+ DEFAULT_TUPLE_IMPLEMENTATION = "active_record_tuple"
12
+
13
+ # Set the base of this soup, i.e. where to get the data. This is the
14
+ # database configuration, i.e.
15
+ #
16
+ # Soup.base = {:database => 'my_soup.db'}
17
+ #
18
+ def self.base=(database_config)
19
+ @database_config = database_config
20
+ end
21
+
22
+ # Call this to set which tuple implementation to use, i.e.
23
+ #
24
+ # Soup.flavour = :active_record
25
+ #
26
+ def self.flavour=(tuple_implementation)
27
+ @tuple_implementation = "#{tuple_implementation}_tuple"
28
+ end
29
+
30
+ # Get the soup ready!
31
+ def self.prepare
32
+ require @tuple_implementation || DEFAULT_TUPLE_IMPLEMENTATION
33
+ Tuple.prepare_database(DEFAULT_CONFIG.merge(@database_config || {}))
34
+ end
35
+ end
metadata CHANGED
@@ -1,57 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
2
4
  name: soup
3
5
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
6
+ version: 0.1.2
7
+ date: 2008-03-06 00:00:00 +00:00
8
+ summary: A mess of data
9
+ require_paths:
10
+ - lib
11
+ email: james at lazyatom dot com
12
+ homepage:
13
+ rubyforge_project:
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
5
25
  platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
6
29
  authors:
7
30
  - James Adam
8
- autorequire:
9
- bindir: bin
10
- cert_chain: []
11
-
12
- date: 2008-03-04 00:00:00 +00:00
13
- default_executable:
14
- dependencies: []
15
-
16
- description:
17
- email: james@lazyatom.com
18
- executables: []
19
-
20
- extensions: []
21
-
22
- extra_rdoc_files: []
23
-
24
31
  files:
25
32
  - lib/active_record_tuple.rb
26
33
  - lib/data_mapper_tuple.rb
27
34
  - lib/sequel_tuple.rb
28
35
  - lib/snip.rb
29
36
  - lib/soup.rb
30
- has_rdoc: false
31
- homepage:
32
- post_install_message:
37
+ - README
38
+ test_files: []
39
+
33
40
  rdoc_options: []
34
41
 
35
- require_paths:
36
- - lib
37
- required_ruby_version: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: "0"
42
- version:
43
- required_rubygems_version: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: "0"
48
- version:
42
+ extra_rdoc_files:
43
+ - README
44
+ executables: []
45
+
46
+ extensions: []
47
+
49
48
  requirements: []
50
49
 
51
- rubyforge_project: soup
52
- rubygems_version: 0.9.5
53
- signing_key:
54
- specification_version: 2
55
- summary: I suppose it's a document database. Or a tuple store. But really, it's just data sloshing around, waiting to be used.
56
- test_files: []
50
+ dependencies: []
57
51