ruboss4ruby 1.1.1 → 1.1.2
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 +4 -0
- data/Manifest.txt +2 -1
- data/lib/ruboss4ruby.rb +3 -3
- data/ruboss4ruby.gemspec +3 -3
- data/test/rails/helpers/controllers.log +1 -0
- data/test/rails/helpers/models.log +2179 -0
- data/test/rails/models/task.rb +1 -3
- data/test/rails/models/user.rb +1 -3
- data/test/rails/test_active_foo.rb +3 -48
- data/test/rails/test_to_fxml.rb +3 -45
- metadata +4 -3
- data/lib/ruboss4ruby/active_record_default_methods.rb +0 -66
data/test/rails/models/task.rb
CHANGED
data/test/rails/models/user.rb
CHANGED
|
@@ -15,7 +15,7 @@ class ActiveFooTest < Test::Unit::TestCase
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def test_task_fxml_has_default_method
|
|
18
|
-
set_response_to tasks(:haydn).to_fxml
|
|
18
|
+
set_response_to tasks(:haydn).to_fxml(:methods => :is_active)
|
|
19
19
|
assert_xml_select 'task is_active'
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -25,57 +25,12 @@ class ActiveFooTest < Test::Unit::TestCase
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def test_user_fxml_has_nothing_to_do_method
|
|
28
|
-
set_response_to users(:ludwig).to_fxml
|
|
28
|
+
set_response_to users(:ludwig).to_fxml(:methods => :has_nothing_to_do)
|
|
29
29
|
assert_xml_select 'user has_nothing_to_do'
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def test_user_fxml_includes_default_method_from_task
|
|
33
|
-
set_response_to users(:ludwig).to_fxml(:include => :tasks)
|
|
33
|
+
set_response_to users(:ludwig).to_fxml(:methods => :is_active, :include => :tasks)
|
|
34
34
|
assert_xml_select 'user tasks task is_active'
|
|
35
35
|
end
|
|
36
|
-
#
|
|
37
|
-
# def test_projects_fxml_includes_tasks
|
|
38
|
-
# set_response_to projects(:music).to_fxml
|
|
39
|
-
# assert_xml_select 'project tasks task'
|
|
40
|
-
# end
|
|
41
|
-
#
|
|
42
|
-
# def test_projects_with_user_included_as_symbol
|
|
43
|
-
# set_response_to projects(:music).to_fxml(:include => :user)
|
|
44
|
-
# assert_xml_select 'project user'
|
|
45
|
-
# end
|
|
46
|
-
#
|
|
47
|
-
# def test_includes_as_hash_returns_hashes
|
|
48
|
-
# assert_equal Hash.new, User.includes_as_hash
|
|
49
|
-
# assert_equal ({:one => 1, :two => 2}), User.includes_as_hash({:one => 1, :two => 2})
|
|
50
|
-
# assert_equal ({:test => {}}), User.includes_as_hash(:test)
|
|
51
|
-
# assert_equal ({:test1 => {}, :test2 => {}}), User.includes_as_hash([:test1, :test2])
|
|
52
|
-
# end
|
|
53
|
-
#
|
|
54
|
-
# def test_validates_length_of_validates_length
|
|
55
|
-
# assert_nothing_raised do
|
|
56
|
-
# @shakespeare.login = 'william_shakespeare'
|
|
57
|
-
# @shakespeare.save
|
|
58
|
-
# assert !@shakespeare.errors.empty?
|
|
59
|
-
# end
|
|
60
|
-
# @shakespeare.login = 'william'
|
|
61
|
-
# @shakespeare.save
|
|
62
|
-
# assert @shakespeare.errors.empty?
|
|
63
|
-
# end
|
|
64
|
-
#
|
|
65
|
-
# def test_you_can_do_to_fxml_with_validates_length
|
|
66
|
-
# assert_nothing_raised do
|
|
67
|
-
# @shakespeare.to_fxml
|
|
68
|
-
# end
|
|
69
|
-
# end
|
|
70
|
-
#
|
|
71
|
-
# def test_array_of_users_includes_default_fxml_includes
|
|
72
|
-
# set_response_to User.find(:all).to_fxml
|
|
73
|
-
# assert_xml_select 'users user tasks task'
|
|
74
|
-
# end
|
|
75
|
-
#
|
|
76
|
-
# def test_to_fxml_should_take_a_block
|
|
77
|
-
# set_response_to users(:ludwig).to_fxml {|xml| xml.test 42}
|
|
78
|
-
# assert_xml_select 'test', '42'
|
|
79
|
-
# end
|
|
80
|
-
|
|
81
36
|
end
|
data/test/rails/test_to_fxml.rb
CHANGED
|
@@ -21,57 +21,15 @@ class ToFxmlTest < Test::Unit::TestCase
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def test_default_xml_methods_on_user_are_included_in_fxml
|
|
24
|
-
set_response_to users(:ludwig).to_fxml
|
|
24
|
+
set_response_to users(:ludwig).to_fxml(:methods => [:has_nothing_to_do, :full_name])
|
|
25
25
|
assert_xml_select 'user full_name', 'Ludwig van Beethoven'
|
|
26
26
|
assert_xml_select 'user has_nothing_to_do'
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def test_default_xml_methods_on_user_are_included_in_fxml_if_you_call_it_twice
|
|
30
|
-
set_response_to users(:ludwig).to_fxml
|
|
31
|
-
set_response_to users(:ludwig).to_fxml
|
|
30
|
+
set_response_to users(:ludwig).to_fxml(:methods => [:has_nothing_to_do, :full_name])
|
|
31
|
+
set_response_to users(:ludwig).to_fxml(:methods => [:has_nothing_to_do, :full_name])
|
|
32
32
|
assert_xml_select 'user full_name', 'Ludwig van Beethoven'
|
|
33
33
|
assert_xml_select 'user has_nothing_to_do'
|
|
34
34
|
end
|
|
35
|
-
|
|
36
|
-
def test_default_xml_methods_exists
|
|
37
|
-
assert User.respond_to?(:default_methods_array)
|
|
38
|
-
assert_equal [:full_name, :has_nothing_to_do], User.default_methods_array
|
|
39
|
-
end
|
|
40
|
-
#
|
|
41
|
-
# def test_default_xml_methods_on_dependencies
|
|
42
|
-
# t = users(:ludwig).tasks.first
|
|
43
|
-
# assert t.class.respond_to?(:default_xml_methods_array)
|
|
44
|
-
# assert_equal [:is_active], t.class.default_xml_methods_array
|
|
45
|
-
# end
|
|
46
|
-
#
|
|
47
|
-
# def test_default_xml_methods_are_included_in_includes
|
|
48
|
-
# set_response_to users(:ludwig).to_fxml(:include => :tasks)
|
|
49
|
-
# assert_xml_select 'tasks task is_active'
|
|
50
|
-
# end
|
|
51
|
-
#
|
|
52
|
-
# def test_model_without_default_xml_methods_still_works
|
|
53
|
-
# assert_nothing_raised{ locations(:vienna).to_fxml }
|
|
54
|
-
# end
|
|
55
|
-
#
|
|
56
|
-
# def test_user_with_non_default_methods_in_to_xml
|
|
57
|
-
# set_response_to users(:ludwig).to_fxml(:methods => :email_host)
|
|
58
|
-
# assert_xml_select 'user email_host', 'vienna.de'
|
|
59
|
-
# assert_xml_select 'user full_name'
|
|
60
|
-
# end
|
|
61
|
-
#
|
|
62
|
-
# def test_model_with_default_xml_includes
|
|
63
|
-
# set_response_to users(:ludwig).to_fxml
|
|
64
|
-
# assert_xml_select 'user tasks task'
|
|
65
|
-
# end
|
|
66
|
-
#
|
|
67
|
-
# def test_simple_properies
|
|
68
|
-
# puts simple_properties
|
|
69
|
-
# end
|
|
70
|
-
|
|
71
|
-
# Test type=.... stuff for has_many, booleans, integers, dates, date-times
|
|
72
|
-
|
|
73
|
-
# Test empty arrays
|
|
74
|
-
|
|
75
|
-
# Test options[:except]
|
|
76
|
-
|
|
77
35
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruboss4ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dima Berastau
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-01-
|
|
12
|
+
date: 2009-01-11 00:00:00 -08:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -104,7 +104,6 @@ files:
|
|
|
104
104
|
- gpl-3.0.txt
|
|
105
105
|
- lib/ruboss4ruby.rb
|
|
106
106
|
- lib/ruboss4ruby/active_foo.rb
|
|
107
|
-
- lib/ruboss4ruby/active_record_default_methods.rb
|
|
108
107
|
- lib/ruboss4ruby/active_record_tasks.rb
|
|
109
108
|
- lib/ruboss4ruby/configuration.rb
|
|
110
109
|
- lib/ruboss4ruby/datamapper_foo.rb
|
|
@@ -177,7 +176,9 @@ files:
|
|
|
177
176
|
- test/rails/fixtures/simple_properties.yml
|
|
178
177
|
- test/rails/fixtures/tasks.yml
|
|
179
178
|
- test/rails/fixtures/users.yml
|
|
179
|
+
- test/rails/helpers/controllers.log
|
|
180
180
|
- test/rails/helpers/functional_test_helper.rb
|
|
181
|
+
- test/rails/helpers/models.log
|
|
181
182
|
- test/rails/helpers/test_helper.rb
|
|
182
183
|
- test/rails/helpers/unit_test_helper.rb
|
|
183
184
|
- test/rails/model.yml
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
module ActiveRecord
|
|
2
|
-
#
|
|
3
|
-
# We also add support for serializing model methods along the lines of:
|
|
4
|
-
#
|
|
5
|
-
# class Project < ActiveRecord::Base
|
|
6
|
-
# default_methods :foobar
|
|
7
|
-
#
|
|
8
|
-
# def foobar
|
|
9
|
-
# 'foobar'
|
|
10
|
-
# end
|
|
11
|
-
# end
|
|
12
|
-
#
|
|
13
|
-
# When you do +to_fxml+ on this model method foobar will be automatically
|
|
14
|
-
# serialized as a simple attribute
|
|
15
|
-
class Base
|
|
16
|
-
class << self
|
|
17
|
-
|
|
18
|
-
# default methods hook
|
|
19
|
-
def default_methods(*args)
|
|
20
|
-
methods = *args.dup
|
|
21
|
-
module_eval <<-END
|
|
22
|
-
def self.default_methods_array
|
|
23
|
-
return [#{methods.inspect}].flatten
|
|
24
|
-
end
|
|
25
|
-
END
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# default methods hook
|
|
29
|
-
def defaults_hash(already_included = [], ignore_default_methods = nil)
|
|
30
|
-
defaults_hash = {:include => {}}
|
|
31
|
-
unless ignore_default_methods
|
|
32
|
-
defaults_hash[:methods] = self.default_methods_array if self.respond_to?(:default_methods_array)
|
|
33
|
-
end
|
|
34
|
-
defaults_hash
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# Flex-friendly serialization patches
|
|
40
|
-
module Serialization
|
|
41
|
-
|
|
42
|
-
alias_method :xml_defaults_old_to_xml, :to_xml unless method_defined?(:xml_defaults_old_to_xml)
|
|
43
|
-
|
|
44
|
-
alias_method :json_defaults_old_to_json, :to_json unless method_defined?(:json_defaults_old_to_json)
|
|
45
|
-
|
|
46
|
-
# adds support for default_methods to standard +to_xml+
|
|
47
|
-
def to_xml(options = {}, &block)
|
|
48
|
-
unless options[:ignore_defaults]
|
|
49
|
-
unless options[:ignore_default_methods]
|
|
50
|
-
options[:methods] = [options[:methods] || []].flatten + (self.class.defaults_hash[:methods] || [])
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
xml_defaults_old_to_xml(options, &block)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# adds support for default_methods to standard +to_json+
|
|
57
|
-
def to_json(options = {}, &block)
|
|
58
|
-
unless options[:ignore_defaults]
|
|
59
|
-
unless options[:ignore_default_methods]
|
|
60
|
-
options[:methods] = [options[:methods] || []].flatten + (self.class.defaults_hash[:methods] || [])
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
json_defaults_old_to_json(options, &block)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|