hanami-sequel 1.1.0.1 → 1.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0cbf077a9722ab354ac3278d807fd85f8678202e96e12cad145e7bc711a52b00
4
- data.tar.gz: ef3765ac590a0c6425307be2ae8db9af3b9b9346e12e615603b633e19b8b4b78
3
+ metadata.gz: 95b9e7168e72d4f4ebdc99b780a94c9638b7cc1104d7dcbeb1025134b7ff2541
4
+ data.tar.gz: ecb1ba24a66d4095fe0719565d12ab2d7820e892c84a1df2ac63f8cb32a749ed
5
5
  SHA512:
6
- metadata.gz: 60a2077245ac568aee15f8c70a89fb8d88e613f9a0c363ca02ce31bb4aa4085de9af5ca78e8c419f94ab90f1e1ba5761795f3c678e2b8c4435e6cef93afe67d8
7
- data.tar.gz: 2c59ce5df2ebd230fd7b8b9e922f75eacb5c04d7325d8a4efcf8d3798cb9db8a7b3e63e561e8d79d372deb487d484635f53964f1815f347a18e0ae6b5893b084
6
+ metadata.gz: bf4cfa6a759f67ed06bde8bb5db314359e6f472446b041990862c5f55e4e503a21a878f9d1d638dab9b4c0dddd81c544ca4bb8eb84cf4b4a60b7aefa61ca8c61
7
+ data.tar.gz: 3299160313db47b265a9068fe7a5dff4647e01e5e55c937f0139b4ea4e048fa98da226d2f4131520b4e4d23144bd2cff5ea56c1c7a7cfba86d16b346ea21b880
@@ -0,0 +1,23 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [1.1.1] - 2018-03-19
10
+ ### Added
11
+ - The CHANGELOG itself.
12
+ - Provide different templates based on the user’s choice of testing framework,
13
+ currently supporting `minitest` and `RSpec`.
14
+ - Improve the testing framework support by adding default Sequel helpers.
15
+ - Prints on screen the different actions performed on files by each command.
16
+
17
+ ## [1.1.0.1] - 2018-03-06
18
+ ### Fixed
19
+ - Push of the correct version to rubygems.org.
20
+
21
+ ## [1.1.0] - 2018-03-06
22
+ ### Added
23
+ - Initial release.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hanami-sequel (1.1.0.1)
4
+ hanami-sequel (1.1.1)
5
5
  hanami (~> 1.1.0)
6
6
  sequel (~> 5.0)
7
7
 
data/README.md CHANGED
@@ -5,7 +5,7 @@ This gem is designed to replace the `hanami-model` one in your
5
5
  commands to the `hanami` executable, and generates Sequel models.
6
6
 
7
7
  Please note that using this gem could be considered bad practice with regards
8
- to Hanami's architectural goals, as it does not provide any help to separate
8
+ to Hanamis architectural goals, as it does not provide any help to separate
9
9
  the model into entities and repositories. On the other hand, it does nothing to
10
10
  prevent it either.
11
11
 
@@ -20,7 +20,7 @@ Add this line to your `config/environment.rb`:
20
20
  require "hamani/sequel/model"
21
21
  ```
22
22
 
23
- Add this line to your application's Gemfile (adding the gem to the `plugins`
23
+ Add this line to your applications Gemfile (adding the gem to the `plugins`
24
24
  group ensures that the `hanami` executable is correctly extended):
25
25
 
26
26
  ```ruby
@@ -35,9 +35,9 @@ And then execute:
35
35
 
36
36
  ## Versioning
37
37
 
38
- This gem's version is based on the major and minor versions of Hanami. For
39
- `hanami-X.Y.Z`, use `hanami-sequel-X.Y.P`. This gem's patch version (denoted as
40
- `P`) is independent from Hanami's patch version (denoted as `Z`).
38
+ This gems version is based on the major and minor versions of Hanami. For
39
+ `hanami-X.Y.Z`, use `hanami-sequel-X.Y.P`. This gems patch version (denoted as
40
+ `P`) is independent from Hanamis patch version (denoted as `Z`).
41
41
 
42
42
  ## Configuration
43
43
 
@@ -64,7 +64,8 @@ Commands:
64
64
  $ hanami sequel model NAME
65
65
 
66
66
  Where `NAME` is the name of the model. This creates a database migration, a
67
- Sequel model and a spec file.
67
+ Sequel model and a spec file. Additionally, a Sequel spec helper file will be
68
+ created if none exists.
68
69
 
69
70
  #### Create a database migration
70
71
 
@@ -110,14 +111,20 @@ This command will fail in the `production` environment.
110
111
 
111
112
  $ hanami sequel install
112
113
 
113
- This command `drop`s, `create`s, `migrate`s, then `seed`s your database. It will fail in
114
- the `production` environment.
114
+ This command `drop`s, `create`s, `migrate`s, then `seed`s your database. It
115
+ will fail in the `production` environment.
115
116
 
116
117
  ## Development
117
118
 
118
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
119
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
120
+ `rake spec` to run the tests. You can also run `bin/console` for an interactive
121
+ prompt that will allow you to experiment.
119
122
 
