minimodel 2.0.0 → 2.0.1

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
- SHA1:
3
- metadata.gz: ead30d3e5905fd4a9cefbcc8acefafea60f88ac3
4
- data.tar.gz: a91bd67fc303c5fa57b4f43865a5fd788bd5bcf8
2
+ SHA256:
3
+ metadata.gz: e3103b9d7124f91936f1ad70da337f999f230a4463a6a7933f7566d5997837ad
4
+ data.tar.gz: d4f57fd1224b32b6ab488b8365457cef1263e119252f38287eb02760c194ba28
5
5
  SHA512:
6
- metadata.gz: 0cf78af9171a8a066e3e1fe244b306c9dfb33803a34b5efff3076a8f87d5441b6166141ac621a9ca623320c43d6675d71ffb270c9d991f642b64da68d3516c9b
7
- data.tar.gz: 57328487523f9ab365bc11ce754e6066d8508ac64c18621573f7dc381aab4e317f9258d18da40167e82a8ff71d4f3ddfba2ef0d99a790e9d2ff241f704bc6a63
6
+ metadata.gz: 13d65ca6e41549bb006fd737b3592c0095f03fbea9badf9f2512611cdaf3860e06579e77d51107da7adc71506ddd81fbbe95ff1e892749ba98f50b3ebad1494d
7
+ data.tar.gz: ef6cbce222f3fa1ebf1e9088e32a824a92ab4250cf6e73bacd880a56910d6d43706f94cb1b99899eac58e507527c1f098bf3ef450de18acd5962a31e14641bf9
@@ -0,0 +1,33 @@
1
+ # 2.0.1
2
+
3
+ * Added CHANGES.md to gem files
4
+
5
+ * Added metadata to gemspec
6
+
7
+ # 2.0.0
8
+
9
+ * Added MiniModel.options method for use with options_for_select
10
+
11
+ * Dropped Ruby 1.8.7 compatibility
12
+
13
+ # 1.0.0
14
+
15
+ * Ruby 1.8.7 compatibility
16
+
17
+ # 0.4.0
18
+
19
+ * Added MiniModel.keys method
20
+
21
+ # 0.3.0
22
+
23
+ * Changed MiniModel.find method to raise exception for non-existent keys
24
+
25
+ # 0.2.0
26
+
27
+ * Added MiniModel#to_json method
28
+
29
+ * Added MiniModel#read_attribute method
30
+
31
+ # 0.1.0
32
+
33
+ * First version!
@@ -1,9 +1,4 @@
1
- Copyright (c) TIMCRAFT <http://timcraft.com>
1
+ Copyright (c) 2011-2020 TIMCRAFT
2
2
 
3
3
  This is an Open Source project licensed under the terms of the LGPLv3 license.
4
4
  Please see <http://www.gnu.org/licenses/lgpl-3.0.html> for license text.
5
-
6
- This code is distributed in the hope that it will be useful,
7
- but WITHOUT ANY WARRANTY; without even the implied warranty of
8
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
- GNU Lesser General Public License for more details.
@@ -1,19 +1,20 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'minimodel'
3
- s.version = '2.0.0'
3
+ s.version = '2.0.1'
4
4
  s.license = 'LGPL-3.0'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ['Tim Craft']
7
7
  s.email = ['mail@timcraft.com']
8
- s.homepage = 'http://github.com/timcraft/minimodel'
8
+ s.homepage = 'https://github.com/timcraft/minimodel'
9
9
  s.description = 'A little Ruby library for defining little models'
10
10
  s.summary = 'See description'
11
- s.files = Dir.glob('{lib,spec}/**/*') + %w(LICENSE.txt README.md Rakefile minimodel.gemspec)
11
+ s.files = Dir.glob('lib/**/*.rb') + %w[CHANGES.md LICENSE.txt README.md minimodel.gemspec]
12
12
  s.required_ruby_version = '>= 1.9.3'
