rhodes 0.3.0 → 1.0.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.
Files changed (65) hide show
  1. data/Manifest.txt +0 -61
  2. data/Rakefile +11 -13
  3. data/lib/rhodes.rb +2 -2
  4. metadata +33 -77
  5. data/History.txt +0 -40
  6. data/README.rdoc +0 -2
  7. data/bin/rhogen +0 -8
  8. data/generators/rhogen.rb +0 -131
  9. data/generators/templates/application/application.rb +0 -4
  10. data/generators/templates/application/index.erb +0 -11
  11. data/generators/templates/application/layout.erb +0 -17
  12. data/generators/templates/model/config.rb +0 -3
  13. data/generators/templates/model/controller.rb +0 -49
  14. data/generators/templates/model/edit.erb +0 -21
  15. data/generators/templates/model/index.erb +0 -10
  16. data/generators/templates/model/new.erb +0 -16
  17. data/generators/templates/model/show.erb +0 -6
  18. data/generators/templates/source/source_adapter.rb +0 -56
  19. data/lib/ServeME.rb +0 -7
  20. data/lib/TestServe.rb +0 -9
  21. data/lib/bsearch.rb +0 -120
  22. data/lib/builtinME.rb +0 -588
  23. data/lib/date.rb +0 -1792
  24. data/lib/date/format.rb +0 -1339
  25. data/lib/dateME.rb +0 -24
  26. data/lib/erb.rb +0 -896
  27. data/lib/find.rb +0 -81
  28. data/lib/rational.rb +0 -19
  29. data/lib/rationalME.rb +0 -530
  30. data/lib/rho.rb +0 -1
  31. data/lib/rho/render.rb +0 -51
  32. data/lib/rho/rho.rb +0 -240
  33. data/lib/rho/rhoapplication.rb +0 -36
  34. data/lib/rho/rhocontact.rb +0 -110
  35. data/lib/rho/rhocontroller.rb +0 -35
  36. data/lib/rho/rhofsconnector.rb +0 -32
  37. data/lib/rho/rhosupport.rb +0 -139
  38. data/lib/rho/rhoviewhelpers.rb +0 -121
  39. data/lib/rhoframework.rb +0 -38
  40. data/lib/rhofsconnector.rb +0 -1
  41. data/lib/rhom.rb +0 -1
  42. data/lib/rhom/rhom.rb +0 -58
  43. data/lib/rhom/rhom_db_adapter.rb +0 -185
  44. data/lib/rhom/rhom_db_adapterME.rb +0 -93
  45. data/lib/rhom/rhom_object.rb +0 -65
  46. data/lib/rhom/rhom_object_factory.rb +0 -197
  47. data/lib/rhom/rhom_source.rb +0 -60
  48. data/lib/singleton.rb +0 -137
  49. data/lib/time.rb +0 -489
  50. data/spec/app_generator_spec.rb +0 -33
  51. data/spec/app_manifest.txt +0 -3
  52. data/spec/configs/account.rb +0 -3
  53. data/spec/configs/case.rb +0 -3
  54. data/spec/configs/employee.rb +0 -3
  55. data/spec/generator_spec_helper.rb +0 -12
  56. data/spec/model_generator_spec.rb +0 -36
  57. data/spec/rho_controller_spec.rb +0 -139
  58. data/spec/rho_spec.rb +0 -61
  59. data/spec/rhom_object_factory_spec.rb +0 -132
  60. data/spec/rhom_spec.rb +0 -45
  61. data/spec/source_generator_spec.rb +0 -27
  62. data/spec/spec_helper.rb +0 -48
  63. data/spec/stubs.rb +0 -31
  64. data/spec/syncdbtest.sqlite +0 -0
  65. data/tasks/rspec.rake +0 -34
