props-activerecord 0.1.0 → 0.2.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: 247bc4451a1641dee16bbf5a91ff53281b753d92
4
- data.tar.gz: d3264b0a4ebb670e5822ba2e7320869a31b9af74
3
+ metadata.gz: 782be55c677b11916012c04e29d873784fcf44bf
4
+ data.tar.gz: ce194b9868c4636b9b39403aa643e2c4152c21ef
5
5
  SHA512:
6
- metadata.gz: 83ca48dc53e14d46073b732a3c28d49f92648fa721ff0ec20215123885eb1e1b18033d121dc420f88d5dc8fd53771b028464226b3df76beaa0c41c11f95d838a
7
- data.tar.gz: eb51d35bb869f26148cf39287bbf3a58352234eacf9c03ac6de530cdecacd96ab3e2d72a37af76770f3d49c74642073ed3fdbf2bb7df4c7e04ffe417dc939176
6
+ metadata.gz: 0a7e720a65366b21f170c3d407e30ac45eb51ae0257d574953551630438cc6cb83db40eaa8dae928d091553023a9b3efc277f0cd1b98e69e7025e46ff975780e
7
+ data.tar.gz: afec4135f52f46c8fdd8974e046197d5c9c226b8cb7c78c2c43eb4634a78e3f2b0a363eda8109eabd2e6991dc32eb08425defa8a0ce52e187ca5ff58faa3bcba
@@ -1,8 +1,10 @@
1
- HISTORY.md
2
- Manifest.txt
3
- README.md
4
- Rakefile
5
- lib/props/activerecord.rb
6
- lib/props/activerecord/models.rb
7
- lib/props/activerecord/schema.rb
8
- lib/props/activerecord/version.rb
1
+ HISTORY.md
2
+ Manifest.txt
3
+ README.md
4
+ Rakefile
5
+ lib/props/activerecord.rb
6
+ lib/props/activerecord/models.rb
7
+ lib/props/activerecord/schema.rb
8
+ lib/props/activerecord/version.rb
9
+ test/helper.rb
10
+ test/test_models.rb
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
- # `props-activerecord` - Manage Setting Hierachies Addon for Database Support (ConfDb, Props Model, etc.)
1
+ # props-activerecord
2
2
 
