lolita-menu 0.2.2 → 0.3.0
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.
- data/History.rdoc +4 -0
- data/VERSION +1 -1
- data/lib/lolita-menu.rb +9 -0
- data/lib/lolita-menu/autocomplete/file_builder.rb +32 -2
- data/lib/lolita-menu/autocomplete/link_set.rb +36 -7
- data/lib/lolita-menu/configuration.rb +24 -0
- data/lolita-menu.gemspec +3 -2
- metadata +4 -3
data/History.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/lolita-menu.rb
CHANGED
@@ -5,6 +5,7 @@ require 'lolita'
|
|
5
5
|
|
6
6
|
module Lolita
|
7
7
|
module Menu
|
8
|
+
autoload :Configuration, "lolita-menu/configuration"
|
8
9
|
module Autocomplete
|
9
10
|
autoload :LinkSet, "lolita-menu/autocomplete/link_set"
|
10
11
|
autoload :FileBuilder, "lolita-menu/autocomplete/file_builder"
|
@@ -29,6 +30,14 @@ module Lolita
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
33
|
+
module LolitaMenuConfiguration
|
34
|
+
def menu
|
35
|
+
@menu ||= Lolita::Menu::Configuration.new
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Lolita.configuration.extend(LolitaMenuConfiguration)
|
40
|
+
|
32
41
|
|
33
42
|
require 'lolita-menu/module'
|
34
43
|
require 'lolita-menu/nested_tree'
|
@@ -5,11 +5,11 @@ module Lolita
|
|
5
5
|
|
6
6
|
class << self
|
7
7
|
def input_file
|
8
|
-
|
8
|
+
Lolita.menu.autocomplete_input_file
|
9
9
|
end
|
10
10
|
|
11
11
|
def output_file
|
12
|
-
|
12
|
+
Lolita.menu.autocomplete_output_file
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -23,9 +23,39 @@ module Lolita
|
|
23
23
|
@file.puts "#{url} #{label || url}"
|
24
24
|
end
|
25
25
|
|
26
|
+
def reject_lines_with url, label = nil
|
27
|
+
lines_arr = @file.readlines
|
28
|
+
label ||= url
|
29
|
+
lines_arr.reject do |line|
|
30
|
+
line_match_url_and_label?(line, url, label)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def exist?(url, label = nil)
|
35
|
+
old_lineno = @file.lineno
|
36
|
+
@file.rewind
|
37
|
+
label ||= url
|
38
|
+
!!@file.detect do |line|
|
39
|
+
line_match_url_and_label(line, url, label)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def write_lines(*lines)
|
44
|
+
lines.each do |line|
|
45
|
+
@file.puts(line)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
26
49
|
def finalize!
|
27
50
|
@file.close
|
28
51
|
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def link_match?(line, url, label)
|
56
|
+
line = line.gsub($/, "")
|
57
|
+
line == "#{url} #{label}"
|
58
|
+
end
|
29
59
|
end
|
30
60
|
|
31
61
|
end
|
@@ -6,15 +6,30 @@ module Lolita
|
|
6
6
|
|
7
7
|
def initialize(&block)
|
8
8
|
@links = []
|
9
|
+
@new_stream = false
|
9
10
|
end
|
10
11
|
|
11
12
|
def add *args
|
12
|
-
|
13
|
-
@file = Lolita::Menu::Autocomplete::FileBuilder.new("a")
|
14
|
-
new_stream = true
|
15
|
-
end
|
13
|
+
open_file("a+")
|
16
14
|
@file.add(*args)
|
17
|
-
if new_stream
|
15
|
+
if @new_stream
|
16
|
+
finalize_file!
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def remove *args
|
21
|
+
finalize_file!
|
22
|
+
open_file("r")
|
23
|
+
lines = @file.reject_lines_with(*args)
|
24
|
+
finalize_file!
|
25
|
+
open_file("w")
|
26
|
+
@file.write_lines(lines)
|
27
|
+
finalize_file!
|
28
|
+
end
|
29
|
+
|
30
|
+
def exist? *args
|
31
|
+
@file.exist?(*args)
|
32
|
+
if @new_stream
|
18
33
|
finalize_file!
|
19
34
|
end
|
20
35
|
end
|
@@ -28,11 +43,25 @@ module Lolita
|
|
28
43
|
end
|
29
44
|
end
|
30
45
|
|
46
|
+
def clear
|
47
|
+
open_file("w")
|
48
|
+
finalize_file!
|
49
|
+
end
|
50
|
+
|
31
51
|
private
|
32
52
|
|
33
53
|
def finalize_file!
|
34
|
-
@file
|
35
|
-
|
54
|
+
if @file
|
55
|
+
@file.finalize!
|
56
|
+
@file = nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def open_file mode
|
61
|
+
unless @file
|
62
|
+
@file = Lolita::Menu::Autocomplete::FileBuilder.new(mode)
|
63
|
+
@new_stream = true
|
64
|
+
end
|
36
65
|
end
|
37
66
|
|
38
67
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Lolita
|
2
|
+
module Menu
|
3
|
+
|
4
|
+
class Configuration
|
5
|
+
attr_writer :autocomplete_output_file
|
6
|
+
attr_writer :autocomplete_input_file
|
7
|
+
|
8
|
+
def autocomplete_output_file
|
9
|
+
file_location(@autocomplete_output_file) || File.join(Rails.root,"public","lolita-menu-url.txt")
|
10
|
+
end
|
11
|
+
|
12
|
+
def autocomplete_input_file
|
13
|
+
file_location(@autocomplete_input_file) || File.join(Rails.root,"config","lolita-menu-urls.rb")
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def file_location(location)
|
19
|
+
location.respond_to?(:call) ? location.call : location
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lolita-menu.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "lolita-menu"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["ITHouse", "Arturs Meisters"]
|
12
|
-
s.date = "2012-09-
|
12
|
+
s.date = "2012-09-17"
|
13
13
|
s.description = "Manage public menus for each project inside Lolita."
|
14
14
|
s.email = "support@ithouse.lv"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -57,6 +57,7 @@ Gem::Specification.new do |s|
|
|
57
57
|
"lib/lolita-menu/autocomplete/collector.rb",
|
58
58
|
"lib/lolita-menu/autocomplete/file_builder.rb",
|
59
59
|
"lib/lolita-menu/autocomplete/link_set.rb",
|
60
|
+
"lib/lolita-menu/configuration.rb",
|
60
61
|
"lib/lolita-menu/module.rb",
|
61
62
|
"lib/lolita-menu/nested_tree.rb",
|
62
63
|
"lib/lolita-menu/nested_tree/branch_builder.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolita-menu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: lolita
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- lib/lolita-menu/autocomplete/collector.rb
|
189
189
|
- lib/lolita-menu/autocomplete/file_builder.rb
|
190
190
|
- lib/lolita-menu/autocomplete/link_set.rb
|
191
|
+
- lib/lolita-menu/configuration.rb
|
191
192
|
- lib/lolita-menu/module.rb
|
192
193
|
- lib/lolita-menu/nested_tree.rb
|
193
194
|
- lib/lolita-menu/nested_tree/branch_builder.rb
|
@@ -232,7 +233,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
232
233
|
version: '0'
|
233
234
|
segments:
|
234
235
|
- 0
|
235
|
-
hash:
|
236
|
+
hash: 2002456122071213605
|
236
237
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
237
238
|
none: false
|
238
239
|
requirements:
|