acts_as_tree_diagram 0.1.0 → 0.1.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
2
  SHA256:
3
- metadata.gz: cce2312b24107bfcd148e593e29df7354db35c073772b08299ebd71516c2987d
4
- data.tar.gz: 47ec6e6b106ece44ac28df6603ca5563dd04fedc85459be363fa1cf1d54bc42c
3
+ metadata.gz: 38afc980a58e34581f024bf03c84cda856ae3ae246121a342fa5b62c7ed9f71a
4
+ data.tar.gz: 4726e887a08c7ebd1435ebccf3f47ee4fe261df58128e0cf211942228e5483f3
5
5
  SHA512:
6
- metadata.gz: b58bbce7bf280a0be89b6254a5c3cbd53733c894371887c493d130b787bae1c21184a6889400ce7a19bc4be60eda53beceafc28613c7ad1045ff0b2209d4e912
7
- data.tar.gz: ab326617d6fc311ecbfc69c1765ec1bd4eac79b651fb001d5dfee63dbfa7b97889b471650d1d67d8a0884a2771f437f8eec99682140c3097bf9222dd7550fb14
6
+ metadata.gz: 5fd5c9d1b1597416d73d85965e8fa3d8d713d4531cb3d6415ec5e67f301f1a24b7d14b64871adc580dd844eec13a5d1a60a7a7c2d1adcb2f851eab74f7c564ff
7
+ data.tar.gz: 11ee120ca9dbf8f4135787551b8ecb340b0827bfef40284835414571f390cb41056b707e15b23a3d859fd15cc355c3202c4537bbf33410d61bfcd6beb0fc18d0
data/README.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # ActsAsTreeDiagram
2
2
  ActsAsTreeDiagram extends ActsAsTree to add simple function for draw tree diagram with html.
3
3
 
