glimmer-cs-gladiator 0.2.2 → 0.2.3

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: 1de235cba50741874f8719322e8c35ffea667929d465e23f3fd2df8a4866acb4
4
- data.tar.gz: 20273095f8e93bff72840e3094ff5f203bc57bf78e0c7ee8b14e0765f7025ca5
3
+ metadata.gz: d8a4a941695d12f14347c9892758f974e5909455a73020eee8d635c4c38e86a3
4
+ data.tar.gz: 929ff0b362ca29394e80f918b65fbdb911892449d9876a4eca14a7ec4c01b8df
5
5
  SHA512:
6
- metadata.gz: 5aba5bf9ad1ba8f077486dbc0d04da40c2138bf02c32d0565e27a520935da088d811e51bd9c90f868ce24c0775add77914e3dbebdfa4abb89f9333719f79cdcb
7
- data.tar.gz: cbb76756dae0901141a3c3b2d69849d1aed409e26d1f7a8ff1fa30a410c3e11edfecd93c4ff03e35023aa2ee64a7dccad276878bb563f94c1298c144e93dfc4d
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 - [Ugliest Text Editor Ever](https://www.reddit.com/r/ruby/comments/hgve8k/gladiator_glimmer_editor_ugliest_text_editor_ever/)
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.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
- Copyright (c) 2020 Andy Maleh. See [LICENSE.txt](LICENSE.txt) for
156
- further details.
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.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 ||= new(ENV['LOCAL_DIR'] || '.').tap do |dir|
13
- dir.refresh
14
- @filewatcher = Filewatcher.new(dir.path)
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
- dir.refresh if !filename.include?('new_file') && !dir.selected_child_path_history.include?(filename) && filename != dir.selected_child_path
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, :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(@display_path, '*')).map {|p| ::File.file?(p) ? Gladiator::File.new(p) : Gladiator::Dir.new(p)}.sort_by {|c| c.path.to_s.downcase }.sort_by {|c| c.class.name }
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
- new_all_children = retrieve_all_children
69
- new_children = retrieve_children
79
+ retrieve_children
80
+ collect_all_children
70
81
  refresh_operation = lambda do
71
- self.all_children = new_all_children
72
- self.children = new_children
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
- self.filtered_path_options = filtered.to_a.map(&:display_path)
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
- all_children_files.select do |child|
93
- child.path.downcase.include?(filter.downcase) ||
94
- child.path.downcase.gsub(/[_\/\.]/, '').include?(filter.downcase)
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 ||= retrieve_all_children
114
+ @all_children ||= collect_all_children
100
115
  end
101
116
 
102
- def retrieve_all_children
103
- ::Dir.glob(::File.join(@display_path, '**', '*')).map {|p| ::File.file?(p) ? Gladiator::File.new(p) : Gladiator::Dir.new(p)}
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?(selected_path) ||
113
- (selected_child && ::File.expand_path(selected_child.path) == ::File.expand_path(selected_path))
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)
@@ -20,7 +20,7 @@ module Glimmer
20
20
  class << self
21
21
  attr_accessor :drag_and_drop
22
22
  attr_accessor :drag
23
- end
23
+ end
24
24
 
25
25
  ## Add options like the following to configure CustomShell by outside consumers
26
26
  #
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.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-21 00:00:00.000000000 Z
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