abyme 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.github/workflows/build.yml +60 -0
- data/.gitignore +10 -0
- data/.rspec +1 -3
- data/.simplecov +0 -0
- data/CHANGELOG.md +93 -0
- data/Gemfile.lock +192 -15
- data/README.md +78 -53
- data/Rakefile +47 -2
- data/abyme.gemspec +14 -2
- data/bin/rails +12 -0
- data/javascript/abyme_controller.js +86 -11
- data/lib/abyme.rb +1 -0
- data/lib/abyme/abyme_builder.rb +16 -0
- data/lib/abyme/action_view_extensions/builder.rb +15 -0
- data/lib/abyme/engine.rb +0 -1
- data/lib/abyme/model.rb +1 -1
- data/lib/abyme/version.rb +3 -1
- data/lib/abyme/view_helpers.rb +169 -14
- data/package.json +1 -1
- metadata +139 -12
- data/.travis.yml +0 -7
- data/abyme-0.1.3.gem +0 -0
- data/lib/generators/.DS_Store +0 -0
- data/lib/generators/abyme/install_generator.rb +0 -25
- data/lib/generators/abyme/templates/abyme_controller.js +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 627dd83f44a40bcdf8ebd3355761ff9e1201c9d9c11e526e00acee11c685e479
|
4
|
+
data.tar.gz: 476215a4ae3e062e79104f0351da75a090c74c25cbde16cdd26016e17cea08cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd5fa9ecb5bae8fdab1272017769649c4ca5945789f47a5c792c6240a2aa45366a335c231128e04feb57448e9275433a303df023ced40c5f26eaafefd03baf78
|
7
|
+
data.tar.gz: 8d5728bd54f6e9292f36f9336e7b8157b1354e17e6348ce1fa07ad611c31c8d5f4d2550f494e4e4d00dfd136c5daf621a1cf6d1ba999c5f2625fc8e1110841b2
|
data/.DS_Store
CHANGED
Binary file
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: build
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v2
|
22
|
+
- name: Set up Ruby
|
23
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
24
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
25
|
+
# uses: ruby/setup-ruby@v1
|
26
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
27
|
+
with:
|
28
|
+
ruby-version: 2.6
|
29
|
+
- name: Install sqlite headers
|
30
|
+
run: |
|
31
|
+
sudo apt-get update
|
32
|
+
sudo apt-get install libsqlite3-dev
|
33
|
+
|
34
|
+
- name: Install dependencies
|
35
|
+
run: bundle install
|
36
|
+
|
37
|
+
- name: Prepare Database
|
38
|
+
run: bundle exec rails db:create db:migrate
|
39
|
+
env:
|
40
|
+
DB_CONNECTION: sqlite
|
41
|
+
DB_DATABASE: db/test.sqlite3
|
42
|
+
RAILS_ENV: test
|
43
|
+
|
44
|
+
- name: Run tests
|
45
|
+
run: bundle exec rake
|
46
|
+
env:
|
47
|
+
DB_CONNECTION: sqlite
|
48
|
+
DB_DATABASE: db/test.sqlite3
|
49
|
+
RAILS_ENV: test
|
50
|
+
|
51
|
+
- name: Coveralls
|
52
|
+
uses: coverallsapp/github-action@master
|
53
|
+
with:
|
54
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
55
|
+
|
56
|
+
- name: Create Coverage Artifact
|
57
|
+
uses: actions/upload-artifact@v2
|
58
|
+
with:
|
59
|
+
name: code-coverage
|
60
|
+
path: coverage/
|
data/.gitignore
CHANGED
@@ -11,3 +11,13 @@ yarn-error.log
|
|
11
11
|
|
12
12
|
# rspec failure tracking
|
13
13
|
.rspec_status
|
14
|
+
node_modules
|
15
|
+
|
16
|
+
# Dummy app
|
17
|
+
spec/dummy/db/*.sqlite3
|
18
|
+
spec/dummy/db/*.sqlite3-journal
|
19
|
+
spec/dummy/db/log/*.log
|
20
|
+
spec/dummy/log/
|
21
|
+
spec/dummy/tmp/
|
22
|
+
spec/dummy/.sass-cache
|
23
|
+
spec/dummy/public
|
data/.rspec
CHANGED
data/.simplecov
ADDED
File without changes
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [Unreleased](https://github.com/bear-in-mind/abyme/tree/HEAD)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/v0.2.4...HEAD)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Bump nokogiri from 1.10.10 to 1.11.1 [\#22](https://github.com/bear-in-mind/abyme/pull/22) ([dependabot[bot]](https://github.com/apps/dependabot))
|
10
|
+
- Solved JS compile bug [\#19](https://github.com/bear-in-mind/abyme/pull/19) ([bear-in-mind](https://github.com/bear-in-mind))
|
11
|
+
|
12
|
+
## [v0.2.4](https://github.com/bear-in-mind/abyme/tree/v0.2.4) (2020-10-18)
|
13
|
+
|
14
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/v0.2.3...v0.2.4)
|
15
|
+
|
16
|
+
**Merged pull requests:**
|
17
|
+
|
18
|
+
- Abymebuilder doc [\#18](https://github.com/bear-in-mind/abyme/pull/18) ([ghbozz](https://github.com/ghbozz))
|
19
|
+
- Last fix [\#17](https://github.com/bear-in-mind/abyme/pull/17) ([bear-in-mind](https://github.com/bear-in-mind))
|
20
|
+
- Drop demo [\#16](https://github.com/bear-in-mind/abyme/pull/16) ([bear-in-mind](https://github.com/bear-in-mind))
|
21
|
+
- Coveralls [\#15](https://github.com/bear-in-mind/abyme/pull/15) ([bear-in-mind](https://github.com/bear-in-mind))
|
22
|
+
- changing action name [\#14](https://github.com/bear-in-mind/abyme/pull/14) ([bear-in-mind](https://github.com/bear-in-mind))
|
23
|
+
- fixing button default text when auto mode [\#13](https://github.com/bear-in-mind/abyme/pull/13) ([ghbozz](https://github.com/ghbozz))
|
24
|
+
- travis and rake update [\#12](https://github.com/bear-in-mind/abyme/pull/12) ([bear-in-mind](https://github.com/bear-in-mind))
|
25
|
+
- Autonomous Spec [\#11](https://github.com/bear-in-mind/abyme/pull/11) ([bear-in-mind](https://github.com/bear-in-mind))
|
26
|
+
|
27
|
+
## [v0.2.3](https://github.com/bear-in-mind/abyme/tree/v0.2.3) (2020-10-15)
|
28
|
+
|
29
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/v0.2.2...v0.2.3)
|
30
|
+
|
31
|
+
## [v0.2.2](https://github.com/bear-in-mind/abyme/tree/v0.2.2) (2020-10-15)
|
32
|
+
|
33
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/v0.2.1...v0.2.2)
|
34
|
+
|
35
|
+
**Merged pull requests:**
|
36
|
+
|
37
|
+
- Dummy app setup \(incomplete\) [\#10](https://github.com/bear-in-mind/abyme/pull/10) ([bear-in-mind](https://github.com/bear-in-mind))
|
38
|
+
|
39
|
+
## [v0.2.1](https://github.com/bear-in-mind/abyme/tree/v0.2.1) (2020-10-15)
|
40
|
+
|
41
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/0.2.0...v0.2.1)
|
42
|
+
|
43
|
+
**Merged pull requests:**
|
44
|
+
|
45
|
+
- fix partial path [\#9](https://github.com/bear-in-mind/abyme/pull/9) ([ghbozz](https://github.com/ghbozz))
|
46
|
+
|
47
|
+
## [0.2.0](https://github.com/bear-in-mind/abyme/tree/0.2.0) (2020-10-14)
|
48
|
+
|
49
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/v0.2.0...0.2.0)
|
50
|
+
|
51
|
+
**Merged pull requests:**
|
52
|
+
|
53
|
+
- End of doc [\#8](https://github.com/bear-in-mind/abyme/pull/8) ([bear-in-mind](https://github.com/bear-in-mind))
|
54
|
+
|
55
|
+
## [v0.2.0](https://github.com/bear-in-mind/abyme/tree/v0.2.0) (2020-10-14)
|
56
|
+
|
57
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/0.1.3...v0.2.0)
|
58
|
+
|
59
|
+
**Merged pull requests:**
|
60
|
+
|
61
|
+
- limit & min count options [\#7](https://github.com/bear-in-mind/abyme/pull/7) ([ghbozz](https://github.com/ghbozz))
|
62
|
+
- Documentation end [\#6](https://github.com/bear-in-mind/abyme/pull/6) ([bear-in-mind](https://github.com/bear-in-mind))
|
63
|
+
- add limit feature [\#5](https://github.com/bear-in-mind/abyme/pull/5) ([ghbozz](https://github.com/ghbozz))
|
64
|
+
|
65
|
+
## [0.1.3](https://github.com/bear-in-mind/abyme/tree/0.1.3) (2020-10-13)
|
66
|
+
|
67
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/v0.1.2...0.1.3)
|
68
|
+
|
69
|
+
## [v0.1.2](https://github.com/bear-in-mind/abyme/tree/v0.1.2) (2020-10-13)
|
70
|
+
|
71
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/0.1.1...v0.1.2)
|
72
|
+
|
73
|
+
**Merged pull requests:**
|
74
|
+
|
75
|
+
- basic lifecycle events [\#4](https://github.com/bear-in-mind/abyme/pull/4) ([ghbozz](https://github.com/ghbozz))
|
76
|
+
|
77
|
+
## [0.1.1](https://github.com/bear-in-mind/abyme/tree/0.1.1) (2020-10-12)
|
78
|
+
|
79
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/v0.1.1...0.1.1)
|
80
|
+
|
81
|
+
## [v0.1.1](https://github.com/bear-in-mind/abyme/tree/v0.1.1) (2020-10-12)
|
82
|
+
|
83
|
+
[Full Changelog](https://github.com/bear-in-mind/abyme/compare/9b99709cd8f84e9401adb8ba6f59f0074e2f416b...v0.1.1)
|
84
|
+
|
85
|
+
**Merged pull requests:**
|
86
|
+
|
87
|
+
- Gem Content [\#3](https://github.com/bear-in-mind/abyme/pull/3) ([bear-in-mind](https://github.com/bear-in-mind))
|
88
|
+
- install generator for stimulus init setup [\#2](https://github.com/bear-in-mind/abyme/pull/2) ([ghbozz](https://github.com/ghbozz))
|
89
|
+
- Update rake requirement from ~\> 10.0 to ~\> 13.0 [\#1](https://github.com/bear-in-mind/abyme/pull/1) ([dependabot[bot]](https://github.com/apps/dependabot))
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile.lock
CHANGED
@@ -1,26 +1,194 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
abyme (0.
|
4
|
+
abyme (0.4.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
actioncable (6.0.3.4)
|
10
|
+
actionpack (= 6.0.3.4)
|
11
|
+
nio4r (~> 2.0)
|
12
|
+
websocket-driver (>= 0.6.1)
|
13
|
+
actionmailbox (6.0.3.4)
|
14
|
+
actionpack (= 6.0.3.4)
|
15
|
+
activejob (= 6.0.3.4)
|
16
|
+
activerecord (= 6.0.3.4)
|
17
|
+
activestorage (= 6.0.3.4)
|
18
|
+
activesupport (= 6.0.3.4)
|
19
|
+
mail (>= 2.7.1)
|
20
|
+
actionmailer (6.0.3.4)
|
21
|
+
actionpack (= 6.0.3.4)
|
22
|
+
actionview (= 6.0.3.4)
|
23
|
+
activejob (= 6.0.3.4)
|
24
|
+
mail (~> 2.5, >= 2.5.4)
|
25
|
+
rails-dom-testing (~> 2.0)
|
26
|
+
actionpack (6.0.3.4)
|
27
|
+
actionview (= 6.0.3.4)
|
28
|
+
activesupport (= 6.0.3.4)
|
29
|
+
rack (~> 2.0, >= 2.0.8)
|
30
|
+
rack-test (>= 0.6.3)
|
31
|
+
rails-dom-testing (~> 2.0)
|
32
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
33
|
+
actiontext (6.0.3.4)
|
34
|
+
actionpack (= 6.0.3.4)
|
35
|
+
activerecord (= 6.0.3.4)
|
36
|
+
activestorage (= 6.0.3.4)
|
37
|
+
activesupport (= 6.0.3.4)
|
38
|
+
nokogiri (>= 1.8.5)
|
39
|
+
actionview (6.0.3.4)
|
40
|
+
activesupport (= 6.0.3.4)
|
41
|
+
builder (~> 3.1)
|
42
|
+
erubi (~> 1.4)
|
43
|
+
rails-dom-testing (~> 2.0)
|
44
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
45
|
+
activejob (6.0.3.4)
|
46
|
+
activesupport (= 6.0.3.4)
|
47
|
+
globalid (>= 0.3.6)
|
48
|
+
activemodel (6.0.3.4)
|
49
|
+
activesupport (= 6.0.3.4)
|
50
|
+
activerecord (6.0.3.4)
|
51
|
+
activemodel (= 6.0.3.4)
|
52
|
+
activesupport (= 6.0.3.4)
|
53
|
+
activestorage (6.0.3.4)
|
54
|
+
actionpack (= 6.0.3.4)
|
55
|
+
activejob (= 6.0.3.4)
|
56
|
+
activerecord (= 6.0.3.4)
|
57
|
+
marcel (~> 0.3.1)
|
58
|
+
activesupport (6.0.3.4)
|
59
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
60
|
+
i18n (>= 0.7, < 2)
|
61
|
+
minitest (~> 5.1)
|
62
|
+
tzinfo (~> 1.1)
|
63
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
64
|
+
addressable (2.7.0)
|
65
|
+
public_suffix (>= 2.0.2, < 5.0)
|
66
|
+
builder (3.2.4)
|
67
|
+
capybara (3.33.0)
|
68
|
+
addressable
|
69
|
+
mini_mime (>= 0.1.3)
|
70
|
+
nokogiri (~> 1.8)
|
71
|
+
rack (>= 1.6.0)
|
72
|
+
rack-test (>= 0.6.3)
|
73
|
+
regexp_parser (~> 1.5)
|
74
|
+
xpath (~> 3.2)
|
75
|
+
childprocess (3.0.0)
|
76
|
+
concurrent-ruby (1.1.8)
|
77
|
+
crass (1.0.6)
|
78
|
+
database_cleaner (1.8.5)
|
79
|
+
database_cleaner-active_record (1.8.0)
|
80
|
+
activerecord
|
81
|
+
database_cleaner (~> 1.8.0)
|
9
82
|
diff-lcs (1.4.4)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
83
|
+
docile (1.3.2)
|
84
|
+
erubi (1.10.0)
|
85
|
+
globalid (0.4.2)
|
86
|
+
activesupport (>= 4.2.0)
|
87
|
+
i18n (1.8.8)
|
88
|
+
concurrent-ruby (~> 1.0)
|
89
|
+
loofah (2.9.0)
|
90
|
+
crass (~> 1.0.2)
|
91
|
+
nokogiri (>= 1.5.9)
|
92
|
+
mail (2.7.1)
|
93
|
+
mini_mime (>= 0.1.1)
|
94
|
+
marcel (0.3.3)
|
95
|
+
mimemagic (~> 0.3.2)
|
96
|
+
method_source (1.0.0)
|
97
|
+
mimemagic (0.3.5)
|
98
|
+
mini_mime (1.0.2)
|
99
|
+
mini_portile2 (2.5.0)
|
100
|
+
minitest (5.14.3)
|
101
|
+
nio4r (2.5.4)
|
102
|
+
nokogiri (1.11.1)
|
103
|
+
mini_portile2 (~> 2.5.0)
|
104
|
+
racc (~> 1.4)
|
105
|
+
public_suffix (4.0.6)
|
106
|
+
puma (5.0.4)
|
107
|
+
nio4r (~> 2.0)
|
108
|
+
racc (1.5.2)
|
109
|
+
rack (2.2.3)
|
110
|
+
rack-test (1.1.0)
|
111
|
+
rack (>= 1.0, < 3)
|
112
|
+
rails (6.0.3.4)
|
113
|
+
actioncable (= 6.0.3.4)
|
114
|
+
actionmailbox (= 6.0.3.4)
|
115
|
+
actionmailer (= 6.0.3.4)
|
116
|
+
actionpack (= 6.0.3.4)
|
117
|
+
actiontext (= 6.0.3.4)
|
118
|
+
actionview (= 6.0.3.4)
|
119
|
+
activejob (= 6.0.3.4)
|
120
|
+
activemodel (= 6.0.3.4)
|
121
|
+
activerecord (= 6.0.3.4)
|
122
|
+
activestorage (= 6.0.3.4)
|
123
|
+
activesupport (= 6.0.3.4)
|
124
|
+
bundler (>= 1.3.0)
|
125
|
+
railties (= 6.0.3.4)
|
126
|
+
sprockets-rails (>= 2.0.0)
|
127
|
+
rails-controller-testing (1.0.5)
|
128
|
+
actionpack (>= 5.0.1.rc1)
|
129
|
+
actionview (>= 5.0.1.rc1)
|
130
|
+
activesupport (>= 5.0.1.rc1)
|
131
|
+
rails-dom-testing (2.0.3)
|
132
|
+
activesupport (>= 4.2.0)
|
133
|
+
nokogiri (>= 1.6)
|
134
|
+
rails-html-sanitizer (1.3.0)
|
135
|
+
loofah (~> 2.3)
|
136
|
+
railties (6.0.3.4)
|
137
|
+
actionpack (= 6.0.3.4)
|
138
|
+
activesupport (= 6.0.3.4)
|
139
|
+
method_source
|
140
|
+
rake (>= 0.8.7)
|
141
|
+
thor (>= 0.20.3, < 2.0)
|
142
|
+
rake (13.0.3)
|
143
|
+
regexp_parser (1.8.2)
|
144
|
+
rspec-core (3.10.1)
|
145
|
+
rspec-support (~> 3.10.0)
|
146
|
+
rspec-expectations (3.10.1)
|
18
147
|
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.
|
20
|
-
rspec-mocks (3.
|
148
|
+
rspec-support (~> 3.10.0)
|
149
|
+
rspec-mocks (3.10.2)
|
21
150
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.
|
23
|
-
rspec-
|
151
|
+
rspec-support (~> 3.10.0)
|
152
|
+
rspec-rails (4.0.2)
|
153
|
+
actionpack (>= 4.2)
|
154
|
+
activesupport (>= 4.2)
|
155
|
+
railties (>= 4.2)
|
156
|
+
rspec-core (~> 3.10)
|
157
|
+
rspec-expectations (~> 3.10)
|
158
|
+
rspec-mocks (~> 3.10)
|
159
|
+
rspec-support (~> 3.10)
|
160
|
+
rspec-support (3.10.2)
|
161
|
+
rubyzip (2.3.0)
|
162
|
+
selenium-webdriver (3.142.7)
|
163
|
+
childprocess (>= 0.5, < 4.0)
|
164
|
+
rubyzip (>= 1.2.2)
|
165
|
+
simplecov (0.19.1)
|
166
|
+
docile (~> 1.1)
|
167
|
+
simplecov-html (~> 0.11)
|
168
|
+
simplecov-html (0.12.3)
|
169
|
+
simplecov-lcov (0.8.0)
|
170
|
+
sprockets (4.0.2)
|
171
|
+
concurrent-ruby (~> 1.0)
|
172
|
+
rack (> 1, < 3)
|
173
|
+
sprockets-rails (3.2.2)
|
174
|
+
actionpack (>= 4.0)
|
175
|
+
activesupport (>= 4.0)
|
176
|
+
sprockets (>= 3.0.0)
|
177
|
+
sqlite3 (1.4.2)
|
178
|
+
thor (1.1.0)
|
179
|
+
thread_safe (0.3.6)
|
180
|
+
tzinfo (1.2.9)
|
181
|
+
thread_safe (~> 0.1)
|
182
|
+
webdrivers (4.4.1)
|
183
|
+
nokogiri (~> 1.6)
|
184
|
+
rubyzip (>= 1.3.0)
|
185
|
+
selenium-webdriver (>= 3.0, < 4.0)
|
186
|
+
websocket-driver (0.7.3)
|
187
|
+
websocket-extensions (>= 0.1.0)
|
188
|
+
websocket-extensions (0.1.5)
|
189
|
+
xpath (3.2.0)
|
190
|
+
nokogiri (~> 1.8)
|
191
|
+
zeitwerk (2.4.2)
|
24
192
|
|
25
193
|
PLATFORMS
|
26
194
|
ruby
|
@@ -28,8 +196,17 @@ PLATFORMS
|
|
28
196
|
DEPENDENCIES
|
29
197
|
abyme!
|
30
198
|
bundler (~> 2.0)
|
199
|
+
capybara
|
200
|
+
database_cleaner-active_record
|
201
|
+
puma
|
202
|
+
rails
|
203
|
+
rails-controller-testing
|
31
204
|
rake (~> 13.0)
|
32
|
-
rspec
|
205
|
+
rspec-rails
|
206
|
+
simplecov
|
207
|
+
simplecov-lcov
|
208
|
+
sqlite3
|
209
|
+
webdrivers
|
33
210
|
|
34
211
|
BUNDLED WITH
|
35
|
-
2.
|
212
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,16 +1,41 @@
|
|
1
1
|
# Abyme 🕳
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/abyme.svg)](https://badge.fury.io/rb/abyme)
|
4
|
+
![build](https://github.com/bear-in-mind/abyme/workflows/build/badge.svg)
|
5
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/f591a9e00f7cf5188ad5/maintainability)](https://codeclimate.com/github/bear-in-mind/abyme/maintainability)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/github/bear-in-mind/abyme/badge.svg)](https://coveralls.io/github/bear-in-mind/abyme?branch=master)
|
7
|
+
|
8
|
+
abyme makes it easy to handle nested attributes in Rails, using [stimulus](https://stimulusjs.org/handbook/introduction) under the hood. Here's an example :
|
9
|
+
```ruby
|
10
|
+
# views/projects/_form.html.erb
|
11
|
+
<%= simple_form_for @project do |f| %>
|
12
|
+
<%= f.input :title %>
|
13
|
+
<%= f.input :description %>
|
14
|
+
<%= f.submit 'Save' %>
|
15
|
+
|
16
|
+
<%= f.abyme_for(:tasks) %>
|
17
|
+
<% end %>
|
18
|
+
```
|
19
|
+
Supposing you have a partial located in `views/abyme/_task_fields` containing your fields for `tasks`, the `abyme_for` command will generate and display 3 elements in this order :
|
20
|
+
- A div containing all task fields for `@project.tasks` (either persisted or already built instances of `tasks`)
|
21
|
+
- A div which will contain all additional tasks about to be created (added through the `Add task` button below)
|
22
|
+
- A button to generate fields for new instances of tasks
|
23
|
+
|
24
|
+
Have a look below to learn more about the different options and needed configuration.
|
25
|
+
|
4
26
|
|
5
27
|
## Disclaimer
|
6
|
-
This project is still a work in progress and subject to change. We
|
28
|
+
This project is still a work in progress and subject to change. We would advise not to use it in production code just yet.
|
7
29
|
|
8
30
|
Any enhancement proposition or bug report welcome !
|
9
31
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
32
|
+
## Demo app
|
33
|
+
|
34
|
+
![Demo preview](https://res.cloudinary.com/aux-belles-autos/image/upload/v1603040053/abyme-preview.gif)
|
35
|
+
|
36
|
+
Check out our demo app here : https://abyme-demo.herokuapp.com/
|
37
|
+
|
38
|
+
Source code is right here : https://github.com/bear-in-mind/abyme_demo
|
14
39
|
|
15
40
|
## Installation
|
16
41
|
|
@@ -23,7 +48,7 @@ gem 'abyme'
|
|
23
48
|
And then execute:
|
24
49
|
|
25
50
|
$ bundle
|
26
|
-
$ yarn add
|
51
|
+
$ yarn add abyme
|
27
52
|
|
28
53
|
|
29
54
|
Assuming you [already installed Stimulus](https://stimulusjs.org/handbook/introduction), add this in `app/javascript/controllers/index.js` :
|
@@ -81,7 +106,7 @@ class Project < ApplicationRecord
|
|
81
106
|
include Abyme::Model
|
82
107
|
has_many :tasks, inverse_of: :project
|
83
108
|
# ...
|
84
|
-
|
109
|
+
abymize :tasks
|
85
110
|
end
|
86
111
|
|
87
112
|
# models/task.rb
|
@@ -89,7 +114,7 @@ class Task < ApplicationRecord
|
|
89
114
|
include Abyme::Model
|
90
115
|
has_many :comments, inverse_of: :task
|
91
116
|
# ...
|
92
|
-
|
117
|
+
abymize :comments
|
93
118
|
end
|
94
119
|
```
|
95
120
|
Note the use of the `inverse_of` option. It is needed for Rails to effectively associate children to their yet unsaved parent. Have a peek to the bottom of [this page](https://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html#method-i-accepts_nested_attributes_for) for more info.
|
@@ -134,15 +159,15 @@ abyme provides helper methods for all these. Here's how our form for `Project` l
|
|
134
159
|
<%= f.input :description %>
|
135
160
|
<%= f.submit 'Save' %>
|
136
161
|
|
137
|
-
<%=
|
162
|
+
<%= f.abyme_for(:tasks) do |abyme| %>
|
138
163
|
<%= abyme.records %>
|
139
164
|
<%= abyme.new_records %>
|
140
|
-
<%=
|
165
|
+
<%= add_associated_record %>
|
141
166
|
<% end %>
|
142
167
|
<% end %>
|
143
168
|
```
|
144
169
|
|
145
|
-
`abyme.records` will contain the persisted associations fields, while `abyme.new_records` will contain fields for the new associations. `
|
170
|
+
`abyme.records` will contain the persisted associations fields, while `abyme.new_records` will contain fields for the new associations. `add_associated_record` will by default generate a button with a text of type "Add `resource_name`". To work properly, this method **has** to be called **inside the block** passed to the `abyme_for` method.
|
146
171
|
|
147
172
|
Now where's the code for these fields ? abyme will assume a **partial** to be present in the directory `/views/abyme` with a *name respecting this naming convention* (just like with [cocoon](https://github.com/nathanvda/cocoon#basic-usage)): `_singular_association_name_fields.html.erb`.
|
148
173
|
|
@@ -153,12 +178,12 @@ This partial might look like this:
|
|
153
178
|
<%= f.input :description %>
|
154
179
|
<%= f.hidden_field :_destroy %>
|
155
180
|
|
156
|
-
<%=
|
181
|
+
<%= remove_associated_record(tag: :div) do %>
|
157
182
|
<i class="fas fa-trash"></i>
|
158
183
|
<% end %>
|
159
184
|
```
|
160
185
|
|
161
|
-
Note the presence of the `
|
186
|
+
Note the presence of the `remove_associated_record` button. Here, we pass it an option to make it a `<div>`, as well as a block to customize its content. Don't forget the `_destroy` attribute, needed to mark items for destruction.
|
162
187
|
|
163
188
|
### What about the controller ?
|
164
189
|
|
@@ -167,11 +192,11 @@ What about it ? Well, not much. That's the actual magical thing about `nested_at
|
|
167
192
|
|
168
193
|
### Auto mode
|
169
194
|
|
170
|
-
Let's now take care of our comments fields. We'll add these using our neat *automatic mode*: just stick this line at the end of the partial:
|
195
|
+
Let's now take care of our comments fields. We'll add these using our neat *automatic mode*: just stick this line at the end of the partial :
|
171
196
|
```ruby
|
172
197
|
# views/abyme/_task_fields.html.erb
|
173
198
|
# ... rest of the partial above
|
174
|
-
<%=
|
199
|
+
<%= f.abyme_for(:comments) %>
|
175
200
|
```
|
176
201
|
Where's the rest of the code ? Well, if the default configuration you saw above in the `_form.html.erb` suits you, and the order in which the different resources appear feels right (persisted first, new fields second, and the 'Add' button last), then you can just spare the block, and it will be taken care of for you. We'll just write our `_comment_fields.html.erb` partial in the `views/abyme` directory and we'll be all set.
|
177
202
|
|
@@ -194,119 +219,118 @@ Which is the way you would configure `nested_attributes` 90% of the time. Should
|
|
194
219
|
A few options can be passed to `abyme.records`:
|
195
220
|
* `collection:` : allows you to pass a collection of your choice to only display specific objects.
|
196
221
|
```ruby
|
197
|
-
<%=
|
222
|
+
<%= f.abyme_for(:tasks) do |abyme| %>
|
198
223
|
<%= abyme.records(collection: @project.tasks.where(done: false)) %>
|
199
224
|
<%= abyme.new_records %>
|
200
|
-
<%=
|
225
|
+
<%= add_associated_record %>
|
201
226
|
<% end %>
|
202
227
|
```
|
203
228
|
* `order:` : allows you to pass an ActiveRecord `order` method to sort your instances the way you want.
|
204
229
|
```ruby
|
205
|
-
<%=
|
230
|
+
<%= f.abyme_for(:tasks) do |abyme| %>
|
206
231
|
<%= abyme.records(order: { created_at: :asc }) %>
|
207
232
|
<%= abyme.new_records %>
|
208
|
-
<%=
|
233
|
+
<%= add_associated_record %>
|
209
234
|
<% end %>
|
210
235
|
```
|
211
|
-
* `partial:` : allows you to indicate a custom partial, if one has not already been passed to `
|
236
|
+
* `partial:` : allows you to indicate a custom partial, if one has not already been passed to `abyme_for`.
|
212
237
|
```ruby
|
213
|
-
<%=
|
238
|
+
<%= f.abyme_for(:tasks) do |abyme| %>
|
214
239
|
<%= abyme.records %>
|
215
240
|
<%= abyme.new_records(partial: 'projects/task_fields') %>
|
216
|
-
<%=
|
241
|
+
<%= add_associated_record %>
|
217
242
|
<% end %>
|
218
243
|
```
|
219
244
|
* `fields_html:` : gives you the possibility to add any HTML attribute you may want to each set of fields. By default, an `abyme--fields` and an `singular_association-fields` class are already present.
|
220
245
|
```ruby
|
221
|
-
<%=
|
246
|
+
<%= f.abyme_for(:tasks) do |abyme| %>
|
222
247
|
<%= abyme.records(fields_html: { class: "some-class" }) %>
|
223
248
|
# Every set of persisted fields will have these 3 classes : 'abyme--fields', 'task-fields', and 'some-class'
|
224
249
|
<%= abyme.new_records %>
|
225
|
-
<%=
|
250
|
+
<%= add_associated_record %>
|
226
251
|
<% end %>
|
227
252
|
```
|
228
|
-
* `wrapper_html:` : gives you the possibility to add any HTML attribute you may want to the wrapper containing all fields.
|
253
|
+
* `wrapper_html:` : gives you the possibility to add any HTML attribute you may want to the wrapper containing all fields.
|
229
254
|
```ruby
|
230
|
-
<%=
|
231
|
-
<%= abyme.records(
|
255
|
+
<%= f.abyme_for(:tasks) do |abyme| %>
|
256
|
+
<%= abyme.records(wrapper_html: { class: "persisted-records" }) %>
|
232
257
|
# The wrapper containing all persisted task fields will have an id "abyme-tasks-wrapper" and a class "persisted-records"
|
233
258
|
<%= abyme.new_records %>
|
234
|
-
<%=
|
259
|
+
<%= add_associated_record %>
|
235
260
|
<% end %>
|
236
261
|
```
|
237
262
|
#### #new_records
|
238
263
|
Here are the options that can be passed to `abyme.new_records`:
|
239
264
|
* `position:` : allows you to specify whether new fields added dynamically should go at the top or at the bottom. `:end` is the default value.
|
240
265
|
```ruby
|
241
|
-
<%=
|
266
|
+
<%= f.abyme_for(:tasks) do |abyme| %>
|
242
267
|
<%= abyme.records %>
|
243
268
|
<%= abyme.new_records(position: :start) %>
|
244
|
-
<%=
|
269
|
+
<%= add_associated_record %>
|
245
270
|
<% end %>
|
246
271
|
```
|
247
272
|
* `partial:` : same as `#records`
|
248
273
|
* `fields_html:` : same as `#records`
|
249
274
|
* `wrapper_html:` : same as `#records`
|
250
275
|
|
251
|
-
#### #
|
276
|
+
#### #add_associated_record, #remove_associated_record
|
252
277
|
These 2 methods behave the same. Here are their options :
|
253
278
|
* `tag:` : allows you to specify a tag of your choosing, like `:a`, or `:div`. Default is `:button`.
|
254
279
|
* `content:` : the text to display inside the element. Default is `Add association_name`
|
255
280
|
* `html:` : gives you the possibility to add any HTML attribute you may want to the element.
|
256
281
|
```ruby
|
257
|
-
<%=
|
282
|
+
<%= f.abyme_for(:tasks) do |abyme| %>
|
258
283
|
# ...
|
259
|
-
<%=
|
284
|
+
<%= add_associated_record(tag: :a, content: "Add a super task", html: {id: "add-super-task"}) %>
|
260
285
|
<% end %>
|
261
286
|
```
|
262
287
|
|
263
288
|
As you may have seen above, you can also pass a block to the method to give it whatever HTML content you want :
|
264
289
|
```ruby
|
265
|
-
<%=
|
290
|
+
<%= f.abyme_for(:tasks) do |abyme| %>
|
266
291
|
# ...
|
267
|
-
<%=
|
292
|
+
<%= add_associated_record(tag: :div, html: {id: "add-super-task", class: "flex"}) do %>
|
268
293
|
<i class="fas fa-plus"></i>
|
269
294
|
<h2>Add a super task</h2>
|
270
295
|
<% end %>
|
271
296
|
<% end %>
|
272
297
|
```
|
273
298
|
|
274
|
-
|
275
|
-
#### #abymize(:association, form_object)
|
299
|
+
#### #abyme_for(:association, form_object)
|
276
300
|
This is the container for all your nested fields. It takes two parameters (the symbolized association and the `form_builder`), and some optional ones. Please note an id is automatically added to this element, which value is : `abyme--association`.
|
277
301
|
* `partial:` : allows you to indicate a custom partial path for both `records` and `new_records`
|
278
302
|
```ruby
|
279
|
-
<%=
|
303
|
+
<%= f.abyme_for(:tasks, partial: 'projects/task_fields') do |abyme| %>
|
280
304
|
<%= abyme.records %>
|
281
305
|
<%= abyme.new_records %>
|
282
|
-
<%=
|
306
|
+
<%= add_associated_record %>
|
283
307
|
<% end %>
|
284
308
|
```
|
285
|
-
* `limit:` : allows you to limit the number of fields that can be created through JS. If you need to limit the number of associations in database, you will need to add validations. You can also pass an option [in your model as well](https://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html#method-i-accepts_nested_attributes_for).
|
309
|
+
* `limit:` : allows you to limit the number of new fields that can be created through JS. If you need to limit the number of associations in database, you will need to add validations. You can also pass an option [in your model as well](https://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html#method-i-accepts_nested_attributes_for).
|
286
310
|
```ruby
|
287
|
-
<%=
|
311
|
+
<%= f.abyme_for(:tasks, limit: 5) do |abyme| %>
|
288
312
|
# Beyond 5 tasks, the add button won't add any more fields. See events section below to see how to handle the 'abyme:limit-reached' event
|
289
313
|
<%= abyme.records %>
|
290
314
|
<%= abyme.new_records %>
|
291
|
-
<%=
|
315
|
+
<%= add_associated_record %>
|
292
316
|
<% end %>
|
293
317
|
```
|
294
|
-
* `
|
318
|
+
* `min_count` : by default, there won't be any blank fields added on page load. By passing a `min_count` option, you can set how many empty fields should appear in the form.
|
295
319
|
```ruby
|
296
|
-
<%=
|
320
|
+
<%= f.abyme_for(:tasks, min_count: 1) do |abyme| %>
|
297
321
|
# 1 blank task will automatically be added to the form.
|
298
322
|
<%= abyme.records %>
|
299
323
|
<%= abyme.new_records %>
|
300
|
-
<%=
|
324
|
+
<%= add_associated_record %>
|
301
325
|
<% end %>
|
302
326
|
```
|
303
327
|
|
304
|
-
*When in auto mode*, the
|
305
|
-
* `
|
328
|
+
*When in auto mode*, the abyme_for method can take a few options:
|
329
|
+
* `button_text:` : this will set the `add_associated_record` button text to the string of your choice.
|
306
330
|
* All options that should be passed to either `records` or `new_records` can be passed here and will be passed down.
|
307
331
|
|
308
332
|
## Events
|
309
|
-
This part is still a work in progress and subject to change. We're providing some basic self-explanatory events to attach to. These are emitted by the main container (created by the `
|
333
|
+
This part is still a work in progress and subject to change. We're providing some basic self-explanatory events to attach to. These are emitted by the main container (created by the `abyme_for` method).
|
310
334
|
|
311
335
|
We're currently thinking about a way to attach to these via Stimulus. Coming soon !
|
312
336
|
|
@@ -322,18 +346,19 @@ document.getElementById('abyme--tasks').addEventListener('abyme:before-add', you
|
|
322
346
|
### Other events
|
323
347
|
* `abyme:limit-reached`
|
324
348
|
```javascript
|
325
|
-
document.getElementById('abyme--tasks')
|
349
|
+
const tasksContainer = document.getElementById('abyme--tasks');
|
350
|
+
tasksContainer.addEventListener('abyme:limit-reached', () => {
|
351
|
+
alert('You reached the max number of tasks !')
|
352
|
+
});
|
326
353
|
```
|
327
354
|
|
328
355
|
## Development
|
329
356
|
|
330
357
|
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.
|
331
358
|
|
332
|
-
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).
|
333
|
-
|
334
359
|
## Contributing
|
335
360
|
|
336
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
361
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bear-in-mind/abyme.
|
337
362
|
|
338
363
|
## License
|
339
364
|
|