13
- s.add_development_dependency('rake', '~> 10')
14
- s.add_development_dependency('activerecord', '~> 5')
15
- s.add_development_dependency('sqlite3', '~> 1.3')
16
- s.add_development_dependency('minitest', '~> 5')
17
- s.add_development_dependency('json', '~> 2')
18
13
  s.require_path = 'lib'
14
+ s.metadata = {
15
+ 'homepage' => 'https://github.com/timcraft/minimodel',
16
+ 'source_code_uri' => 'https://github.com/timcraft/minimodel',
17
+ 'bug_tracker_uri' => 'https://github.com/timcraft/minimodel/issues',
18
+ 'changelog_uri' => 'https://github.com/timcraft/minimodel/blob/main/CHANGES.md'
19
+ }
19
20
  end
metadata CHANGED
@@ -1,85 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Craft
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-09 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '10'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '10'
27
- - !ruby/object:Gem::Dependency
28
- name: activerecord
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '5'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '5'
41
- - !ruby/object:Gem::Dependency
42
- name: sqlite3
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.3'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.3'
55
- - !ruby/object:Gem::Dependency
56
- name: minitest
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '5'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '5'
69
- - !ruby/object:Gem::Dependency
70
- name: json
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '2'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '2'
11
+ date: 2020-11-03 00:00:00.000000000 Z
12
+ dependencies: []
83
13
  description: A little Ruby library for defining little models
84
14
  email:
85
15
  - mail@timcraft.com
@@ -87,21 +17,21 @@ executables: []
87
17
  extensions: []
88
18
  extra_rdoc_files: []
89
19
  files:
20
+ - CHANGES.md
90
21
  - LICENSE.txt
91
22
  - README.md
92
- - Rakefile
93
23
  - lib/minimodel.rb
94
24
  - lib/minimodel/associations.rb
95
25
  - minimodel.gemspec
96
- - spec/colour_spec.rb
97
- - spec/currency_data.yml
98
- - spec/currency_spec.rb
99
- - spec/dutch_education_spec.rb
100
- homepage: http://github.com/timcraft/minimodel
26
+ homepage: https://github.com/timcraft/minimodel
101
27
  licenses:
102
28
  - LGPL-3.0
103
- metadata: {}
104
- post_install_message:
29
+ metadata:
30
+ homepage: https://github.com/timcraft/minimodel
31
+ source_code_uri: https://github.com/timcraft/minimodel
32
+ bug_tracker_uri: https://github.com/timcraft/minimodel/issues
33
+ changelog_uri: https://github.com/timcraft/minimodel/blob/main/CHANGES.md
34
+ post_install_message:
105
35
  rdoc_options: []
106
36
  require_paths:
107
37
  - lib
@@ -116,9 +46,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
46
  - !ruby/object:Gem::Version
117
47
  version: '0'
118
48
  requirements: []
119
- rubyforge_project:
120
- rubygems_version: 2.6.11
121
- signing_key:
49
+ rubygems_version: 3.1.4
50
+ signing_key:
122
51
  specification_version: 4
123
52
  summary: See description
