rhodes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.gitignore +2 -0
  2. data/History.txt +4 -0
  3. data/Manifest.txt +52 -0
  4. data/README.rdoc +2 -0
  5. data/Rakefile +33 -0
  6. data/bin/rhogen +8 -0
  7. data/generators/rhogen.rb +99 -0
  8. data/generators/templates/application/application.rb +4 -0
  9. data/generators/templates/application/index.html +25 -0
  10. data/generators/templates/model/config.rb +3 -0
  11. data/generators/templates/model/controller.rb +48 -0
  12. data/generators/templates/model/edit.erb +21 -0
  13. data/generators/templates/model/index.erb +10 -0
  14. data/generators/templates/model/new.erb +16 -0
  15. data/lib/ServeME.rb +7 -0
  16. data/lib/TestServe.rb +9 -0
  17. data/lib/builtinME.rb +481 -0
  18. data/lib/date.rb +1781 -0
  19. data/lib/date/format.rb +1313 -0
  20. data/lib/erb.rb +896 -0
  21. data/lib/find.rb +81 -0
  22. data/lib/rational.rb +19 -0
  23. data/lib/rho.rb +1 -0
  24. data/lib/rho/render.rb +9 -0
  25. data/lib/rho/renderME.rb +8 -0
  26. data/lib/rho/rho.rb +173 -0
  27. data/lib/rho/rhoapplication.rb +36 -0
  28. data/lib/rho/rhocontroller.rb +51 -0
  29. data/lib/rho/rhofsconnector.rb +39 -0
  30. data/lib/rho/rhofsconnectorME.rb +36 -0
  31. data/lib/rho/rhosupport.rb +139 -0
  32. data/lib/rhodes.rb +5 -0
  33. data/lib/rhofsconnector.rb +5 -0
  34. data/lib/rhom.rb +1 -0
  35. data/lib/rhom/rhom.rb +41 -0
  36. data/lib/rhom/rhom_db_adapter.rb +183 -0
  37. data/lib/rhom/rhom_db_adapterME.rb +91 -0
  38. data/lib/rhom/rhom_object.rb +53 -0
  39. data/lib/rhom/rhom_object_factory.rb +246 -0
  40. data/lib/singleton.rb +313 -0
  41. data/lib/time.rb +839 -0
  42. data/rhodes.gemspec +18 -0
  43. data/spec/app_generator_spec.rb +27 -0
  44. data/spec/generator_spec_helper.rb +12 -0
  45. data/spec/model_generator_spec.rb +28 -0
  46. data/spec/rho_spec.rb +28 -0
  47. data/spec/rhom_object_factory_spec.rb +147 -0
  48. data/spec/spec.opts +1 -0
  49. data/spec/spec_helper.rb +14 -0
  50. data/spec/stubs.rb +17 -0
  51. data/spec/syncdbtest.sqlite +0 -0
  52. data/tasks/rspec.rake +34 -0
  53. metadata +157 -0