@@ -1,33 +0,0 @@
1
- require File.dirname(__FILE__) + '/generator_spec_helper'
2
-
3
- describe Rhogen::AppGenerator do
4
-
5
- app_name = 'NeatApp'
6
-
7
- it "should complain if no name is specified" do
8
- lambda {
9
- @generator = Rhogen::AppGenerator.new('/tmp', {})
10
- }.should raise_error(::Templater::TooFewArgumentsError)
11
- end
12
-
13
-
14
- it "should generate class_name" do
15
- @generator = Rhogen::AppGenerator.new('/tmp', {}, 'Class-With-Hyphens')
16
- @generator.class_name.should == 'ClassWithHyphens'
17
- end
18
-
19
- before do
20
- @generator = Rhogen::AppGenerator.new('/tmp', {}, app_name)
21
- end
22
-
23
- it "should create application.rb, index.erb, and layout.erb files" do
24
- ['application.rb', 'index.erb', 'layout.erb'].each do |template|
25
- @generator.should create("/tmp/#{app_name}/#{template}")
26
- end
27
- end
28
-
29
- it "should generate valid erb templates" do
30
- pending "need to figure out how to validate erb"
31
- end
32
-
33
- end
@@ -1,3 +0,0 @@
1
- configs/account
2
- configs/case
3
- configs/employee
@@ -1,3 +0,0 @@
1
- require 'rho'
2
-
3
- Rho::RhoConfig::add_source("Account", {"url"=>"http://rhosyncdev.rhohub.com/sources/1", "source_id"=>1})
@@ -1,3 +0,0 @@
1
- require 'rho'
2
-
3
- Rho::RhoConfig::add_source("Case", {"url"=>"http://rhosyncdev.rhohub.com/sources/2", "source_id"=>2})
@@ -1,3 +0,0 @@
1
- require 'rho'
2
-
3
- Rho::RhoConfig::add_source("Employee", {"url"=>"http://rhosyncdev.rhohub.com/sources/3", "source_id"=>3})
@@ -1,12 +0,0 @@
1
- $:.push File.join(File.dirname(__FILE__), '..', 'lib')
2
-
3
- require 'rubygems'
4
- require 'spec'
5
- require 'templater/spec/helpers'
6
-
7
- $:.push File.join(File.dirname(__FILE__), '..', 'generators')
8
- require 'rhogen'
9
-
10
- Spec::Runner.configure do |config|
11
- config.include Templater::Spec::Helpers
12
- end
@@ -1,36 +0,0 @@
1
- require File.dirname(__FILE__) + '/generator_spec_helper'
2
- require 'fileutils'
3
-
4
- describe Rhogen::ModelGenerator do
5
-
6
- model_name = 'employee'
7
-
8
- it "should complain if no name is specified" do
9
- lambda {
10
- @generator = Rhogen::ModelGenerator.new('/tmp', {})
11
- }.should raise_error(::Templater::TooFewArgumentsError)
12
- end
13
-
14
- before do
15
- @generator = Rhogen::ModelGenerator.new('/tmp', {}, model_name, "http://something.com/sources/5", 5, "name,industry,address")
16
- end
17
-
18
- it "should have attributes" do
19
- @generator.attributes?.should == true
20
- end
21
-
22
- it "should have all attributes" do
23
- @generator.attributes.should == ['name', 'industry', 'address']
24
- end
25
-
26
- it "should create config.rb, controller.rb, index.erb, edit.erb, and new.erb files" do
27
- ['config.rb', 'controller.rb', 'index.erb', 'edit.erb', 'new.erb', 'show.erb'].each do |template|
28
- @generator.should create("/tmp/#{model_name.camel_case}/#{template}")
29
- end
30
- end
31
-
32
- it "should generate valid erb templates" do
33
- pending "need to figure out how to validate erb"
34
- end
35
-
36
- end
@@ -1,139 +0,0 @@
1
- #
2
- # rho_controller_spec.rb
3
- # rhodes
4
- #
5
- # Copyright (C) 2008 Lars Burgess. All rights reserved.
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- #
20
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
21
- require File.dirname(__FILE__) + "/spec_helper"
22
- require 'rho/rhocontroller'
23
-
24
- describe "Rho" do
25
-
26
- it_should_behave_like "rho initializer"
27
-
28
- describe "url_for and link_to" do
29
-
30
- before(:each) do
31
- @c = Rho::RhoController.new
32
- @c.stub!(:send).and_return(nil)
33
- @c.serve(nil,{'application' => 'application', 'model' => 'model'},{})
34
- end
35
-
36
- it "should generate urls for empty params" do
37
- @c.url_for().should == '/application/model'
38
- end
39
-
40
- it "should generate urls for a url" do
41
- @c.url_for('/some_url').should == '/some_url'
42
- end
43
-
44
- it "should generate urls for a symbol" do
45
- @c.url_for(:new).should == 'new'
46
- end
47
-
48
- it "should generate urls for an action" do
49
- @c.url_for(:action => :new).should == '/application/model/new'
50
- end
51
-
52
- it "should generate urls for an action and id" do
53
- @c.url_for(:action => :show, :id => '{12}').should == '/application/model/{12}/show'
54
- end
55
-
56
- it "should generate urls for create or index actions" do
57
- @c.url_for(:action => :index, :id => '{12}').should == '/application/model'
58
- @c.url_for(:action => :create).should == '/application/model'
59
- end
60
-
61
- it "should generate urls for an model, action, and id" do
62
- @c.url_for(:model => 'another_model', :action => :show, :id => '{12}').should == '/application/another_model/{12}/show'
63
- @c.url_for(:model => :another_model, :action => :show, :id => '{12}').should == '/application/another_model/{12}/show'
64
- end
65
-
66
- it "should generate urls for an application, model, action, and id" do
67
- @c.url_for(:application => :another_app, :model => :another_model,
68
- :action => :show, :id => '{12}').should == '/another_app/another_model/{12}/show'
69
- end
70
-
71
- it "should generate urls with a query" do
72
- @c.url_for(:action => :create, :query => {:name => 'John Smith',
73
- 'address' => "http://john.smith.com"}).should == '/application/model?name=John%20Smith&address=http%3A%2F%2Fjohn.smith.com'
74
- end
75
-
76
- it "should generate urls with a fragment" do
77
- @c.url_for(:action => :show, :id => '{12}', :fragment => "an-anchor").should == '/application/model/{12}/show#an-anchor'
78
- end
79
-
80
- it "should generate link for a url" do
81
- @c.link_to("Visit Other Site", "http://www.rhomobile.com/").should == "<a href=\"http://www.rhomobile.com/\" >Visit Other Site</a>"
82
- end
83
-
84
- it "should generate link for an action" do
85
- @c.link_to("Help", :action => "help").should == "<a href=\"/application/model/help\" >Help</a>"
86
- end
87
-
88
- it "should generate link for 'delete' action" do
89
- @c.link_to("Delete", :action => "delete", :id => '{12}').should == "<a href=\"/application/model/{12}/delete\" onclick=\"var f = document.createElement('form'); f.style.display = 'none';this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.submit();return false;\">Delete</a>"
90
- end
91
-
92
- it "should generate link for an action and style it" do
93
- @c.link_to("Show", { :action => "show", :id => '{12}'},"style=\"height:4px;width:7px;border-width:0px;\"").should == "<a href=\"/application/model/{12}/show\" style=\"height:4px;width:7px;border-width:0px;\">Show</a>"
94
- end
95
-
96
- it "should generate link for 'delete' action and style it" do
97
- @c.link_to("Delete", { :action => "delete", :id => '{12}' }, "class=\"delete_link\"").should == "<a href=\"/application/model/{12}/delete\" class=\"delete_link\" onclick=\"var f = document.createElement('form'); f.style.display = 'none';this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.submit();return false;\">Delete</a>"
98
- end
99
-
100
- it "should generate link with a query" do
101
- @c.link_to("Invate",:action => :invite, :query => {:name => 'John Smith', 'address' => "http://john.smith.com"}).should == "<a href=\"/application/model/invite?name=John%20Smith&address=http%3A%2F%2Fjohn.smith.com\" >Invate</a>"
102
- end
103
-
104
- end #describe "url_for and link_to"
105
-
106
- describe "redirect" do
107
-
108
- before(:each) do
109
- @response = Hash.new
110
- @response['headers'] = {}
111
- @c = Rho::RhoController.new
112
- @c.stub!(:send).and_return(nil)
113
- @c.serve(nil,{'application' => 'application', 'model' => 'model'},@response)
114
- end
115
-
116
- it "should redirect to a url" do
117
- @c.redirect "/start-page"
118
- @response['headers']['Location'].should == "/start-page"
119
- @response['status'].should == 302
120
- @response['message'].should == 'Moved temporarily'
121
- end
122
-
123
- it "should redirect to an action" do
124
- @c.redirect :action => :show, :id => '{12}'
125
- @response['headers']['Location'].should == "/application/model/{12}/show"
126
- @response['status'].should == 302
127
- @response['message'].should == 'Moved temporarily'
128
- end
129
-
130
- it "should redirect to an action with 301 status code and status message" do
131
- @c.redirect({:action => :show, :id => '{12}'}, {'status' => 301, 'message' => 'Moved permanently'})
132
- @response['headers']['Location'].should == "/application/model/{12}/show"
133
- @response['status'].should == 301
134
- @response['message'].should == 'Moved permanently'
135
- end
136
-
137
- end #describe "redirect"
138
-
139
- end
@@ -1,61 +0,0 @@
1
- #
2
- # rho_spec.rb
3
- # rhodes
4
- #
5
- # Copyright (C) 2008 Lars Burgess. All rights reserved.
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- #
20
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
21
- require File.dirname(__FILE__) + "/spec_helper"
22
-
23
- describe "Rho" do
24
-
25
- it_should_behave_like "rho initializer"
26
- it_should_behave_like "rho db initializer"
27
-
28
- it "should populate configuration in sources table" do
29
- sources = Rhom::RhomDbAdapter::select_from_table('sources','*')
30
- sources.size.should > 1
31
- end
32
-
33
- it "should initialize configuration only once" do
34
- Rhom::RhomDbAdapter::delete_all_from_table('sources')
35
- @rho.source_initialized?(1).should == false
36
- @rho.init_sources
37
- @rho.source_initialized?(1).should == true
38
- end
39
-
40
- it "should have start_path" do
41
- Rho::RhoConfig.start_path.should == '/'
42
- end
43
-
44
- it "should set start_path" do
45
- Rho::RhoConfig.start_path = '/foo/bar'
46
- Rho::RhoConfig.start_path.should == '/foo/bar'
47
- end
48
-
49
- it "should retrieve start_path" do
50
- Rho::RhoConfig.start_path = '/'
51
- @rho.get_start_path.should == '/'
52
- end
53
-
54
- it "should return from get_app" do
55
- pending "fix relative paths for testing of get_app"
56
- end
57
-
58
- it "should serve request" do
59
- pending "need to mock request"
60
- end
61
- end
@@ -1,132 +0,0 @@
1
- #
2
- # rhom_object_factory_spec.rb
3
- # rhodes
4
- #
5
- # Copyright (C) 2008 Lars Burgess. All rights reserved.
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- # This program is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
- #
19
- require File.dirname(__FILE__) + "/spec_helper"
20
-
21
- describe "RhomObjectFactory" do
22
-
23
- it_should_behave_like "rho initializer"
24
- it_should_behave_like "rho db initializer"
25
-
26
- it "should set source_id attributes" do
27
- Account.get_source_id.should == "1"
28
- Case.get_source_id.should == "2"
29
- Employee.get_source_id.should == "3"
30
- end
31
-
32
- it "should dynamically assign values" do
33
- account = Account.new
34
- account.name = 'hello name'
35
- account.industry = 'hello industry'
36
- account.object = '3560c0a0-ef58-2f40-68a5-fffffffffffff'
37
- account.value = 'xyz industries'
38
- account.name.should == 'hello name'
39
- account.industry.should == 'hello industry'
40
- account.object.should == '3560c0a0-ef58-2f40-68a5-fffffffffffff'
41
- account.value.should == 'xyz industries'
42
- end
43
-
44
- it "should retrieve Case models" do
45
- results = Case.find(:all)
46
- results.length.should == 7
47
- results[0].case_number.should == "57"
48
- results[4].name.should == "implement SugarCRM sample app"
49
- end
50
-
51
- it "should retrieve Account models" do
52
- results = Account.find(:all)
53
- results.length.should == 5
54
- results[0].name.should == "vSpring"
55
- results[0].industry.should == "Finance"
56
- results[1].name.should == "Rhomobile"
57
- results[1].industry.should == "Technology"
58
- results[4].industry.should == "Technology"
59
- results[4].name.should == "Mobio India"
60
- end
61
-
62
- it "should have correct number of attributes" do
63
- @account = Account.find(:all).first
64
-
65
- @account.instance_variables.size.should == 36
66
- end
67
-
68
- it "should calculate same djb_hash" do
69
- vars = {"name"=>"foobarthree", "industry"=>"entertainment"}
70
- account = Account.new(vars)
71
- account.object.should == "272128608299468889014"
72
- end
73
-
74
- it "should create a record" do
75
- vars = {"name"=>"some new record", "industry"=>"electronices"}
76
- @account1 = Account.new(vars)
77
- new_id = @account1.object
78
- @account1.save
79
- @account2 = Account.find(new_id)
80
- @account2.object.should =="{#{@account1.object}}"
81
- @account2.name.should == vars['name']
82
- @account2.industry.should == vars['industry']
83
- end
84
-
85
- it "should destroy a record" do
86
- count = Account.find(:all).size
87
- @account = Account.find(:all)[0]
88
- destroy_id = @account.object
89
- @account.destroy
90
- @account_nil = Account.find(destroy_id)
91
- @account_nil.size.should == 0
92
- new_count = Account.find(:all).size
93
- (count - 1).should == new_count
94
- end
95
-
96
- it "should partially update a record" do
97
- new_attributes = {"name"=>"Mobio US"}
98
- @account = Account.find("44e804f2-4933-4e20-271c-48fcecd9450d")
99
- @account.update_attributes(new_attributes)
100
- @new_acct = Account.find("44e804f2-4933-4e20-271c-48fcecd9450d")
101
- @new_acct.name.should == "Mobio US"
102
- @new_acct.industry.should == "Technology"
103
- end
104
-
105
- it "should fully update a record" do
106
- new_attributes = {"name"=>"Mobio US", "industry"=>"Electronics"}
107
- @account = Account.find(:all).first
108
- @account.update_attributes(new_attributes)
109
-
110
- @new_acct = Account.find(:all).first
111
-
112
- @new_acct.name.should == "Mobio US"
113
- @new_acct.industry.should == "Electronics"
114
- end
115
-
116
- it "should retrieve and modify one record" do
117
- @acct = Account.find('44e804f2-4933-4e20-271c-48fcecd9450d')
118
-
119
- @acct.name.should == "Mobio US"
120
- @acct.industry.should == "Technology"
121
-
122
- @acct.name = "Rhomobile US"
123
-
124
- @acct.name.should == "Rhomobile US"
125
- end
126
-
127
- it "should return an empty value for a non-existent attribute" do
128
- @acct = Account.find('44e804f2-4933-4e20-271c-48fcecd9450d')
129
-
130
- @acct.foobar.should be_nil
131
- end
132
- end
@@ -1,45 +0,0 @@
1
- #
2
- # rhom_spec.rb
3
- # rhodes
4
- #
5
- # Copyright (C) 2008 Lars Burgess. All rights reserved.
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- #
20
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
21
- require File.dirname(__FILE__) + "/spec_helper"
22
-
23
- describe "Rhom" do
24
-
25
- it_should_behave_like "rho initializer"
26
- it_should_behave_like "rho db initializer"
27
-
28
- it "should get client_id" do
29
- Rhom::Rhom::client_id.should == '67320d31-e42e-4156-af91-5d9bd7175b08'
30
- end
31
-
32
- it "should perform full reset of database" do
33
- Rhom::Rhom::database_full_reset
34
- Rhom::RhomDbAdapter::select_from_table('object_values','*').length.should == 0
35
- Rhom::RhomDbAdapter::select_from_table('client_info','*').length.should == 0
36
- Rhom::Rhom::client_id.should be_nil
37
- end
38
-
39
- it "should perform full database reset and logout" do
40
- Rhom::Rhom::database_full_reset_and_logout
41
- Rhom::RhomDbAdapter::select_from_table('object_values','*').length.should == 0
42
- Rhom::RhomDbAdapter::select_from_table('client_info','*').length.should == 0
43
- Rhom::Rhom::client_id.should be_nil
44
- end
45
- end