124
53
  test_files: []
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- require 'rake/testtask'
2
-
3
- task :default => :spec
4
-
5
- Rake::TestTask.new(:spec) do |t|
6
- t.test_files = FileList['spec/*_spec.rb']
7
- t.warning = true
8
- end
@@ -1,16 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'minimodel'
3
-
4
- class Colour < MiniModel
5
- indexed_by :id, auto_increment: true
6
-
7
- insert name: 'Blue', hexdigits: '0000FF'
8
- insert name: 'Red', hexdigits: 'FF0000'
9
- insert name: 'Green', hexdigits: '00FF00'
10
- end
11
-
12
- describe 'Colour' do
13
- it 'assigns auto incrementing id values' do
14
- Colour.all.map(&:id).sort.must_equal([1, 2, 3])
15
- end
16
- end
@@ -1,8 +0,0 @@
1
- EUR:
2
- name: Euro
3
-
4
- GBP:
5
- name: Pound sterling
6
-
7
- USD:
8
- name: United States dollar
@@ -1,126 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'minimodel'
3
- require 'json'
4
-
5
- class Currency < MiniModel
6
- indexed_by :code
7
-
8
- load_from 'spec/currency_data.yml'
9
-
10
- insert code: 'INR', name: 'Indian rupee'
11
- insert code: 'JPY', name: 'Japanese yen'
12
- end
13
-
14
- describe 'A currency object' do
15
- before do
16
- @euro = Currency.new(code: 'EUR', name: 'Euro')
17
- end
18
-
19
- it 'responds to code and name methods' do
20
- @euro.respond_to?(:code).must_equal(true)
21
- @euro.respond_to?(:name).must_equal(true)
22
- end
23
-
24
- it 'provides attribute reader methods' do
25
- @euro.code.must_equal('EUR')
26
- @euro.name.must_equal('Euro')
27
- end
28
-
29
- describe 'eql query method' do
30
- it 'returns true when passed a currency object with the same attributes' do
31
- @euro.eql?(@euro).must_equal(true)
32
- @euro.eql?(Currency.new(code: 'EUR', name: 'Euro')).must_equal(true)
33
- end
34
-
35
- it 'returns false when given a currency object with a different code' do
36
- @euro.eql?(Currency.new(code: 'GBP', name: 'Pound sterling')).must_equal(false)
37
- end
38
- end
39
-
40
- describe 'to_hash method' do
41
- it 'returns a hash containing the object attributes' do
42
- @euro.to_hash.must_equal({code: 'EUR', name: 'Euro'})
43
- end
44
- end
45
-
46
- describe 'to_json method' do
47
- it 'returns a string containing the object attributes encoded as json' do
48
- output = @euro.to_json
49
- output.must_match(/\{.+?\}/)
50
- output.must_match(/"code":"EUR"/)
51
- output.must_match(/"name":"Euro"/)
52
- end
53
- end
54
-
55
- describe 'read_attribute method' do
56
- it 'returns the value corresponding to the given attribute name' do
57
- @euro.read_attribute(:code).must_equal('EUR')
58
- @euro.read_attribute(:name).must_equal('Euro')
59
- end
60
- end
61
- end
62
-
63
- describe 'Currency' do
64
- describe 'all class method' do
65
- it 'returns an array containing currency objects' do
66
- Currency.all.must_be_kind_of(Array)
67
- Currency.all.each { |object| object.must_be_kind_of(Currency) }
68
- end
69
- end
70
-
71
- describe 'keys class method' do
72
- it 'returns an array containing all the primary keys' do
73
- Currency.keys.must_equal(%w(EUR GBP USD INR JPY))
74
- end
75
- end
76
-
77
- describe 'options class method' do
78
- it 'returns a hash mapping the given text attribute to primary keys' do
79
- options = {
80
- 'Euro' => 'EUR',
81
- 'Pound sterling' => 'GBP',
82
- 'United States dollar' => 'USD',
83
- 'Indian rupee' => 'INR',
84
- 'Japanese yen' => 'JPY'
85
- }
86
-
87
- Currency.options(:name).must_equal(options)
88
- end
89
- end
90
-
91
- describe 'primary_key class method' do
92
- it 'returns the name of the primary key attribute' do
93
- Currency.primary_key.must_equal(:code)
94
- end
95
- end
96
-
97
- describe 'count class method' do
98
- it 'returns the total number of currencies' do
99
- Currency.count.must_equal(5)
100
- end
101
- end
102
-
103
- describe 'find class method' do
104
- it 'returns the correct currency object' do
105
- currency = Currency.find('EUR')
106
-
107
- currency.must_be_kind_of(Currency)
108
- currency.code.must_equal('EUR')
109
- currency.name.must_equal('Euro')
110
- end
111
-
112
- it 'raises an error if the currency cannot be found' do
113
- proc { Currency.find('FOO') }.must_raise(KeyError) # 1.9
114
- end
115
-
116
- it 'yields if the currency cannot be found and the caller supplies a block' do
117
- Currency.find('FOO') { nil }.must_be_nil
118
- end
119
- end
120
-
121
- describe 'insert class method' do
122
- it 'raises an error when passed a key that already exists' do
123
- proc { Currency.insert(code: 'EUR', name: 'Euro') }.must_raise(MiniModel::DuplicateKeyError)
124
- end
125
- end
126
- end
@@ -1,111 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'minimodel'
3
- require 'minimodel/associations'
4
- require 'active_record'
5
-
6
- ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
7
-
8
- ActiveRecord::Schema.define(version: 1) do
9
- create_table :courses, force: true do |t|
10
- t.string :name, index: true
11
- t.string :level_name, index: true
12
- end
13
- end
14
-
15
- class Level < MiniModel
16
- indexed_by :name
17
-
18
- has_many :courses
19
- has_many :profiles
20
-
21
- insert name: 'VMBO-T'
22
- insert name: 'HAVO'
23
- insert name: 'VWO'
24
- end
25
-
26
- class Profile < MiniModel
27
- indexed_by :id, auto_increment: true
28
-
29
- belongs_to :level
30
-
31
- insert level_name: 'VMBO-T', name: 'Techniek'
32
- insert level_name: 'VMBO-T', name: 'Zorg en Welzijn'
33
- insert level_name: 'VMBO-T', name: 'Economie'
34
- insert level_name: 'VMBO-T', name: 'Landbouw'
35
-
36
- insert level_name: 'HAVO', name: 'Economie en Maatschappij'
37
- insert level_name: 'HAVO', name: 'Cultuur en Maatschappij'
38
- insert level_name: 'HAVO', name: 'Natuur en Gezondheid'
39
- insert level_name: 'HAVO', name: 'Natuur en Techniek'
40
-
41
- insert level_name: 'VWO', name: 'Economie en Maatschappij'
42
- insert level_name: 'VWO', name: 'Cultuur en Maatschappij'
43
- insert level_name: 'VWO', name: 'Natuur en Gezondheid'
44
- insert level_name: 'VWO', name: 'Natuur en Techniek'
45
- end
46
-
47
- class Course < ActiveRecord::Base
48
- def level
49
- @level ||= Level.find(level_name)
50
- end
51
- end
52
-
53
- Level.all.each do |level|
54
- for course_name in %w( Nederlands Engels Duits )
55
- Course.create!(level_name: level.name, name: "#{level.name}/#{course_name}")
56
- end
57
- end
58
-
59
- describe 'A level object' do
60
- before do
61
- @level = Level.find('VMBO-T')
62
-
63
- @profile_names = ['Economie', 'Landbouw', 'Techniek', 'Zorg en Welzijn']
64
-
65
- @course_names = %w( VMBO-T/Duits VMBO-T/Engels VMBO-T/Nederlands )
66
- end
67
-
68
- describe 'profiles method' do
69
- it 'returns an enumerable object with the correct size' do
70
- profiles = @level.profiles
71
- profiles.must_respond_to(:each)
72
- profiles.class.ancestors.must_include(Enumerable)
73
- profiles.size.must_equal(4)
74
- end
75
- end
76
-
77
- describe 'courses method' do
78
- it 'returns an enumerable object with the correct size' do
79
- courses = @level.courses
80
- courses.must_respond_to(:each)
81
- courses.class.ancestors.must_include(Enumerable)
82
- courses.size.must_equal(3)
83
- end
84
- end
85
- end
86
-
87
- describe 'A profile object' do
88
- before do
89
- @profile = Profile.find(8)
90
- end
91
-
92
- describe 'level method' do
93
- it 'returns the correct level object' do
94
- @profile.level.must_be_kind_of(Level)
95
- @profile.level.name.must_equal('HAVO')
96
- end
97
- end
98
- end
99
-
100
- describe 'A course object' do
101
- before do
102
- @course = Course.find_by_name('VWO/Engels')
103
- end
104
-
105
- describe 'level method' do
106
- it 'returns the correct level object' do
107
- @course.level.must_be_kind_of(Level)
108
- @course.level.name.must_equal('VWO')
109
- end
110
- end
111
- end