hanami-fabrication 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/README.md +64 -0
- data/Rakefile +5 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/hanami-fabrication.gemspec +32 -0
- data/lib/hanami/fabrication.rb +33 -0
- data/lib/hanami/fabrication/version.rb +5 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8806c5eeb0e62ad2bdb6ccda3b70de06036c18a0
|
4
|
+
data.tar.gz: 903382a6ed9feab5bfbbbf868b1490044cb9d24a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9c34867b2ec07c543cf9c4ddf4f0f03fa4f75521fd14c8aa04a91e9ea59255715f9fe072459246cca3815e1ead3fbf080387116cae902202be126f2355a09748
|
7
|
+
data.tar.gz: d84cd0c44f70176227c628eae86a2fd9caf2ee5bccdc3ccce5cb79b6016adb52807eed9713d2ec7e7fe216631df609218c2d8685ac4ab4b743004e64d8309784
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Hanami::Fabrication
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'hanami-fabrication'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install hanami-fabrication
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Add a fabricator:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
# spec/support/fabricators/user.rb
|
25
|
+
|
26
|
+
Fabricator(:user) do
|
27
|
+
name { "L" }
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
Create, build, attributes:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
Fabricate.create(:user)
|
35
|
+
# => #<User:0x007f9e6a3cc1d8 @attributes={:id=>1, :name=>"L"}>
|
36
|
+
|
37
|
+
Fabricate.create(:user, name: "MG")
|
38
|
+
# => #<User:0x007fb71dbf6180 @attributes={:id=>2, :name=>"MG"}>
|
39
|
+
|
40
|
+
Fabricate.build(:user)
|
41
|
+
# => #<User:0x007fadc0d74bf8 @attributes={:name=>"L"}>
|
42
|
+
|
43
|
+
Fabricate.build(:user, name: "MG")
|
44
|
+
# => #<User:0x007f95a3388ea8 @attributes={:name=>"MG"}>
|
45
|
+
|
46
|
+
Fabricate.attributes_for(:user)
|
47
|
+
# => {:name=>"L"}
|
48
|
+
|
49
|
+
Fabricate.attributes_for(:user, name: "MG")
|
50
|
+
# => {:name=>"MG"}
|
51
|
+
```
|
52
|
+
|
53
|
+
For a complete reference of the usage, please read [Fabrication docs](https://www.fabricationgem.org).
|
54
|
+
|
55
|
+
## Development
|
56
|
+
|
57
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
58
|
+
|
59
|
+
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).
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jodosha/hanami-fabrication.
|
64
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "hanami/fabrication"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hanami/fabrication/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hanami-fabrication"
|
8
|
+
spec.version = Hanami::Fabrication::VERSION
|
9
|
+
spec.authors = ["Luca Guidi"]
|
10
|
+
spec.email = ["me@lucaguidi.com"]
|
11
|
+
|
12
|
+
spec.summary = "Fabrication for Hanami"
|
13
|
+
spec.description = "Fabrication support for Hanami"
|
14
|
+
spec.homepage = "https://github.com/jodosha/hanami-fabrication"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_dependency "hanami-utils", "< 2.0"
|
27
|
+
spec.add_dependency "fabrication", "~> 2.16"
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "fabrication"
|
2
|
+
require "hanami/fabrication/version"
|
3
|
+
require "hanami/utils/class"
|
4
|
+
|
5
|
+
module Fabrication
|
6
|
+
module Generator
|
7
|
+
class Hanami < Base
|
8
|
+
def self.supports?(klass)
|
9
|
+
defined?(::Hanami::Entity) && klass.ancestors.include?(::Hanami::Entity)
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_instance
|
13
|
+
self._instance = _klass.new(_attributes)
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def persist
|
19
|
+
self._instance = repository.create(_instance.to_hash)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def repository
|
25
|
+
::Hanami::Utils::Class.load!("#{_klass}Repository").new
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Fabrication.configure do |config|
|
32
|
+
config.generators << Fabrication::Generator::Hanami
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hanami-fabrication
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luca Guidi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: hanami-utils
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "<"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "<"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fabrication
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.16'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.13'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.13'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.5'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.5'
|
83
|
+
description: Fabrication support for Hanami
|
84
|
+
email:
|
85
|
+
- me@lucaguidi.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- Gemfile
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bin/console
|
96
|
+
- bin/setup
|
97
|
+
- hanami-fabrication.gemspec
|
98
|
+
- lib/hanami/fabrication.rb
|
99
|
+
- lib/hanami/fabrication/version.rb
|
100
|
+
homepage: https://github.com/jodosha/hanami-fabrication
|
101
|
+
licenses: []
|
102
|
+
metadata:
|
103
|
+
allowed_push_host: https://rubygems.org
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.6.8
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Fabrication for Hanami
|
124
|
+
test_files: []
|