rhodes 2.2.4.beta.1 → 2.2.5.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +10 -0
- data/Rakefile +119 -3
- data/lib/build/jake.rb +15 -1
- data/lib/framework/dateME.rb +6 -1
- data/lib/framework/rho/render.rb +18 -15
- data/lib/framework/rho/rho.rb +105 -43
- data/lib/framework/rho/rhoapplication.rb +1 -1
- data/lib/framework/rho/rhocontact.rb +41 -13
- data/lib/framework/rho/rhocontroller.rb +10 -1
- data/lib/framework/rho/rhoevent_c.rb +6 -1
- data/lib/framework/rho/rhosupport.rb +1 -1
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rholang/rhomsg_de.rb +1 -1
- data/lib/framework/rholang/rhomsg_es.rb +1 -1
- data/lib/framework/rholang/rhomsg_it.rb +28 -0
- data/lib/framework/rhom/rhom.rb +6 -0
- data/lib/framework/rhom/rhom_model.rb +14 -7
- data/lib/framework/rhom/rhom_object_factory.rb +121 -56
- data/lib/framework/version.rb +1 -1
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/AndroidManifest.full.xml +62 -0
- data/platform/android/Rhodes/AndroidManifest.xml +3 -34
- data/platform/android/Rhodes/jni/include/rhodes/JNIRhodes.h +17 -2
- data/platform/android/Rhodes/jni/src/alert.cpp +16 -0
- data/platform/android/Rhodes/jni/src/callbacks.cpp +27 -3
- data/platform/android/Rhodes/jni/src/nativebar.cpp +3 -0
- data/platform/android/Rhodes/jni/src/nativeview.cpp +131 -1
- data/platform/android/Rhodes/jni/src/phonebook.cpp +102 -41
- data/platform/android/Rhodes/jni/src/rhodes.cpp +113 -32
- data/platform/android/Rhodes/jni/src/ringtones.cpp +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +1 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +9 -8
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +184 -49
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +49 -25
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +104 -57
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +36 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +24 -14
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +7 -8
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +185 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoNativeViewManager.java +54 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Contact.java +107 -14
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +72 -24
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorOld.java +22 -21
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Phonebook.java +91 -11
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +10 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientNew.java +11 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsNew.java +10 -0
- data/platform/android/build/android.rake +50 -9
- data/platform/android/build/librhocommon_build.files +1 -0
- data/platform/bb/Hsqldb/src/org/hsqldb/Parser.java +3 -2
- data/platform/bb/Hsqldb/src/org/hsqldb/SchemaManager.java +3 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/Session.java +7 -0
- data/platform/bb/Hsqldb/src/org/hsqldb/Tokenizer.java +2 -2
- data/platform/bb/RubyVM/RubyVM.jdp +1 -0
- data/platform/bb/RubyVM/src/com/rho/AppBuildConfig.java +22 -0
- data/platform/bb/RubyVM/src/com/rho/RhoRuby.java +5 -0
- data/platform/bb/RubyVM/src/com/rho/net/RhoConnection.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +51 -4
- data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +21 -10
- data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +82 -33
- data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +59 -6
- data/platform/bb/RubyVM/src/com/xruby/GeneratedMethods/RubyFloat_Methods.java +5 -0
- data/platform/bb/RubyVM/src/com/xruby/GeneratedMethods/RubyString_Methods.java +19 -7
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/ArrayPacker.java +1 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyFloat.java +5 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyString.java +55 -11
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyTime.java +18 -2
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyKernelModule.java +8 -5
- data/platform/bb/RubyVM/src/j2me/lang/CharacterMe.java +1 -1
- data/platform/bb/RubyVM/src/j2me/util/StringParser.java +2 -0
- data/platform/bb/build/RubyVM_build.files +1 -0
- data/platform/bb/build/bb.rake +21 -2
- data/platform/bb/rhodes/platform/4.7/com/rho/RhoMainScreen.java +3 -3
- data/platform/bb/rhodes/platform/common/com/rho/RhoMainScreen.java +1 -1
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +1 -2
- data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +15 -16
- data/platform/bb/rhodes/src/com/rho/rubyext/RhoCalendar.java +4 -0
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +58 -0
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +90 -4
- data/platform/iphone/Classes/AppManager/AppManager.m +43 -5
- data/platform/iphone/Classes/Event/Event.h +2 -0
- data/platform/iphone/Classes/Event/Event.m +12 -1
- data/platform/iphone/Classes/GeoLocation/LocationController.m +9 -3
- data/platform/iphone/Classes/MapView/MapViewController.m +20 -9
- data/platform/iphone/Classes/NativeBar.m +27 -0
- data/platform/iphone/Classes/Phonebook/phonebook.m +17 -0
- data/platform/iphone/Classes/RhoAlert.m +61 -1
- data/platform/iphone/Classes/RhoMainView.h +1 -0
- data/platform/iphone/Classes/Rhodes.h +2 -0
- data/platform/iphone/Classes/Rhodes.m +108 -1
- data/platform/iphone/Classes/SimpleMainView.h +4 -0
- data/platform/iphone/Classes/SimpleMainView.m +30 -3
- data/platform/iphone/Classes/SplashViewController.m +3 -1
- data/platform/iphone/Classes/TabbedMainView.h +2 -0
- data/platform/iphone/Classes/TabbedMainView.m +63 -11
- data/platform/iphone/Classes/rho/net/NetRequestImpl.m +26 -0
- data/platform/iphone/Info.plist +12 -1
- data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +8 -0
- data/platform/iphone/rbuild/iphone.rake +181 -25
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +5 -5
- data/platform/shared/common/IRhoThreadImpl.h +1 -1
- data/platform/shared/common/PosixThreadImpl.cpp +5 -3
- data/platform/shared/common/PosixThreadImpl.h +1 -1
- data/platform/shared/common/RhoFilePath.h +11 -0
- data/platform/shared/common/RhoNativeViewManager.h +17 -0
- data/platform/shared/common/RhoThread.h +1 -1
- data/platform/shared/common/RhodesApp.cpp +29 -8
- data/platform/shared/common/ThreadQueue.cpp +5 -3
- data/platform/shared/common/ThreadQueue.h +2 -1
- data/platform/shared/common/app_build_configs.c +25 -0
- data/platform/shared/common/app_build_configs.h +11 -0
- data/platform/shared/net/AsyncHttp.cpp +5 -5
- data/platform/shared/net/CURLNetRequest.cpp +25 -7
- data/platform/shared/net/CURLNetRequest.h +2 -1
- data/platform/shared/net/HttpServer.cpp +28 -0
- data/platform/shared/ruby/ext/nativebar/nativebar.i +3 -0
- data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +26 -1
- data/platform/shared/ruby/ext/rho/rhoruby.c +6 -0
- data/platform/shared/ruby/ext/rho/rhoruby.h +1 -0
- data/platform/shared/ruby/ext/rho/rhosupport.c +15 -2
- data/platform/shared/ruby/ext/syncengine/syncengine.i +14 -2
- data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +97 -2
- data/platform/shared/ruby/ext/system/system.i +13 -0
- data/platform/shared/ruby/ext/system/system_wrap.c +104 -1
- data/platform/shared/rubyext/RhoAppAdapter.cpp +7 -0
- data/platform/shared/sync/SyncEngine.cpp +43 -3
- data/platform/shared/sync/SyncEngine.h +13 -0
- data/platform/shared/sync/SyncNotify.cpp +41 -23
- data/platform/shared/sync/SyncNotify.h +18 -4
- data/platform/shared/sync/SyncSource.cpp +52 -14
- data/platform/shared/sync/SyncSource.h +1 -0
- data/platform/shared/sync/SyncThread.cpp +29 -9
- data/platform/shared/sync/SyncThread.h +4 -2
- data/platform/wm/RhoLib/RhoLib.vcproj +8 -0
- data/platform/wm/build/build_inf.js +15 -9
- data/platform/wm/build/wm.rake +10 -5
- data/platform/wm/rhodes/Alert.cpp +10 -0
- data/platform/wm/rhodes/Alert.h +3 -3
- data/platform/wm/rhodes/MainWindow.cpp +171 -26
- data/platform/wm/rhodes/MainWindow.h +23 -1
- data/platform/wm/rhodes/MetaHandler.cpp +192 -0
- data/platform/wm/rhodes/MetaHandler.h +31 -0
- data/platform/wm/rhodes/RhoNativeViewManager.cpp +126 -0
- data/platform/wm/rhodes/RhoNativeViewManagerWM.h +20 -0
- data/platform/wm/rhodes/Rhodes.cpp +91 -2
- data/platform/wm/rhodes/Rhodes.rc +15 -6
- data/platform/wm/rhodes/SyncStatusDlg.cpp +32 -0
- data/platform/wm/rhodes/SyncStatusDlg.h +29 -0
- data/platform/wm/rhodes/resource.h +5 -2
- data/platform/wm/rhodes/rho/common/RhoThreadImpl.cpp +3 -1
- data/platform/wm/rhodes/rho/common/RhoThreadImpl.h +1 -1
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +146 -14
- data/platform/wm/rhodes/rhodes.vcproj +28 -0
- data/rakefile.rb +119 -3
- data/res/build-tools/iphonesim/README +58 -0
- data/res/build-tools/iphonesim/Source/iPhoneSimulator.h +43 -0
- data/res/build-tools/iphonesim/Source/iPhoneSimulator.m +224 -0
- data/res/build-tools/iphonesim/Source/main.m +52 -0
- data/res/build-tools/iphonesim/Source/nsprintf.h +3 -0
- data/res/build-tools/iphonesim/Source/nsprintf.m +42 -0
- data/res/build-tools/iphonesim/build/Release/iphonesim +0 -0
- data/res/build-tools/iphonesim/iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h +124 -0
- data/res/build-tools/iphonesim/iphonesim.xcodeproj/project.pbxproj +261 -0
- data/res/build-tools/iphonesim/iphonesim_Prefix.pch +7 -0
- data/res/generators/rhogen.rb +5 -0
- data/res/generators/templates/application/app/layout.erb +7 -13
- data/res/generators/templates/application/app/loading.png +0 -0
- data/res/generators/templates/application/build.yml +3 -0
- data/res/generators/templates/application/icon/icon114.png +0 -0
- data/res/generators/templates/application/icon/icon57.png +0 -0
- data/res/generators/templates/application/icon/icon72.png +0 -0
- data/res/generators/templates/application/public/css/iphone.css +96 -0
- data/res/generators/templates/application/public/images/backButton.png +0 -0
- data/res/generators/templates/application/public/jqtouch/jqtouch.js +2 -1
- data/res/generators/templates/application/rhoconfig.txt +2 -0
- data/rhodes.gemspec +1 -1
- data/spec/phone_spec/app/spec/array_pack_spec.rb +108 -0
- data/spec/phone_spec/app/spec/bulksync_spec.rb +1 -0
- data/spec/phone_spec/app/spec/date_spec.rb +27 -0
- data/spec/phone_spec/app/spec/fixtures/classes.rb +91 -0
- data/spec/phone_spec/app/spec/lstrip_spec.rb +57 -0
- data/spec/phone_spec/app/spec/rho_spec.rb +50 -19
- data/spec/phone_spec/app/spec/rhom_object_spec.rb +78 -0
- data/spec/phone_spec/app/spec/rstrip_spec.rb +51 -0
- data/spec/phone_spec/app/spec/strip_spec.rb +50 -0
- data/spec/phone_spec/app/spec/syncengine_spec.rb +46 -3
- data/spec/phone_spec/app/spec_runner.rb +6 -0
- metadata +34 -4
@@ -0,0 +1,108 @@
|
|
1
|
+
# ~~~~~~~~~~
|
2
|
+
# Script encoding of this file should be neither ASCII-8BIT, US-ASCII nor UTF-8.
|
3
|
+
# This makes it easier to verify that Strings are converted into correct encodings.
|
4
|
+
|
5
|
+
require 'spec/fixtures/classes'
|
6
|
+
|
7
|
+
def binary(str) str.force_encoding(Encoding::ASCII_8BIT) end
|
8
|
+
def utf8(str) str.force_encoding(Encoding::UTF_8) end
|
9
|
+
|
10
|
+
describe "Array#pack with format 'm'" do
|
11
|
+
it "encodes string with Base64 encoding" do
|
12
|
+
["ABCDEF"].pack('m').should == "QUJDREVG\n"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "converts series of 3-char sequences into four 4-char sequences" do
|
16
|
+
["ABCDEFGHI"].pack('m').size.should == 4+4+4+1
|
17
|
+
end
|
18
|
+
|
19
|
+
it "fills chars with non-significant bits with '=' sign" do
|
20
|
+
["A"].pack('m').should == "QQ==\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
#it "appends newline at the end of result string" do
|
24
|
+
# ["A"].pack('m')[-1].should == ?\n
|
25
|
+
#end
|
26
|
+
|
27
|
+
it "appends newline whenever after consumes 45 bytes by default" do
|
28
|
+
["ABC"*31].pack('m').should ==
|
29
|
+
"QUJD"*15 + "\n" +
|
30
|
+
"QUJD"*15 + "\n" +
|
31
|
+
"QUJD\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
=begin
|
35
|
+
it "appends newline whenever after consumes [number/3]*3 of bytes for the specified number > 2, where [x] is the floor function" do
|
36
|
+
s = ["ABC"*3].pack('m3').should == "QUJD\n"*3
|
37
|
+
s = ["ABC"*3+"\x01"].pack('m3').should == "QUJD\n"*3 + "AQ==\n"
|
38
|
+
|
39
|
+
s = ["ABC"*3].pack('m4').should == "QUJD\n"*3
|
40
|
+
s = ["ABC"*3+"\x01"].pack('m4').should == "QUJD\n"*3 + "AQ==\n"
|
41
|
+
s = ["ABC"*3+"\x01"].pack('m5').should == "QUJD\n"*3 + "AQ==\n"
|
42
|
+
s = ["ABC"*3+"\x01"].pack('m6').should == "QUJDQUJD\nQUJDAQ==\n"
|
43
|
+
end
|
44
|
+
=end
|
45
|
+
|
46
|
+
it "ignores line length parameter if it is 1 or 2" do
|
47
|
+
wrapped_at_45 =
|
48
|
+
"QUJD"*15 + "\n" +
|
49
|
+
"QUJD"*15 + "\n" +
|
50
|
+
"QUJD\n"
|
51
|
+
["ABC"*31].pack('m1').should == wrapped_at_45
|
52
|
+
["ABC"*31].pack('m2').should == wrapped_at_45
|
53
|
+
end
|
54
|
+
|
55
|
+
=begin
|
56
|
+
# feature changed in 1.9 - [ruby-dev:35904].
|
57
|
+
it "does not append newline if line length parameter is 0" do
|
58
|
+
["ABC"*31].pack('m0').should == "QUJD"*31
|
59
|
+
["ABC"*31 + "\x01"].pack('m0').should == "QUJD"*31 + "AQ=="
|
60
|
+
end
|
61
|
+
=end
|
62
|
+
|
63
|
+
it "comsumres only one array item per a format" do
|
64
|
+
["ABC", "DEF"].pack('m').should == "QUJD\n"
|
65
|
+
["ABC", "DEF"].pack('m3').should == "QUJD\n"
|
66
|
+
["ABC", "DEF"].pack('m3m3').should == "QUJD\nREVG\n"
|
67
|
+
end
|
68
|
+
|
69
|
+
it "encodes 6-bit char less than 26 with capital letters" do
|
70
|
+
[( 0*4).chr].pack('m').should == "AA==\n"
|
71
|
+
[( 1*4).chr].pack('m').should == "BA==\n"
|
72
|
+
|
73
|
+
[(25*4).chr].pack('m').should == "ZA==\n"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "encodes 6-bit char from 26 to 51 with lowercase letters" do
|
77
|
+
[(26*4).chr].pack('m').should == "aA==\n"
|
78
|
+
[(27*4).chr].pack('m').should == "bA==\n"
|
79
|
+
|
80
|
+
[(51*4).chr].pack('m').should == "zA==\n"
|
81
|
+
end
|
82
|
+
|
83
|
+
it "encodes 6-bit char 62 with '+'" do
|
84
|
+
[(62*4).chr].pack('m').should == "+A==\n"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "encodes 6-bit char 63 with '/'" do
|
88
|
+
[(63*4).chr].pack('m').should == "/A==\n"
|
89
|
+
end
|
90
|
+
|
91
|
+
it "returns empty string if source string is empty" do
|
92
|
+
[""].pack('m').should == ""
|
93
|
+
end
|
94
|
+
|
95
|
+
=begin
|
96
|
+
it "tries to convert the pack argument to a String using #to_str" do
|
97
|
+
obj = mock('to_str')
|
98
|
+
obj.should_receive(:to_str).and_return("ABC")
|
99
|
+
[obj].pack('m').should == "QUJD\n"
|
100
|
+
end
|
101
|
+
=end
|
102
|
+
|
103
|
+
=begin
|
104
|
+
it "returns an US-ASCII string" do
|
105
|
+
["abcd"].pack('m').encoding.should == Encoding::US_ASCII
|
106
|
+
end
|
107
|
+
=end
|
108
|
+
end
|
@@ -28,6 +28,7 @@ describe "BulkSync_test" do
|
|
28
28
|
::Rhom::Rhom.database_full_reset_and_logout
|
29
29
|
|
30
30
|
SyncEngine.set_syncserver('http://store-bulk.rhohub.com/application')
|
31
|
+
#SyncEngine.set_syncserver('http://localhost:9292/application')
|
31
32
|
Rho::RhoConfig.bulksync_state='0'
|
32
33
|
|
33
34
|
@save_sync_types = ::Rho::RHO.get_user_db().select_from_table('sources','name, sync_type')
|
@@ -14,4 +14,31 @@ describe "DateTime" do
|
|
14
14
|
str2 = date.strftime("%m/%d/%Y")
|
15
15
|
str2.should == "07/08/2010"
|
16
16
|
end
|
17
|
+
|
18
|
+
it "should format GMT datetime" do
|
19
|
+
str = "11/22/2010 04:13 PM"
|
20
|
+
|
21
|
+
time = Time.strptime(str, "%m/%d/%Y %I:%M %p")
|
22
|
+
#time.utc?.should == false
|
23
|
+
|
24
|
+
dbTime = time.utc
|
25
|
+
dbTime.utc?.should == true
|
26
|
+
|
27
|
+
res = dbTime.strftime("%Y%m%dT%H%M%S.000 GMT")
|
28
|
+
|
29
|
+
puts "res: #{res}"
|
30
|
+
#res.should == "20101122T131300.000 GMT"
|
31
|
+
end
|
32
|
+
|
33
|
+
if !defined? RHO_ME
|
34
|
+
it "should commercial date" do
|
35
|
+
Date.today.cweek
|
36
|
+
res = Date.commercial(2010, 33, 1)
|
37
|
+
puts "Date.commercial(2010, 33, 1) : #{res}"
|
38
|
+
res.year.should == 2010
|
39
|
+
|
40
|
+
res.to_s.should == "2010-08-16"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
17
44
|
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module ArraySpecs
|
2
|
+
def self.max_32bit_size
|
3
|
+
2**32/4
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.max_64bit_size
|
7
|
+
2**64/8
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.frozen_array
|
11
|
+
frozen_array = [1,2,3]
|
12
|
+
frozen_array.freeze
|
13
|
+
frozen_array
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.recursive_array
|
17
|
+
a = [1, 'two', 3.0]
|
18
|
+
5.times { a << a }
|
19
|
+
a
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.head_recursive_array
|
23
|
+
a = []
|
24
|
+
5.times { a << a }
|
25
|
+
a << 1 << 'two' << 3.0
|
26
|
+
a
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.empty_recursive_array
|
30
|
+
a = []
|
31
|
+
a << a
|
32
|
+
a
|
33
|
+
end
|
34
|
+
|
35
|
+
class MyArray < Array; end
|
36
|
+
|
37
|
+
class Sexp < Array
|
38
|
+
def initialize(*args)
|
39
|
+
super(args)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# TODO: replace specs that use this with #should_not_receive(:to_ary)
|
44
|
+
# expectations on regular objects (e.g. Array instances).
|
45
|
+
class ToAryArray < Array
|
46
|
+
def to_ary() ["to_ary", "was", "called!"] end
|
47
|
+
end
|
48
|
+
|
49
|
+
class MyRange < Range; end
|
50
|
+
|
51
|
+
class AssocKey
|
52
|
+
def ==(other); other == 'it'; end
|
53
|
+
end
|
54
|
+
|
55
|
+
class D
|
56
|
+
def <=>(obj)
|
57
|
+
return 4 <=> obj unless obj.class == D
|
58
|
+
0
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class SubArray < Array
|
63
|
+
def initialize(*args)
|
64
|
+
ScratchPad.record args
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class ArrayConvertable
|
69
|
+
attr_accessor :called
|
70
|
+
def initialize(*values, &block)
|
71
|
+
@values = values;
|
72
|
+
end
|
73
|
+
|
74
|
+
def to_a
|
75
|
+
self.called = :to_a
|
76
|
+
@values
|
77
|
+
end
|
78
|
+
|
79
|
+
def to_ary
|
80
|
+
self.called = :to_ary
|
81
|
+
@values
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class ArrayNotReallyConvertable
|
86
|
+
def to_ary
|
87
|
+
raise "Oups"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
|
2
|
+
#require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes.rb'
|
3
|
+
|
4
|
+
describe "String#lstrip" do
|
5
|
+
it "returns a copy of self with leading whitespace removed" do
|
6
|
+
" hello ".lstrip.should == "hello "
|
7
|
+
" hello world ".lstrip.should == "hello world "
|
8
|
+
"\n\r\t\n\r hello world ".lstrip.should == "hello world "
|
9
|
+
"hello".lstrip.should == "hello"
|
10
|
+
end
|
11
|
+
|
12
|
+
# spec/core/string/lstrip_spec.rb
|
13
|
+
#not_compliant_on :rubinius do
|
14
|
+
#it "does not strip leading \0" do
|
15
|
+
# "\x00hello".lstrip.should == "\x00hello"
|
16
|
+
#end
|
17
|
+
#end
|
18
|
+
|
19
|
+
it "taints the result when self is tainted" do
|
20
|
+
#"".taint.lstrip.tainted?.should == true
|
21
|
+
#"ok".taint.lstrip.tainted?.should == true
|
22
|
+
#" ok".taint.lstrip.tainted?.should == true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "String#lstrip!" do
|
27
|
+
it "modifies self in place and returns self" do
|
28
|
+
a = " hello "
|
29
|
+
a.lstrip!.should == a
|
30
|
+
a.should == "hello "
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns nil if no modifications were made" do
|
34
|
+
a = "hello"
|
35
|
+
a.lstrip!.should == nil
|
36
|
+
a.should == "hello"
|
37
|
+
end
|
38
|
+
|
39
|
+
#ruby_version_is ""..."1.9" do
|
40
|
+
#it "raises a TypeError if self is frozen" do
|
41
|
+
# "hello".freeze.lstrip! # ok, nothing changed
|
42
|
+
# "".freeze.lstrip! # ok, nothing changed
|
43
|
+
|
44
|
+
# lambda { " hello ".freeze.lstrip! }.should raise_error(TypeError)
|
45
|
+
#end
|
46
|
+
#end
|
47
|
+
|
48
|
+
#ruby_version_is "1.9" do
|
49
|
+
# ruby_bug "#1550", "1.9.2" do
|
50
|
+
# it "raises a RuntimeError if self is frozen" do
|
51
|
+
# lambda { "hello".freeze.lstrip! }.should raise_error(RuntimeError)
|
52
|
+
# lambda { "".freeze.lstrip! }.should raise_error(RuntimeError)
|
53
|
+
# lambda { " hello ".freeze.lstrip! }.should raise_error(RuntimeError)
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
#end
|
57
|
+
end
|
@@ -150,10 +150,15 @@ describe "RhoRuby" do
|
|
150
150
|
it "split should have nil" do
|
151
151
|
line = "Account|parent_name|44e804f2-4933-4e20-271c-48fcecd9450d||\n"
|
152
152
|
parts = line.chomp.split('|')
|
153
|
-
|
153
|
+
|
154
|
+
parts.should == ['Account','parent_name','44e804f2-4933-4e20-271c-48fcecd9450d']
|
154
155
|
parts[3].should be_nil
|
155
156
|
parts[4].should be_nil
|
156
157
|
end
|
158
|
+
|
159
|
+
it "should empty fields when limit isn't given" do
|
160
|
+
"1,2,,3,4,,".split(',').should == ["1", "2", "", "3", "4"]
|
161
|
+
end
|
157
162
|
|
158
163
|
it "should call to_a on string" do
|
159
164
|
s = "abcdef"
|
@@ -289,26 +294,54 @@ end
|
|
289
294
|
a[5..10].should == []
|
290
295
|
end
|
291
296
|
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
297
|
+
it "should call Float.to_f" do
|
298
|
+
ftest = 0.34
|
299
|
+
ftest.is_a?(Float).should == true
|
300
|
+
|
301
|
+
fres = ftest.to_f
|
302
|
+
fres.is_a?(Float).should == true
|
303
|
+
|
304
|
+
fres.should == ftest
|
298
305
|
|
299
|
-
res.to_s.should == "2010-08-16"
|
300
306
|
end
|
301
|
-
|
307
|
+
|
308
|
+
it "splits between characters when its argument is an empty string" do
|
309
|
+
"hi!".split("").should == ["h", "i", "!"]
|
310
|
+
#"hi!".split("", -1).should == ["h", "i", "!", ""]
|
311
|
+
"hi!".split("", 2).should == ["h", "i!"]
|
312
|
+
end
|
313
|
+
|
314
|
+
it "should split empty string" do
|
315
|
+
block = nil
|
316
|
+
if block.nil?
|
317
|
+
buffer = []
|
318
|
+
else
|
319
|
+
buffer = block.split('')
|
320
|
+
end
|
321
|
+
|
322
|
+
buffer.should_not be_nil
|
323
|
+
buffer.should == []
|
324
|
+
buffer.length.should == 0
|
325
|
+
end
|
326
|
+
|
327
|
+
it "should split empty string1" do
|
328
|
+
|
329
|
+
block = '' if block.nil?
|
330
|
+
buffer = block.split('')
|
331
|
+
|
332
|
+
buffer.should_not be_nil
|
333
|
+
buffer.should == []
|
334
|
+
buffer.length.should == 0
|
335
|
+
end
|
302
336
|
|
303
|
-
end
|
304
|
-
=begin
|
305
|
-
describe "String#split with String" do
|
306
337
|
it "returns an array of substrings based on splitting on the given string" do
|
307
338
|
"mellow yellow".split("ello").should == ["m", "w y", "w"]
|
308
339
|
end
|
309
|
-
|
340
|
+
|
310
341
|
it "suppresses trailing empty fields when limit isn't given or 0" do
|
311
342
|
"1,2,,3,4,,".split(',').should == ["1", "2", "", "3", "4"]
|
343
|
+
"1,2,,3,4".split(',').should == ["1", "2", "", "3", "4"]
|
344
|
+
|
312
345
|
"1,2,,3,4,,".split(',', 0).should == ["1", "2", "", "3", "4"]
|
313
346
|
" a b c\nd ".split(" ").should == ["", "a", "b", "c\nd"]
|
314
347
|
"hai".split("hai").should == []
|
@@ -346,6 +379,10 @@ describe "String#split with String" do
|
|
346
379
|
" a b c\nd ".split(" ", -1).should == ["", "a", "b", "c\nd", ""]
|
347
380
|
",".split(",", -1).should == ["", ""]
|
348
381
|
end
|
382
|
+
end
|
383
|
+
|
384
|
+
=begin
|
385
|
+
describe "String#split with String" do
|
349
386
|
|
350
387
|
it "defaults to $; when string isn't given or nil" do
|
351
388
|
begin
|
@@ -378,12 +415,6 @@ describe "String#split with String" do
|
|
378
415
|
"a\x00a b".split(' ').should == ["a\x00a", "b"]
|
379
416
|
end
|
380
417
|
|
381
|
-
it "splits between characters when its argument is an empty string" do
|
382
|
-
"hi!".split("").should == ["h", "i", "!"]
|
383
|
-
"hi!".split("", -1).should == ["h", "i", "!", ""]
|
384
|
-
"hi!".split("", 2).should == ["h", "i!"]
|
385
|
-
end
|
386
|
-
|
387
418
|
it "doesn't set $~" do
|
388
419
|
$~ = nil
|
389
420
|
"x.y.z".split(".")
|
@@ -823,6 +823,67 @@ describe "Rhom::RhomObject" do
|
|
823
823
|
@accts[1].name.should == "Aeroprise"
|
824
824
|
@accts[1].industry.should == "Technology"
|
825
825
|
end
|
826
|
+
|
827
|
+
it "should order by block" do
|
828
|
+
@accts = getAccount.find(:all, :order => 'name') do |x,y|
|
829
|
+
y <=> x
|
830
|
+
end
|
831
|
+
|
832
|
+
@accts[0].name.should == "Mobio India"
|
833
|
+
@accts[0].industry.should == "Technology"
|
834
|
+
@accts[1].name.should == "Aeroprise"
|
835
|
+
@accts[1].industry.should == "Technology"
|
836
|
+
|
837
|
+
@accts = getAccount.find(:all, :order => 'name', :orderdir => 'DESC') do |x,y|
|
838
|
+
y <=> x
|
839
|
+
end
|
840
|
+
|
841
|
+
@accts[0].name.should == "Aeroprise"
|
842
|
+
@accts[0].industry.should == "Technology"
|
843
|
+
@accts[1].name.should == "Mobio India"
|
844
|
+
@accts[1].industry.should == "Technology"
|
845
|
+
|
846
|
+
puts "block without order parameter"
|
847
|
+
@accts = getAccount.find(:all) do |item1,item2|
|
848
|
+
item2.name <=> item1.name
|
849
|
+
end
|
850
|
+
|
851
|
+
@accts[0].name.should == "Mobio India"
|
852
|
+
@accts[0].industry.should == "Technology"
|
853
|
+
@accts[1].name.should == "Aeroprise"
|
854
|
+
@accts[1].industry.should == "Technology"
|
855
|
+
|
856
|
+
end
|
857
|
+
|
858
|
+
it "should order by multiple columns" do
|
859
|
+
getAccount.create(:name=>'ZMobile', :industry => 'IT', :modified_by_name => 'user')
|
860
|
+
getAccount.create(:name=>'Aeroprise', :industry => 'Accounting', :modified_by_name => 'admin')
|
861
|
+
|
862
|
+
@accts = getAccount.find(:all, :order => ['name', 'industry'], :orderdir => ['ASC', 'DESC'])
|
863
|
+
|
864
|
+
@accts.length().should == 4
|
865
|
+
@accts[0].name.should == "Aeroprise"
|
866
|
+
@accts[0].industry.should == "Technology"
|
867
|
+
@accts[1].name.should == "Aeroprise"
|
868
|
+
@accts[1].industry.should == "Accounting"
|
869
|
+
@accts[2].name.should == "Mobio India"
|
870
|
+
@accts[2].industry.should == "Technology"
|
871
|
+
@accts[3].name.should == "ZMobile"
|
872
|
+
@accts[3].industry.should == "IT"
|
873
|
+
|
874
|
+
puts "multiple order with condition"
|
875
|
+
@accts = getAccount.find(:all, :conditions => {:modified_by_name => 'admin'},
|
876
|
+
:order => ['name', 'industry'], :orderdir => ['ASC', 'DESC'])
|
877
|
+
|
878
|
+
@accts.length().should == 3
|
879
|
+
@accts[0].name.should == "Aeroprise"
|
880
|
+
@accts[0].industry.should == "Technology"
|
881
|
+
@accts[1].name.should == "Aeroprise"
|
882
|
+
@accts[1].industry.should == "Accounting"
|
883
|
+
@accts[2].name.should == "Mobio India"
|
884
|
+
@accts[2].industry.should == "Technology"
|
885
|
+
|
886
|
+
end
|
826
887
|
|
827
888
|
it "should return records when order by is nil for some records" do
|
828
889
|
@accts = getAccount.find(:all, :order => 'shipping_address_country', :dont_ignore_missed_attribs => true)
|
@@ -836,16 +897,33 @@ describe "Rhom::RhomObject" do
|
|
836
897
|
end
|
837
898
|
|
838
899
|
it "should delete_all" do
|
900
|
+
vars = {"name"=>"foobarthree", "industry"=>"entertainment"}
|
901
|
+
account = getAccount.create(vars)
|
902
|
+
|
839
903
|
getAccount.delete_all
|
840
904
|
|
841
905
|
getAccount.find(:all).length.should == 0
|
906
|
+
|
907
|
+
if $spec_settings[:sync_model]
|
908
|
+
records = ::Rho::RHO.get_user_db().select_from_table('changed_values','*', 'source_id' => getAccount().get_source_id() )
|
909
|
+
records.length.should == 0
|
910
|
+
end
|
842
911
|
end
|
843
912
|
|
844
913
|
it "should delete_all with conditions" do
|
914
|
+
vars = {"name"=>"foobarthree", "industry"=>"entertainment"}
|
915
|
+
account = getAccount.create(vars)
|
916
|
+
|
845
917
|
getAccount.delete_all(:conditions => {'name' => 'Mobio India'})
|
846
918
|
|
847
919
|
@accts = getAccount.find(:all, :conditions => {'name' => 'Mobio India'})
|
848
920
|
@accts.length.should == 0
|
921
|
+
|
922
|
+
if $spec_settings[:sync_model]
|
923
|
+
records = ::Rho::RHO.get_user_db().select_from_table('changed_values','*', 'source_id' => getAccount().get_source_id() )
|
924
|
+
records.length.should > 0
|
925
|
+
end
|
926
|
+
|
849
927
|
end
|
850
928
|
|
851
929
|
it "should delete_all with conditions across objects" do
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
|
2
|
+
#require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes.rb'
|
3
|
+
|
4
|
+
describe "String#rstrip" do
|
5
|
+
it "returns a copy of self with trailing whitespace removed" do
|
6
|
+
" hello ".rstrip.should == " hello"
|
7
|
+
" hello world ".rstrip.should == " hello world"
|
8
|
+
" hello world \n\r\t\n\r".rstrip.should == " hello world"
|
9
|
+
"hello".rstrip.should == "hello"
|
10
|
+
"hello".rstrip.should == "hello"
|
11
|
+
end
|
12
|
+
|
13
|
+
#it "taints the result when self is tainted" do
|
14
|
+
# "".taint.rstrip.tainted?.should == true
|
15
|
+
# "ok".taint.rstrip.tainted?.should == true
|
16
|
+
# "ok ".taint.rstrip.tainted?.should == true
|
17
|
+
#end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "String#rstrip!" do
|
21
|
+
it "modifies self in place and returns self" do
|
22
|
+
a = " hello "
|
23
|
+
a.rstrip!.should == a
|
24
|
+
a.should == " hello"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns nil if no modifications were made" do
|
28
|
+
a = "hello"
|
29
|
+
a.rstrip!.should == nil
|
30
|
+
a.should == "hello"
|
31
|
+
end
|
32
|
+
|
33
|
+
#ruby_version_is ""..."1.9" do
|
34
|
+
#it "raises a TypeError if self is frozen" do
|
35
|
+
# "hello".freeze.rstrip! # ok, nothing changed
|
36
|
+
# "".freeze.rstrip! # ok, nothing changed
|
37
|
+
|
38
|
+
# lambda { " hello ".freeze.rstrip! }.should raise_error(TypeError)
|
39
|
+
#end
|
40
|
+
#end
|
41
|
+
|
42
|
+
#ruby_version_is "1.9" do
|
43
|
+
# ruby_bug "[ruby-core:23666]", "1.9.2" do
|
44
|
+
# it "raises a RuntimeError if self is frozen" do
|
45
|
+
# lambda { "hello".freeze.rstrip! }.should raise_error(RuntimeError)
|
46
|
+
# lambda { "".freeze.rstrip! }.should raise_error(RuntimeError)
|
47
|
+
# lambda { " hello ".freeze.rstrip! }.should raise_error(RuntimeError)
|
48
|
+
# end
|
49
|
+
#end
|
50
|
+
#end
|
51
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
|
2
|
+
#require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes.rb'
|
3
|
+
|
4
|
+
describe "String#strip" do
|
5
|
+
it "returns a new string with leading and trailing whitespace removed" do
|
6
|
+
" hello ".strip.should == "hello"
|
7
|
+
" hello world ".strip.should == "hello world"
|
8
|
+
"\tgoodbye\r\n".strip.should == "goodbye"
|
9
|
+
" goodbye \000".strip.should == "goodbye"
|
10
|
+
end
|
11
|
+
|
12
|
+
#it "taints the result when self is tainted" do
|
13
|
+
# "".taint.strip.tainted?.should == true
|
14
|
+
# "ok".taint.strip.tainted?.should == true
|
15
|
+
# " ok ".taint.strip.tainted?.should == true
|
16
|
+
#end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "String#strip!" do
|
20
|
+
it "modifies self in place and returns self" do
|
21
|
+
a = " hello "
|
22
|
+
a.strip!.should == a
|
23
|
+
a.should == "hello"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns nil if no modifications where made" do
|
27
|
+
a = "hello"
|
28
|
+
a.strip!.should == nil
|
29
|
+
a.should == "hello"
|
30
|
+
end
|
31
|
+
|
32
|
+
#ruby_version_is ""..."1.9" do
|
33
|
+
# it "raises a TypeError if self is frozen" do
|
34
|
+
# "hello".freeze.strip! # ok, nothing changed
|
35
|
+
# "".freeze.strip! # ok, nothing changed
|
36
|
+
|
37
|
+
# lambda { " hello ".freeze.strip! }.should raise_error(TypeError)
|
38
|
+
# end
|
39
|
+
#end
|
40
|
+
|
41
|
+
#ruby_version_is "1.9" do
|
42
|
+
# ruby_bug "#1552", "1.9.2" do
|
43
|
+
# it "raises a RuntimeError if self is frozen" do
|
44
|
+
# lambda {"hello".freeze.strip! }.should raise_error(RuntimeError)
|
45
|
+
# lambda {"".freeze.strip! }.should raise_error(RuntimeError)
|
46
|
+
# lambda { " hello ".freeze.strip! }.should raise_error(RuntimeError)
|
47
|
+
# end
|
48
|
+
#end
|
49
|
+
#end
|
50
|
+
end
|
@@ -44,6 +44,9 @@ def getCustomer_str
|
|
44
44
|
'Customer'
|
45
45
|
end
|
46
46
|
|
47
|
+
SYNC_SERVER_URL = 'http://rhodes-store-server.heroku.com/application'
|
48
|
+
#SYNC_SERVER_URL = 'http://localhost:9292/application'
|
49
|
+
|
47
50
|
describe "SyncEngine_test" do
|
48
51
|
|
49
52
|
before(:all) do
|
@@ -51,8 +54,7 @@ describe "SyncEngine_test" do
|
|
51
54
|
|
52
55
|
::Rhom::Rhom.database_fullclient_reset_and_logout
|
53
56
|
|
54
|
-
SyncEngine.set_syncserver(
|
55
|
-
#SyncEngine.set_syncserver('http://localhost:9292/application')
|
57
|
+
SyncEngine.set_syncserver(SYNC_SERVER_URL)
|
56
58
|
|
57
59
|
@save_sync_types = ::Rho::RHO.get_user_db().select_from_table('sources','name, sync_type')
|
58
60
|
::Rho::RHO.get_user_db().update_into_table('sources',{'sync_type'=>'none'})
|
@@ -66,6 +68,10 @@ describe "SyncEngine_test" do
|
|
66
68
|
end
|
67
69
|
|
68
70
|
end
|
71
|
+
|
72
|
+
after (:each) do
|
73
|
+
Rho::RhoConfig.syncserver = SYNC_SERVER_URL
|
74
|
+
end
|
69
75
|
|
70
76
|
it "should update syncserver at runtime" do
|
71
77
|
|
@@ -91,7 +97,16 @@ describe "SyncEngine_test" do
|
|
91
97
|
res['error_code'].to_i.should == ::Rho::RhoError::ERR_CLIENTISNOTLOGGEDIN
|
92
98
|
|
93
99
|
end
|
94
|
-
|
100
|
+
=begin
|
101
|
+
it "should update sources from database" do
|
102
|
+
uniq_sources = Rho::RhoConfig::sources.values
|
103
|
+
|
104
|
+
::Rho::RHO.get_instance().load_server_sources("{\"partition\":\"user\"}")
|
105
|
+
::Rhom::Rhom.database_fullclient_reset_and_logout
|
106
|
+
|
107
|
+
#uniq_sources.should == Rho::RhoConfig::sources.values
|
108
|
+
end
|
109
|
+
=end
|
95
110
|
it "should login" do
|
96
111
|
|
97
112
|
res = ::Rho::RhoSupport::parse_query_parameters SyncEngine.login('lars', 'larspass', "/app/Settings/login_callback")
|
@@ -199,6 +214,34 @@ describe "SyncEngine_test" do
|
|
199
214
|
cust22.first.should == cust2.first
|
200
215
|
|
201
216
|
end
|
217
|
+
|
218
|
+
it "should process error sync" do
|
219
|
+
|
220
|
+
records = ::Rho::RHO.get_user_db().select_from_table('changed_values','*')
|
221
|
+
records.length.should == 0
|
222
|
+
|
223
|
+
cust1 = getCustomer.create( {:first => "CustTest1"})
|
224
|
+
|
225
|
+
records = ::Rho::RHO.get_user_db().select_from_table('changed_values','*')
|
226
|
+
records.length.should_not == 0
|
227
|
+
|
228
|
+
Rho::RhoConfig.syncserver = 'http://rhodes-store-server.heroku2.com/application'
|
229
|
+
res = ::Rho::RhoSupport::parse_query_parameters getCustomer.sync
|
230
|
+
res['status'].should == 'error'
|
231
|
+
res['error_code'].to_i.should == ::Rho::RhoError::ERR_NETWORK
|
232
|
+
|
233
|
+
records = ::Rho::RHO.get_user_db().select_from_table('changed_values','*')
|
234
|
+
records.length.should_not == 0
|
235
|
+
|
236
|
+
Rho::RhoConfig.syncserver = SYNC_SERVER_URL
|
237
|
+
res = ::Rho::RhoSupport::parse_query_parameters getCustomer.sync
|
238
|
+
res['status'].should == 'ok'
|
239
|
+
res['error_code'].to_i.should == ::Rho::RhoError::ERR_NONE
|
240
|
+
|
241
|
+
records = ::Rho::RHO.get_user_db().select_from_table('changed_values','*')
|
242
|
+
records.length.should == 0
|
243
|
+
|
244
|
+
end
|
202
245
|
|
203
246
|
it "should modify Product" do
|
204
247
|
SyncEngine.logged_in.should == 1
|