guillermo-fluidrb 0.0.3 → 0.1.0

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/Rakefile CHANGED
@@ -12,7 +12,7 @@ require 'rake/clean'
12
12
 
13
13
  require 'spec/rake/spectask'
14
14
 
15
- task :default => :"spec"
15
+ task :default => :spec
16
16
 
17
17
  desc "Run all specs in spec directory"
18
18
  Spec::Rake::SpecTask.new(:spec) do |t|
@@ -25,7 +25,7 @@ namespace :spec do
25
25
  Spec::Rake::SpecTask.new(:rcov) do |t|
26
26
  t.spec_files = FileList['spec/*_spec.rb']
27
27
  t.rcov = true
28
- t.rcov_opts = ['--exclude', 'spec']
28
+ t.rcov_opts = ['--exclude', 'spec,gems']
29
29
  end
30
30
 
31
31
  desc "Print Specdoc for all specs"
@@ -43,22 +43,40 @@ begin
43
43
  require File.join(File.dirname(__FILE__),'lib','fluiddb','version.rb')
44
44
 
45
45
  Echoe.new('fluidrb',FluidDB::VERSION) do |p|
46
- # p.description = "Ruby FluidDB Api"
46
+ p.description = "Ruby FluidDB Api"
47
47
  p.summary = "Ruby api for access to FluidDB Api"
48
48
  p.url = "http://wiki.github.com/guillermo/fluidrb"
49
49
  p.author = "Guillermo Álvarez"
50
- # p.email = "guillermo@cientifico.net"
51
- # p.version = FluidDB::VERSION
52
- #p.docs_host
53
- #p.rdoc_pattern
54
- p.runtime_dependencies = ["json >= 1.1.3"]
55
- # p.ignore_pattern = FileList[".gitignore"]
50
+ p.email = "guillermo@cientifico.net"
51
+ p.runtime_dependencies = ["brianmario-yajl-ruby >= 0.6.3"]
52
+ p.ignore_pattern = `cat .gitignore`.split
56
53
 
57
54
  end
58
55
 
59
56
  desc 'Prepare, commit and push to github'
60
57
  task :deploy => [:spec, :clean, :clobber, :git_clean, :manifest, :build_gemspec,:commit,:push]
61
58
 
59
+ desc 'Commit and generate doc'
60
+ task :commit_doc => [:git_reset, :rdoc, "spec:coverage", :checkout_gh_pages, :commit, :push, :checkout_master]
61
+
62
+
63
+ Rake::RDocTask.new do |rd|
64
+ rd.rdoc_files.include("lib/**/*.rb","lib/*.rb")
65
+ rd.options << '-d'
66
+ end
67
+
68
+ task :checkout_master do
69
+ `git checkout master`
70
+ end
71
+
72
+ task :checkout_gh_pages do
73
+ `git checkout gh-pages`
74
+ end
75
+
76
+ task :git_reset do
77
+ `git reset --hard`
78
+ end
79
+
62
80
  task :push do
63
81
  puts "Uploading changes"
64
82
  `git push origin `
