activerecord-utils 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eecd95d124a2fccb441fb7dfeafc2d5dc87c3679
4
- data.tar.gz: ce9c1533eb2bd30b81bc0ba41b31fb4223c15bb3
3
+ metadata.gz: a972ada88d58d419b8cbe37ffd2a8f759ed71317
4
+ data.tar.gz: 35bbf160a49f76616d701fb52d6aebff58ee4698
5
5
  SHA512:
6
- metadata.gz: b3f887f9f2709b50bafe9b8ed500be5fece830ad71355f4c7e7d9baacaa41d1d10d42aca019b2be98f00b26445fb50f74d031ebc336928e561f57fa630cd9ec7
7
- data.tar.gz: f036fddcc6990e7932b15d9ccbb29168214d58a12b6b5080e0e908cb084ca6d46f395fcd2f8b9f2d6f95f9f968108c7438ae9c025c2170149961955a92fa17b8
6
+ metadata.gz: 85725b37c1121e4c61eb56e9f917408526ce676f19ec3742894bbfa1a89bef5f35fb1e6fda6e101ca77b33559e56d489c88312350e9df36a24828d5e4baef6c9
7
+ data.tar.gz: b161fed850886f04ae9056cdf28253cf831a1390237c1594c7b7b62ec60527ceeef5c3aebb673aaa30e133ccfe3242576d18404cd614cb1779038e18440ff457
data/History.md CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  ### 0.1.0 / 2013-11-22
2
3
 
3
4
  * Everything is new. First release.
data/Manifest.txt CHANGED
@@ -10,3 +10,4 @@ lib/activerecord/utils/version.rb
10
10
  test/helper.rb
11
11
  test/test_finders.rb
12
12
  test/test_random.rb
13
+ test/test_readers.rb
@@ -60,6 +60,7 @@ class Base
60
60
  ### todo: use a different name e.g.:
61
61
  ## read_attribute_cascade ?? - does anything like this exists already?
62
62
  ## why? why not?
63
+ value = nil
63
64
  keys.each do |key|
64
65
  value = read_attribute( key )
65
66
  break unless value.nil? # if value.nil? == false
@@ -2,7 +2,7 @@
2
2
  module ActiveRecord
3
3
 
4
4
  module Utils
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
 
8
8
  end # module ActiveRecord
data/test/helper.rb CHANGED
@@ -3,11 +3,8 @@
3
3
 
4
4
  ## minitest setup
5
5
 
6
- # require 'minitest/unit'
7
6
  require 'minitest/autorun'
8
7
 
9
- # include MiniTest::Unit # lets us use TestCase instead of MiniTest::Unit::TestCase
10
-
11
8
 
12
9
  # ruby stdlibs
13
10
 
@@ -21,7 +18,7 @@ require 'logger'
21
18
  require 'active_record'
22
19
 
23
20
  require 'logutils'
24
- require 'logutils/db' # NB: explict require required for LogDb (not automatic)
21
+ require 'logutils/activerecord'
25
22
 
26
23
 
27
24
  # our own code
@@ -35,6 +32,27 @@ class Beer < ActiveRecord::Base
35
32
  alias_attr_writer :abvwrite, :abv
36
33
  end
37
34
 
35
+ class Feed < ActiveRecord::Base
36
+ attr_reader_w_fallbacks :published, :touched
37
+ end
38
+
39
+
40
+ class CreateFeedDb
41
+ def up
42
+ ActiveRecord::Schema.define do
43
+
44
+ create_table :feeds do |t|
45
+ t.string :key, null: false
46
+ t.string :title, null: false
47
+
48
+ t.datetime :publised
49
+ t.datetime :touched
50
+
51
+ t.timestamps
52
+ end
53
+ end # Schema.define
54
+ end # method up
55
+ end
38
56
 
39
57
 
40
58
  class CreateBeerDb
@@ -57,7 +75,7 @@ class CreateBeerDb
57
75
  end # Schema.define
58
76
  end # method up
59
77
 
