medea 0.2.25 → 0.2.28
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Rakefile +2 -21
- data/index.html +78 -0
- data/lib/medea/jasonlistproperty.rb +29 -0
- data/lib/medea/list_properties.rb +1 -1
- data/lib/medea/version.rb +3 -0
- data/lib/test.rb +31 -0
- data/lib/testjdq.rb +40 -0
- data/lib/testjlp.rb +30 -0
- data/lib/testmeta.rb +38 -0
- data/lib/testsublist.rb +46 -0
- data/medea.gemspec +23 -0
- metadata +23 -7
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -1,21 +1,2 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'jeweler'
|
5
|
-
Jeweler::Tasks.new do |s|
|
6
|
-
s.name = "medea"
|
7
|
-
s.summary = "Simple wrapper for persisting objects to JasonDB"
|
8
|
-
s.email = "michaelj@jasondb.com"
|
9
|
-
s.homepage = "https://github.com/rob-linton/Medea"
|
10
|
-
s.description = "Simple wrapper for persisting objects to JasonDB"
|
11
|
-
s.authors = ["Michael Jensen"]
|
12
|
-
s.files = FileList["[A-Z]*", "{lib}/medea.rb", "{lib}/medea/*"]
|
13
|
-
s.files.exclude '{lib}/test*'
|
14
|
-
s.add_dependency 'json'
|
15
|
-
s.add_dependency 'rest-client'
|
16
|
-
s.add_dependency 'uuidtools'
|
17
|
-
end
|
18
|
-
rescue LoadError
|
19
|
-
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
20
|
-
end
|
21
|
-
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
data/index.html
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
7
|
+
|
8
|
+
<title>rob-linton/Medea @ GitHub</title>
|
9
|
+
|
10
|
+
<style type="text/css">
|
11
|
+
body {
|
12
|
+
margin-top: 1.0em;
|
13
|
+
background-color: #28904b;
|
14
|
+
font-family: "Helvetica,Arial,FreeSans";
|
15
|
+
color: #ffffff;
|
16
|
+
}
|
17
|
+
#container {
|
18
|
+
margin: 0 auto;
|
19
|
+
width: 700px;
|
20
|
+
}
|
21
|
+
h1 { font-size: 3.8em; color: #d76fb4; margin-bottom: 3px; }
|
22
|
+
h1 .small { font-size: 0.4em; }
|
23
|
+
h1 a { text-decoration: none }
|
24
|
+
h2 { font-size: 1.5em; color: #d76fb4; }
|
25
|
+
h3 { text-align: center; color: #d76fb4; }
|
26
|
+
a { color: #d76fb4; }
|
27
|
+
.description { font-size: 1.2em; margin-bottom: 30px; margin-top: 30px; font-style: italic;}
|
28
|
+
.download { float: right; }
|
29
|
+
pre { background: #000; color: #fff; padding: 15px;}
|
30
|
+
hr { border: 0; width: 80%; border-bottom: 1px solid #aaa}
|
31
|
+
.footer { text-align:center; padding-top:30px; font-style: italic; }
|
32
|
+
</style>
|
33
|
+
|
34
|
+
</head>
|
35
|
+
|
36
|
+
<body>
|
37
|
+
<a href="http://github.com/rob-linton/Medea"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
|
38
|
+
|
39
|
+
<div id="container">
|
40
|
+
|
41
|
+
<div class="download">
|
42
|
+
<a href="http://github.com/rob-linton/Medea/zipball/master">
|
43
|
+
<img border="0" width="90" src="http://github.com/images/modules/download/zip.png"></a>
|
44
|
+
<a href="http://github.com/rob-linton/Medea/tarball/master">
|
45
|
+
<img border="0" width="90" src="http://github.com/images/modules/download/tar.png"></a>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<h1><a href="http://github.com/rob-linton/Medea">Medea</a>
|
49
|
+
<span class="small">by <a href="http://github.com/rob-linton">rob-linton</a></span></h1>
|
50
|
+
|
51
|
+
<div class="description">
|
52
|
+
Jasondb library for Ruby
|
53
|
+
</div>
|
54
|
+
|
55
|
+
<p>This is the main site for the Ruby interface to Jasondb. </p><h2>Contact</h2>
|
56
|
+
<p>robl@jasondb.com
|
57
|
+
|
58
|
+
|
59
|
+
<h2>Download</h2>
|
60
|
+
<p>
|
61
|
+
You can download this project in either
|
62
|
+
<a href="http://github.com/rob-linton/Medea/zipball/master">zip</a> or
|
63
|
+
<a href="http://github.com/rob-linton/Medea/tarball/master">tar</a> formats.
|
64
|
+
</p>
|
65
|
+
<p>You can also clone the project with <a href="http://git-scm.com">Git</a>
|
66
|
+
by running:
|
67
|
+
<pre>$ git clone git://github.com/rob-linton/Medea</pre>
|
68
|
+
</p>
|
69
|
+
|
70
|
+
<div class="footer">
|
71
|
+
get the source code on GitHub : <a href="http://github.com/rob-linton/Medea">rob-linton/Medea</a>
|
72
|
+
</div>
|
73
|
+
|
74
|
+
</div>
|
75
|
+
|
76
|
+
|
77
|
+
</body>
|
78
|
+
</html>
|
@@ -77,6 +77,35 @@ module Medea
|
|
77
77
|
@state = :prefetch
|
78
78
|
end
|
79
79
|
|
80
|
+
def remove! member
|
81
|
+
raise RuntimeError, "You can only remove an item if you are accessing this list from an object." unless @parent.is_a? JasonObject
|
82
|
+
raise ArgumentError, "You can only remove #{@type.name} items from this collection!" unless member.is_a? @type
|
83
|
+
raise ArgumentError, "This item (#{member.jason_key}) doesn't exist in the list you're trying to remove it from!" unless self.include? member
|
84
|
+
|
85
|
+
if @list_type == :value
|
86
|
+
member.jason_parent = nil
|
87
|
+
member.jason_parent_list = nil
|
88
|
+
member.save!
|
89
|
+
elsif @list_type == :reference
|
90
|
+
|
91
|
+
#send DELETE to JasonDB::db_auth_url/a_class.name/
|
92
|
+
url = "#{JasonDB::db_auth_url}#{@type.name}/#{@parent.jason_key}/#{@list_name}/#{member.jason_key}"
|
93
|
+
|
94
|
+
response = RestClient.delete url
|
95
|
+
|
96
|
+
if response.code == 201
|
97
|
+
#delete successful!
|
98
|
+
else
|
99
|
+
raise "DELETE failed! Could not remove membership"
|
100
|
+
end
|
101
|
+
else
|
102
|
+
#parent is a JasonObject, but this list is something other than :value or :reference??
|
103
|
+
raise "Invalid list type or trying to remove an item from a subquery list!"
|
104
|
+
end
|
105
|
+
|
106
|
+
@state = :prefetch
|
107
|
+
end
|
108
|
+
|
80
109
|
def to_url
|
81
110
|
url = "#{JasonDB::db_auth_url}@#{@time_limit}.#{@result_format}?"
|
82
111
|
params = ["VERSION0"]
|
@@ -6,7 +6,7 @@ module JasonObjectListProperties
|
|
6
6
|
module MetaListProperties
|
7
7
|
def create_member_list list_name, list_class, list_type
|
8
8
|
list = {}
|
9
|
-
list = self.class_variable_get :@@lists if self.class_variable_defined? :@@lists
|
9
|
+
list = self.send(:class_variable_get, :@@lists) if self.class_variable_defined? :@@lists
|
10
10
|
list[list_name] = [list_class, list_type]
|
11
11
|
self.send(:class_variable_set, "@@lists", list)
|
12
12
|
|
data/lib/test.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
$: << "~/Projects/Medea/lib"
|
2
|
+
require 'rubygems'
|
3
|
+
require 'medea'
|
4
|
+
|
5
|
+
class Person < Medea::JasonObject
|
6
|
+
end
|
7
|
+
|
8
|
+
mikey = Person.new
|
9
|
+
puts "state: #{mikey.jason_state}"
|
10
|
+
mikey.name = "Michael"
|
11
|
+
mikey.age = 21
|
12
|
+
mikey.location = {:longitude => -30.123213, :latitude => 130.1231458}
|
13
|
+
puts mikey.jason_key
|
14
|
+
puts mikey.to_json
|
15
|
+
mikey.save!
|
16
|
+
|
17
|
+
puts "state: #{mikey.jason_state}"
|
18
|
+
|
19
|
+
puts "Changing name => Bob"
|
20
|
+
mikey.name = "Bob"
|
21
|
+
|
22
|
+
puts "state: #{mikey.jason_state}"
|
23
|
+
puts mikey.to_json
|
24
|
+
mikey.save!
|
25
|
+
puts "state: #{mikey.jason_state}"
|
26
|
+
|
27
|
+
puts "Enter a Person key to retrieve: "
|
28
|
+
id = gets.strip
|
29
|
+
|
30
|
+
person = Person.new id
|
31
|
+
puts person.to_json
|
data/lib/testjdq.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
$: << "~/Projects/Medea/lib"
|
2
|
+
require 'medea'
|
3
|
+
|
4
|
+
class Person < Medea::JasonObject
|
5
|
+
end
|
6
|
+
|
7
|
+
class Company < Medea::JasonObject
|
8
|
+
has_many :employees, Person
|
9
|
+
end
|
10
|
+
|
11
|
+
puts "Lets make a person!"
|
12
|
+
p = Person.new
|
13
|
+
puts "Name?"
|
14
|
+
p.name = gets.strip
|
15
|
+
puts "Age?"
|
16
|
+
p.age = gets.strip.to_i
|
17
|
+
puts "OK - Saving"
|
18
|
+
p.save!
|
19
|
+
|
20
|
+
puts "", "Lets make a company!"
|
21
|
+
c = Company.new
|
22
|
+
puts "Name?"
|
23
|
+
c.name = gets.strip
|
24
|
+
puts "Address?"
|
25
|
+
c.address = gets.strip
|
26
|
+
puts "OK - Saving"
|
27
|
+
c.save!
|
28
|
+
|
29
|
+
puts "", "Making #{p.name} a member of #{c.name}"
|
30
|
+
c.employees.add! p
|
31
|
+
puts "OK - Saving"
|
32
|
+
p.save!
|
33
|
+
|
34
|
+
puts "", "Now querying for Persons that are members of #{c.name}"
|
35
|
+
r = c.employees
|
36
|
+
puts "Query: #{r.to_url}"
|
37
|
+
puts "Got #{r.count} items:"
|
38
|
+
r.each do |p|
|
39
|
+
puts p.name
|
40
|
+
end
|
data/lib/testjlp.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
$: << "~/Projects/Medea/lib"
|
2
|
+
require 'medea'
|
3
|
+
|
4
|
+
class Person < Medea::JasonObject
|
5
|
+
has_many :followees, Person
|
6
|
+
end
|
7
|
+
|
8
|
+
p = Person.get_by_key "p6c75c02f-ed93-4ee8-9746-3603e915be23"
|
9
|
+
|
10
|
+
puts p.followees.to_url
|
11
|
+
puts p.followees.count
|
12
|
+
|
13
|
+
puts "Let's make a new person!"
|
14
|
+
|
15
|
+
p1 = Person.new
|
16
|
+
puts "Name?"
|
17
|
+
p1.name = gets.strip
|
18
|
+
if p1.name != ""
|
19
|
+
puts "Saving..."
|
20
|
+
p1.save!
|
21
|
+
|
22
|
+
puts "Making #{p.name} follow #{p1.name}..."
|
23
|
+
p.followees.add! p1
|
24
|
+
end
|
25
|
+
puts "Done!"
|
26
|
+
list = p.followees
|
27
|
+
puts "#{p.name} now following #{list.count} users:"
|
28
|
+
list.each do |f|
|
29
|
+
puts " - #{f.jason_key}: #{f.name}\n"
|
30
|
+
end
|
data/lib/testmeta.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
$: << "~/Projects/Medea/lib"
|
2
|
+
require 'medea'
|
3
|
+
|
4
|
+
class Message < Medea::JasonObject
|
5
|
+
end
|
6
|
+
|
7
|
+
class User < Medea::JasonObject
|
8
|
+
owns_many :messages, Message
|
9
|
+
end
|
10
|
+
|
11
|
+
puts "Enter an id, or blank to make a new user:"
|
12
|
+
id = gets.strip
|
13
|
+
if id == ""
|
14
|
+
u = User.new
|
15
|
+
puts "User's name?"
|
16
|
+
u.name = gets.strip
|
17
|
+
|
18
|
+
puts "Saving"
|
19
|
+
u.save!
|
20
|
+
else
|
21
|
+
u = User.get_by_key id
|
22
|
+
puts "#{u.name} has posted #{u.messages.count} messages"
|
23
|
+
end
|
24
|
+
|
25
|
+
while true
|
26
|
+
puts "Enter a message (blank to stop):"
|
27
|
+
message = gets.strip
|
28
|
+
break if message == ""
|
29
|
+
m = Message.new
|
30
|
+
m.message = message
|
31
|
+
m.from = u.name
|
32
|
+
u.messages.add! m
|
33
|
+
end
|
34
|
+
|
35
|
+
puts "Fetching messages..."
|
36
|
+
u.messages.each do |e|
|
37
|
+
puts " - #{e.message}\n"
|
38
|
+
end
|
data/lib/testsublist.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
$: << "~/Projects/Medea/lib"
|
2
|
+
require 'medea'
|
3
|
+
|
4
|
+
class Message < Medea::JasonObject; end
|
5
|
+
|
6
|
+
class User < Medea::JasonObject
|
7
|
+
owns_many :messages, Message
|
8
|
+
has_many :followees, User
|
9
|
+
end
|
10
|
+
|
11
|
+
u1 = User.new
|
12
|
+
u1.name = "Fred"
|
13
|
+
u1.save!
|
14
|
+
|
15
|
+
u2 = User.new
|
16
|
+
u2.name = "George"
|
17
|
+
u2.save!
|
18
|
+
|
19
|
+
u1.followees.add! u2
|
20
|
+
u1.followees.add! (User.get_by_key "p438639000")
|
21
|
+
u1.followees.add! u1
|
22
|
+
|
23
|
+
m1 = Message.new
|
24
|
+
m1.from = u2.name
|
25
|
+
m1.message = "Hello! This is George"
|
26
|
+
u2.messages.add! m1
|
27
|
+
|
28
|
+
m3 = Message.new
|
29
|
+
m3.from = u1.name
|
30
|
+
m3.message = "George sent me here, hope it's fun!"
|
31
|
+
u1.messages.add! m3
|
32
|
+
|
33
|
+
m2 = Message.new
|
34
|
+
m2.from = u2.name
|
35
|
+
m2.message = "Man, this is a long day!"
|
36
|
+
u2.messages.add! m2
|
37
|
+
|
38
|
+
puts "#{u2.name} has posted #{u2.messages.count} messages"
|
39
|
+
|
40
|
+
puts "#{u1.name} is following #{u1.followees.count} users"
|
41
|
+
puts "#{u1.name}'s timeline has #{u1.followees.messages.count} messages in it"
|
42
|
+
|
43
|
+
u1.followees.messages.each do |m|
|
44
|
+
puts "#{m.from}:"
|
45
|
+
puts " #{m.message}"
|
46
|
+
end
|
data/medea.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "medea/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "medea"
|
7
|
+
s.version = Medea::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Michael Jensen"]
|
10
|
+
s.email = ["michaelj@jasondb.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Simple wrapper for persisting objects to JasonDB}
|
13
|
+
s.description = %q{Simple wrapper for persisting objects to JasonDB}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_dependency "json"
|
21
|
+
s.add_dependency "rest-client"
|
22
|
+
s.add_dependency "uuidtools"
|
23
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: medea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 47
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
9
|
+
- 28
|
10
|
+
version: 0.2.28
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Michael Jensen
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
+
date: 2011-01-05 00:00:00 +11:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -25,6 +26,7 @@ dependencies:
|
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
28
30
|
segments:
|
29
31
|
- 0
|
30
32
|
version: "0"
|
@@ -38,6 +40,7 @@ dependencies:
|
|
38
40
|
requirements:
|
39
41
|
- - ">="
|
40
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
41
44
|
segments:
|
42
45
|
- 0
|
43
46
|
version: "0"
|
@@ -51,23 +54,27 @@ dependencies:
|
|
51
54
|
requirements:
|
52
55
|
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
54
58
|
segments:
|
55
59
|
- 0
|
56
60
|
version: "0"
|
57
61
|
type: :runtime
|
58
62
|
version_requirements: *id003
|
59
63
|
description: Simple wrapper for persisting objects to JasonDB
|
60
|
-
email:
|
64
|
+
email:
|
65
|
+
- michaelj@jasondb.com
|
61
66
|
executables: []
|
62
67
|
|
63
68
|
extensions: []
|
64
69
|
|
65
|
-
extra_rdoc_files:
|
66
|
-
|
70
|
+
extra_rdoc_files: []
|
71
|
+
|
67
72
|
files:
|
73
|
+
- Gemfile
|
68
74
|
- README
|
69
75
|
- Rakefile
|
70
76
|
- VERSION
|
77
|
+
- index.html
|
71
78
|
- lib/medea.rb
|
72
79
|
- lib/medea/active_model_methods.rb
|
73
80
|
- lib/medea/inheritable_attributes.rb
|
@@ -76,8 +83,15 @@ files:
|
|
76
83
|
- lib/medea/jasonlistproperty.rb
|
77
84
|
- lib/medea/jasonobject.rb
|
78
85
|
- lib/medea/list_properties.rb
|
86
|
+
- lib/medea/version.rb
|
87
|
+
- lib/test.rb
|
88
|
+
- lib/testjdq.rb
|
89
|
+
- lib/testjlp.rb
|
90
|
+
- lib/testmeta.rb
|
91
|
+
- lib/testsublist.rb
|
92
|
+
- medea.gemspec
|
79
93
|
has_rdoc: true
|
80
|
-
homepage:
|
94
|
+
homepage: ""
|
81
95
|
licenses: []
|
82
96
|
|
83
97
|
post_install_message:
|
@@ -90,6 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
104
|
requirements:
|
91
105
|
- - ">="
|
92
106
|
- !ruby/object:Gem::Version
|
107
|
+
hash: 3
|
93
108
|
segments:
|
94
109
|
- 0
|
95
110
|
version: "0"
|
@@ -98,6 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
113
|
requirements:
|
99
114
|
- - ">="
|
100
115
|
- !ruby/object:Gem::Version
|
116
|
+
hash: 3
|
101
117
|
segments:
|
102
118
|
- 0
|
103
119
|
version: "0"
|