fossil 0.4.5 → 0.4.6

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.5
1
+ 0.4.6
data/fossil.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fossil}
8
- s.version = "0.4.5"
8
+ s.version = "0.4.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Patrick Lardin, Daniel Sudol"]
12
- s.date = %q{2010-06-25}
12
+ s.date = %q{2010-06-28}
13
13
  s.description = %q{Access FOS/betrieve db with this Sequel based orm wrapper}
14
14
  s.email = %q{plardin@xojet.com}
15
15
  s.files = [
@@ -127,7 +127,6 @@ Gem::Specification.new do |s|
127
127
  "lib/sequel/serializer/serializer.rb",
128
128
  "lib/sequel/serializer/xml_serializer.rb",
129
129
  "lib/sequel/sqlite_pervasive_adapter.rb",
130
- "lib/serial_number.rb",
131
130
  "spec/be_model_with_values_matcher.rb",
132
131
  "spec/be_model_with_values_matcher_spec.rb",
133
132
  "spec/hash_extentions_spec.rb",
data/lib/fossil.rb CHANGED
@@ -18,7 +18,6 @@ end
18
18
  dir = File.dirname(__FILE__)
19
19
  files = [File.join(dir,'number_helper.rb')] +
20
20
  [File.join(dir,'hash_extentions.rb')] +
21
- [File.join(dir,'serial_number.rb')] +
22
21
  [File.join(dir,'sequel','serializer','serializer.rb')] +
23
22
  Dir.glob(File.join(dir,'sequel','*.rb')) +
24
23
  Dir.glob(File.join(dir,'models','*.rb'))
@@ -84,7 +84,8 @@ module Sequel
84
84
  # to_json ignores the special __ delegator methods ( like 'leg_status__downcase' )
85
85
  # that we use in orm.
86
86
  def to_fos_json(options = {})
87
- fill_hash(options[:methods])
87
+ options = {:only=>[]}.merge(options)
88
+ to_json(options)
88
89
  end
89
90
 
90
91
  def from_json(json)
@@ -31,7 +31,7 @@ module Sequel
31
31
 
32
32
  def serializable_method_names
33
33
  Array(options[:methods]).inject([]) do |method_attributes, name|
34
- method_attributes << name if !name.blank? and @record.respond_to?(name.to_s)
34
+ method_attributes << name if !name.blank? #and @record.respond_to?(name.to_s)
35
35
  method_attributes
36
36
  end
37
37
  end
@@ -151,8 +151,8 @@ module Sequel #:nodoc:
151
151
  # end
152
152
  # end
153
153
  # end
154
- def to_fos_xml(options ={}, &block)
155
- options = {:skip_instruct=>true, :dasherize=>false, :only=>[]}.merge(options)
154
+ def to_fos_xml(options ={}, &block)
155
+ options = {:skip_instruct=>true, :skip_types=>true, :dasherize=>false, :only=>[]}.merge(options)
156
156
  to_xml(options, &block)
157
157
  end
158
158
 
@@ -209,7 +209,7 @@ module Sequel #:nodoc:
209
209
 
210
210
  def serializable_method_attributes
211
211
  Array(options[:methods]).inject([]) do |method_attributes, name|
212
- method_attributes << MethodAttribute.new(name.to_s, @record) if @record.respond_to?(name.to_s)
212
+ method_attributes << MethodAttribute.new(name.to_s, @record) #if @record.respond_to?(name.to_s)
213
213
  method_attributes
214
214
  end
215
215
  end
@@ -229,6 +229,7 @@ module Sequel #:nodoc:
229
229
  end
230
230
 
231
231
  def add_tag(attribute)
232
+ # p "add_tag #{attribute} attribute.name=#{attribute.name} options=#{options} options[:skip_types]=#{options[:skip_types]}"
232
233
  builder.tag!(
233
234
  reformat_name(attribute.name),
234
235
  attribute.value.to_s,
@@ -373,7 +374,7 @@ module ActiveSupport #:nodoc:
373
374
  module Array #:nodoc:
374
375
  module Conversions
375
376
  def to_fos_xml(options = {})
376
- to_xml({:skip_instruct=>true, :dasherize=>false, :only=>[]}.merge(options))
377
+ to_xml({:skip_instruct=>true, :skip_types=>true, :dasherize=>false, :only=>[]}.merge(options))
377
378
  end
378
379
  end
379
380
  end
@@ -385,7 +386,7 @@ module ActiveSupport #:nodoc:
385
386
  module Hash #:nodoc:
386
387
  module Conversions
387
388
  def to_fos_xml(options = {})
388
- to_xml({:dasherize=>false, :only=>[]}.merge(options))
389
+ to_xml({:skip_instruct=>true, :skip_types=>true, :dasherize=>false, :only=>[]}.merge(options))
389
390
  end
390
391
  end
391
392
  end
@@ -15,11 +15,11 @@ describe "Sequel::Model extentions" do
15
15
  Dude.first.fill_hash([:doo]).should == {:doo=>1}
16
16
  end
17
17
 
18
- describe "recognizes __ in method name and creates delegators only once" do
18
+ describe "method missing recognizes __ in method name and creates delegators only once" do
19
19
  it "for one level deep" do
20
20
  mock.proxy(Dude).delegate(:name, :to => :my_friend, :prefix => true, :allow_nil => true)
21
21
  Dude.first.fill_hash([:my_friend__name,:my_friend__name]).should == {:my_friend_name=>'dans buddy'}
22
- Dude.first.method(:my_friend_name).unbind
22
+ Dude.send(:remove_method, :my_friend_name)
23
23
  end
24
24
 
25
25
  it "for two levels deep" do
@@ -27,41 +27,15 @@ describe "Sequel::Model extentions" do
27
27
  mock.proxy(Horse).delegate(:my_friend, :to => :dude, :prefix => true, :allow_nil => true)
28
28
  mock.proxy(Horse).delegate(:name, :to => :dude_my_friend, :prefix => true, :allow_nil => true)
29
29
  mock.proxy(Horse).delegate(:kid_date, :to => :dude_my_friend, :prefix => true, :allow_nil => true)
30
- h = Horse.first
31
- h.fill_hash([:dude__my_friend__kid_date,:dude__my_friend__name]).should == {:dude_my_friend_name=>'dans buddy',:dude_my_friend_kid_date=>1}
32
- h.method(:dude_my_friend).unbind
33
- h.method(:dude_my_friend_name).unbind
34
- h.method(:dude_my_friend_kid_date).unbind
35
- # class Horse; remove_method :dude_my_friend; remove_method :dude_my_friend_name; remove_method :dude_my_friend_kid_date; end
30
+ Horse.first
31
+ Horse.first.fill_hash([:dude__my_friend__kid_date,:dude__my_friend__name]).should == {:dude_my_friend_name=>'dans buddy',:dude_my_friend_kid_date=>1}
32
+ Horse.send(:remove_method,:dude_my_friend)
33
+ Horse.send(:remove_method,:dude_my_friend_name)
34
+ Horse.send(:remove_method,:dude_my_friend_kid_date)
36
35
  end
37
36
  end
38
37
  end
39
38
 
40
- describe "method missing recognizes __ in method name and creates delegators only once" do
41
- it "for one level deep" do
42
- mock.proxy(Dude).delegate(:name, :to => :my_friend, :prefix => true, :allow_nil => true)
43
- Dude.first.send(:my_friend__name) == 'dans buddy'
44
- Dude.first.respond_to? :my_friend_name
45
- Dude.first.send(:my_friend__name) == 'dans buddy'
46
- # class Dude; remove_method :my_friend_name; end
47
- Dude.first.method(:my_friend_name).unbind
48
- end
49
-
50
- it "for two levels deep" do
51
- MyFriend.column_alias :kid_date, :'kid - date'
52
- mock.proxy(Horse).delegate(:my_friend, :to => :dude, :prefix => true, :allow_nil => true)
53
- mock.proxy(Horse).delegate(:name, :to => :dude_my_friend, :prefix => true, :allow_nil => true)
54
- mock.proxy(Horse).delegate(:kid_date, :to => :dude_my_friend, :prefix => true, :allow_nil => true)
55
- h = Horse.first
56
- h.send(:dude__my_friend__name).should == 'dans buddy'
57
- h.send(:dude__my_friend__kid_date).should == 1
58
- h.method(:dude_my_friend).unbind
59
- h.method(:dude_my_friend_name).unbind
60
- h.method(:dude_my_friend_kid_date).unbind
61
- # class Horse; remove_method :dude_my_friend; remove_method :dude_my_friend_name; remove_method :dude_my_friend_kid_date; end
62
- end
63
- end
64
-
65
39
  it "can update and save" do
66
40
  add_test_table_data({:date_col => 123, :time_col=>60})
67
41
  record = TestTable.first
@@ -148,7 +122,7 @@ describe "Sequel::Model extentions" do
148
122
  @record.date_col_date_view_mdy.should == "05/03/1900"
149
123
  # ruby 1.9.1 not making date as 5/3/1900, so this just makes it
150
124
  # pass .. but eventually we drop that ipc method anyway, so I dont care.
151
- @record.date_col_date_view_mdy_ipc.should =~ /[0]+5\/[0]+3\/1900/
125
+ @record.date_col_date_view_mdy_ipc.should =~ /[0]*5\/[0]*3\/1900/
152
126
  end
153
127
 
154
128
  it "shows correct time view" do
@@ -15,7 +15,7 @@ describe Sequel::Pervasive::DatabaseMethods do
15
15
  raise(Exception, 'testing do_transaction transactions')
16
16
  end
17
17
  ### end testing do_transaction
18
- rescue StandardError => e
18
+ rescue Exception => e
19
19
  ensure
20
20
  r.drop if r
21
21
  end
@@ -2,21 +2,33 @@ require File.dirname(__FILE__) + '/../../spec_helper'
2
2
  require File.dirname(__FILE__) + '/../spec_helper_tables' unless metaclass.class_variable_defined? :@@set_up_demo_tables
3
3
 
4
4
  describe "Sequel::Serializer" do
5
- describe "to_fos_json method adds options to only for" do
6
- it "single sequel model" do
7
- add_test_table_data({:id=>1,:'goofy name col' => 123})
8
- data = TestTable.first
9
- mock(data).fill_hash([])
5
+
6
+ describe "to_fos_json method" do
7
+
8
+ it "adds :only=>[] to the options hash" do
9
+ data = Trip.new
10
+ mock(data).to_json({:only=>[], :methods=>[]})
10
11
  data.to_fos_json(:methods=>[])
11
12
  end
12
13
 
13
- it "an array of sequel models" do
14
- add_test_table_data({:id=>1,:'goofy name col' => 123})
14
+ it "handles single sequel model" do
15
+ add_test_table_data({:id=>1, :'goofy name col' => 123})
15
16
  data = TestTable.first
16
- array = [data]
17
- mock(data).fill_hash([]) # expecting this method to be called on the data
18
- array.to_fos_json(:methods=>[])
17
+ data.to_fos_json(:methods=>[:'goofy name col']).should == "{\"goofy name col\":123}"
18
+ end
19
+
20
+ it "handles an array of sequel models" do
21
+ add_test_table_data({:id=>1, :'goofy name col' => 123})
22
+ array = [TestTable.first]
23
+ array.to_fos_json(:methods=>[:'goofy name col']).should==["{\"goofy name col\":123}"]
24
+ end
25
+
26
+ it "shows methods which are dynamically delegated" do
27
+ add_test_table_data({:id=>1, :'date_col' => 123})
28
+ data = TestTable.first
29
+ data.to_fos_json(:methods=>[:date_col__round]).should == "{\"date_col__round\":123}"
19
30
  end
20
31
 
21
32
  end
33
+
22
34
  end
@@ -1,6 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
2
  require File.dirname(__FILE__) + '/../spec_helper_tables' unless metaclass.class_variable_defined? :@@set_up_demo_tables
3
- #require 'active_resource'
4
3
 
5
4
  describe "Sequel::Serializer" do
6
5
 
@@ -8,14 +7,14 @@ describe "Sequel::Serializer" do
8
7
  it "single sequel model" do
9
8
  add_test_table_data({:id=>1,:'goofy name col' => 123})
10
9
  data = TestTable.first
11
- mock(data).to_xml({:dasherize=>false, :skip_instruct=>true, :only=>[]})
10
+ mock(data).to_xml({:skip_instruct=>true, :skip_types=>true, :dasherize=>false, :only=>[]})
12
11
  data.to_fos_xml
13
12
  end
14
13
 
15
14
  it "an array of sequel models" do
16
15
  add_test_table_data({:id=>1,:'goofy name col' => 123})
17
16
  data = [TestTable.first]
18
- mock(data).to_xml({:dasherize=>false, :skip_instruct=>true, :only=>[]})
17
+ mock(data).to_xml({:skip_instruct=>true, :skip_types=>true, :dasherize=>false, :only=>[]})
19
18
  data.to_fos_xml
20
19
  end
21
20
  end
@@ -32,13 +31,25 @@ describe "Sequel::Serializer" do
32
31
  } )