60
- end # class CreateMovieDb
78
+ end # class CreateBeerDb
61
79
 
62
80
 
63
81
 
@@ -81,9 +99,15 @@ def setup_in_memory_db
81
99
  ## build schema
82
100
  LogDb.create
83
101
  CreateBeerDb.new.up
84
-
102
+
85
103
  Beer.create!( key: 'ottakringerhelles', name: 'Ottakringer Helles' )
86
104
  Beer.create!( key: 'ottakringerzwicklrot', name: 'Ottakringer Zwickl Rot' )
105
+
106
+
107
+ CreateFeedDb.new.up
108
+
109
+ Feed.create!( key: 'viennarb', title: 'vienna.rb Blog' )
110
+ Feed.create!( key: 'rubyonrails', title: 'Ruby on Rails Blog' )
87
111
  end
88
112
 
89
113
 
data/test/test_finders.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'helper'
4
4
 
5
- class TestFinders < MiniTest::Unit::TestCase
5
+ class TestFinders < MiniTest::Test
6
6
 
7
7
 
8
8
  def test_find_by
data/test/test_random.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'helper'
4
4
 
5
- class TestRandom < MiniTest::Unit::TestCase
5
+ class TestRandom < MiniTest::Test
6
6
 
7
7
  def test_rnd
8
8
  b = Beer.rnd
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ class TestReaders < MiniTest::Test
6
+
7
+ def test_fallbacks
8
+
9
+ f = Feed.find_by_key!( 'viennarb' )
10
+ assert_equal nil, f.published
11
+ assert_equal nil, f.read_attribute_w_fallbacks( :published, :touched )
12
+
13
+ f = Feed.find_by_key!( 'rubyonrails' )
14
+ assert_equal nil, f.published
15
+ assert_equal nil, f.read_attribute_w_fallbacks( :published, :touched )
16
+
17
+ end
18
+
19
+ end # class TestRandom
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-15 00:00:00.000000000 Z
11
+ date: 2014-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logutils
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '4.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hoe
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.10'
47
+ version: '3.13'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.10'
54
+ version: '3.13'
55
55
  description: activerecord-utils - utilities (e.g. random, alias_attr, etc.) for activerecord
56
56
  email: webslideshow@googlegroups.com
57
57
  executables: []
@@ -61,6 +61,7 @@ extra_rdoc_files:
61
61
  - Manifest.txt
62
62
  - README.md
63
63
  files:
64
+ - ".gemtest"
64
65
  - History.md
65
66
  - Manifest.txt
66
67
  - README.md
@@ -73,33 +74,34 @@ files:
73
74
  - test/helper.rb
74
75
  - test/test_finders.rb
75
76
  - test/test_random.rb
76
- - .gemtest
77
+ - test/test_readers.rb
77
78
  homepage: https://github.com/rubylibs/activerecord-utils
78
79
  licenses:
79
80
  - Public Domain
80
81
  metadata: {}
81
82
  post_install_message:
82
83
  rdoc_options:
83
- - --main
84
+ - "--main"
84
85
  - README.md
85
86
  require_paths:
86
87
  - lib
87
88
  required_ruby_version: !ruby/object:Gem::Requirement
88
89
  requirements:
89
- - - ! '>='
90
+ - - ">="
90
91
  - !ruby/object:Gem::Version
91
92
  version: 1.9.2
92
93
  required_rubygems_version: !ruby/object:Gem::Requirement
93
94
  requirements:
94
- - - ! '>='
95
+ - - ">="
95
96
  - !ruby/object:Gem::Version
96
97
  version: '0'
97
98
  requirements: []
98
99
  rubyforge_project:
99
- rubygems_version: 2.1.10
100
+ rubygems_version: 2.4.2
100
101
  signing_key:
101
102
  specification_version: 4
102
103
  summary: activerecord-utils - utilities (e.g. random, alias_attr, etc.) for activerecord
103
104
  test_files:
105
+ - test/test_readers.rb
104
106
  - test/test_finders.rb
105
107
  - test/test_random.rb