rhodes 0.1.2 → 0.1.3

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.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.1.3 2008-12-11
2
+ * Updated source_adapter generator to have base class
3
+ * fixed #50, removed dependency on Find library
4
+
5
+ == 0.1.2 2008-12-09
6
+ * Added rhogen source <MySourceAdapter>
7
+
1
8
  == 0.1.1 2008-11-18
2
9
  * Fixed template application name
3
10
 
data/Manifest.txt CHANGED
@@ -19,7 +19,6 @@ lib/builtinME.rb
19
19
  lib/date.rb
20
20
  lib/date/format.rb
21
21
  lib/erb.rb
22
- lib/find.rb
23
22
  lib/rational.rb
24
23
  lib/rho.rb
25
24
  lib/rho/render.rb
@@ -1,38 +1,35 @@
1
- class <%=name%>
2
- attr_accessor :client
1
+ class <%=name%> < SourceAdapter
3
2
 
4
3
  def initialize(source)
5
- @source=source
4
+ super
6
5
  end
7
6
 
8
7
  def login
8
+ #TODO: Write some code here
9
9
  end
10
10
 
11
11
  def query
12
+ # TODO: write some code here
12
13
  end
13
14
 
14
15
  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
16
+ # usually the generic base class sync does the job
17
+ super
25
18
  end
26
19
 
27
20
  def create(name_value_list)
21
+ #TODO: write some code here
28
22
  end
29
23
 
30
24
  def update(name_value_list)
25
+ #TODO: write some code here
31
26
  end
32
27
 
33
28
  def delete(name_value_list)
29
+ #TODO: write some code here if applicable
34
30
  end
35
31
 
36
32
  def logoff
33
+ #TODO: write some code here if applicable
37
34
  end
38
35
  end
data/lib/rho/rho.rb CHANGED
@@ -12,13 +12,13 @@ module Rho
12
12
  class RHO
13
13
  APPLICATIONS = {}
14
14
 
15
- def initialize(app_base_path=nil)
15
+ def initialize(app_manifest_filename=nil)
16
16
  puts "Calling RHO.initialize"
17
17
  Rhom::RhomDbAdapter::open(Rho::RhoFSConnector::get_db_fullpathname)
18
- if app_base_path
19
- process_model_dirs(app_base_path)
18
+ if app_manifest_filename
19
+ process_model_dirs(app_manifest_filename)
20
20
  else
21
- process_model_dirs(RhoApplication::get_base_app_path)
21
+ process_model_dirs(Rho::RhoFSConnector::get_app_manifest_filename)
22
22
  end
23
23
  init_sources
24
24
  end
@@ -29,17 +29,15 @@ module Rho
29
29
  end
30
30
 
31
31
  # Return the directories where we need to load configuration files
32
- def process_model_dirs(app_base_path=nil)
33
- Rho::RhoFSConnector::enum_files(app_base_path,'config.rb') do |path|
34
- require path
32
+ def process_model_dirs(app_manifest_filename=nil)
33
+ File.open(app_manifest_filename).each do |line|
34
+ require File.join(File.dirname(app_manifest_filename), line.chop)
35
35
  end
36
36
  end
37
37
 
38
38
  # setup the sources table and model attributes for all applications
39
39
  def init_sources
40
- puts 'sources initialized? ' + self.sources_initialized?.inspect
41
- if defined? Rho::RhoConfig::sources and not self.sources_initialized?
42
- Rhom::RhomDbAdapter::delete_all_from_table('sources')
40
+ if defined? Rho::RhoConfig::sources
43
41
  src_attribs = []
44
42
 
45
43
  # quick and dirty way to get unique array of hashes
@@ -47,22 +45,27 @@ module Rho
47
45
  result << h unless result.include?(h); result
48
46
  }
49
47
 
50
- # generate unique source list in databse for sync
48
+ # generate unique source list in database for sync
51
49
  uniq_sources.each do |source|
50
+
52
51
  src_id = source['source_id']
53
52
  url = source['url']
54
- Rhom::RhomDbAdapter::insert_into_table('sources',
55
- {"source_id"=>src_id,"source_url"=>url})
53
+ if !self.source_initialized?(src_id)
54
+ puts "initializing source #{src_id}..."
55
+ Rhom::RhomDbAdapter::insert_into_table('sources',
56
+ {"source_id"=>src_id,"source_url"=>url})
57
+ end
56
58
  end
