rhodes 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -12,6 +12,7 @@ generators/templates/model/controller.rb
12
12
  generators/templates/model/edit.erb
13
13
  generators/templates/model/index.erb
14
14
  generators/templates/model/new.erb
15
+ generators/templates/source/source_adapter.rb
15
16
  lib/ServeME.rb
16
17
  lib/TestServe.rb
17
18
  lib/builtinME.rb
@@ -29,6 +30,7 @@ lib/rho/rhocontroller.rb
29
30
  lib/rho/rhofsconnector.rb
30
31
  lib/rho/rhofsconnectorME.rb
31
32
  lib/rho/rhosupport.rb
33
+ lib/rho/settings_controller.rb
32
34
  lib/rhodes.rb
33
35
  lib/rhofsconnector.rb
34
36
  lib/rhom.rb
@@ -45,6 +47,8 @@ spec/generator_spec_helper.rb
45
47
  spec/model_generator_spec.rb
46
48
  spec/rho_spec.rb
47
49
  spec/rhom_object_factory_spec.rb
50
+ spec/settings_controller_spec.rb
51
+ spec/source_generator_spec.rb
48
52
  spec/spec.opts
49
53
  spec/spec_helper.rb
50
54
  spec/stubs.rb
data/generators/rhogen.rb CHANGED
@@ -93,7 +93,28 @@ module Rhogen
93
93
 
94
94
  end
95
95
 
96
+ class SourceGenerator < BaseGenerator
97
+ def self.source_root
98
+ File.join(File.dirname(__FILE__), 'templates', 'source')
99
+ end
100
+
101
+ desc <<-DESC
102
+ Generates a new source adapter with the given name and attributes. You must specify name.
103
+ You can also specify an optional attribute list in the form: 'attribute1', 'attribute2', 'attribute3'...
104
+ DESC
105
+
106
+ first_argument :name, :required => true, :desc => "model name"
107
+ second_argument :attributes, :as => :array, :default => [], :required => false, :desc => "array of attributes (only string suppported right now)"
108
+
109
+ template :config do |template|
110
+ template.source = 'source_adapter.rb'
111
+ template.destination = "lib/#{name.snake_case}.rb"
112
+ end
113
+
114
+ end
115
+
96
116
  add :app, AppGenerator
97
117
  add :model, ModelGenerator
118
+ add :source, SourceGenerator
98
119
 
99
120
  end
@@ -0,0 +1,38 @@
1
+ class <%=name%>
2
+ attr_accessor :client
3
+
4
+ def initialize(source)
5
+ @source=source
6
+ end
7
+
8
+ def login
9
+ end
10
+
11
+ def query
12
+ end
13
+
14
+ def sync
15
+ @result.entry_list.each do |x|
16
+ x.name_value_list.each do |y|
17
+ o=ObjectValue.new
18
+ o.source_id=@source.id
19
+ o.object=x['id']
20
+ o.attrib=y.name
21
+ o.value=y.value
22
+ o.save
23
+ end
24
+ end
25
+ end
26
+
27
+ def create(name_value_list)
28
+ end
29
+
30
+ def update(name_value_list)
31
+ end
32
+
33
+ def delete(name_value_list)
34
+ end
35
+
36
+ def logoff
37
+ end
38
+ end
@@ -0,0 +1,23 @@
1
+ require 'rho'
2
+ require 'rho/rhocontroller'
3
+
4
+ module Rho
5
+ class SettingsController < Rho::RhoController
6
+ include Rhom::RhomObject
7
+ def get_source(id)
8
+ ::Rhom::RhomDbAdapter::select_from_table('sources','*',{"source_id"=>strip_braces(id)}).first
9
+ end
10
+
11
+ def update_source(source, id)
12
+ if source and id
13
+ ::Rhom::RhomDbAdapter::update_into_table('sources',
14
+ {"source_url"=>source['source_url']},
15
+ {"source_id"=>strip_braces(id)})
16
+ end
17
+ end
18
+
19
+ def get_all_sources
20
+ Rho::RhoConfig::sources
21
+ end
22
+ end
23
+ end
data/lib/rhodes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Rhodes
2
2
  unless defined? Rhodes::VERSION
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  end
@@ -52,7 +52,7 @@ module Rhom
52
52
  def execute_sql(sql=nil)
53
53
  result = []
54
54
  if sql
55
- puts 'query is ' + sql
55
+ #puts 'query is ' + sql
56
56
  # Make sure we lock the sync engine's mutex
57
57
  # before we perform a database transaction.
58
58
  # This prevents concurrency issues.
data/spec/rho_spec.rb CHANGED
@@ -26,9 +26,7 @@ describe "Rho" do
26
26
 
27
27
  it "should populate configuration in sources table" do
28
28
  sources = Rhom::RhomDbAdapter::select_from_table('sources','*')
29
- puts 'sources: ' + sources.inspect
30
-
31
- sources.size.should == 3
29
+ sources.size.should == 4
32
30
  end
33
31
 
34
32
  it "should initialize configuration only once" do
@@ -50,7 +50,7 @@ describe "RhomObjectFactory" do
50
50
 