data/rhodes.gemspec ADDED
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{rhodes}
3
+ s.version = Rhodes::VERSION
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Rhomobile dev"]
7
+ s.date = %q{2008-10-24}
8
+ s.description = %q{The Rhodes application framework allows developers to create native mobile applications with the brevity, productivity and power of the Ruby programming language.}
9
+ s.email = ["dev@rhomobile.com"]
10
+ s.executables = []
11
+ s.files = FileList['lib/**/*.rb', '[A-Z]*', 'spec/**/*'].to_a
12
+ s.has_rdoc = true
13
+ s.homepage = %q{http://www.rhomobile.com/}
14
+ s.rdoc_options = ["--main", "../../README.rdoc", "--line-numbers"]
15
+ s.rubyforge_project = %q{rhodes}
16
+ s.rubygems_version = "#{Rhodes::VERSION}"
17
+ s.summary = "rhodes #{Rhodes::VERSION}"
18
+ end
@@ -0,0 +1,27 @@
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
+ before do
14
+ @generator = Rhogen::AppGenerator.new('/tmp', {}, app_name)
15
+ end
16
+
17
+ it "should create application.rb and index.html files" do
18
+ ['application.rb', 'index.html'].each do |template|
19
+ @generator.should create("/tmp/#{app_name}/#{template}")
20
+ end
21
+ end
22
+
23
+ it "should generate valid erb templates" do
24
+ pending "need to figure out how to validate erb"
25
+ end
26
+
27
+ end
@@ -0,0 +1,12 @@
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
@@ -0,0 +1,28 @@
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)
16
+ end
17
+
18
+ it "should create config.rb, controller.rb, index.erb, edit.erb, and new.erb files" do
19
+ ['config.rb', 'controller.rb', 'index.erb', 'edit.erb', 'new.erb'].each do |template|
20
+ @generator.should create("/tmp/#{model_name.camel_case}/#{template}")
21
+ end
22
+ end
23
+
24
+ it "should generate valid erb templates" do
25
+ pending "need to figure out how to validate erb"
26
+ end
27
+
28
+ end
data/spec/rho_spec.rb ADDED
@@ -0,0 +1,28 @@
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 populate configuration in sources table" do
26
+ pending 'somebody should implement this!'
27
+ end
28
+ end
@@ -0,0 +1,147 @@
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
+ 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
35
+
36
+ before(:each) do
37
+ FileUtils.cp_r('spec/syncdbtest.sqlite','build/syncdbtest.sqlite')
38
+ end
39
+
40
+ after(:each) do
41
+ FileUtils.rm_rf('build/syncdbtest.sqlite')
42
+ @rhom = nil
43
+ end
44
+
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
+ it "should set source_id attributes" do
56
+ "1".should == Account.get_source_id
57
+ "2".should == Case.get_source_id
58
+ end
59
+
60
+ it "should dynamically assign values" do
61
+ account = Account.new
62
+ account.name = 'hello name'
63
+ account.industry = 'hello industry'
64
+ account.object = '3560c0a0-ef58-2f40-68a5-fffffffffffff'
65
+ account.value = 'xyz industries'
66
+ account.name.should == 'hello name'
67
+ account.industry.should == 'hello industry'
68
+ account.object.should == '3560c0a0-ef58-2f40-68a5-fffffffffffff'
69
+ account.value.should == 'xyz industries'
70
+ end
71
+
72
+ it "should retrieve Case models" do
73
+ results = Case.find(:all)
74
+ array_print(results)
75
+ results.length.should == 5
76
+ "60".should == results[0].case_number
77
+ "hire another engineer".should == results[4].name
78
+ end
79
+
80
+ it "should retrieve Account models" do
81
+ results = Account.find(:all)
82
+ results.each_with_index do |result,i|
83
+ puts "result[#{i}]: " + result.inspect
84
+ end
85
+ results.length.should == 5
86
+ #array_print(results)
87
+
88
+ "Mobio India".should == results[0].name
89
+ "Technology".should == results[0].industry
90
+ "Aeroprise".should == results[1].name
91
+ "Technology".should == results[1].industry
92
+ "Electronics".should == results[4].industry
93
+ "Mirapath".should == results[4].name
94
+ end
95
+
96
+ it "should calculate same djb_hash" do
97
+ vars = {"name"=>"foobarthree", "industry"=>"entertainment"}
98
+ account = Account.new(vars)
99
+ account.object.should == "272128608299468889014"
100
+ end
101
+
102
+ it "should create a record" do
103
+ vars = {"name"=>"some new record", "industry"=>"electronices"}
104
+ @account1 = Account.new(vars)
105
+ new_id = @account1.object
106
+ @account1.save
107
+ @account2 = Account.find(new_id).first
108
+ @account2.object.should =="{#{@account1.object}}"
109
+ @account2.name.should == vars['name']
110
+ @account2.industry.should == vars['industry']
111
+ end
112
+
113
+ it "should destroy a record" do
114
+ count = Account.find(:all).size
115
+ @account = Account.find(:all)[0]
116
+ destroy_id = @account.object
117
+ @account.destroy
118
+ @account_nil = Account.find(destroy_id)
119
+
120
+ @account_nil.size.should == 0
121
+ new_count = Account.find(:all).size
122
+
123
+ (count - 1).should == new_count
124
+ end
125
+
126
+ it "should partially update a record" do
127
+ new_attributes = {"name"=>"Mobio US"}
128
+ @account = Account.find(:all).first
129
+ @account.update_attributes(new_attributes)
130
+
131
+ @new_acct = Account.find(:all).first
132
+
133
+ "Mobio US".should == @new_acct.name
134
+ "Technology".should == @new_acct.industry
135
+ end
136
+
137
+ it "should fully update a record" do
138
+ new_attributes = {"name"=>"Mobio US", "industry"=>"Electronics"}
139
+ @account = Account.find(:all).first
140
+ @account.update_attributes(new_attributes)
141
+
142
+ @new_acct = Account.find(:all).first
143
+
144
+ "Mobio US".should == @new_acct.name
145
+ "Electronics".should == @new_acct.industry
146
+ end
147
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,14 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.join(File.dirname(__FILE__), '..'))
10
+
11
+ # Use the rubygem for local testing
12
+ require 'spec/stubs'
13
+ require 'rho/rho'
14
+ require 'rhom/rhom'
data/spec/stubs.rb ADDED
@@ -0,0 +1,17 @@
1
+ # Stubs for testing
2
+ class Fixnum
3
+ def fdiv
4
+ end
5
+ end
6
+ class Bignum
7
+ def fdiv
8
+ end
9
+ end
10
+ class SyncEngine
11
+ def self.dosync
12
+ end
13
+ def self.lock_sync_mutex
14
+ end
15
+ def self.unlock_sync_mutex
16
+ end
17
+ end
Binary file
data/tasks/rspec.rake ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ task :test do
18
+ end
19
+
20
+ $:.unshift(File.join(File.dirname(__FILE__), '..'))
21
+ require 'spec/stubs'
22
+
23
+ desc "Run the specs under spec/models"
24
+ Spec::Rake::SpecTask.new do |t|
25
+ t.spec_opts = ['--options', "spec/spec.opts"]
26
+ t.spec_files = FileList['spec/**/*_spec.rb']
27
+ t.rcov = true
28
+ t.rcov_opts = ['--include',
29
+ '"lib/rhom/*,lib/rho/*"',
30
+ '--exclude',
31
+ '"spec/*,lib/date.rb,lib/rational.rb,lib/time.rb,lib/find.rb,config.rb,lib/erb.rb,lib/singleton.rb,lib/pairparser.rb,/Library/Ruby/Gems/*,/var/lib/gems/*,/usr/lib/ruby"',
32
+ '--text-report',
33
+ '--html']
34
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rhodes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rhomobile Dev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-25 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: sqlite3-ruby
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.4
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rcov
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: newgem
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.1.0
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: hoe
57
+ type: :development
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 1.8.0
64
+ version:
65
+ description: ""
66
+ email:
67
+ - dev@rhomobile.com
68
+ executables:
69
+ - rhogen
70
+ extensions: []
71
+
72
+ extra_rdoc_files:
73
+ - History.txt
74
+ - Manifest.txt
75
+ - README.rdoc
76
+ files:
77
+ - .gitignore
78
+ - History.txt
79
+ - Manifest.txt
80
+ - README.rdoc
81
+ - Rakefile
82
+ - bin/rhogen
83
+ - generators/rhogen.rb
84
+ - generators/templates/application/application.rb
85
+ - generators/templates/application/index.html
86
+ - generators/templates/model/config.rb
87
+ - generators/templates/model/controller.rb
88
+ - generators/templates/model/edit.erb
89
+ - generators/templates/model/index.erb
90
+ - generators/templates/model/new.erb
91
+ - lib/ServeME.rb
92
+ - lib/TestServe.rb
93
+ - lib/builtinME.rb
94
+ - lib/date.rb
95
+ - lib/date/format.rb
96
+ - lib/erb.rb
97
+ - lib/find.rb
98
+ - lib/rational.rb
99
+ - lib/rho.rb
100
+ - lib/rho/render.rb
101
+ - lib/rho/renderME.rb
102
+ - lib/rho/rho.rb
103
+ - lib/rho/rhoapplication.rb
104
+ - lib/rho/rhocontroller.rb
105
+ - lib/rho/rhofsconnector.rb
106
+ - lib/rho/rhofsconnectorME.rb
107
+ - lib/rho/rhosupport.rb
108
+ - lib/rhodes.rb
109
+ - lib/rhofsconnector.rb
110
+ - lib/rhom.rb
111
+ - lib/rhom/rhom.rb
112
+ - lib/rhom/rhom_db_adapter.rb
113
+ - lib/rhom/rhom_db_adapterME.rb
114
+ - lib/rhom/rhom_object.rb
115
+ - lib/rhom/rhom_object_factory.rb
116
+ - lib/singleton.rb
117
+ - lib/time.rb
118
+ - rhodes.gemspec
119
+ - spec/app_generator_spec.rb
120
+ - spec/generator_spec_helper.rb
121
+ - spec/model_generator_spec.rb
122
+ - spec/rho_spec.rb
123
+ - spec/rhom_object_factory_spec.rb
124
+ - spec/spec.opts
125
+ - spec/spec_helper.rb
126
+ - spec/stubs.rb
127
+ - spec/syncdbtest.sqlite
128
+ - tasks/rspec.rake
129
+ has_rdoc: true
130
+ homepage: " * See rhodes/README.rdoc for more information"
131
+ post_install_message:
132
+ rdoc_options:
133
+ - --main
134
+ - README.rdoc
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: "0"
142
+ version:
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: "0"
148
+ version:
149
+ requirements: []
150
+
151
+ rubyforge_project: rhodes
152
+ rubygems_version: 1.3.1
153
+ signing_key:
154
+ specification_version: 2
155
+ summary: ""
156
+ test_files: []
157
+