enumark 0.1.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/README.md +9 -0
- data/enumark.gemspec +1 -1
- data/lib/enumark/config.rb +17 -0
- data/lib/enumark/dir.rb +16 -0
- data/lib/enumark/item.rb +3 -2
- data/lib/enumark/version.rb +1 -1
- data/lib/enumark.rb +3 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa3a4cc7fa496b1863e6de8c004144d85d983e1b8886f252c909c1031b215f66
|
4
|
+
data.tar.gz: a462ef2d2b0ee84b4330e6daa2b528bbf1e643181715ff8bfb0030c2fabc6207
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0712afefeb2f3950b7763cb4d2246e39034a393bf8beb75bc88e10c22f6d45122fcf19f38cda647f4f3ec441705648b46d88fc729f3162cc2cfc50bb66bbd1a3
|
7
|
+
data.tar.gz: 482ce353a24835363a27a64b15e0d74e08e352ab57cc5e19b0008f3bfa0dabbeeed195b669f006d212bc76fcd8a604d8e16bb077d9e1fb85fcf012eb52ba348c
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.1.1
|
data/README.md
CHANGED
@@ -27,6 +27,8 @@ enum = Enumark.new('/path/to/bookmark_dump_file')
|
|
27
27
|
|
28
28
|
enum.each do |item|
|
29
29
|
item.name
|
30
|
+
item.dump_date
|
31
|
+
item.add_date
|
30
32
|
item.href
|
31
33
|
item.host
|
32
34
|
item.categories
|
@@ -62,6 +64,13 @@ dir.added # select items in last file but not in second to last
|
|
62
64
|
dir.deleted # reject items in last file
|
63
65
|
dir.uniq # union all items
|
64
66
|
dir.static # select items appear in all files
|
67
|
+
dir.all # enumerator of all items in all files
|
68
|
+
```
|
69
|
+
|
70
|
+
Set config
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
Enumark::Config.set(logger: STDOUT)
|
65
74
|
```
|
66
75
|
|
67
76
|
## Development
|
data/enumark.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = "Enumerate chrome bookmark dump file"
|
12
12
|
spec.homepage = "https://github.com/turnon/enumark"
|
13
13
|
spec.license = "MIT"
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new(">=
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
|
15
15
|
|
16
16
|
# Specify which files should be added to the gem when it is released.
|
17
17
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/lib/enumark/dir.rb
CHANGED
@@ -22,5 +22,21 @@ class Enumark
|
|
22
22
|
def static
|
23
23
|
@static ||= @enumarks.reverse_each.reduce(&:&)
|
24
24
|
end
|
25
|
+
|
26
|
+
def all
|
27
|
+
Enumerator.new do |yielder|
|
28
|
+
logger = Config.get(:logger)
|
29
|
+
file_count = @enumarks.count
|
30
|
+
|
31
|
+
@enumarks.each_with_index do |enum, idx|
|
32
|
+
enum.each do |item|
|
33
|
+
yielder << item
|
34
|
+
logger.printf("--> %6d/%-6d = %3f \r", idx + 1, file_count, ((idx + 1).to_f / file_count * 100).round(2)) if logger
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
logger.puts if logger
|
39
|
+
end
|
40
|
+
end
|
25
41
|
end
|
26
42
|
end
|
data/lib/enumark/item.rb
CHANGED
@@ -7,9 +7,10 @@ class Enumark
|
|
7
7
|
PATTERN = /HREF="(.*?)".*ADD_DATE="(.*?)".*>(.*)<\/A>/
|
8
8
|
USELESS_SHARP = /\#.*$/
|
9
9
|
|
10
|
-
attr_reader :name, :href, :add_date, :categories
|
10
|
+
attr_reader :dump_date, :name, :href, :add_date, :categories
|
11
11
|
|
12
|
-
def initialize(line, categories)
|
12
|
+
def initialize(dump_date, line, categories)
|
13
|
+
@dump_date = dump_date
|
13
14
|
m = line.match(PATTERN)
|
14
15
|
@href = m[1].gsub(USELESS_SHARP, '')
|
15
16
|
@add_date = Time.at(m[2].to_i)
|
data/lib/enumark/version.rb
CHANGED
data/lib/enumark.rb
CHANGED
@@ -5,6 +5,7 @@ require 'enumark/item'
|
|
5
5
|
require 'enumark/category'
|
6
6
|
require 'enumark/grouping'
|
7
7
|
require 'enumark/dir'
|
8
|
+
require 'enumark/config'
|
8
9
|
|
9
10
|
class Enumark
|
10
11
|
include Enumerable
|
@@ -62,13 +63,14 @@ class Enumark
|
|
62
63
|
end
|
63
64
|
|
64
65
|
def _read_all_lines
|
66
|
+
dump_date = Pathname.new(@file).basename('.html').to_s
|
65
67
|
categories = []
|
66
68
|
@items = []
|
67
69
|
|
68
70
|
File.new(@file).each do |line|
|
69
71
|
case line
|
70
72
|
when Item::PREFIX
|
71
|
-
item = Item.new(line, categories.dup)
|
73
|
+
item = Item.new(dump_date, line, categories.dup)
|
72
74
|
@items.push(item)
|
73
75
|
when Category::START
|
74
76
|
categories.push(Category.new(line))
|
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.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -32,6 +32,7 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- ".gitignore"
|
35
|
+
- ".ruby-version"
|
35
36
|
- CODE_OF_CONDUCT.md
|
36
37
|
- Gemfile
|
37
38
|
- LICENSE.txt
|
@@ -42,6 +43,7 @@ files:
|
|
42
43
|
- enumark.gemspec
|
43
44
|
- lib/enumark.rb
|
44
45
|
- lib/enumark/category.rb
|
46
|
+
- lib/enumark/config.rb
|
45
47
|
- lib/enumark/dir.rb
|
46
48
|
- lib/enumark/grouping.rb
|
47
49
|
- lib/enumark/item.rb
|
@@ -58,14 +60,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
60
|
requirements:
|
59
61
|
- - ">="
|
60
62
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
63
|
+
version: 3.1.0
|
62
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
65
|
requirements:
|
64
66
|
- - ">="
|
65
67
|
- !ruby/object:Gem::Version
|
66
68
|
version: '0'
|
67
69
|
requirements: []
|
68
|
-
rubygems_version: 3.
|
70
|
+
rubygems_version: 3.3.7
|
69
71
|
signing_key:
|
70
72
|
specification_version: 4
|
71
73
|
summary: Enumerate chrome bookmark dump file
|