data/fluidrb.gemspec CHANGED
@@ -2,19 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{fluidrb}
5
- s.version = "0.0.3"
5
+ s.version = "0.1.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Guillermo \303\201lvarez"]
9
- s.date = %q{2009-09-06}
10
- s.description = %q{Ruby api for access to FluidDB Api}
11
- s.email = %q{}
12
- s.executables = ["fluiddb", "fluiddb-sandbox"]
13
- s.extra_rdoc_files = ["README.md", "bin/fluiddb", "bin/fluiddb-sandbox", "lib/fluiddb.rb", "lib/fluiddb/connection.rb", "lib/fluiddb/console/common.rb", "lib/fluiddb/console/console.rb", "lib/fluiddb/console/sandbox.rb", "lib/fluiddb/error.rb", "lib/fluiddb/namespace.rb", "lib/fluiddb/object.rb", "lib/fluiddb/resource.rb", "lib/fluiddb/tag.rb", "lib/fluiddb/user.rb", "lib/fluiddb/version.rb"]
14
- s.files = ["Manifest", "README.md", "Rakefile", "bin/fluiddb", "bin/fluiddb-sandbox", "fluidrb.gemspec", "lib/fluiddb.rb", "lib/fluiddb/connection.rb", "lib/fluiddb/console/common.rb", "lib/fluiddb/console/console.rb", "lib/fluiddb/console/sandbox.rb", "lib/fluiddb/error.rb", "lib/fluiddb/namespace.rb", "lib/fluiddb/object.rb", "lib/fluiddb/resource.rb", "lib/fluiddb/tag.rb", "lib/fluiddb/user.rb", "lib/fluiddb/version.rb", "spec/namespace_spec.rb", "spec/object_spec.rb", "spec/spec_helper.rb", "spec/tag_spec.rb", "spec/user_spec.rb"]
9
+ s.date = %q{2009-09-19}
10
+ s.description = %q{Ruby FluidDB Api}
11
+ s.email = %q{guillermo@cientifico.net}
12
+ s.files = ["fluidrb.gemspec", "Rakefile"]
15
13
  s.has_rdoc = true
