rhodes 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +1 -2
- data/generators/templates/application/layout.erb +3 -3
- data/lib/date/format.rb +4 -4
- data/lib/rhodes.rb +5 -1
- data/lib/rhom/rhom_db_adapterME.rb +3 -1
- data/lib/rhom/rhom_object_factory.rb +24 -24
- data/lib/rhom/rhom_source.rb +54 -0
- data/lib/time.rb +5 -8
- data/spec/rho_spec.rb +1 -1
- metadata +3 -4
- data/lib/rho/settings_controller.rb +0 -23
- data/spec/settings_controller_spec.rb +0 -49
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -32,7 +32,6 @@ lib/rho/rhocontroller.rb
|
|
32
32
|
lib/rho/rhofsconnector.rb
|
33
33
|
lib/rho/rhosupport.rb
|
34
34
|
lib/rho/rhoviewhelpers.rb
|
35
|
-
lib/rho/settings_controller.rb
|
36
35
|
lib/rhodes.rb
|
37
36
|
lib/rhoframework.rb
|
38
37
|
lib/rhofsconnector.rb
|
@@ -42,6 +41,7 @@ lib/rhom/rhom_db_adapter.rb
|
|
42
41
|
lib/rhom/rhom_db_adapterME.rb
|
43
42
|
lib/rhom/rhom_object.rb
|
44
43
|
lib/rhom/rhom_object_factory.rb
|
44
|
+
lib/rhom/rhom_source.rb
|
45
45
|
lib/singleton.rb
|
46
46
|
lib/time.rb
|
47
47
|
rhodes.gemspec
|
@@ -54,7 +54,6 @@ spec/generator_spec_helper.rb
|
|
54
54
|
spec/model_generator_spec.rb
|
55
55
|
spec/rho_spec.rb
|
56
56
|
spec/rhom_object_factory_spec.rb
|
57
|
-
spec/settings_controller_spec.rb
|
58
57
|
spec/source_generator_spec.rb
|
59
58
|
spec/spec.opts
|
60
59
|
spec/spec_helper.rb
|
@@ -3,15 +3,15 @@
|
|
3
3
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
4
4
|
<head>
|
5
5
|
<title><%= class_name %></title>
|
6
|
-
|
6
|
+
<%% if System::get_property('platform') == 'APPLE' %>
|
7
7
|
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
|
8
8
|
<style type="text/css" media="screen">@import "/shared/js/iui/iui.css"; @import "/shared/css/rho.css";</style>
|
9
9
|
<script type="application/x-javascript" src="/shared/js/iui/iui.js"></script>
|
10
10
|
<script src="/shared/js/jquery-1.2.6.min.js"></script>
|
11
11
|
<script src="/shared/js/rho.js"></script>
|
12
|
-
|
12
|
+
<%% end %>
|
13
13
|
</head>
|
14
14
|
<body>
|
15
|
-
|
15
|
+
<%%= @content %>
|
16
16
|
</body>
|
17
17
|
</html>
|
data/lib/date/format.rb
CHANGED
@@ -298,7 +298,7 @@ class Date
|
|
298
298
|
when 'w', 'Ow'; emit_n(wday, 1, f)
|
299
299
|
when 'X', 'EX'; emit_a(strftime('%H:%M:%S'), 0, f)
|
300
300
|
when 'x', 'Ex'; emit_a(strftime('%m/%d/%y'), 0, f)
|
301
|
-
when 'Y', 'EY'; emit_sn(year, 4, f)
|
301
|
+
when 'Y', 'EY'; emit_sn(year(), 4, f)
|
302
302
|
when 'y', 'Ey', 'Oy'; emit_n(year % 100, 2, f)
|
303
303
|
when 'Z'; emit_au(strftime('%:z'), 0, f)
|
304
304
|
when /\A(:{0,3})z/
|
@@ -1034,7 +1034,7 @@ class Date
|
|
1034
1034
|
def self._parse(str, comp=true)
|
1035
1035
|
str = str.dup
|
1036
1036
|
|
1037
|
-
e = Format::Bag.new
|
1037
|
+
e = Date::Format::Bag.new
|
1038
1038
|
|
1039
1039
|
e._comp = comp
|
1040
1040
|
|
@@ -1246,8 +1246,8 @@ class Date
|
|
1246
1246
|
else
|
1247
1247
|
dst = zone.sub!(/\s+dst\z/, '')
|
1248
1248
|
end
|
1249
|
-
if Format::ZONES.include?(zone)
|
1250
|
-
offset = Format::ZONES[zone]
|
1249
|
+
if Date::Format::ZONES.include?(zone)
|
1250
|
+
offset = Date::Format::ZONES[zone]
|
1251
1251
|
offset += 3600 if dst
|
1252
1252
|
elsif zone.sub!(/\A(?:gmt|utc?)?([-+])/, '')
|
1253
1253
|
sign = $1
|
data/lib/rhodes.rb
CHANGED
@@ -17,6 +17,8 @@
|
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
#
|
20
|
+
require 'rhodes'
|
21
|
+
|
20
22
|
module Rhom
|
21
23
|
class RhomDbAdapter
|
22
24
|
|
@@ -26,7 +28,7 @@ module Rhom
|
|
26
28
|
def open(dbfile=nil)
|
27
29
|
puts "DB name = " + dbfile.inspect
|
28
30
|
unless @@database or dbfile.nil?
|
29
|
-
db = DbAdapter.new(
|
31
|
+
db = DbAdapter.new(Rhodes::DBVERSION)
|
30
32
|
@@database = db
|
31
33
|
end
|
32
34
|
|
@@ -26,22 +26,24 @@ module Rhom
|
|
26
26
|
|
27
27
|
def initialize
|
28
28
|
unless not defined? Rho::RhoConfig::sources
|
29
|
-
init_source_attribs
|
29
|
+
::Rhom::RhomObjectFactory::init_source_attribs
|
30
30
|
init_objects
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
34
|
+
class << self
|
35
|
+
def init_source_attribs
|
36
|
+
# merge source attributes into config hash
|
37
|
+
# TODO: This shouldn't reference 'source[1]' directly
|
38
|
+
Rho::RhoConfig::sources.each do |source|
|
39
|
+
src_attribs = ::Rhom::RhomDbAdapter::select_from_table(::Rhom::TABLE_NAME,
|
40
|
+
'attrib',
|
41
|
+
{"source_id"=>source[1]['source_id'].to_s},
|
42
|
+
{"distinct"=>true})
|
43
|
+
# update our source with the proper attributes
|
44
|
+
source[1].merge!({"attribs"=>src_attribs})
|
45
|
+
end
|
46
|
+
end
|
45
47
|
end
|
46
48
|
|
47
49
|
# Initialize new object with dynamic attributes
|
@@ -103,8 +105,16 @@ module Rhom
|
|
103
105
|
# returns an array of objects based on an existing array
|
104
106
|
def get_list(objs)
|
105
107
|
new_list = []
|
106
|
-
|
107
|
-
|
108
|
+
attrib_length = 0
|
109
|
+
source = Rho::RhoConfig::sources[self.name.to_s]
|
110
|
+
if source
|
111
|
+
attrib_length = source['attribs'].length
|
112
|
+
end
|
113
|
+
if attrib_length == 0
|
114
|
+
# source attributes are not initialized, try again
|
115
|
+
::Rhom::RhomObjectFactory::init_source_attribs
|
116
|
+
end
|
117
|
+
if objs and source and attrib_length > 0
|
108
118
|
list_length = 0
|
109
119
|
list_length = (objs.length / attrib_length) unless attrib_length == 0
|
110
120
|
new_obj = nil
|
@@ -129,10 +139,6 @@ module Rhom
|
|
129
139
|
end
|
130
140
|
new_list << new_obj
|
131
141
|
end
|
132
|
-
else
|
133
|
-
# source attributes are not initialized,
|
134
|
-
# try again
|
135
|
-
RhomObjectFactory::init_sources
|
136
142
|
end
|
137
143
|
new_list
|
138
144
|
end
|
@@ -210,12 +216,6 @@ module Rhom
|
|
210
216
|
# then we procede with update
|
211
217
|
if new_val and val != new_val
|
212
218
|
unless self.method_name_reserved?(method) or new_val.length == 0
|
213
|
-
# update viewable list
|
214
|
-
=begin
|
215
|
-
result = ::Rhom::RhomDbAdapter::update_into_table(::Rhom::TABLE_NAME,
|
216
|
-
{"value"=>new_val},
|
217
|
-
{"object"=>obj, "attrib"=>method})
|
218
|
-
=end
|
219
219
|
# update sync list
|
220
220
|
result = ::Rhom::RhomDbAdapter::insert_into_table(::Rhom::TABLE_NAME,
|
221
221
|
{"source_id"=>self.get_inst_source_id,
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'time'
|
2
|
+
require 'rhom/rhom_object'
|
3
|
+
|
4
|
+
module Rhom
|
5
|
+
class RhomSource
|
6
|
+
attr_accessor :source_url
|
7
|
+
attr_reader :source_id, :name, :last_updated, :last_inserted_size,
|
8
|
+
:last_deleted_size, :last_sync_duration,
|
9
|
+
:last_sync_success
|
10
|
+
|
11
|
+
def initialize(args)
|
12
|
+
# setup the name
|
13
|
+
# TODO: should really store this in the database
|
14
|
+
Rho::RhoConfig::sources.each do |key,value|
|
15
|
+
if value['source_id'].to_i == args['source_id'].to_i
|
16
|
+
@name = key
|
17
|
+
end
|
18
|
+
end
|
19
|
+
@source_id = args['source_id'].to_i
|
20
|
+
@source_url = args['source_url']
|
21
|
+
@last_updated = Time.at(args['last_updated'].to_i).to_s
|
22
|
+
@last_inserted_size = args['last_inserted_size'].to_i
|
23
|
+
@last_deleted_size = args['last_deleted_size'].to_i
|
24
|
+
@last_sync_duration = args['last_sync_duration'].to_i
|
25
|
+
@last_sync_success = args['last_sync_success'].to_i == 1 ? true : false
|
26
|
+
end
|
27
|
+
|
28
|
+
class << self
|
29
|
+
include RhomObject
|
30
|
+
def find(*args)
|
31
|
+
list = []
|
32
|
+
if args.first == :all
|
33
|
+
results = ::Rhom::RhomDbAdapter::select_from_table('sources', '*')
|
34
|
+
|
35
|
+
results.each do |result|
|
36
|
+
list << RhomSource.new(result)
|
37
|
+
end
|
38
|
+
else
|
39
|
+
result = ::Rhom::RhomDbAdapter::select_from_table('sources', '*',
|
40
|
+
{"source_id" => strip_braces(args.first)}).first
|
41
|
+
list << RhomSource.new(result)
|
42
|
+
end
|
43
|
+
list.size > 1 ? list : list[0]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def update_attributes(params=nil)
|
48
|
+
if params
|
49
|
+
::Rhom::RhomDbAdapter::update_into_table('sources', {"source_url"=>params['source_url']},
|
50
|
+
{"source_id"=>strip_braces(params['source_id'])})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/time.rb
CHANGED
@@ -40,10 +40,7 @@
|
|
40
40
|
# $Id$
|
41
41
|
#
|
42
42
|
|
43
|
-
|
44
|
-
else
|
45
|
-
require 'date/format'
|
46
|
-
end
|
43
|
+
require 'date/format'
|
47
44
|
|
48
45
|
#
|
49
46
|
# Implements the extensions to the Time class that are described in the
|
@@ -347,7 +344,7 @@ class Time
|
|
347
344
|
else
|
348
345
|
year += 1900
|
349
346
|
end
|
350
|
-
self.utc(year, $2, $1.to_i, $4.to_i, $5.to_i, $6.to_i)
|
347
|
+
self.utc(year(), $2, $1.to_i, $4.to_i, $5.to_i, $6.to_i)
|
351
348
|
elsif /\A\s*
|
352
349
|
(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\x20
|
353
350
|
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\x20
|
@@ -416,9 +413,9 @@ class Time
|
|
416
413
|
#
|
417
414
|
def rfc2822
|
418
415
|
sprintf('%s, %02d %s %d %02d:%02d:%02d ',
|
419
|
-
RFC2822_DAY_NAME[wday],
|
420
|
-
day, RFC2822_MONTH_NAME[mon-1], year,
|
421
|
-
hour, min, sec) +
|
416
|
+
RFC2822_DAY_NAME[wday()],
|
417
|
+
day(), RFC2822_MONTH_NAME[mon()-1], year(),
|
418
|
+
hour(), min(), sec() ) +
|
422
419
|
if utc?
|
423
420
|
'-0000'
|
424
421
|
else
|
data/spec/rho_spec.rb
CHANGED
@@ -26,7 +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
|
-
sources.size.should >
|
29
|
+
sources.size.should > 1
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should initialize configuration only once" do
|
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.2.
|
4
|
+
version: 0.2.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: 2009-01-
|
12
|
+
date: 2009-01-23 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -139,7 +139,6 @@ files:
|
|
139
139
|
- lib/rho/rhofsconnector.rb
|
140
140
|
- lib/rho/rhosupport.rb
|
141
141
|
- lib/rho/rhoviewhelpers.rb
|
142
|
-
- lib/rho/settings_controller.rb
|
143
142
|
- lib/rhodes.rb
|
144
143
|
- lib/rhoframework.rb
|
145
144
|
- lib/rhofsconnector.rb
|
@@ -149,6 +148,7 @@ files:
|
|
149
148
|
- lib/rhom/rhom_db_adapterME.rb
|
150
149
|
- lib/rhom/rhom_object.rb
|
151
150
|
- lib/rhom/rhom_object_factory.rb
|
151
|
+
- lib/rhom/rhom_source.rb
|
152
152
|
- lib/singleton.rb
|
153
153
|
- lib/time.rb
|
154
154
|
- rhodes.gemspec
|
@@ -161,7 +161,6 @@ files:
|
|
161
161
|
- spec/model_generator_spec.rb
|
162
162
|
- spec/rho_spec.rb
|
163
163
|
- spec/rhom_object_factory_spec.rb
|
164
|
-
- spec/settings_controller_spec.rb
|
165
164
|
- spec/source_generator_spec.rb
|
166
165
|
- spec/spec.opts
|
167
166
|
- spec/spec_helper.rb
|
@@ -1,23 +0,0 @@
|
|
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
|
@@ -1,49 +0,0 @@
|
|
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 > 0
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should retrieve source for update" do
|
37
|
-
@controller.get_source('{1}')['source_url'].should =~ /sources\/1/
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should retrieve source without braces" do
|
42
|
-
@controller.get_source('1')['source_url'].should =~ /sources\/1/
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should update source" do
|
46
|
-
@controller.update_source({'source_url'=>'http://acme.com/sources/30'},'1')
|
47
|
-
@controller.get_source('1')['source_url'].should == 'http://acme.com/sources/30'
|
48
|
-
end
|
49
|
-
end
|