51
51
  it "should retrieve Case models" do
52
52
  results = Case.find(:all)
53
- array_print(results)
53
+ #array_print(results)
54
54
  results.length.should == 5
55
55
  "60".should == results[0].case_number
56
56
  "hire another engineer".should == results[4].name
@@ -58,9 +58,6 @@ describe "RhomObjectFactory" do
58
58
 
59
59
  it "should retrieve Account models" do
60
60
  results = Account.find(:all)
61
- results.each_with_index do |result,i|
62
- puts "result[#{i}]: " + result.inspect
63
- end
64
61
  results.length.should == 5
65
62
  #array_print(results)
66
63
 
@@ -0,0 +1,48 @@
1
+ #
2
+ # settings_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 'rho/settings_controller'
22
+ require File.dirname(__FILE__) + "/spec_helper"
23
+
24
+ describe "Rho" do
25
+
26
+ it_should_behave_like "rho initializer"
27
+
28
+ before(:all) do
29
+ @controller = Rho::SettingsController.new
30
+ end
31
+
32
+ it "should get all sources for index" do
33
+ @controller.get_all_sources.size.should == 4
34
+ end
35
+
36
+ it "should retrieve source for update" do
37
+ @controller.get_source('{1}')['source_url'].should == 'http://rhosync.rhohub.com/sources/1'
38
+ end
39
+
40
+ it "should retrieve source without braces" do
41
+ @controller.get_source('1')['source_url'].should == 'http://rhosync.rhohub.com/sources/1'
42
+ end
43
+
44
+ it "should update source" do
45
+ @controller.update_source({'source_url'=>'http://acme.com/sources/30'},'1')
46
+ @controller.get_source('1')['source_url'].should == 'http://acme.com/sources/30'
47
+ end
48
+ end
@@ -0,0 +1,27 @@
1
+ require File.dirname(__FILE__) + '/generator_spec_helper'
2
+
3
+ describe Rhogen::SourceGenerator do
4
+
5
+ source_name = 'NeatSource'
6
+
7
+ it "should complain if no name is specified" do
8
+ lambda {
9
+ @generator = Rhogen::SourceGenerator.new('/tmp', {})
10
+ }.should raise_error(::Templater::TooFewArgumentsError)
11
+ end
12
+
13
+ before do
14
+ @generator = Rhogen::SourceGenerator.new('/tmp', {}, source_name)
15
+ end
16
+
17
+ it "should create neat_source.rb files" do
18
+ ['neat_source.rb'].each do |template|
19
+ @generator.should create("/tmp/lib/#{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
data/spec/spec_helper.rb CHANGED
@@ -11,7 +11,6 @@ $:.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 'rho/settings_controller'
15
14
  require 'rhom/rhom'
16
15
 
17
16
  describe "rho initializer", :shared => true do
@@ -21,9 +20,6 @@ describe "rho initializer", :shared => true do
21
20
  before(:all) do
22
21
  FileUtils.mkdir_p('build')
23
22
  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
23
  Object::const_set("SYNC_DB_FILE", "../../build/syncdbtest.sqlite") unless defined? SYNC_DB_FILE
28
24
  @rho = Rho::RHO.new(File.dirname(__FILE__) + "/../../../apps/")
29
25
  @rhom = Rhom::RhomObjectFactory.new
data/tasks/rspec.rake CHANGED
@@ -27,8 +27,8 @@ Spec::Rake::SpecTask.new do |t|
27
27
  t.rcov = true
28
28
  t.rcov_opts = ['--include',
29
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"',
30
+ '-x',
31
+ 'spec,gems,sqlite3/*,lib/date.rb,lib/rational.rb,lib/time.rb,lib/find.rb,config.rb,lib/erb.rb,lib/singleton.rb,lib/pairparser.rb',
32
32
  '--text-report',
33
33
  '--html']
34
34
  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.1
4
+ version: 0.1.2
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-12-05 00:00:00 -08:00
12
+ date: 2008-12-09 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -118,6 +118,7 @@ files:
118
118
  - generators/templates/model/edit.erb
119
119
  - generators/templates/model/index.erb
120
120
  - generators/templates/model/new.erb
121
+ - generators/templates/source/source_adapter.rb
121
122
  - lib/ServeME.rb
122
123
  - lib/TestServe.rb
123
124
  - lib/builtinME.rb
@@ -135,6 +136,7 @@ files:
135
136
  - lib/rho/rhofsconnector.rb
136
137
  - lib/rho/rhofsconnectorME.rb
137
138
  - lib/rho/rhosupport.rb
139
+ - lib/rho/settings_controller.rb
138
140
  - lib/rhodes.rb
139
141
  - lib/rhofsconnector.rb
140
142
  - lib/rhom.rb
@@ -151,6 +153,8 @@ files:
151
153
  - spec/model_generator_spec.rb
152
154
  - spec/rho_spec.rb
153
155
  - spec/rhom_object_factory_spec.rb
156
+ - spec/settings_controller_spec.rb
157
+ - spec/source_generator_spec.rb
154
158
  - spec/spec.opts
155
159
  - spec/spec_helper.rb
156
160
  - spec/stubs.rb