16
14
  s.homepage = %q{http://wiki.github.com/guillermo/fluidrb}
17
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Fluidrb", "--main", "README.md"]
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Fluidrb", "--main", "README"]
18
16
  s.require_paths = ["lib"]
19
17
  s.rubyforge_project = %q{fluidrb}
20
18
  s.rubygems_version = %q{1.3.1}
@@ -25,11 +23,11 @@ Gem::Specification.new do |s|
25
23
  s.specification_version = 2
26
24
 
27
25
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
- s.add_runtime_dependency(%q<json>, [">= 0", "= 1.1.3"])
26
+ s.add_runtime_dependency(%q<brianmario-yajl-ruby>, [">= 0", "= 0.6.3"])
29
27
  else
30
- s.add_dependency(%q<json>, [">= 0", "= 1.1.3"])
28
+ s.add_dependency(%q<brianmario-yajl-ruby>, [">= 0", "= 0.6.3"])
31
29
  end
32
30
  else
33
- s.add_dependency(%q<json>, [">= 0", "= 1.1.3"])
31
+ s.add_dependency(%q<brianmario-yajl-ruby>, [">= 0", "= 0.6.3"])
34
32
  end
35
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guillermo-fluidrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Guillermo \xC3\x81lvarez"
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-06 00:00:00 -07:00
12
+ date: 2009-09-19 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: json
16
+ name: brianmario-yajl-ruby
17
17
  type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
@@ -23,55 +23,19 @@ dependencies:
23
23
  version: "0"
24
24
  - - "="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.3
26
+ version: 0.6.3
27
27
  version:
28
- description: Ruby api for access to FluidDB Api
29
- email: ""
30
- executables:
31
- - fluiddb
32
- - fluiddb-sandbox
28
+ description: Ruby FluidDB Api
29
+ email: guillermo@cientifico.net
30
+ executables: []
31
+
33
32
  extensions: []
34
33
 
35
- extra_rdoc_files:
36
- - README.md
37
- - bin/fluiddb
38
- - bin/fluiddb-sandbox
39
- - lib/fluiddb.rb
40
- - lib/fluiddb/connection.rb
41
- - lib/fluiddb/console/common.rb
42
- - lib/fluiddb/console/console.rb
43
- - lib/fluiddb/console/sandbox.rb
44
- - lib/fluiddb/error.rb
45
- - lib/fluiddb/namespace.rb
46
- - lib/fluiddb/object.rb
47
- - lib/fluiddb/resource.rb
48
- - lib/fluiddb/tag.rb
49
- - lib/fluiddb/user.rb
50
- - lib/fluiddb/version.rb
34
+ extra_rdoc_files: []
35
+
51
36
  files:
52
- - Manifest
53
- - README.md
54
- - Rakefile
55
- - bin/fluiddb
56
- - bin/fluiddb-sandbox
57
37
  - fluidrb.gemspec
58
- - lib/fluiddb.rb
59
- - lib/fluiddb/connection.rb
60
- - lib/fluiddb/console/common.rb
61
- - lib/fluiddb/console/console.rb
62
- - lib/fluiddb/console/sandbox.rb
63
- - lib/fluiddb/error.rb
64
- - lib/fluiddb/namespace.rb
65
- - lib/fluiddb/object.rb
66
- - lib/fluiddb/resource.rb
67
- - lib/fluiddb/tag.rb
68
- - lib/fluiddb/user.rb
69
- - lib/fluiddb/version.rb
70
- - spec/namespace_spec.rb
71
- - spec/object_spec.rb
72
- - spec/spec_helper.rb
73
- - spec/tag_spec.rb
74
- - spec/user_spec.rb
38
+ - Rakefile
75
39
  has_rdoc: true
76
40
  homepage: http://wiki.github.com/guillermo/fluidrb
77
41
  licenses:
@@ -82,7 +46,7 @@ rdoc_options:
82
46
  - --title
83
47
  - Fluidrb
84
48
  - --main
85
- - README.md
49
+ - README
86
50
  require_paths:
87
51
  - lib
88
52
  required_ruby_version: !ruby/object:Gem::Requirement
data/Manifest DELETED
File without changes
data/README.md DELETED
@@ -1,128 +0,0 @@
1
- FLUIDRB
2
- =======
3
-
4
- Ruby api for fluidDB
5
-
6
-
7
-
8
-
9
-
10
- Current Features
11
- ----------------
12
-
13
- * fluiddb and fluiddb-sandbox command to open a fluiddb console with history and completion
14
- * Full implemented: Namespace, Object, Tag and User
15
-
16
-
17
- Todo
18
- ----
19
-
20
- * permissions:
21
- * policies:
22
-
23
- Spec Coverage
24
- -------------
25
-
26
- FluidDB::Namespace
27
- should find the user namespace
28
- should create a new namespace
29
- should edit namespace
30
- should remove namespaces
31
- should raise error
32
- on create if already exists
33
- on remove if no exists
34
- FluidDB::Object
35
- should create an Object
36
- should read and write tags
37
- should find objects
38
- FluidDB::Tag
39
- should be able to find
40
- should create a new tag
41
- should edit a tag
42
- should remove a tag
43
- should raise error
44
- on create if already exists
45
- on remove if no exists
46
- FluidDB::User
47
- should return an User if exists
48
- should raise an error if an User doesn't exists
49
-
50
-
51
- Sample Session
52
- --------------
53
-
54
- FluidDb (master)$ ./bin/fluiddb-sandbox
55
- Welcome to FluidDB Ruby Console
56
- ===============================
57
-
58
- Remember: * FDB == FluidDB
59
- * set $debug = true for debugg messages
60
- * FDB is ready to work with the sandbox"
61
-
62
-
63
- >> obj = FDB::Object.create!(:about => 'Cerveza Wadus')
64
- => #<FluidDB::Object URI="https://fluidDB.fluidinfo.com/objects/e7c83db0-b2be-4a9c-bd9b-800d80a97e45", about="Cerveza Wadus", path="/objects/e7c83db0-b2be-4a9c-bd9b-800d80a97e45", id="e7c83db0-b2be-4a9c-bd9b-800d80a97e45">
65
-
66
- >> obj.test.opinion = 'good taste'
67
- => "good taste"
68
-
69
- >> obj.test.opinion
70
- => #<FluidDB::Object path="/objects/0c171290-6d8d-467d-9789-3733c9c83e7f/test/opinion">
71
-
72
- >> obj.test.opinion.value
73
- => "good taste"
74
-
75
- >> obj / 'test/opinion'
76
- => "good taste"
77
-
78
- >> FDB::Object.find('has test/opinion').map{|obj| obj.test.opinion.value }
79
- => ["These is a "really good" object", "Good taste", "good opinion", "good taste"]
80
-
81
- >> obj.tags.map{|t| t.value}
82
- => ["Cerveza Wadus", "Good taste"]
83
-
84
- >> FDB::User.find('test')
85
- => #<FluidDB::User path="/users/test", name="test", id="8cc64c7d-a155-4246-ab2b-564f87fd9222">
86
-
87
- >> ns = FDB::Namespace.create!('test/cars', 'cars namespace')
88
- => #<FluidDB::Namespace URI="https://fluidDB.fluidinfo.com/namespaces/test/cars", path="/namespaces/test/cars", id="2876cad0-0fbf-4a02-b191-ee442a69d249">
89
-
90
- >> ns.update!("i don't have any car for a namespace")
91
- => #<FluidDB::Namespace URI="https://fluidDB.fluidinfo.com/namespaces/test/cars", path="/namespaces/test/cars", value="", id="2876cad0-0fbf-4a02-b191-ee442a69d249">
92
-
93
- >> FDB::Namespace.find('test/cars').destroy!
94
- => true
95
-
96
- >> FDB::Namespace.find('test').namespaces[-2..-1]
97
- => [#<FluidDB::Namespace path="/namespaces/test/fluidrb:guillermo:12522082095738315431458669685913185">, #<FluidDB::Namespace path="/namespaces/test/cars">]
98
-
99
- >> FDB::Tag.create!('test/opinion','opinion tag')
100
- => #<FluidDB::Tag indexed=true, URI="https://fluidDB.fluidinfo.com/tags/test/opinion", path="/tags/test/opinion", description="opinion tag", id="f00696ac-f2a7-4651-be55-bc43c60bd3e7">
101
-
102
- >> FDB::Tag.find('test/opinion')
103
- => #<FluidDB::Tag indexed=true, path="/tags/test/opinion", description="save my opinion", id="f00696ac-f2a7-4651-be55-bc43c60bd3e7">
104
-
105
- >> FDB::Tag.find('test/opinion').update!('Bad opinions').fetch
106
- => #<FluidDB::Tag indexed=true, path="/tags/test/opinion", value="", description="Bad opinions", id="f00696ac-f2a7-4651-be55-bc43c60bd3e7">
107
-
108
- >> FDB::Tag.find('test/opinion').destroy!
109
- => true
110
-
111
- >> FDB::Tag.find('test/opinion')
112
- FluidDB::Error: 404: TNonexistentAttribute at test/opinion}
113
-
114
-
115
- Disclaimer
116
- ----------
117
-
118
- These is just two nights work for personal playing with fluiddb, so it is not full clean as good as production software (must be).
119
- Feel free to fork me.
120
-
121
- About
122
- -----
123
- Based on the [work](http://github.com/ecarnevale/rb-fluidDB/tree/master) of [Emanuel Carnevale](http://twitter.com/onigiri)
124
-
125
- Author
126
- ------
127
- Guillermo Álvarez Fernández ( guillermo@cientifico.net )
128
-
data/bin/fluiddb DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- system "irb -f -r irb/completion -r irb/ext/save-history -r #{File.join(File.dirname(__FILE__),"..","lib","fluiddb")} -r fluiddb/console/console --prompt simple --readline"
data/bin/fluiddb-sandbox DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- system "irb -f -r irb/completion -r irb/ext/save-history -r #{File.join(File.dirname(__FILE__),"..","lib","fluiddb")} -r fluiddb/console/sandbox --prompt simple --readline"
data/lib/fluiddb.rb DELETED
@@ -1,20 +0,0 @@
1
- $:.unshift File.dirname(__FILE__)
2
- require 'rubygems'
3
- require 'json'
4
- require 'net/http'
5
- require 'net/https'
6
- require 'uri'
7
- require 'mime/types'
8
- require 'ostruct'
9
-
10
-
11
- require 'fluiddb/version'
12
- require 'fluiddb/error'
13
- require 'fluiddb/connection'
14
- require 'fluiddb/resource'
15
-
16
- require 'fluiddb/object'
17
- require 'fluiddb/user'
18
- require 'fluiddb/tag'
19
- require 'fluiddb/namespace'
20
-
@@ -1,72 +0,0 @@
1
-
2
- module FluidDB
3
- class << self
4
-
5
- # Set credentials
6
- def set_credentials(user,pass,server = 'fluiddb.fluidinfo.com', scheme = 'http', port = nil)
7
- @user, @pass, @server, @scheme, @port = user, pass, server, scheme, port
8
- connect!
9
- end
10
-
11
- def query(method,path,payload={},args={},headers={})
12
-
13
- uri = URI.parse(path)
14
- uri.query = URI.encode(args.map {|k,v| "#{k}=#{v}"}.join('&'))
15
-
16
- headers = DEFAULT_HEADERS.merge(headers)
17
- if [:post, :put].include?(method)
18
- payload = payload.to_json
19
- headers['Content-length'] = payload.size.to_s
20
- end
21
-
22
- $stderr << "#{method.to_s.upcase}: #{uri.to_s} (#{payload.inspect}, #{headers.inspect})\n" if $debug
23
- res = query_server(method,uri.to_s,payload,headers)
24
-
25
-
26
- data = ''
27
- if MIME::Type.simplified(res['content-type']) == 'application/json'
28
- data = symbolize_keys(JSON.parse(res.body)) if res.body
29
- else
30
- data = res.body if res.body
31
- end
32
- $stderr << "#{res.code}: #{data.inspect}\n" if $debug
33
- raise FluidDB::Error.new(data) unless [200,201,204].include?(res.code.to_i)
34
-
35
- data
36
- end
37
-
38
-
39
- protected
40
-
41
- attr_accessor :connection, :user, :pass, :server, :scheme
42
-
43
- def connect!
44
- @connection = Net::HTTP.new(@server, @port || @scheme == 'https' ? 443 : 80)
45
- @connection.use_ssl = true if @scheme == 'https'
46
- @connection.start
47
- end
48
-
49
- DEFAULT_HEADERS = {'Content-type' => 'application/json', 'Accept' => 'application/json'}
50
-
51
-
52
- def query_server(method, path, payload={}, headers = {})
53
- req = Net::HTTP.const_get(method.to_s.capitalize).new(path, headers)
54
- req.basic_auth(@user, @pass) if @user
55
-
56
- if [:post, :put].include?(method)
57
- @connection.request(req,payload)
58
- else
59
- @connection.request(req)
60
- end
61
- end
62
-
63
- def symbolize_keys(hash)
64
- hash.inject({}) do |options, (key, value)|
65
- options[(key.to_sym rescue key) || key] = value
66
- options
67
- end
68
- end
69
-
70
-
71
- end
72
- end
@@ -1,20 +0,0 @@
1
- begin
2
- require 'wirble'
3
- # start wirble (with color)
4
- Wirble.init
5
- Wirble.colorize
6
- rescue LoadError => err
7
- puts "sudo gem install wirble to get some colorization"
8
- end
9
- IRB.conf[:SAVE_HISTORY] = 1000
10
- IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.fluiddb-history"
11
-
12
- FDB = FluidDB
13
-
14
- puts <<-EOF
15
- Welcome to FluidDB Ruby Console
16
- ===============================
17
-
18
- Remember: * FDB == FluidDB
19
- * set $debug = true for debugg messages
20
- EOF
@@ -1,9 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'common.rb')
2
-
3
- puts <<-EOF
4
- * FDB.set_credentials(user,pass) to access to your fluidDB account
5
-
6
- EOF
7
-
8
-
9
-
@@ -1,11 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'common.rb')
2
-
3
-
4
- FDB.set_credentials('test','test','sandbox.fluidinfo.com','https')
5
-
6
- puts <<-EOPUTS
7
- * FDB is ready to work with the sandbox"
8
-
9
- EOPUTS
10
-
11
-
data/lib/fluiddb/error.rb DELETED
@@ -1,17 +0,0 @@
1
-
2
-
3
- module FluidDB
4
- class Error < Exception
5
- def self.new(info)
6
- info = "#{info[:errorCode]}: #{info[:errorClass]} at #{info[:path]}}" if info.is_a? Hash
7
- super(info)
8
- end
9
-
10
- def self.check_errors(ret)
11
- raise FluidDB::Error.new(ret) if ret && ret[:errorCode]
12
- end
13
- end
14
-
15
- end
16
-
17
-
@@ -1,43 +0,0 @@
1
- module FluidDB
2
- class Namespace < Resource
3
-
4
- def self.create!(namespace,description)
5
- path = namespace.split('/')[0..-2].join('/')
6
- name = namespace.split('/').last
7
-
8
- new_namespace = new(:path => '/namespaces/'+path)
9
- new_namespace.post!(:description => description, :name => name)
10
- end
11
-
12
- def self.find(namespace)
13
- new(:path => "/namespaces/#{namespace}").fetch
14
- end
15
-
16
- def fetch
17
- get!(:returnDescription => true, :returnNamespaces => true, :returnTags => true)
18
- self
19
- end
20
-
21
- def update!(description)
22
- put!(:description=>description)
23
- self
24
- end
25
-
26
- def destroy!
27
- ret = delete!
28
- true
29
- end
30
-
31
- def tags
32
- @table[:tagNames] || fetch
33
- @table[:tagNames]
34
- end
35
-
36
- def namespaces
37
- @table[:namespaceNames] || fetch
38
- @table[:namespaceNames] && @table[:namespaceNames].map do |n|
39
- Namespace.new(:path => @table[:path] + '/' + n)
40
- end
41
- end
42
- end
43
- end
@@ -1,66 +0,0 @@
1
-
2
- module FluidDB
3
-
4
- # FluidDB Object
5
- class Object < Resource
6
-
7
- # Create a new object.
8
- # FluidDB::Object.create!
9
- # FluidDB::Object.create!(:about => 'Cocacola')
10
- def self.create!(opts = {})
11
- new(opts.merge(:path => '/objects')).post!(opts)
12
- end
13
-
14
- def self.find(query)
15
- res = FluidDB.query(:get, "/objects", {}, {:query => query})[:ids] || []
16
- res.map{|o| self.new(:path => "/objects/#{o}")}
17
- end
18
-
19
- # Fetch the object from the server
20
- def fetch
21
- merge_with_self(get!)
22
- self
23
- end
24
-
25
-
26
- # Return the value of a tag
27
- # fluiddbobj / "user/opinion" => 'Really nice'
28
- def / (tag)
29
- Object.new(:path => self.path + "/"+tag ).value
30
- end
31
-
32
- # Simple form to fetch tags
33
- # fluiddbobj.user.opinion.fetch! => 'Really nice'
34
- # fluiddbobj.user.opinion = 'Not Really nice'
35
- def method_missing(meth,*args)
36
- if meth.to_s =~ /=$/
37
- obj = Object.new(:path => self.path+"/"+ meth.to_s.gsub(/=$/,''))
38
- obj.update!(*args)
39
- else
40
- obj = (super || Object.new(:path => self.path+"/"+meth.to_s ))
41
- end
42
- obj
43
- end
44
-
45
- def value
46
- @table[:value] || fetch
47
- @table[:value]
48
- end
49
-
50
- # Update the value of a tag
51
- def update!(value)
52
- put!({:value=>value})
53
- self
54
- end
55
-
56
- # Return an array of names that that object contains
57
- def tags
58
- @table[:tagPaths] || fetch
59
- @table[:tagPaths].map do |tag|
60
- Object.new(:path => @table[:path]+'/'+tag)
61
- end
62
- end
63
-
64
- end
65
- end
66
-
@@ -1,43 +0,0 @@
1
- module FluidDB
2
- class Resource < OpenStruct
3
-
4
- def head!(payload={}, uri_args={}, additional_headers = {})
5
- FluidDB.query(:head, @table[:path], payload, uri_args, additional_headers)
6
- end
7
-
8
- def put!(payload={}, uri_args={}, additional_headers = {})
9
- res = FluidDB.query(:put, @table[:path], payload, uri_args, additional_headers)
10
- merge_with_self(res)
11
- self
12
- end
13
-
14
- def get!(uri_args = {}, additional_headers = {})
15
- new_data = FluidDB.query(:get, @table[:path],{}, uri_args, additional_headers)
16
- merge_with_self(new_data)
17
- end
18
-
19
- def post!(payload={}, uri_args={}, additional_headers = {})
20
- res = FluidDB.query(:post, @table[:path], payload, uri_args, additional_headers)
21
- merge_with_self(res)
22
- update_path_from_uri
23
- self
24
- end
25
-
26
- def delete!(payload={}, uri_args={}, additional_headers = {})
27
- FluidDB.query(:delete, @table[:path], payload, uri_args, additional_headers)
28
- end
29
-
30
- private
31
- def merge_with_self(new_data)
32
- if new_data.is_a? Hash
33
- @table.merge!(new_data)
34
- else
35
- @table.merge!(:value => new_data)
36
- end
37
- end
38
-
39
- def update_path_from_uri
40
- self.path = URI.parse(self.URI).path
41
- end
42
- end
43
- end
data/lib/fluiddb/tag.rb DELETED
@@ -1,32 +0,0 @@
1
- module FluidDB
2
- class Tag < Resource
3
-
4
- def self.create!(tag,description,indexed = true)
5
- path = tag.split('/')[0..-2].join('/')
6
- name = tag.split('/').last
7
-
8
- new_tag = new(:path => '/tags/'+path, :description => description, :indexed => indexed)
9
- new_tag.post!(:description => description, :name => name, :indexed => indexed)
10
- end
11
-
12
- def self.find(tag)
13
- new(:path => '/tags/'+tag).fetch
14
- end
15
-
16
- def fetch
17
- get!(:returnDescription => true)
18
- self
19
- end
20
-
21
- def update!(description)
22
- put!(:description=>description)
23
- self
24
- end
25
-
26
- def destroy!
27
- ret = delete!
28
- true
29
- end
30
-
31
- end
32
- end
data/lib/fluiddb/user.rb DELETED
@@ -1,12 +0,0 @@
1
- module FluidDB
2
- class User < Resource
3
- def self.find(name)
4
- new(:path => '/users/'+name).fetch
5
- end
6
-
7
- def fetch
8
- get!
9
- self
10
- end
11
- end
12
- end
@@ -1,3 +0,0 @@
1
- module FluidDB
2
- VERSION = '0.0.3'
3
- end
@@ -1,42 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'spec_helper')
2
-
3
- describe FluidDB::Namespace do
4
-
5
- it 'should find the user namespace' do
6
- FluidDB::Namespace.find('test').should be_kind_of(FluidDB::Namespace)
7
- end
8
-
9
- it 'should create a new namespace' do
10
- name = generate_uniq
11
- FluidDB::Namespace.create!("test/#{name}",'description').should be
12
- end
13
-
14
- it 'should edit namespace' do
15
- name = generate_uniq
16
- ns = FluidDB::Namespace.create!("test/#{name}",'description')
17
- ns.update!('another description')
18
- ns.fetch.description.should == 'another description'
19
- end
20
-
21
- it 'should remove namespaces' do
22
- name = generate_uniq
23
- ns = FluidDB::Namespace.create!("test/#{name}",'description')
24
- ns.destroy!.should == true
25
- end
26
-
27
- describe 'should raise error' do
28
- it 'on create if already exists' do
29
- name = generate_uniq
30
- FluidDB::Namespace.create!("test/#{name}",'description')
31
- lambda{ FluidDB::Namespace.create!("test/#{name}",'description') }.should raise_error( FluidDB::Error )
32
- end
33
-
34
- it 'on remove if no exists' do
35
- name = generate_uniq
36
- ns = FluidDB::Namespace.create!("test/#{name}",'description')
37
- ns.delete!
38
- lambda{ ns.delete! }.should raise_error( FluidDB::Error )
39
- end
40
- end
41
-
42
- end
data/spec/object_spec.rb DELETED
@@ -1,41 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'spec_helper')
2
-
3
- describe FluidDB::Object do
4
- before(:all) do
5
- FDB::Tag.create!('test/opinion','opinion tag') rescue nil
6
- end
7
-
8
- it 'should create an Object' do
9
- about = generate_uniq
10
- o = FluidDB::Object.create!(:about => about)
11
-
12
- o.create!.should be_kind_of(FluidDB::Object)
13
- o.about.should == about
14
- end
15
-
16
- it 'should read and write tags' do
17
- o = FluidDB::Object.create!
18
- message = 'These is a "really good" object'
19
- o.test.opinion = message
20
-
21
- (o / "test/opinion").should == message
22
- o.test.opinion.value.should == message
23
- end
24
-
25
- it 'should return tags' do
26
- about = generate_uniq
27
- obj = FluidDB::Object.create!(:about => about)
28
- obj.tags.each do |t|
29
- t.should be_kind_of(FluidDB::Object)
30
- end
31
- end
32
-
33
- it 'should find objects' do
34
- o = FluidDB::Object.create!(:about => 'a object with opinion')
35
- o.test.opinion = 'good opinion'
36
-
37
- objs = FluidDB::Object.find("has test/opinion").map{|o| o / "test/opinion"}
38
- objs.should be_include('good opinion')
39
- end
40
-
41
- end
data/spec/spec_helper.rb DELETED
@@ -1,8 +0,0 @@
1
- require File.dirname(__FILE__) + '/../lib/fluiddb'
2
-
3
- FluidDB.set_credentials('test','test','sandbox.fluidinfo.com')
4
-
5
-
6
- def generate_uniq
7
- "fluidrb:#{`who am i`.split.first}:" + Time.now.to_i.to_s + Time.now.usec.to_s + rand(9999999999999999999).to_s
8
- end
data/spec/tag_spec.rb DELETED
@@ -1,53 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'spec_helper')
2
-
3
- describe FluidDB::Tag do
4
-
5
- it 'should be able to find' do
6
- name = generate_uniq
7
- FluidDB::Tag.create!("test/#{name}",'description')
8
-
9
- tag = FluidDB::Tag.find("test/#{name}")
10
- tag.should be_kind_of(FluidDB::Tag)
11
- tag.description.should == 'description'
12
- end
13
-
14
- it 'should create a new tag' do
15
- name = generate_uniq
16
- tag = FluidDB::Tag.create!("test/#{name}",'description')
17
-
18
- tag.should be_kind_of(FluidDB::Tag)
19
- tag.description.should == 'description'
20
- tag.indexed.should == true
21
- end
22
-
23
- it 'should edit a tag' do
24
- name = generate_uniq
25
- tag = FluidDB::Tag.create!("test/#{name}",'description')
26
-
27
- tag.update!('new description')
28
- FluidDB::Tag.find("test/#{name}").description.should == 'new description'
29
- end
30
-
31
- it 'should remove a tag' do
32
- name = generate_uniq
33
- tag = FluidDB::Tag.create!("test/#{name}",'description')
34
- tag.destroy!.should == true
35
- end
36
-
37
- describe 'should raise error' do
38
- it 'on create if already exists' do
39
- name = generate_uniq
40
- tag = FluidDB::Tag.create!("test/#{name}",'description')
41
-
42
- lambda{ FluidDB::Tag.create!("test/#{name}",'description') }.should raise_error( FluidDB::Error )
43
- end
44
-
45
- it 'on remove if no exists' do
46
- name = generate_uniq
47
- tag = FluidDB::Tag.create!("test/#{name}",'description')
48
- tag.destroy!.should == true
49
- lambda{ tag.destroy! }.should raise_error( FluidDB::Error)
50
- end
51
- end
52
-
53
- end
data/spec/user_spec.rb DELETED
@@ -1,14 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'spec_helper')
2
-
3
- describe FluidDB::User do
4
-
5
- it 'should return an User if exists' do
6
- u = FluidDB::User.find('test')
7
- u.should be_kind_of(FluidDB::User)
8
- u.name.should == 'test'
9
- end
10
-
11
- it 'should raise an error if an User doesn\'t exists' do
12
- lambda { FluidDB::User.find('probablyanonexistinguser') }.should raise_error(FluidDB::Error)
13
- end
14
- end