glimmer-cs-gladiator 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -6
- data/VERSION +1 -1
- data/lib/models/glimmer/gladiator/dir.rb +41 -20
- data/lib/models/glimmer/gladiator/file.rb +1 -0
- data/lib/views/glimmer/gladiator.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8a4a941695d12f14347c9892758f974e5909455a73020eee8d635c4c38e86a3
|
4
|
+
data.tar.gz: 929ff0b362ca29394e80f918b65fbdb911892449d9876a4eca14a7ec4c01b8df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 993c7ae4684351d97b8b583cf5f59aef4a6d2aec5a68d8c121b6a95bc4e2ee035d6d21f677c8cd79febd5b4379e81808f4b0b977a1aadb388ddba4ab74694b4b
|
7
|
+
data.tar.gz: 32d823df2493950f822fdcfceb28fc5d2b6998152ab233dd0e8668f013d0bd5301dd6ec220d4719bd88683f53bbbd33ddbdceac03bb8d1f02fa77bee2cc432b6
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# <img src='https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-cs-gladiator-logo.svg' height=85 /> Gladiator 0.2.
|
2
|
-
## [Glimmer Custom Shell](https://github.com/AndyObtiva/glimmer#custom-shell-gem)
|
1
|
+
# <img src='https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-cs-gladiator-logo.svg' height=85 /> Gladiator 0.2.3 - [Ugliest Text Editor Ever](https://www.reddit.com/r/ruby/comments/hgve8k/gladiator_glimmer_editor_ugliest_text_editor_ever/)
|
2
|
+
## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer Custom Shell](https://github.com/AndyObtiva/glimmer#custom-shell-gem)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-cs-gladiator.svg)](http://badge.fury.io/rb/glimmer-cs-gladiator)
|
4
4
|
|
5
5
|
![Gladiator](images/glimmer-gladiator.png)
|
@@ -93,7 +93,7 @@ To reuse Gladiator as a Glimmer Custom Shell inside another Glimmer application,
|
|
93
93
|
following to the application's `Gemfile`:
|
94
94
|
|
95
95
|
```
|
96
|
-
gem 'glimmer-cs-gladiator', '~> 0.2.
|
96
|
+
gem 'glimmer-cs-gladiator', '~> 0.2.3'
|
97
97
|
```
|
98
98
|
|
99
99
|
Run:
|
@@ -152,11 +152,12 @@ The signal TERM is in use by the JVM and will not work correctly on this platfor
|
|
152
152
|
|
153
153
|
## Copyright
|
154
154
|
|
155
|
-
|
156
|
-
|
155
|
+
[MIT](https://opensource.org/licenses/MIT)
|
156
|
+
|
157
|
+
Copyright (c) 2020 Andy Maleh. See [LICENSE.txt](LICENSE.txt) for further details.
|
157
158
|
|
158
159
|
--
|
159
160
|
|
160
|
-
Built with [Glimmer](https://github.com/AndyObtiva/glimmer) (Ruby Desktop Development GUI Library)
|
161
|
+
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 />](https://github.com/AndyObtiva/glimmer) Built with [Glimmer](https://github.com/AndyObtiva/glimmer) (Ruby Desktop Development GUI Library)
|
161
162
|
|
162
163
|
Gladiator icon made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
@@ -9,29 +9,32 @@ module Glimmer
|
|
9
9
|
|
10
10
|
class << self
|
11
11
|
def local_dir
|
12
|
-
@local_dir
|
13
|
-
|
14
|
-
@
|
12
|
+
unless @local_dir
|
13
|
+
@local_dir = new(ENV['LOCAL_DIR'] || '.', true)
|
14
|
+
@local_dir.refresh
|
15
|
+
@filewatcher = Filewatcher.new(@local_dir.path)
|
15
16
|
@thread = Thread.new(@filewatcher) do |fw|
|
16
17
|
fw.watch do |filename, event|
|
17
18
|
if @last_update.nil? || (Time.now.to_f - @last_update) > REFRESH_DELAY
|
18
|
-
|
19
|
+
@local_dir.refresh if !filename.include?('new_file') && !@local_dir.selected_child_path_history.include?(filename) && filename != @local_dir.selected_child_path
|
19
20
|
end
|
20
21
|
@last_update = Time.now.to_f
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
25
|
+
@local_dir
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
29
|
attr_accessor :selected_child, :filter, :children, :filtered_path_options, :filtered_path, :path, :display_path
|
28
30
|
attr_reader :name, :parent
|
29
|
-
attr_writer :all_children
|
31
|
+
attr_writer :all_children
|
30
32
|
|
31
|
-
def initialize(path)
|
33
|
+
def initialize(path, is_local_dir = false)
|
32
34
|
@display_path = path
|
33
35
|
@path = ::File.expand_path(@display_path)
|
34
36
|
@name = ::File.basename(::File.expand_path(path))
|
37
|
+
@display_path = @path.sub(Dir.local_dir.path, '').sub(/^\//, '') unless is_local_dir
|
35
38
|
self.filtered_path_options = []
|
36
39
|
end
|
37
40
|
|
@@ -48,7 +51,15 @@ module Glimmer
|
|
48
51
|
end
|
49
52
|
|
50
53
|
def retrieve_children
|
51
|
-
::Dir.glob(::File.join(@
|
54
|
+
@children = ::Dir.glob(::File.join(@path, '*')).map do |p|
|
55
|
+
::File.file?(p) ? Gladiator::File.new(p) : Gladiator::Dir.new(p)
|
56
|
+
end.sort_by do |c|
|
57
|
+
c.path.to_s.downcase
|
58
|
+
end.sort_by do |c|
|
59
|
+
c.class.name
|
60
|
+
end.each do |child|
|
61
|
+
child.retrieve_children if child.is_a?(Dir)
|
62
|
+
end
|
52
63
|
end
|
53
64
|
|
54
65
|
def selected_child_path_history
|
@@ -65,11 +76,11 @@ module Glimmer
|
|
65
76
|
|
66
77
|
def refresh(async: true, force: false)
|
67
78
|
return if @refresh_paused && !force
|
68
|
-
|
69
|
-
|
79
|
+
retrieve_children
|
80
|
+
collect_all_children
|
70
81
|
refresh_operation = lambda do
|
71
|
-
|
72
|
-
|
82
|
+
notify_observers(:children)
|
83
|
+
notify_observers(:all_children)
|
73
84
|
end
|
74
85
|
if async
|
75
86
|
async_exec(&refresh_operation)
|
@@ -84,23 +95,31 @@ module Glimmer
|
|
84
95
|
else
|
85
96
|
@filter = value
|
86
97
|
end
|
87
|
-
|
98
|
+
@last_filtered = filtered.to_a
|
99
|
+
self.filtered_path_options = @last_filtered.map(&:display_path)
|
100
|
+
@last_filter = @filter
|
88
101
|
end
|
89
102
|
|
90
103
|
def filtered
|
91
104
|
return if filter.nil?
|
92
|
-
|
93
|
-
|
94
|
-
|
105
|
+
children_files = !@last_filter.to_s.empty? && filter.downcase.start_with?(@last_filter.downcase) ? @last_filtered : all_children_files
|
106
|
+
children_files.select do |child|
|
107
|
+
child_path = child.path.to_s.sub(Dir.local_dir.path, '')
|
108
|
+
child_path.downcase.include?(filter.downcase) ||
|
109
|
+
child_path.downcase.gsub(/[_\/.-]/, '').include?(filter.downcase.gsub(/[_\/.-]/, ''))
|
95
110
|
end.sort_by {|c| c.path.to_s.downcase}
|
96
111
|
end
|
97
112
|
|
98
113
|
def all_children
|
99
|
-
@all_children ||=
|
114
|
+
@all_children ||= collect_all_children
|
100
115
|
end
|
101
116
|
|
102
|
-
def
|
103
|
-
|
117
|
+
def collect_all_children
|
118
|
+
@all_children = children.reduce([]) do |output, child|
|
119
|
+
addition = [child]
|
120
|
+
addition += child.collect_all_children if child.is_a?(Dir)
|
121
|
+
output + addition
|
122
|
+
end
|
104
123
|
end
|
105
124
|
|
106
125
|
def all_children_files
|
@@ -108,9 +127,11 @@ module Glimmer
|
|
108
127
|
end
|
109
128
|
|
110
129
|
def selected_child_path=(selected_path)
|
130
|
+
full_selected_path = selected_path.include?(Dir.local_dir.path) ? selected_path : ::File.join(Dir.local_dir.path, selected_path)
|
111
131
|
return if selected_path.nil? ||
|
112
|
-
::Dir.exist?(
|
113
|
-
(selected_child &&
|
132
|
+
::Dir.exist?(full_selected_path) ||
|
133
|
+
(selected_child && selected_child.path == full_selected_path)
|
134
|
+
selected_path = full_selected_path
|
114
135
|
if ::File.file?(selected_path)
|
115
136
|
@selected_child&.write_dirty_content
|
116
137
|
new_child = Gladiator::File.new(selected_path)
|
@@ -14,6 +14,7 @@ module Glimmer
|
|
14
14
|
@display_path = path
|
15
15
|
@name = ::File.basename(path)
|
16
16
|
@path = ::File.expand_path(path)
|
17
|
+
@display_path = @path.sub(Dir.local_dir.path, '').sub(/^\//, '')
|
17
18
|
@top_index = 0
|
18
19
|
@selection_count = 0
|
19
20
|
@selection = Point.new(0, 0 + @selection_count)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-cs-gladiator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|