33
32
  end
34
33
 
34
+ it "to_xml works with references to dynamic delegated columns" do
35
+ add_test_table_data({:id=>1,:'date_col' => 123})
36
+ TestTable.column_alias :'date_col', :date_col
37
+
38
+ TestTable.first.to_fos_xml(:methods => :date_col__round).should equal_xml(
39
+ %{
40
+ <test_table>
41
+ <date_col__round>123</date_col__round>
42
+ </test_table>
43
+ } )
44
+ end
45
+
35
46
  it "to_fos_xml with many to one assoc" do
36
47
  Dude.o_to_n :horses, :class=>:Horse, :prefix => 'dude'
37
48
 
38
49
  Dude.first.to_fos_xml(:only=> :name, :include=> :horses).should equal_xml(
39
50
  %{ <dude>
40
51
  <name>dano</name>
41
- <horses type="array">
52
+ <horses>
42
53
  <horse> <name>pinto</name> </horse>
43
54
  <horse> <name>silver</name> </horse>
44
55
  </horses>
@@ -62,7 +73,7 @@ describe "Sequel::Serializer" do
62
73
  Horse.n_to_o :dude, :class=>:Dude, :prefix=>'dude'
63
74
 
64
75
  Horse.all.to_fos_xml(:only=> [:name], :include=> :dude).should equal_xml(
65
- %{ <horses type="array">
76
+ %{ <horses>
66
77
  <horse> <name>pinto</name>
67
78
  <dude> <name>dano</name> </dude>
68
79
  </horse>
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 5
9
- version: 0.4.5
8
+ - 6
9
+ version: 0.4.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Patrick Lardin, Daniel Sudol
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-25 00:00:00 -07:00
17
+ date: 2010-06-28 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -180,7 +180,6 @@ files:
180
180
  - lib/sequel/serializer/serializer.rb
181
181
  - lib/sequel/serializer/xml_serializer.rb
182
182
  - lib/sequel/sqlite_pervasive_adapter.rb
183
- - lib/serial_number.rb
184
183
  - spec/be_model_with_values_matcher.rb
185
184
  - spec/be_model_with_values_matcher_spec.rb
186
185
  - spec/hash_extentions_spec.rb
data/lib/serial_number.rb DELETED
@@ -1,14 +0,0 @@
1
- class SerialNumber
2
- attr_reader :max
3
-
4
- def initialize(max)
5
- @index= -1
6
- @max= max
7
- end
8
-
9
- def next
10
- @index = -1 if @index == max
11
- @index += 1
12
- @index
13
- end
14
- end