geturl 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 411f93bbcd2d3d670c3690bfe90c7bcf90b2af1c4ccab49c79cb0c697245ebc4
4
- data.tar.gz: 53246132b245beb548e09311cb291d8dbce585fcaef3b98d3b6356d24ad42353
3
+ metadata.gz: 3d9ec99a5f37c46ebbbf76d465debe1abc47d11ee6875141fb4bd503a81ff983
4
+ data.tar.gz: a267f7a3b1f5ec2cabf17644c7bf6d677f9b88051435c4fe39b625faaabd1741
5
5
  SHA512:
6
- metadata.gz: 2fb81625dc50caa479849145ebb598d980d5948237c90b9394291a2ed0fd5a8b609ca59d0d84f42eda6388f10e25192703c5e3e6beed3c727dff8f7b3551dd0c
7
- data.tar.gz: f97fe1082a7a68ebdd9e1ba91a955d99767e773a9f23f0668db3c772c2e5545ea7d84831abc9be219c0c98a88af32b7c296ceb093c6c0cd0d017b4c26f5dba75
6
+ metadata.gz: 8568cd64eb2f3441d7b8c725d0d1245f28c0656302ecb4e680d792a2a60019678c4c49208df1c5a5428c516fac0bc8f8f35f4cd68873bb7aa491a9cec3a2c76a
7
+ data.tar.gz: 81a8416623afbc57f2046105bb3f6abd7f9727479cd6d9865476f5f516b7d8a9d577febe9c083a0a7ab9f527ebbfeca76d70d4c51b2e3aa5e4d0055ec93021a3
data/bin/geturl CHANGED
@@ -9,8 +9,9 @@ module GetUrlCli
9
9
 
10
10
  # Reads the command line and runs the selected action.
11
11
  def run
12
- flags = %w(--save --delete --reload --sources --register --unregister --reload -v --show-all --color)
13
- parameters = %w(--format --sources --tags --description --template)
12
+ flags = %w(--save --delete --reload --sources --register --unregister
13
+ --reload -v --show-all --match-all --color --show-score)
14
+ parameters = %w(--format --sources --tags --description --template -n)
14
15
  @arguments, @options = CliParser.parse(flags, parameters)
15
16
 
16
17
  if @options.include?('--save')
@@ -54,6 +55,9 @@ module GetUrlCli
54
55
  geturl --show-all [source-id]
55
56
  geturl --reload
56
57
 
58
+ # More information
59
+ For more details, please visit: https://gitlab.com/osisoft-gems/geturl
60
+
57
61
  }.gsub(/^ /, '')
58
62
  end
59
63
 
@@ -142,8 +146,8 @@ module GetUrlCli
142
146
 
143
147
  # Searches for specific urls.
144
148
  def search
145
- ids = @option['--sources'].to_s.split(',') rescue nil
146
- items = GetUrl::Searcher.search(@arguments, 'ids' => ids)
149
+ @options['ids'] = @option['--sources'].to_s.split(',') rescue nil
150
+ items = GetUrl::Searcher.search(@arguments, @options)
147
151
  output_data(items)
148
152
  end
149
153
 
@@ -67,6 +67,10 @@ module GetUrl
67
67
  # Removes all items that are not relevant (score of 0).
68
68
  @items.delete_if {|item| item['score'] == 0}
69
69
 
70
+ if options['--match-all']
71
+ @items.delete_if {|item| item['scored_keywords'] < keywords.size}
72
+ end
73
+
70
74
  # Sort by score
71
75
  @items.sort {|x, y|
72
76
  y['score'] <=> x['score'] rescue y <=> x
@@ -75,7 +79,12 @@ module GetUrl
75
79
  # Remove all score values
76
80
  @items.each {|item|
77
81
  item.delete('score')
78
- }
82
+ item.delete('scored_keywords')
83
+ } unless options.include?('--show-score')
84
+
85
+ n = options['-n'].to_i || 0
86
+ @items = @items[0..n-1] if n > 0
87
+
79
88
  return @items
80
89
  end
81
90
 
@@ -89,14 +98,19 @@ module GetUrl
89
98
  score = 0
90
99
  begin
91
100
  score += get_field_score(item['name'], keyword, 50, 25)
92
- score += get_field_score(item['description'], keyword, 10, 2)
101
+ score += get_field_score(item['url'], keyword, 50, 25)
102
+ score += get_field_score(item['description'], keyword, 30, 2)
93
103
  item['tags'].to_a.each {|tag|
94
- score += get_field_score(tag, keyword, 30, 5)
104
+ score += get_field_score(tag, keyword, 20, 5)
95
105
  }
96
106
  rescue
97
107
  end
98
108
  item['score'] ||= 0
99
- item['score'] += score * factor
109
+ item['scored_keywords'] ||= 0
110
+ if score > 0
111
+ item['score'] += score * factor
112
+ item['scored_keywords'] += 1
113
+ end
100
114
  end
101
115
 
102
116
 
metadata CHANGED
@@ -1,20 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geturl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taco Jan Osinga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-14 00:00:00.000000000 Z
11
+ date: 2018-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mustache
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ - - ">="
18
21
  - !ruby/object:Gem::Version
19
22
  version: 1.0.5
20
23
  type: :runtime
@@ -22,6 +25,9 @@ dependencies:
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - - ">="
25
31
  - !ruby/object:Gem::Version
26
32
  version: 1.0.5
27
33
  - !ruby/object:Gem::Dependency
@@ -29,6 +35,9 @@ dependencies:
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.0'
40
+ - - ">="
32
41
  - !ruby/object:Gem::Version
33
42
  version: 0.0.3
34
43
  type: :runtime
@@ -36,6 +45,9 @@ dependencies:
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
47
  - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.0'
50
+ - - ">="
39
51
  - !ruby/object:Gem::Version
40
52
  version: 0.0.3
41
53
  description: A simple command-line bookmarking tool, with support of external, read-only