enumark 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/enumark.rb +36 -11
- data/lib/enumark/version.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: 5ff7445e38a40b2f5e2e7196c9873833d1853c8994cf0ac13699c322174658ee
|
4
|
+
data.tar.gz: 2d679d07bed90e0973701f6fd01a5a6b2c0c86bf61529a97d3ade1d57d68ca4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ab4b15cf7de8e56c3af1e681f369258e9806b34736e2ffb5df85c4195a9be354c272d46e2627c5f1bf8bd69b26f9144ac1f46736835926f481c2a5bc0204a92
|
7
|
+
data.tar.gz: c86177d92d36168653a669d5f11ed2136549026760c042a89ad385aece50bcc1faf69e269c30fcf2ae57d53b9df839db200fe3a0a7cd5f335b28463fdfc2a255
|
data/README.md
CHANGED
data/lib/enumark.rb
CHANGED
@@ -72,14 +72,40 @@ class Enumark
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
class Grouping
|
76
|
+
Group = Struct.new(:name, :items)
|
77
|
+
|
78
|
+
def initialize(enumark, key, &post)
|
79
|
+
@lock = Mutex.new
|
80
|
+
@collection = nil
|
81
|
+
|
82
|
+
@enumark = enumark
|
83
|
+
@key = key
|
84
|
+
@post = post
|
85
|
+
end
|
86
|
+
|
87
|
+
def each(&block)
|
88
|
+
unless @collection
|
89
|
+
@lock.synchronize do
|
90
|
+
@collection = @enumark.group_by(&@key)
|
91
|
+
@collection = @post.call(@collection) if @post
|
92
|
+
@collection = @collection.map{ |k, items| Group.new(k, items) }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
@collection.each(&block)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
75
100
|
def initialize(file)
|
76
101
|
@file = file
|
77
102
|
@lock = Mutex.new
|
78
103
|
@read = false
|
79
104
|
@items = []
|
80
105
|
|
81
|
-
@
|
82
|
-
@
|
106
|
+
@hosts = Grouping.new(self, :host)
|
107
|
+
@dup_titles = Grouping.new(self, :name){ |groups| groups.select{ |_, items| items.count > 1 } }
|
108
|
+
@dup_hrefs = Grouping.new(self, :href){ |groups| groups.select{ |_, items| items.count > 1 } }
|
83
109
|
end
|
84
110
|
|
85
111
|
def each(&block)
|
@@ -88,16 +114,15 @@ class Enumark
|
|
88
114
|
end
|
89
115
|
|
90
116
|
def each_host(&block)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
98
|
-
end
|
117
|
+
@hosts.each(&block)
|
118
|
+
end
|
119
|
+
|
120
|
+
def each_dup_title(&block)
|
121
|
+
@dup_titles.each(&block)
|
122
|
+
end
|
99
123
|
|
100
|
-
|
124
|
+
def each_dup_href(&block)
|
125
|
+
@dup_hrefs.each(&block)
|
101
126
|
end
|
102
127
|
|
103
128
|
private
|
data/lib/enumark/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enumark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|