swift 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
data/ext/attribute.cc CHANGED
@@ -5,7 +5,7 @@ ID fcall;
5
5
  VALUE attribute_default(VALUE self) {
6
6
  VALUE value = rb_iv_get(self, "@default");
7
7
 
8
- if (NIL_P(value) || rb_special_const_p(value))
8
+ if (NIL_P(value) || rb_obj_is_kind_of(value, rb_cNumeric) || rb_special_const_p(value))
9
9
  return value;
10
10
  else if (rb_respond_to(value, fcall))
11
11
  return rb_funcall(value, fcall, 0);
data/ext/query.cc CHANGED
@@ -1,7 +1,7 @@
1
1
  #include "query.h"
2
2
 
3
3
  ID fstrftime, fto_s, fusec;
4
- VALUE dtformat, tzformat;
4
+ VALUE dtformat, tzformat, utf8;
5
5
 
6
6
  VALUE query_execute(Query *query) {
7
7
  try {
@@ -61,7 +61,7 @@ void query_bind_values(Query *query, VALUE bind_values, std::string driver) {
61
61
  else {
62
62
  bind_value = TO_S(bind_value);
63
63
  if (strcmp(rb_enc_get(bind_value)->name, "UTF-8") != 0)
64
- bind_value = rb_str_encode(bind_value, rb_str_new2("UTF-8"), 0, Qnil);
64
+ bind_value = rb_str_encode(bind_value, utf8, 0, Qnil);
65
65
  query->bind.push_back(dbi::PARAM((unsigned char*)RSTRING_PTR(bind_value), RSTRING_LEN(bind_value)));
66
66
  }
67
67
  }
@@ -73,4 +73,9 @@ void init_swift_query() {
73
73
  fusec = rb_intern("usec");
74
74
  dtformat = rb_str_new2("%F %T.");
75
75
  tzformat = rb_str_new2("%z");
76
+ utf8 = rb_str_new2("UTF-8");
77
+
78
+ rb_global_variable(&utf8);
79
+ rb_global_variable(&tzformat);
80
+ rb_global_variable(&dtformat);
76
81
  }
data/swift.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{swift}
8
- s.version = "0.7.0"
8
+ s.version = "0.7.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Shane Hanna", "Bharanee 'Barney' Rathna"]
12
- s.date = %q{2010-09-20}
12
+ s.date = %q{2010-09-24}
13
13
  s.description = %q{A rational rudimentary database abstraction.}
14
14
  s.email = ["shane.hanna@gmail.com", "deepfryed@gmail.com"]
15
15
  s.extensions = ["ext/extconf.rb"]
data/test/test_adapter.rb CHANGED
@@ -115,6 +115,11 @@ describe 'Adapter' do
115
115
  data = "Sally Arthurton\tsally@local\nJonas Arthurton\tjonas@local\n"
116
116
  assert_equal 2, @db.write('users', %w{name email}, data)
117
117
  end
118
+
119
+ it 'writes with no columns specified' do
120
+ data = "1\tSally Arthurton\tsally@local\t2010-01-01 00:00:00\n"
121
+ assert_equal 1, @db.write('users', [], data)
122
+ end
118
123
  end
119
124
  end
120
125
  end
data/test/test_scheme.rb CHANGED
@@ -7,6 +7,7 @@ describe 'scheme' do
7
7
  attribute :id, Swift::Type::Integer, serial: true, key: true
8
8
  attribute :name, Swift::Type::String, default: "dave"
9
9
  attribute :age, Swift::Type::Integer, default: 18
10
+ attribute :height, Swift::Type::Float, default: 172.25
10
11
  attribute :email, Swift::Type::String
11
12
  attribute :verified, Swift::Type::Boolean, default: false
12
13
  attribute :created_at, Swift::Type::Time, default: proc { Time.now }
@@ -15,37 +16,38 @@ describe 'scheme' do
15
16
 
16
17
  describe 'attributes' do
17
18
  it 'defines attributes' do
18
- instance = @user.new
19
+ user = @user.new
19
20
  %w(id name age email created_at).each do |m|
20
- assert instance.respond_to?(m), "responds to m"
21
- assert instance.respond_to?("#{m}="), "responds to m="
21
+ assert user.respond_to?(m), "responds to m"
22
+ assert user.respond_to?("#{m}="), "responds to m="
22
23
  end
23
24
  end
24
25
  end
25
26
 
26
27
  describe 'instantiation' do
27
28
  it 'returns a new instance with defaults' do
28
- instance = @user.new
29
- assert_kind_of @user, instance
30
- assert_kind_of Time, instance.created_at
29
+ user = @user.new
30
+ assert_kind_of @user, user
31
+ assert_kind_of Time, user.created_at
31
32
 
32
- assert_equal nil, instance.id
33
- assert_equal 'dave', instance.name
34
- assert_equal 18, instance.age
35
- assert_equal nil, instance.email
36
- assert_equal false, instance.verified
33
+ assert_equal nil, user.id
34
+ assert_equal 'dave', user.name
35
+ assert_equal 18, user.age
36
+ assert_equal 172.25, user.height
37
+ assert_equal nil, user.email
38
+ assert_equal false, user.verified
37
39
  end
38
40
 
39
- it 'returns a new instance' do
40
- instance = @user.new name: 'cary', age: 22, email: 'cary@local'
41
+ it 'returns a new user' do
42
+ user = @user.new name: 'cary', age: 22, email: 'cary@local'
41
43
 
42
- assert_kind_of @user, instance
43
- assert_kind_of Time, instance.created_at
44
+ assert_kind_of @user, user
45
+ assert_kind_of Time, user.created_at
44
46
 
45
- assert_equal nil, instance.id
46
- assert_equal 'cary', instance.name
47
- assert_equal 22, instance.age
48
- assert_equal 'cary@local', instance.email
47
+ assert_equal nil, user.id
48
+ assert_equal 'cary', user.name
49
+ assert_equal 22, user.age
50
+ assert_equal 'cary@local', user.email
49
51
  end
50
52
  end
51
53
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 0
9
- version: 0.7.0
8
+ - 1
9
+ version: 0.7.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Shane Hanna
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-20 00:00:00 +10:00
18
+ date: 2010-09-24 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency