enumark 0.1.4 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b85bfbf07990e9f2a38461056ade65766019e3b322c7f4f64778d8627a1c6561
4
- data.tar.gz: 5c42a625adbfd33c04d8d5cec939fb7fc91355e127dfe6181328433a7c7f7dc6
3
+ metadata.gz: e3887e4765d58b0f634bcfff37be0d33a666b1fb0b7b8d7528a24070552092c6
4
+ data.tar.gz: 42856dea821e7f2692cd1cec49cc11a7c6a5f70b30c33d0a6b8d9865b042cf34
5
5
  SHA512:
6
- metadata.gz: ed84f93d9a0b17acce86b08cc50e64517c023c46e85e29661471088afafb54c749bd3e20da4d42aecd6f91ecb1cbe201ce8d2e95ee50aafdfd729a440f33ed34
7
- data.tar.gz: 9b679c8511689282e29c8c9b602d33510088d7ef00d1cba6bf88e60871d49c1ac02995de895dccff4a3385a5ae45729ecd2d85a353838c74ea1e096d7c922e62
6
+ metadata.gz: 915ff888a7805f299600adbf9a80d6d5174b43422a61e5874650ae692e65760767d67a33fe367f6fbd5adef08d67b32d8f31dc63925c4f96c209b355deed545b
7
+ data.tar.gz: b5059abedec7387c0be9ba0c253e93fc8f4dad504ab847e0fc4c398a5997464600d795476522ed416f46416edb6f831ee6dee6f740b53ae5da4eb579106de99f
data/.gitignore CHANGED
@@ -7,4 +7,3 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  *.gem
10
- Gemfile.lock
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.6.3
data/Gemfile.lock ADDED
@@ -0,0 +1,27 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ enumark (1.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.3)
10
+ method_source (1.0.0)
11
+ minitest (5.16.3)
12
+ pry (0.14.1)
13
+ coderay (~> 1.1)
14
+ method_source (~> 1.0)
15
+ rake (13.0.6)
16
+
17
+ PLATFORMS
18
+ ruby
19
+
20
+ DEPENDENCIES
21
+ enumark!
22
+ minitest (~> 5.0)
23
+ pry
24
+ rake (~> 13.0)
25
+
26
+ BUNDLED WITH
27
+ 1.17.2
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
@@ -53,6 +55,12 @@ enum.each_category do |cate|
53
55
  end
54
56
  ```
55
57
 
58
+ Sort category by capacity
59
+
60
+ ```ruby
61
+ enum.each_category.map{ |cate| [cate.items.count, cate.name] }.sort
62
+ ```
63
+
56
64
  Explore trends of your dump files:
57
65
 
58
66
  ```ruby
@@ -62,6 +70,13 @@ dir.added # select items in last file but not in second to last
62
70
  dir.deleted # reject items in last file
63
71
  dir.uniq # union all items
64
72
  dir.static # select items appear in all files
73
+ dir.all # enumerator of all items in all files
74
+ ```
75
+
76
+ Set config
77
+
78
+ ```ruby
79
+ Enumark::Config.set(logger: STDOUT)
65
80
  ```
66
81
 
67
82
  ## 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(">= 2.4.0")
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.3")
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.
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Enumark
4
+ module Config
5
+ class << self
6
+ def set(**cfg)
7
+ (@cfg ||= {}).merge!(cfg)
8
+ end
9
+
10
+ def get(key)
11
+ @cfg[key]
12
+ end
13
+ end
14
+
15
+ set
16
+ end
17
+ end
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Enumark
4
- VERSION = "0.1.4"
4
+ VERSION = "1.1.1"
5
5
  end
data/lib/enumark.rb CHANGED
@@ -5,6 +5,8 @@ require 'enumark/item'
5
5
  require 'enumark/category'
6
6
  require 'enumark/grouping'
7
7
  require 'enumark/dir'
8
+ require 'enumark/config'
9
+ require 'pathname'
8
10
 
9
11
  class Enumark
10
12
  include Enumerable
@@ -62,13 +64,14 @@ class Enumark
62
64
  end
63
65
 
64
66
  def _read_all_lines
67
+ dump_date = Pathname.new(@file).basename('.html').to_s
65
68
  categories = []
66
69
  @items = []
67
70
 
68
71
  File.new(@file).each do |line|
69
72
  case line
70
73
  when Item::PREFIX
71
- item = Item.new(line, categories.dup)
74
+ item = Item.new(dump_date, line, categories.dup)
72
75
  @items.push(item)
73
76
  when Category::START
74
77
  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.1.4
4
+ version: 1.1.1
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-16 00:00:00.000000000 Z
11
+ date: 2022-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -32,8 +32,10 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - ".gitignore"
35
+ - ".tool-versions"
35
36
  - CODE_OF_CONDUCT.md
36
37
  - Gemfile
38
+ - Gemfile.lock
37
39
  - LICENSE.txt
38
40
  - README.md
39
41
  - Rakefile
@@ -42,6 +44,7 @@ files:
42
44
  - enumark.gemspec
43
45
  - lib/enumark.rb
44
46
  - lib/enumark/category.rb
47
+ - lib/enumark/config.rb
45
48
  - lib/enumark/dir.rb
46
49
  - lib/enumark/grouping.rb
47
50
  - lib/enumark/item.rb
@@ -58,14 +61,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
61
  requirements:
59
62
  - - ">="
60
63
  - !ruby/object:Gem::Version
61
- version: 2.4.0
64
+ version: 2.6.3
62
65
  required_rubygems_version: !ruby/object:Gem::Requirement
63
66
  requirements:
64
67
  - - ">="
65
68
  - !ruby/object:Gem::Version
66
69
  version: '0'
67
70
  requirements: []
68
- rubygems_version: 3.2.3
71
+ rubygems_version: 3.0.3
69
72
  signing_key:
70
73
  specification_version: 4
71
74
  summary: Enumerate chrome bookmark dump file