cfrederick-titanium 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +80 -3
- data/lib/sqlite_adapter.rb +2 -2
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -1,5 +1,82 @@
|
|
1
|
-
=
|
1
|
+
= titanium
|
2
|
+
|
3
|
+
titanium is a Rack[http://rack.rubyforge.org] based application server that follows
|
4
|
+
RESTful[http://en.wikipedia.org/wiki/Representational_State_Transfer] principals to
|
5
|
+
automatically interact with a
|
6
|
+
document-oriented[http://en.wikipedia.org/wiki/Document-oriented_database] database.
|
7
|
+
Additionally, titanium uses JSON[http://en.wikipedia.org/wiki/JSON] to return information back to
|
8
|
+
the consumer.
|
9
|
+
|
10
|
+
== What are some possible uses for titanium?
|
11
|
+
The most common choice is for simple AJAX enabled web applications; however, the list below includes additional ideas.
|
12
|
+
|
13
|
+
* to develop web applications with only HTML and JavaScript
|
14
|
+
* to develop a content management system with an administrative interface for another system
|
15
|
+
* to prototype a web page/site
|
16
|
+
* to provide simple storage access to anything with the ability to make HTTP requests
|
17
|
+
* shared hosting providers could add titanium to their Rack enabled web servers to allow customers the ability to create web applications with storage just by using HTML and JavaScript
|
18
|
+
|
19
|
+
== How does titanium work?
|
20
|
+
|
21
|
+
Standard HTTP protocol conventions are used to determine what database actions to perform.
|
22
|
+
|
23
|
+
Below are examples of HTTP requests and a brief explanation of the database action that will be executed.
|
24
|
+
|
25
|
+
Inserts a car into the datastore. The data saved is determined from the POST parameters. Returns the key of the item saved.
|
26
|
+
POST /foo/car
|
27
|
+
|
28
|
+
Updates the car with key 55. The data updated is taken from the PUT parameters. Returns the key of the item updated.
|
29
|
+
PUT /foo/car@55
|
30
|
+
|
31
|
+
Returns all cars
|
32
|
+
GET /foo/car
|
33
|
+
|
34
|
+
Returns a single car who's key is equal to 55.
|
35
|
+
GET /foo/car@55
|
36
|
+
|
37
|
+
Returns all Honda car's made in 2009
|
38
|
+
GET /foo/car?year=2009&make=Honda
|
39
|
+
|
40
|
+
Returns all car's made in 2009 sorted by make in ascending order
|
41
|
+
GET /foo/car?year=2009&sort-field=make&sort-order=asc
|
42
|
+
|
43
|
+
Returns the second page of five results of Honda car's made in 2009 sorted by model in descending order
|
44
|
+
GET /foo/car?year=2009&make=Honda&sort-field=model&sort-order=desc&limit=5&offset=5
|
45
|
+
|
46
|
+
Deletes the car with key 55
|
47
|
+
DELETE /foo/car@55
|
48
|
+
|
49
|
+
Deletes all cars
|
50
|
+
DELETE /foo/car
|
51
|
+
|
52
|
+
== Getting started
|
53
|
+
Follow the instructions below to start developing a site using titanium.
|
54
|
+
|
55
|
+
Create the folder structure below for the web application's source.
|
56
|
+
myapp
|
57
|
+
myapp/public
|
58
|
+
myapp/tmp
|
59
|
+
|
60
|
+
Create an <tt>index.html</tt> file in the <tt>myapp/public</tt> folder.
|
61
|
+
|
62
|
+
Create a rackup file at <tt>myapp/config.ru</tt> with the following contents. This file is used to tell
|
63
|
+
the titanium server where the web application resides. <em>Make sure to use the full path to the
|
64
|
+
<tt>myapp/public</tt> folder.</em>
|
65
|
+
require 'titanium'
|
66
|
+
run Titanium::Server.new("/var/www/myapp/public")
|
67
|
+
|
68
|
+
Download and install Ruby[http://www.ruby-lang.org] at http://www.ruby-lang.org/en/downloads.
|
69
|
+
|
70
|
+
Download and install SQLite3[http://sqlite.org] for Ruby. Typically this involves downloading
|
71
|
+
a precompiled set of binaries from http://sqlite.org/download.html, and unpacking the download into the
|
72
|
+
ruby/bin directory.
|
73
|
+
|
74
|
+
Install the titanium gem with:
|
75
|
+
sudo gem install cfrederick-titanium
|
76
|
+
|
77
|
+
Run titanium using the <tt>config.ru</tt> created above.
|
78
|
+
rackup /var/www/myapp/config.ru
|
79
|
+
|
80
|
+
View at: http://localhost:9292
|
2
81
|
|
3
|
-
= How does titanium work?
|
4
82
|
|
5
|
-
= Getting started
|
data/lib/sqlite_adapter.rb
CHANGED
@@ -73,7 +73,7 @@ module Titanium
|
|
73
73
|
@db.execute(sql_insert_attribute, :resource_key => resource_key, :key => key, :value => value)
|
74
74
|
end
|
75
75
|
end
|
76
|
-
return resource_key
|
76
|
+
return resource_key.to_s
|
77
77
|
end
|
78
78
|
|
79
79
|
def update(resource_key, metadata)
|
@@ -99,7 +99,7 @@ module Titanium
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def count_by_name(name)
|
102
|
-
return @db.get_first_value(sql_count_of_resources_by_type_name, :name => name)
|
102
|
+
return @db.get_first_value(sql_count_of_resources_by_type_name, :name => name).to_i
|
103
103
|
end
|
104
104
|
|
105
105
|
def delete_all_by_name(name)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfrederick-titanium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Frederick
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.2.
|
33
|
+
version: 1.2.2
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: json_pure
|