4
+ ![Ruby](https://img.shields.io/badge/Ruby-CC342D?style=for-the-badge&logo=ruby&logoColor=white)
5
+ [![Gem Version](https://badge.fury.io/rb/acts_as_tree_diagram.svg)](https://badge.fury.io/rb/acts_as_tree_diagram)
6
+ ![](https://ruby-gem-downloads-badge.herokuapp.com/acts_as_tree_diagram)
7
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
8
+ [![CircleCI](https://circleci.com/gh/routeflags/acts_as_tree_diagram.svg?style=svg)](https://circleci.com/gh/routeflags/acts_as_tree_diagram)
9
+
10
+
11
+ # See It Work
12
+ ![tree_diagram](https://user-images.githubusercontent.com/25024587/160236618-5498e757-2c3e-474a-b397-99bd6b88ea73.gif)
13
+
4
14
  ## Usage
5
15
 
6
16
  1. Append the following line to your `app/assets/application.scss`:
@@ -17,21 +27,16 @@ end
17
27
  3. Then append the line to your view file like below:
18
28
  ```html
19
29
  <div id="act_as_tree_diagram">
20
- <ul class="tree">
21
- <code>
22
- ルート
23
- </code>
24
- <ul>
25
- <li>
26
- <code>
27
- <%= link_to Animal.find(1).name, animals_path(Animal.find(1)) %>
28
- </code>
29
- <ul>
30
- <%= Animal.draw_diagram(where: { id: 1 }, path: animals_path).html_safe %>
31
- </ul>
32
- </li>
30
+ <ul class="tree">
31
+ <li>
32
+ <code>
33
+ <%= link_to Animal.find(1).name, animals_path(Animal.find(1)) %>
34
+ </code>
35
+ <ul>
36
+ <%= Animal.diagram_molecules_tag(where: { id: 1 }, path: animals_path).html_safe %>
37
+ </ul>
38
+ </li>
33
39
  </ul>
34
- </ul>
35
40
  </div>
36
41
  ```
37
42
 
@@ -52,14 +57,44 @@ Or install it yourself as:
52
57
  $ gem install acts_as_tree_diagram
53
58
  ```
54
59
 
55
- ## Stuffs
56
60
 
57
- Heavy depend on [ActAsTree](https://github.com/amerine/acts_as_tree) and [Pretty Clean Tree Diagram In Pure CSS &#124; CSS Script](https://www.cssscript.com/clean-tree-diagram/). Thanks much!
61
+ ## Development
62
+
63
+ ### Test
64
+
65
+ ```bash
66
+ bin/test
67
+ ```
58
68
 
59
69
  ## Contributing
60
- Contribution directions go here.
70
+
71
+ Bug reports and pull requests are welcome on Github at https://github.com/routeflags/acts_as_tree_diagram. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/routeflags/acts_as_tree_diagram/main/CODE_OF_CONDUCT.md).
61
72
 
62
73
  ## License
74
+
63
75
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
64
76
 
77
+ ## Changelog
78
+
79
+ TimelineRailsHelper's changelog is available [here](https://github.com/routeflags/acts_as_tree_diagram/blob/main/CHANGELOG.md.md).
80
+
81
+ ## Code of Conduct
82
+
83
+ Everyone interacting in the PunchClock project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/routeflags/acts_as_tree_diagram/main/CODE_OF_CONDUCT.md).
84
+
85
+ ## You may enjoy owning other libraries and my company.
86
+
87
+ * [routeflagsinc / jma — Bitbucket](https://bitbucket.org/routeflagsinc/jma/src/main/)
88
+ - for the Japan Meteorological Agency (気象庁) for searching new information simplifies.
89
+ * [smapira / punch_time — Bitbucket](https://bitbucket.org/smapira/punch_time/src/master/)
90
+ - Work time calculations using punch clock.
91
+ * [smapira / rspec-css — Bitbucket](https://bitbucket.org/smapira/rspec-css/src/master/)
92
+ - Record your test suite's computed CSS during future test runs for deterministic and accurate tests.
93
+ * [routeflags/timeline_rails_helper: The TimelineRailsHelper provides a timeline_molecules_tag helper to draw a vertical time line usable with vanilla CSS.](https://github.com/routeflags/timeline_rails_helper)
94
+ * [routeflags/acts_as_tree_diagram: ActsAsTreeDiagram extends ActsAsTree to add simple function for draw tree diagram with html.](https://github.com/routeflags/acts_as_tree_diagram)
95
+ * [株式会社旗指物](https://blog.routeflags.com/)
96
+
97
+ ## Аcknowledgment
65
98
 
99
+ - [ActAsTree](https://github.com/amerine/acts_as_tree)
100
+ - [Tree view from unordered list](https://codepen.io/ross-angus/pen/jwxMjL)
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/setup"
3
+ require 'bundler/setup'
4
4
 
5
- require "bundler/gem_tasks"
5
+ require 'bundler/gem_tasks'
@@ -1,3 +1,5 @@
1
+ // Credit for the code: https://codepen.io/ross-angus/pen/jwxMjL
2
+
1
3
  #act_as_tree_diagram {
2
4
 
3
5
  /* It's supposed to look like a tree diagram */
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActsAsTreeDiagram
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
@@ -3,13 +3,31 @@ require 'acts_as_tree_diagram/railtie'
3
3
 
4
4
  module ActsAsTreeDiagram
5
5
  module ViewDiagram
6
- def draw_diagram(options = {})
6
+ # Animal.diagram_molecules_tag(where: { id: 1 }, path: animals_path).html_safe
7
+ # => "<li>
8
+ # <code><a href="/animals/2">2</a></code>
9
+ # <ul>
10
+ # <li><code><a href="/animals/5">5</a></code></li>
11
+ # </ul>
12
+ # </li>
13
+ # <li><code><a href="/animals/3">3</a></code>
14
+ # <ul>
15
+ # <li><code><a href="/animals/7">44</a></code></li>
16
+ # </ul>
17
+ # </li>"
18
+ #
19
+ # @param [Hash] options .
20
+ # @return [String]
21
+ def diagram_molecules_tag(options = {})
7
22
  where = options.fetch :where, {}
8
23
  where(where).map { |x| draw_tree(x, options) }.join("\n")
9
24
  end
10
25
 
11
26
  private
12
27
 
28
+ # @param [ApplicationRecord] node
29
+ # @param [Hash] options
30
+ # @return [String] html
13
31
  def draw_tree(node, options = {})
14
32
  html = ''
15
33
  node.children.each do |child|
@@ -22,9 +40,13 @@ module ActsAsTreeDiagram
22
40
  html.concat "<ul>#{draw_tree(child, options)}</ul>" if child.children.any?
23
41
  html.concat '</li>'
24
42
  end
25
- html.html_safe
43
+ html
26
44
  end
27
45
 
46
+ # @param [String] path
47
+ # @param [ApplicationRecord] node
48
+ # @param [String] label
49
+ # @return [String] html
28
50
  def generate_tree_url(path, node, label)
29
51
  "<a href='#{path}/#{node.id}'>#{label}</a>"
30
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_tree_diagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - smapira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-26 00:00:00.000000000 Z
11
+ date: 2022-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acts_as_tree
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: actionpack
56
+ name: better_errors
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: activesupport
70
+ name: binding_of_caller
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,49 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: json
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler-audit
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: listen
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry-byebug
85
127
  requirement: !ruby/object:Gem::Requirement
86
128
  requirements:
87
129
  - - ">="
@@ -109,7 +151,7 @@ dependencies:
109
151
  - !ruby/object:Gem::Version
110
152
  version: '0'
111
153
  - !ruby/object:Gem::Dependency
112
- name: rubocop
154
+ name: rake
113
155
  requirement: !ruby/object:Gem::Requirement
114
156
  requirements:
115
157
  - - ">="
@@ -123,7 +165,7 @@ dependencies:
123
165
  - !ruby/object:Gem::Version
124
166
  version: '0'
125
167
  - !ruby/object:Gem::Dependency
126
- name: sprockets-rails
168
+ name: rubocop-rails
127
169
  requirement: !ruby/object:Gem::Requirement
128
170
  requirements:
129
171
  - - ">="
@@ -151,7 +193,7 @@ dependencies:
151
193
  - !ruby/object:Gem::Version
152
194
  version: '0'
153
195
  - !ruby/object:Gem::Dependency
154
- name: uglifier
196
+ name: web-console
155
197
  requirement: !ruby/object:Gem::Requirement
156
198
  requirements:
157
199
  - - ">="
@@ -164,9 +206,10 @@ dependencies:
164
206
  - - ">="
165
207
  - !ruby/object:Gem::Version
166
208
  version: '0'
167
- description: Draws a tree diagram from a acts_as_tree model
209
+ description: " ActsAsTreeDiagram extends ActsAsTree to add simple function for
210
+ draw tree diagram with html.\n"
168
211
  email:
169
- - smapira@routeflags.com
212
+ - 25024587+smapira@users.noreply.github.com
170
213
  executables: []
171
214
  extensions: []
172
215
  extra_rdoc_files: []
@@ -178,11 +221,14 @@ files:
178
221
  - lib/acts_as_tree_diagram.rb
179
222
  - lib/acts_as_tree_diagram/railtie.rb
180
223
  - lib/acts_as_tree_diagram/version.rb
181
- homepage: https://github.com/smapira/acts_as_tree_diagram
224
+ homepage: https://github.com/routeflags/acts_as_tree_diagram
182
225
  licenses:
183
226
  - MIT
184
227
  metadata:
185
- homepage_uri: https://github.com/smapira/acts_as_tree_diagram
228
+ homepage_uri: https://github.com/routeflags/acts_as_tree_diagram
229
+ source_code_uri: https://github.com/routeflags/acts_as_tree_diagram
230
+ bug_tracker_uri: https://github.com/routeflags/acts_as_tree_diagram/issues
231
+ changelog_uri: https://github.com/routeflags/acts_as_tree_diagram//blob/main/CHANGELOG.md
186
232
  post_install_message:
187
233
  rdoc_options: []
188
234
  require_paths: