rhodes 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.1.1 2008-11-18
2
+ * Fixed template application name
3
+
1
4
  == 0.1.0 2008-11-18
2
5
 
3
6
  * 1 major enhancement:
data/Rakefile CHANGED
@@ -15,6 +15,9 @@ $hoe = Hoe.new('rhodes', Rhodes::VERSION) do |p|
15
15
  ['sqlite3-ruby','>= 1.2.4'],
16
16
  ['rcov'],
17
17
  ['rspec'],
18
+ ['templater'],
19
+ ['diff-lcs'],
20
+ ['extlib']
18
21
  ]
19
22
  p.extra_dev_deps = [
20
23
  ['newgem', ">= #{::Newgem::VERSION}"]
@@ -1,4 +1,4 @@
1
1
  require 'rho/rhoapplication'
2
2
 
3
- class <%= class_name %> < Rho::RhoApplication
3
+ class <%= class_name %>Application < Rho::RhoApplication
4
4
  end
data/lib/rho/render.rb CHANGED
@@ -2,6 +2,9 @@ require 'erb'
2
2
 
3
3
  module Rho
4
4
  class RhoController
5
+ def self.renderfile(filename)
6
+ ERB.new(IO.read(filename)).result(binding)
7
+ end
5
8
  def render(view)
6
9
  ERB.new(IO.read(@request[:modelpath]+view.to_s+'.erb')).result(binding)
7
10
  end
data/lib/rho/renderME.rb CHANGED
@@ -1,6 +1,9 @@
1
1
 
2
2
  module Rho
3
3
  class RhoController
4
+ def self.renderfile(filename)
5
+ eval(filename+'_erb', binding)
6
+ end
4
7
  def render(view)
5
8
  eval(@request[:modelpath]+view.to_s+'_erb', binding )
6
9
  end
data/lib/rho/rho.rb CHANGED
@@ -1,4 +1,9 @@
1
1
  require 'time'
2
+ if defined? RHO_ME
3
+ require 'rho/renderME'
4
+ else
5
+ require 'rho/render'
6
+ end
2
7
  require 'rho/rhoapplication'
3
8
  require 'rhom'
4
9
  require 'rhofsconnector'
@@ -32,10 +37,10 @@ module Rho
32
37
 
33
38
  # setup the sources table and model attributes for all applications
34
39
  def init_sources
35
- if defined? Rho::RhoConfig::sources
40
+ puts 'sources initialized? ' + self.sources_initialized?.inspect
41
+ if defined? Rho::RhoConfig::sources and not self.sources_initialized?
36
42
  Rhom::RhomDbAdapter::delete_all_from_table('sources')
37
43
  src_attribs = []
38
- attribs_empty = false
39
44
 
40
45
  # quick and dirty way to get unique array of hashes
41
46
  uniq_sources = Rho::RhoConfig::sources.values.inject([]) { |result,h|
@@ -51,6 +56,10 @@ module Rho
51
56
  end
52
57
  end
53
58
  end
59
+
60
+ def sources_initialized?
61
+ Rhom::RhomDbAdapter::select_from_table('sources','*').size > 0 ? true : false
62
+ end
54
63
 
55
64
  def get_app(appname)
56
65
  if (APPLICATIONS[appname].nil?)
@@ -82,6 +91,17 @@ module Rho
82
91
  end
83
92
  end
84
93
 
94
+ def serve_index(index_name)
95
+ begin
96
+ puts 'inside RHO.serve_index: ' + index_name
97
+ res = init_response
98
+ res['request-body'] = RhoController::renderfile(index_name)
99
+ return send_response(res)
100
+ rescue Exception => e
101
+ return send_error(e.message,500,true)
102
+ end
103
+ end
104
+
85
105
  def init_response(status=200,message="OK",body="")
86
106
  res = Hash.new
87
107
  res['status'] = status
data/lib/rhodes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Rhodes
2
2
  unless defined? Rhodes::VERSION
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
- end
5
+ end
@@ -87,7 +87,7 @@ module Rhom
87
87
  obj = strip_braces(args.first.to_s)
88
88
  result = ::Rhom::RhomDbAdapter::select_from_table(::Rhom::TABLE_NAME,
89
89
  '*',
90
- {"object"=>obj})
90
+ {"object"=>obj,"update_type"=>'query'})
91
91
  end
92
92
  list = get_list(result)
93
93
  if list.length == 1
data/spec/rho_spec.rb CHANGED
@@ -21,8 +21,24 @@ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
21
21
  require File.dirname(__FILE__) + "/spec_helper"
22
22
 
23
23
  describe "Rho" do
24
+
25
+ it_should_behave_like "rho initializer"
24
26
 
25
27
  it "should populate configuration in sources table" do
26
- pending 'somebody should implement this!'
28
+ sources = Rhom::RhomDbAdapter::select_from_table('sources','*')
29
+ puts 'sources: ' + sources.inspect
30
+
31
+ sources.size.should == 3
32
+ end
33
+
34
+ it "should initialize configuration only once" do
35
+ Rhom::RhomDbAdapter::delete_all_from_table('sources')
36
+ @rho.sources_initialized?.should == false
37
+ @rho.init_sources
38
+ @rho.sources_initialized?.should == true
39
+ end
40
+
41
+ it "should serve request" do
42
+ pending "need to mock request"
27
43
  end
28
44
  end
@@ -19,19 +19,8 @@
19
19
  require File.dirname(__FILE__) + "/spec_helper"
20
20
 
21
21
  describe "RhomObjectFactory" do
22
-
23
- attr_accessor :rhom, :rho
24
-
25
- before(:all) do
26
- FileUtils.mkdir_p('build')
27
- FileUtils.cp_r('spec/syncdbtest.sqlite','build/syncdbtest.sqlite')
28
- Rho::RhoConfig::add_source("Account", {"url"=>"http://rhosync.rhomobile.com/sources/1", "source_id"=>1})
29
- Rho::RhoConfig::add_source("Case", {"url"=>"http://rhosync.rhomobile.com/sources/1", "source_id"=>2})
30
- Rho::RhoConfig::add_source("Employee", {"url"=>"http://rhosync.rhomobile.com/sources/1", "source_id"=>3})
31
- Object::const_set("SYNC_DB_FILE", "../../build/syncdbtest.sqlite") unless defined? SYNC_DB_FILE
32
- @rho = Rho::RHO.new(File.dirname(__FILE__) + "/../../../apps/")
33
- @rhom = Rhom::RhomObjectFactory.new
34
- end
22
+
23
+ it_should_behave_like "rho initializer"
35
24
 
36
25
  before(:each) do
37
26
  FileUtils.cp_r('spec/syncdbtest.sqlite','build/syncdbtest.sqlite')
@@ -42,16 +31,6 @@ describe "RhomObjectFactory" do
42
31
  @rhom = nil
43
32
  end
44
33
 
45
- after(:all) do
46
- FileUtils.rm_rf('build')
47
- end
48
-
49
- def array_print(arr)
50
- arr.each_with_index do |x,i|
51
- puts "arr[#{i}] = #{x.inspect}"
52
- end
53
- end
54
-
55
34
  it "should set source_id attributes" do
56
35
  "1".should == Account.get_source_id
57
36
  "2".should == Case.get_source_id
@@ -93,6 +72,13 @@ describe "RhomObjectFactory" do
93
72
  "Mirapath".should == results[4].name
94
73
  end
95
74
 
75
+ it "should have correct number of attributes" do
76
+ @account = Account.find(:all).first
77
+
78
+ # expecting name, industry, update_type, object, source_id
79
+ @account.instance_variables.size.should == 5
80
+ end
81
+
96
82
  it "should calculate same djb_hash" do
97
83
  vars = {"name"=>"foobarthree", "industry"=>"entertainment"}
98
84
  account = Account.new(vars)
@@ -104,7 +90,7 @@ describe "RhomObjectFactory" do
104
90
  @account1 = Account.new(vars)
105
91
  new_id = @account1.object
106
92
  @account1.save
107
- @account2 = Account.find(new_id).first
93
+ @account2 = Account.find(new_id)
108
94
  @account2.object.should =="{#{@account1.object}}"
109
95
  @account2.name.should == vars['name']
110
96
  @account2.industry.should == vars['industry']
data/spec/spec_helper.rb CHANGED
@@ -11,4 +11,31 @@ $:.unshift(File.join(File.dirname(__FILE__), '..'))
11
11
  # Use the rubygem for local testing
12
12
  require 'spec/stubs'
13
13
  require 'rho/rho'
14
- require 'rhom/rhom'
14
+ require 'rho/settings_controller'
15
+ require 'rhom/rhom'
16
+
17
+ describe "rho initializer", :shared => true do
18
+
19
+ attr_accessor :rhom, :rho
20
+
21
+ before(:all) do
22
+ FileUtils.mkdir_p('build')
23
+ FileUtils.cp_r('spec/syncdbtest.sqlite','build/syncdbtest.sqlite')
24
+ Rho::RhoConfig::add_source("Account", {"url"=>"http://rhosync.rhohub.com/sources/1", "source_id"=>1})
25
+ Rho::RhoConfig::add_source("Case", {"url"=>"http://rhosync.rhohub.com/sources/2", "source_id"=>2})
26
+ Rho::RhoConfig::add_source("Employee", {"url"=>"http://rhosync.rhohub.com/sources/3", "source_id"=>3})
27
+ Object::const_set("SYNC_DB_FILE", "../../build/syncdbtest.sqlite") unless defined? SYNC_DB_FILE
28
+ @rho = Rho::RHO.new(File.dirname(__FILE__) + "/../../../apps/")
29
+ @rhom = Rhom::RhomObjectFactory.new
30
+ end
31
+
32
+ after(:all) do
33
+ FileUtils.rm_rf('build')
34
+ end
35
+
36
+ def array_print(arr)
37
+ arr.each_with_index do |x,i|
38
+ puts "arr[#{i}] = #{x.inspect}"
39
+ end
40
+ end
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhodes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rhomobile Dev
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-25 00:00:00 -08:00
12
+ date: 2008-12-05 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,6 +42,36 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: "0"
44
44
  version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: templater
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: diff-lcs
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: extlib
67
+ type: :runtime
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
45
75
  - !ruby/object:Gem::Dependency
46
76
  name: newgem
47
77
  type: :development