120
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
123
+ To install this gem onto your local machine, run `bundle exec rake install`. To
124
+ release a new version, update the version number in `version.rb`, and then run
125
+ `bundle exec rake release`, which will create a git tag for the version, push
126
+ git commits and tags, and push the `.gem` file to
127
+ [rubygems.org](https://rubygems.org).
121
128
 
122
129
  ## Known issues / To-do list
123
130
 
@@ -126,4 +133,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
126
133
 
127
134
  ## Contributing
128
135
 
129
- Bug reports and pull requests are welcome on GitHub at https://github.com/malin-as/hanami-sequel.
136
+ Bug reports and pull requests are welcome on GitHub at
137
+ [https://github.com/malin-as/hanami-sequel](https://github.com/malin-as/hanami-sequel).
@@ -7,6 +7,10 @@ module Hanami
7
7
  @hanamirc ||= Hanamirc.new(Pathname.new('.'))
8
8
  end
9
9
 
10
+ def self.hanamirc_test
11
+ hanamirc.options[:test] || hanamirc.default_options[:test]
12
+ end
13
+
10
14
  def self.lib_path
11
15
  @lib_path ||= "lib/#{hanamirc.options[:project]}"
12
16
  end
@@ -48,6 +52,12 @@ module Hanami
48
52
  content = ERB.new(File.read(template))
49
53
  .result(erbinding&.bind)
50
54
  File.write(destination, content)
55
+
56
+ log_file_handling('create', destination)
57
+ end
58
+
59
+ def self.log_file_handling(verb, file)
60
+ puts "%12s %s" % [verb, file]
51
61
  end
52
62
  end
53
63
  end
@@ -1,4 +1,5 @@
1
1
  require 'erb'
2
+ require 'fileutils'
2
3
 
3
4
  module Hanami
4
5
  module Sequel
@@ -38,7 +39,21 @@ module Hanami
38
39
  'models',
39
40
  "/#{under_name}_model_spec.rb")
40
41
 
41
- CLI.generate(CLI.template('model-spec'), b, destination)
42
+ model_spec = "model-spec-#{CLI.hanamirc_test}"
43
+ CLI.generate(CLI.template(model_spec), b, destination)
44
+
45
+ # spec/model_helpers.rb
46
+
47
+ dest_helper = 'spec/models_helper.rb'
48
+
49
+ if File.exist?(dest_helper)
50
+ CLI.log_file_handling('skip', dest_helper)
51
+ else
52
+ model_helper = "models-helper-#{CLI.hanamirc_test}"
53
+ CLI.generate(CLI.template(model_helper), nil, dest_helper)
54
+
55
+ CLI.log_file_handling('create', dest_helper)
56
+ end
42
57
  end
43
58
  end
44
59
  end
@@ -0,0 +1,7 @@
1
+ require_relative '../../models_helper.rb'
2
+
3
+ # This assumes that you are using minitest/test
4
+
5
+ class Test<%= model_name %> < SequelTestCase
6
+ # place your tests here
7
+ end
@@ -0,0 +1,5 @@
1
+ require_relative '../../models_helper.rb'
2
+
3
+ RSpec.describe <%= model_name %>, type: :model do
4
+ # place your tests here
5
+ end
@@ -0,0 +1,13 @@
1
+ # This is for minitest/test
2
+ # cf https://sequel.jeremyevans.net/rdoc/files/doc/testing_rdoc.html
3
+
4
+ # Use this class as the base class for your tests
5
+ class SequelTestCase < Minitest::Test
6
+ def run(*args, &block)
7
+ Sequel::Model.db.transaction(rollback: :always,
8
+ auto_savepoint: true,
9
+ isolation: :serializable) do
10
+ super
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ RSpec.configure do |config|
2
+ config.before(:suite) do
3
+ # you can prepare your database contents here
4
+ end
5
+
6
+ # Each test is ran within a serializable transaction to ensure the maximum
7
+ # isolation level possible. This allows parallelisation of the tests.
8
+ config.around(:each, type: :model) do |example|
9
+ Sequel::Model.db.transaction(rollback: :always,
10
+ auto_savepoint: true,
11
+ isolation: :serializable) do
12
+ example.run
13
+ end
14
+ end
15
+
16
+ config.after(:suite) do
17
+ # you can remove your database contents here
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  module Hanami
2
2
  module Sequel
3
- VERSION = "1.1.0.1"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Malina Sulca
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-06 00:00:00.000000000 Z
11
+ date: 2018-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,6 +91,7 @@ files:
91
91
  - ".gitignore"
92
92
  - ".rspec"
93
93
  - ".travis.yml"
94
+ - CHANGELOG.md
94
95
  - Gemfile
95
96
  - Gemfile.lock
96
97
  - LICENSE
@@ -113,7 +114,10 @@ files:
113
114
  - lib/hanami/sequel/templates/migration.erb
114
115
  - lib/hanami/sequel/templates/model-migration.erb
115
116
  - lib/hanami/sequel/templates/model-sequel.erb
116
- - lib/hanami/sequel/templates/model-spec.erb
117
+ - lib/hanami/sequel/templates/model-spec-minitest.erb
118
+ - lib/hanami/sequel/templates/model-spec-rspec.erb
119
+ - lib/hanami/sequel/templates/models-helper-minitest.erb
120
+ - lib/hanami/sequel/templates/models-helper-rspec.erb
117
121
  - lib/hanami/sequel/version.rb
118
122
  homepage: https://github.com/malin-as/hanami-sequel.git
119
123
  licenses: []
@@ -1,3 +0,0 @@
1
- RSpec.describe <%= model_name %> do
2
- # place your tests here
3
- end