3
- * home :: [github.com/rubylibs/props-activerecord](https://github.com/rubylibs/props-activerecord)
4
- * bugs :: [github.com/rubylibs/props-activerecord/issues](https://github.com/rubylibs/props-activerecord/issues)
3
+ Manage Setting Hierachies Addon for Database Support (ConfDb, Props Model, etc.)
4
+
5
+ * home :: [github.com/rubylibs/props](https://github.com/rubylibs/props)
6
+ * bugs :: [github.com/rubylibs/props/issues](https://github.com/rubylibs/props/issues)
5
7
  * gem :: [rubygems.org/gems/props-activerecord](https://rubygems.org/gems/props-activerecord)
6
8
  * rdoc :: [rubydoc.info/gems/props-activerecord](http://rubydoc.info/gems/props-activerecord)
7
9
 
@@ -12,7 +14,7 @@
12
14
 
13
15
  Example:
14
16
 
15
- ~~~
17
+ ```
16
18
  require 'props/activerecord' # include database support
17
19
 
18
20
  ConfDb.create # build schema / tables (props)
@@ -23,17 +25,17 @@ puts "Props:"
23
25
  Prop.order( 'created_at asc' ).all.each do |prop|
24
26
  puts " #{prop.key} / #{prop.value} | #{prop.created_at}"
25
27
  end
26
- ~~~
28
+ ```
27
29
 
28
30
  More examples:
29
31
 
30
- ~~~
32
+ ```
31
33
  ConfDb.tables # dump stats to console
32
34
  ConfDb.delete! # delete all records
33
- ~~~
35
+ ```
34
36
 
35
37
 
36
38
  ## License
37
39
 
38
- The `props-utils` scripts are dedicated to the public domain.
40
+ The `props-activerecord` scripts are dedicated to the public domain.
39
41
  Use it as you please with no restrictions whatsoever.
data/Rakefile CHANGED
@@ -8,10 +8,10 @@ Hoe.spec 'props-activerecord' do
8
8
  self.summary = 'props-activerecord - Manage Setting Hierachies Addon for Database Support (ConfDb, Props Model, etc.)'
9
9
  self.description = summary
10
10
 
11
- self.urls = ['https://github.com/rubylibs/props-activerecord']
11
+ self.urls = ['https://github.com/rubylibs/props']
12
12
 
13
13
  self.author = 'Gerald Bauer'
14
- self.email = 'webslideshow@googlegroups.com'
14
+ self.email = 'ruby-talk@ruby-lang.org'
15
15
 
16
16
  # switch extension to .markdown for gihub formatting
17
17
  self.readme_file = 'README.md'
@@ -20,12 +20,12 @@ Hoe.spec 'props-activerecord' do
20
20
  self.licenses = ['Public Domain']
21
21
 
22
22
  self.extra_deps = [
23
- ['props', '>=1.1.2'],
24
- ['activerecord'], # NB: will include activesupport,etc.
25
- ]
23
+ ['props', '>=1.2.0'],
24
+ ['activerecord'], # Note: will include activesupport, etc.
25
+ ]
26
26
 
27
27
  self.spec_extras = {
28
- required_ruby_version: '>= 1.9.2'
28
+ required_ruby_version: '>= 2.3'
29
29
  }
30
30
 
31
31
  end
@@ -4,7 +4,6 @@
4
4
  ## note: assumes props alreay required
5
5
  ## this is an addon/plugin/extension for the props gems (that is, will NOT work stand-alone)
6
6
 
7
-
8
7
  # rubygems / 3rd party libs
9
8
  require 'active_record' ## todo: add sqlite3? etc.
10
9
 
@@ -41,4 +40,3 @@ end # module ConfDb
41
40
 
42
41
 
43
42
  puts ConfDb.banner if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG) # say hello
44
-
@@ -2,22 +2,23 @@
2
2
 
3
3
  module ConfDb
4
4
 
5
- class CreateDb < ActiveRecord::Migration
5
+ class CreateDb
6
6
 
7
7
  def up
8
+ ActiveRecord::Schema.define do
8
9
 
9
10
  create_table :props do |t|
10
11
  t.string :key, null: false
11
12
  t.string :value, null: false
12
- t.string :kind # e.g. version|user|sys(tem)|db etc. # note: can NOT use type - already used by ActiveRecord
13
+
14
+ # note: do NOT/can NOT use type - already used by ActiveRecord (for single-table-inheritance/STI)
15
+ t.string :kind # e.g. version|user|sys(tem)|db etc.
16
+
13
17
  t.timestamps
14
18
  end
15
19
 
16
- end
17
-
18
- def down
19
- raise ActiveRecord::IrreversibleMigration
20
- end
20
+ end # Schema.define
21
+ end # method up
21
22
 
22
23
  end # class CreateDb
23
24
 
@@ -3,7 +3,7 @@
3
3
  module ConfDb
4
4
 
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
- MINOR = 1
6
+ MINOR = 2
7
7
  PATCH = 0
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
@@ -18,7 +18,6 @@ module ConfDb
18
18
 
19
19
  def self.root
20
20
  "#{File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )}"
21
- end
21
+ end
22
22
 
23
23
  end # module ConfDb
24
-
@@ -0,0 +1,40 @@
1
+
2
+ ## $:.unshift(File.dirname(__FILE__))
3
+
4
+ ## minitest setup
5
+
6
+ require 'minitest/autorun'
7
+
8
+
9
+ # our own code
10
+ require 'props'
11
+ require 'props/activerecord' # Note: explict require required for ConfDb (not automatic)
12
+
13
+
14
+ Prop = ConfDb::Model::Prop
15
+
16
+
17
+
18
+ def setup_in_memory_db
19
+ # Database Setup & Config
20
+
21
+ db_config = {
22
+ adapter: 'sqlite3',
23
+ database: ':memory:'
24
+ }
25
+
26
+ pp db_config
27
+
28
+ ActiveRecord::Base.logger = Logger.new( STDOUT )
29
+ ## ActiveRecord::Base.colorize_logging = false - no longer exists - check new api/config setting?
30
+
31
+ ## NB: every connect will create a new empty in memory db
32
+ ActiveRecord::Base.establish_connection( db_config )
33
+
34
+
35
+ ## build schema
36
+ ConfDb.create
37
+ end
38
+
39
+
40
+ setup_in_memory_db()
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ class TestModels < MiniTest::Test
6
+
7
+ def setup
8
+ ConfDb.delete!
9
+ end
10
+
11
+ def test_count
12
+ assert_equal 0, Prop.count
13
+ end
14
+
15
+
16
+ def test_create
17
+ prop = Prop.create!( key: 'key', value: 'value' )
18
+
19
+ assert_equal 1, Prop.count
20
+ end
21
+
22
+ end # class TestModels
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: props-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.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-12-03 00:00:00.000000000 Z
11
+ date: 2017-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: props
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.2
19
+ version: 1.2.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
- version: 1.1.2
26
+ version: 1.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,17 +58,17 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.13'
61
+ version: '3.16'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.13'
68
+ version: '3.16'
69
69
  description: props-activerecord - Manage Setting Hierachies Addon for Database Support
70
70
  (ConfDb, Props Model, etc.)
71
- email: webslideshow@googlegroups.com
71
+ email: ruby-talk@ruby-lang.org
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files:
@@ -84,7 +84,9 @@ files:
84
84
  - lib/props/activerecord/models.rb
85
85
  - lib/props/activerecord/schema.rb
86
86
  - lib/props/activerecord/version.rb
87
- homepage: https://github.com/rubylibs/props-activerecord
87
+ - test/helper.rb
88
+ - test/test_models.rb
89
+ homepage: https://github.com/rubylibs/props
88
90
  licenses:
89
91
  - Public Domain
90
92
  metadata: {}
@@ -98,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
100
  requirements:
99
101
  - - ">="
100
102
  - !ruby/object:Gem::Version
101
- version: 1.9.2
103
+ version: '2.3'
102
104
  required_rubygems_version: !ruby/object:Gem::Requirement
103
105
  requirements:
104
106
  - - ">="
@@ -106,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
108
  version: '0'
107
109
  requirements: []
108
110
  rubyforge_project:
109
- rubygems_version: 2.4.2
111
+ rubygems_version: 2.5.2
110
112
  signing_key:
111
113
  specification_version: 4
112
114
  summary: props-activerecord - Manage Setting Hierachies Addon for Database Support