57
59
  end
58
60
  end
59
61
 
60
- def sources_initialized?
61
- Rhom::RhomDbAdapter::select_from_table('sources','*').size > 0 ? true : false
62
+ def source_initialized?(source_id)
63
+ Rhom::RhomDbAdapter::select_from_table('sources','*', 'source_id'=>source_id).size > 0 ? true : false
62
64
  end
63
65
 
64
66
  def get_app(appname)
65
67
  if (APPLICATIONS[appname].nil?)
68
+ puts "app require: #{RhoApplication::get_app_path(appname)+'application'}"
66
69
  require RhoApplication::get_app_path(appname)+'application'
67
70
  APPLICATIONS[appname] = Object.const_get(appname+'Application').new
68
71
  end
@@ -1,5 +1,3 @@
1
- require 'find'
2
-
3
1
  module Rho
4
2
  class RhoFSConnector
5
3
 
@@ -12,6 +10,10 @@ module Rho
12
10
  def get_base_app_path
13
11
  File.join(File.dirname(File.expand_path(__FILE__)), '../../apps/')
14
12
  end
13
+
14
+ def get_app_manifest_filename
15
+ File.join(File.dirname(File.expand_path(__FILE__)), '../../apps/app_manifest.txt')
16
+ end
15
17
 
16
18
  def get_model_path(appname, modelname)
17
19
  File.join(File.dirname(File.expand_path(__FILE__)), '../../apps/'+appname+'/'+modelname+'/')
@@ -24,15 +26,6 @@ module Rho
24
26
  File.join(File.dirname(File.expand_path(__FILE__)), '../../db/syncdb.sqlite')
25
27
  end
26
28
  end
27
-
28
- def enum_files(paths, filename) # :yield: path
29
- Find.find(paths) do |path|
30
- if File.basename(path) == filename
31
- yield path
32
- end
33
- end
34
- end
35
-
36
29
  end
37
30
 
38
31
  end # RhoApplication
@@ -11,6 +11,10 @@ module Rho
11
11
  def get_base_app_path
12
12
  'apps/'
13
13
  end
14
+
15
+ def get_app_manifest_filename
16
+ get_base_app_path+'app_manifest.txt'
17
+ end
14
18
 
15
19
  def get_model_path(appname, modelname)
16
20
  'apps/'+appname+'/'+modelname+'/'
@@ -23,14 +27,6 @@ module Rho
23
27
  'syncdb_.dbs'
24
28
  end
25
29
  end
26
-
27
- def enum_files(paths, filename) # :yield: path
28
- yield get_app_path('Rhosugar/Account') + filename
29
- yield get_app_path('Rhosugar/Case') + filename
30
- yield get_app_path('Rhosugar/Employee') + filename
31
- end
32
-
33
30
  end
34
-
35
31
  end # RhoApplication
36
32
  end # Rho
data/lib/rhodes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Rhodes
2
2
  unless defined? Rhodes::VERSION
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
@@ -71,7 +71,7 @@ module Rhom
71
71
  SyncEngine::unlock_sync_mutex
72
72
  end
73
73
  end
74
- puts "returned #{result.length.to_s} records..."
74
+ #puts "returned #{result.length.to_s} records..."
75
75
  result
76
76
  end
77
77
 
@@ -10,6 +10,12 @@ describe Rhogen::AppGenerator do
10
10
  }.should raise_error(::Templater::TooFewArgumentsError)
11
11
  end
12
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
+
13
19
  before do
14
20
  @generator = Rhogen::AppGenerator.new('/tmp', {}, app_name)
15
21
  end
@@ -12,7 +12,15 @@ describe Rhogen::ModelGenerator do
12
12
  end
13
13
 
14
14
  before do
15
- @generator = Rhogen::ModelGenerator.new('/tmp', {}, model_name, "http://something.com/sources/5", 5)
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']
16
24
  end
17
25
 
18
26
  it "should create config.rb, controller.rb, index.erb, edit.erb, and new.erb files" do
data/spec/rho_spec.rb CHANGED
@@ -31,9 +31,13 @@ describe "Rho" do
31
31
 
32
32
  it "should initialize configuration only once" do
33
33
  Rhom::RhomDbAdapter::delete_all_from_table('sources')
34
- @rho.sources_initialized?.should == false
34
+ @rho.source_initialized?(1).should == false
35
35
  @rho.init_sources
36
- @rho.sources_initialized?.should == true
36
+ @rho.source_initialized?(1).should == true
37
+ end
38
+
39
+ it "should return from get_app" do
40
+ pending "fix relative paths for testing of get_app"
37
41
  end
38
42
 
39
43
  it "should serve request" do
data/spec/spec_helper.rb CHANGED
@@ -21,7 +21,7 @@ describe "rho initializer", :shared => true do
21
21
  FileUtils.mkdir_p('build')
22
22
  FileUtils.cp_r('spec/syncdbtest.sqlite','build/syncdbtest.sqlite')
23
23
  Object::const_set("SYNC_DB_FILE", "../../build/syncdbtest.sqlite") unless defined? SYNC_DB_FILE
24
- @rho = Rho::RHO.new(File.dirname(__FILE__) + "/../../../apps/")
24
+ @rho = Rho::RHO.new(File.join(File.dirname(File.expand_path(__FILE__)), '../../../apps/app_manifest.txt'))
25
25
  @rhom = Rhom::RhomObjectFactory.new
26
26
  end
27
27
 
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.2
4
+ version: 0.1.3
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-09 00:00:00 -08:00
12
+ date: 2008-12-11 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -80,7 +80,7 @@ dependencies:
80
80
  requirements:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: 1.1.0
83
+ version: 1.2.0
84
84
  version:
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: hoe
@@ -125,7 +125,6 @@ files:
125
125
  - lib/date.rb
126
126
  - lib/date/format.rb
127
127
  - lib/erb.rb
128
- - lib/find.rb
129
128
  - lib/rational.rb
130
129
  - lib/rho.rb
131
130
  - lib/rho/render.rb
data/lib/find.rb DELETED
@@ -1,81 +0,0 @@
1
- #
2
- # find.rb: the Find module for processing all files under a given directory.
3
- #
4
-
5
- #
6
- # The +Find+ module supports the top-down traversal of a set of file paths.
7
- #
8
- # For example, to total the size of all files under your home directory,
9
- # ignoring anything in a "dot" directory (e.g. $HOME/.ssh):
10
- #
11
- # require 'find'
12
- #
13
- # total_size = 0
14
- #
15
- # Find.find(ENV["HOME"]) do |path|
16
- # if FileTest.directory?(path)
17
- # if File.basename(path)[0] == ?.
18
- # Find.prune # Don't look any further into this directory.
19
- # else
20
- # next
21
- # end
22
- # else
23
- # total_size += FileTest.size(path)
24
- # end
25
- # end
26
- #
27
- module Find
28
-
29
- #
30
- # Calls the associated block with the name of every file and directory listed
31
- # as arguments, then recursively on their subdirectories, and so on.
32
- #
33
- # See the +Find+ module documentation for an example.
34
- #
35
- def find(*paths) # :yield: path
36
- block_given? or return enum_for(__method__, *paths)
37
-
38
- paths.collect!{|d| raise Errno::ENOENT unless File.exist?(d); d.dup}
39
- while file = paths.shift
40
- catch(:prune) do
41
- yield file.dup.taint
42
- next unless File.exist? file
43
- begin
44
- if File.lstat(file).directory? then
45
- d = Dir.open(file)
46
- begin
47
- for f in d
48
- next if f == "." or f == ".."
49
- if File::ALT_SEPARATOR and file =~ /^(?:[\/\\]|[A-Za-z]:[\/\\]?)$/ then
50
- f = file + f
51
- elsif file == "/" then
52
- f = "/" + f
53
- else
54
- f = File.join(file, f)
55
- end
56
- paths.unshift f.untaint
57
- end
58
- ensure
59
- d.close
60
- end
61
- end
62
- rescue Errno::ENOENT, Errno::EACCES
63
- end
64
- end
65
- end
66
- end
67
-
68
- #
69
- # Skips the current file or directory, restarting the loop with the next
70
- # entry. If the current file is a directory, that directory will not be
71
- # recursively entered. Meaningful only within the block associated with
72
- # Find::find.
73
- #
74
- # See the +Find+ module documentation for an example.
75
- #
76
- def prune
77
- throw :prune
78
- end
79
-
80
- module_function :find, :prune
81
- end