syclink 0.1.4 → 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
- SHA1:
3
- metadata.gz: 40ff743e0e2bae626b25f0588b883b9a4644e2e6
4
- data.tar.gz: 8b4b75c663e46b204a9f9d49accb041ffdd512fd
2
+ SHA256:
3
+ metadata.gz: ed4a3ff5243875f090239740417af2c31fbf320405212b18768c0e43b91ad70c
4
+ data.tar.gz: 1c99edda059bbc51b3ea2715054136dae767b62c329a172de2ae49c3a70a1f3e
5
5
  SHA512:
6
- metadata.gz: f41f7033506333e002a2079ba1828be595fe32306c69d6c0e4058abd467fb6c0e93ada8bb38a1666d34a29fee913bf5b437385e2e8f6ba8ac1eb82384b282e17
7
- data.tar.gz: f4d7e3934391b0fa7cd4a63a4234e1e69ad36e5dd5d56fa152ab8d763b3cc45b7e8d53a441a4d3f0a915870b8ca77a07206ac3ea635c678f1b8e646471054267
6
+ metadata.gz: 6d636b857f04488b901a04b48d5f522b2db686dcda7165970c1c20d1b18fdedaec4295b5d009ae175c6b4b926c80ad24aa4a951e42797c0cbed4eb6173e2efbc
7
+ data.tar.gz: d439e3ea09788c80becb9c73ee2583423b09833b523b85a3964c891ed60ff325c15f67c7ebb152f6d60e72fd529d28b7ea127340cf038022bf1b35b29584854b
data/Gemfile.lock CHANGED
@@ -1,28 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- syclink (0.1.4)
5
- gli (= 2.13.1)
4
+ syclink (0.2.0)
5
+ gli (>= 2.22.0)
6
6
  sqlite3 (= 1.3.10)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  diff-lcs (1.2.5)
12
- gli (2.13.1)
13
- rspec (3.3.0)
14
- rspec-core (~> 3.3.0)
15
- rspec-expectations (~> 3.3.0)
16
- rspec-mocks (~> 3.3.0)
17
- rspec-core (3.3.1)
18
- rspec-support (~> 3.3.0)
19
- rspec-expectations (3.3.0)
12
+ gli (2.22.0)
13
+ rspec (3.13.0)
14
+ rspec-core (~> 3.13.0)
15
+ rspec-expectations (~> 3.13.0)
16
+ rspec-mocks (~> 3.13.0)
17
+ rspec-core (3.13.2)
18
+ rspec-support (~> 3.13.0)
19
+ rspec-expectations (3.13.3)
20
20
  diff-lcs (>= 1.2.0, < 2.0)
21
- rspec-support (~> 3.3.0)
22
- rspec-mocks (3.3.1)
21
+ rspec-support (~> 3.13.0)
22
+ rspec-mocks (3.13.2)
23
23
  diff-lcs (>= 1.2.0, < 2.0)
24
- rspec-support (~> 3.3.0)
25
- rspec-support (3.3.0)
24
+ rspec-support (~> 3.13.0)
25
+ rspec-support (3.13.2)
26
26
  sass (3.4.15)
27
27
  sqlite3 (1.3.10)
28
28
 
@@ -30,6 +30,9 @@ PLATFORMS
30
30
  ruby
31
31
 
32
32
  DEPENDENCIES
33
- rspec (= 3.3.0)
33
+ rspec (>= 3.13)
34
34
  sass (= 3.4.15)
35
35
  syclink!
36
+
37
+ BUNDLED WITH
38
+ 2.6.2
data/README.md CHANGED
@@ -268,6 +268,9 @@ To import all files from `some-directory` call
268
268
 
269
269
  $ syclink import dir ~/some-directory/**/*
270
270
 
271
+ A path given like ~/some-directory/ will be expanded to ~/some-directory/* which
272
+ will read all files in the given directory, but not in sub-directories.
273
+
271
274
  If on Windows and the directory contains .URL-files the URL within the .URL-file
272
275
  will be used as the link target.
273
276
 
data/bin/syclink CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'gli'
3
+ require 'fileutils'
4
+
3
5
  begin # XXX: Remove this begin/rescue before distributing your app
4
6
  require 'syclink'
5
7
  rescue LoadError
@@ -343,7 +345,7 @@ command :import do |c|
343
345
  c.command :mf do |s|
344
346
 
345
347
  s.action do |global_options,options,args|
346
- unless File.exists? args[0]
348
+ unless File.exist? args[0]
347
349
  STDERR.puts <<-HERE.gsub(/^ {10}/, '')
348
350
  Error: #{args[0]} doesn't exist!
349
351
  Firefox stores its bookmarks in a SQLite3 database called
@@ -365,7 +367,7 @@ command :import do |c|
365
367
  c.command :gc do |s|
366
368
 
367
369
  s.action do |global_options,options,args|
368
- unless File.exists? args[0]
370
+ unless File.exist? args[0]
369
371
  STDERR.puts <<-HERE.gsub(/^ {10}/, '')
370
372
  Error: #{args[0]} doesn't exist!
371
373
  Google Chrome stores its bookmarks in a JSON file called
@@ -401,7 +403,7 @@ command :import do |c|
401
403
  s.flag [:t, :tags]
402
404
 
403
405
  s.action do |global_options,options,args|
404
- unless File.exists? args[0]
406
+ unless File.exist? args[0]
405
407
  STDERR.puts <<-HERE.gsub(/^ {10}/, '')
406
408
  Error: #{args[0]} doesn't exist!
407
409
  Internet Explorer stores its bookmarks in a directory structure.
@@ -427,6 +429,9 @@ command :import do |c|
427
429
  sub-directory
428
430
 
429
431
  PATH_TO_DIRECTORY/**/* will import all files and sub-directories
432
+
433
+ PATH_TO_DIRECTORY/ will be expanded to PATH_TO_DIRECTORY/* which will import
434
+ all files in the provided directory
430
435
  HERE
431
436
 
432
437
  c.arg_name 'PATH_TO_DIRECTORY'
@@ -447,8 +452,7 @@ command :import do |c|
447
452
  s.flag [:t, :tags]
448
453
 
449
454
  s.action do |global_options,options,args|
450
- @designer.import_links(SycLink::FileImporter.new(args.shift,
451
- options))
455
+ @designer.import_links(SycLink::FileImporter.new(args, options))
452
456
  end
453
457
  end
454
458
  end
@@ -472,7 +476,7 @@ pre do |global,command,options,args|
472
476
  @designer = SycLink::Designer.new
473
477
  global[:website] ||= config[:default_website]
474
478
 
475
- if File.exists? yaml_file(syclink_website_directory, global[:website])
479
+ if File.exist? yaml_file(syclink_website_directory, global[:website])
476
480
  @designer.load_website(yaml_file(syclink_website_directory,
477
481
  global[:website]))
478
482
 
@@ -2,6 +2,7 @@ require_relative 'website'
2
2
  require_relative 'link'
3
3
  require_relative 'infrastructure'
4
4
  require 'yaml'
5
+ require 'fileutils'
5
6
 
6
7
  # Module that creates a link list and generates an html representation
7
8
  module SycLink
@@ -135,12 +136,12 @@ module SycLink
135
136
  # Loads a website based on the provided YAML-file and asigns it to the
136
137
  # designer to operate on
137
138
  def load_website(website)
138
- @website = YAML.load_file(website)
139
+ @website = YAML.safe_load_file(website, permitted_classes: [SycLink::Website, SycLink::Link])
139
140
  end
140
141
 
141
142
  # Deletes the website if it already exists
142
143
  def delete_website(directory)
143
- if File.exists? yaml_file(directory, website.title)
144
+ if File.exist? yaml_file(directory, website.title)
144
145
  FileUtils.rm(yaml_file(directory, website.title))
145
146
  end
146
147
  end
@@ -2,10 +2,11 @@ module SycLink
2
2
 
3
3
  class FileImporter < Importer
4
4
 
5
+ GLOB_PATTERN = /^[^\*\?\[\]\{\}]*/
6
+
5
7
  def read
6
- root_dir = File.dirname(path).scan(/^[^\*|\?]*/).first
7
- regex = Regexp.new("(?<=#{root_dir}).*")
8
- Dir.glob(path).map do |file|
8
+ regex = Regexp.new("(?<=#{root_dir(path)}).*")
9
+ files(path).map do |file|
9
10
  next if File.directory? file
10
11
  url, name = if File.extname(file).upcase == ".URL"
11
12
  begin
@@ -24,6 +25,29 @@ module SycLink
24
25
  end.compact
25
26
  end
26
27
 
28
+ private
29
+
30
+ def files(path)
31
+ if path.is_a?(String)
32
+ Dir.glob(expand_to_glob(path))
33
+ elsif path.is_a?(Array)
34
+ path.size > 1 ? path : Dir.glob(expand_to_glob(path.first))
35
+ else
36
+ abort "Path #{path} is not a valid path"
37
+ end
38
+ end
39
+
40
+ def expand_to_glob(path)
41
+ File.directory?(path) ? File.expand_path("*", path) : path
42
+ end
43
+
44
+ def root_dir(path)
45
+ if path.is_a?(String)
46
+ path
47
+ else
48
+ File.dirname(path.first)
49
+ end.scan(GLOB_PATTERN).first
50
+ end
27
51
  end
28
52
 
29
53
  end
@@ -56,6 +56,8 @@ module SycLink
56
56
  .squeeze(" ")
57
57
  .split('/')
58
58
 
59
+ tags.reject! { |tag| tag.empty? }
60
+
59
61
  if tags.empty? || opts[:level] == 0
60
62
  "Default"
61
63
  else
@@ -1,4 +1,6 @@
1
1
  # Module that creates a link list and generates an html representation
2
+ require 'fileutils'
3
+
2
4
  module SycLink
3
5
 
4
6
  # Helper methods to setup the infrastructure for syclink
@@ -6,21 +8,21 @@ module SycLink
6
8
 
7
9
  # Creates a directory if it does not exist
8
10
  def create_directory_if_missing(directory)
9
- unless File.exists? directory
10
- Dir.mkdir directory
11
+ unless File.exist? directory
12
+ FileUtils.mkdir_p directory
11
13
  end
12
14
  end
13
15
 
14
16
  # Copies a file to a target directory
15
17
  def copy_file_if_missing(file, to_directory)
16
- unless File.exists? File.join(to_directory, File.basename(file))
18
+ unless File.exist? File.join(to_directory, File.basename(file))
17
19
  FileUtils.cp(file, to_directory)
18
20
  end
19
21
  end
20
22
 
21
23
  # Loads the configuration from a file
22
24
  def load_config(file)
23
- unless File.exists? file
25
+ unless File.exist? file
24
26
  File.open(file, 'w') do |f|
25
27
  YAML.dump({ default_website: 'default' }, f)
26
28
  end
@@ -2,6 +2,6 @@
2
2
  module SycLink
3
3
 
4
4
  # Version of the application
5
- VERSION = '0.1.4'
5
+ VERSION = '0.2.0'
6
6
 
7
7
  end
data/setup.md CHANGED
@@ -49,13 +49,18 @@ repository.
49
49
  Select the Ruby version
50
50
  =======================
51
51
  For a new project we want to use the newst Ruby version. At this writing it is
52
- verison 2.2.1. Suppose we use [RVM](https://rvm.io/). If not already installed
52
+ verison 3.2.6. Suppose we use [RVM](https://rvm.io/). If not already installed
53
53
  we install it with
54
54
 
55
55
  $ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
56
56
  $ \curl -sSL https://get.rvm.io | bash -s stable
57
- $ rvm install 2.2.1
58
- $ rvm use 2.2.1
57
+ $ rvm install 3.2.6
58
+ $ rvm use 3.2.6
59
+
60
+ Using [rbenv](https://github.com/rbenv/rbenv) we install ruby and select it for the directory
61
+
62
+ $ rbenv install 3.2.6
63
+ $ rbenv local 3.2.6
59
64
 
60
65
  Install RSpec
61
66
  =============
@@ -39,19 +39,20 @@ module SycLink
39
39
 
40
40
  before do
41
41
  ie_directory = File.join(File.dirname(__FILE__), 'ie/')
42
+
42
43
  @result = [ [ "http://www.example.com/", "ie", "", "one" ],
43
44
  [ "http://www.example.com/", "ie", "", "one,two"],
44
- [ "http://www.example.com/", "ie", "", "Default"] ]
45
+ [ "http://www.example.com/", "ie", "", "Default"] ].sort
45
46
 
46
47
  @ie = InternetExplorer.new(ie_directory)
47
48
  end
48
49
 
49
50
  it "should import bookmarks" do
50
- expect(@ie.read).to eq @result
51
+ expect(@ie.read.sort).to eq @result
51
52
  end
52
53
 
53
54
  it "should read rows" do
54
- expect(@ie.rows).to eq @result
55
+ expect(@ie.rows.sort).to eq @result
55
56
  end
56
57
 
57
58
  it "should create links" do
@@ -115,7 +116,7 @@ module SycLink
115
116
  ["/home/pierre/Work/syclink/spec/syclink/fi/a/two.pdf",
116
117
  "two.pdf", "", "a"],
117
118
  ["/home/pierre/Work/syclink/spec/syclink/fi/one.pdf",
118
- "one.pdf", "", "Default"]]
119
+ "one.pdf", "", "Default"]].sort
119
120
  @pdf_zero = [["/home/pierre/Work/syclink/spec/syclink/fi/b/three.pdf",
120
121
  "three.pdf", "", "Default"],
121
122
  ["/home/pierre/Work/syclink/spec/syclink/fi/b/a/four.pdf",
@@ -123,7 +124,7 @@ module SycLink
123
124
  ["/home/pierre/Work/syclink/spec/syclink/fi/a/two.pdf",
124
125
  "two.pdf", "", "Default"],
125
126
  ["/home/pierre/Work/syclink/spec/syclink/fi/one.pdf",
126
- "one.pdf", "", "Default"]]
127
+ "one.pdf", "", "Default"]].sort
127
128
  @txt_files = [["/home/pierre/Work/syclink/spec/syclink/fi/a.txt",
128
129
  "a.txt", "", "Default"]]
129
130
  @any_files = [["/home/pierre/Work/syclink/spec/syclink/fi/b/three.pdf",
@@ -137,7 +138,7 @@ module SycLink
137
138
  ["/home/pierre/Work/syclink/spec/syclink/fi/one.pdf",
138
139
  "one.pdf", "", "Default"],
139
140
  ["http://www.example.com/",
140
- "ie", "", "c"]]
141
+ "ie", "", "c"]].sort
141
142
  @any_level = [["/home/pierre/Work/syclink/spec/syclink/fi/b/three.pdf",
142
143
  "three.pdf", "", "b"],
143
144
  ["/home/pierre/Work/syclink/spec/syclink/fi/b/a/four.pdf",
@@ -149,7 +150,7 @@ module SycLink
149
150
  ["/home/pierre/Work/syclink/spec/syclink/fi/one.pdf",
150
151
  "one.pdf", "", "Default"],
151
152
  ["http://www.example.com/",
152
- "ie", "", "c"]]
153
+ "ie", "", "c"]].sort
153
154
  @pdf_tags = [["/home/pierre/Work/syclink/spec/syclink/fi/b/three.pdf",
154
155
  "three.pdf", "", "Prime,Second"],
155
156
  ["/home/pierre/Work/syclink/spec/syclink/fi/b/a/four.pdf",
@@ -161,12 +162,12 @@ module SycLink
161
162
  ["/home/pierre/Work/syclink/spec/syclink/fi/one.pdf",
162
163
  "one.pdf", "", "Prime,Second"],
163
164
  ["http://www.example.com/",
164
- "ie", "", "Prime,Second"]]
165
+ "ie", "", "Prime,Second"]].sort
165
166
  end
166
167
 
167
168
  it "should import pdf filenames" do
168
169
  fi = FileImporter.new(File.join(@file_dir, "**/*.pdf"))
169
- expect(fi.read).to eq @pdf_files
170
+ expect(fi.read.sort).to eq @pdf_files
170
171
  end
171
172
 
172
173
  it "should import a fully qualified text-file" do
@@ -176,7 +177,7 @@ module SycLink
176
177
 
177
178
  it "should import any file" do
178
179
  fi = FileImporter.new(File.join(@file_dir, "**/*"))
179
- expect(fi.read).to eq @any_files
180
+ expect(fi.read.sort).to eq @any_files
180
181
  end
181
182
 
182
183
  it "should read rows from pdf" do
@@ -196,18 +197,18 @@ module SycLink
196
197
 
197
198
  it "should use only the parent directory as the tag" do
198
199
  fi = FileImporter.new(File.join(@file_dir, "**/*"), level: 1)
199
- expect(fi.read).to eq @any_level
200
+ expect(fi.read.sort).to eq @any_level
200
201
  end
201
202
 
202
203
  it "should not import tags" do
203
204
  fi = FileImporter.new(File.join(@file_dir, "**/*.pdf"), level: 0)
204
- expect(fi.read).to eq @pdf_zero
205
+ expect(fi.read.sort).to eq @pdf_zero
205
206
  end
206
207
 
207
208
  it "should specify tags during import" do
208
209
  fi = FileImporter.new(File.join(@file_dir, "**/*"),
209
210
  level: 2, tags: "Prime,Second")
210
- expect(fi.read).to eq @pdf_tags
211
+ expect(fi.read.sort).to eq @pdf_tags
211
212
  end
212
213
  end
213
214
 
data/syclink.gemspec CHANGED
@@ -13,14 +13,13 @@ spec = Gem::Specification.new do |s|
13
13
  s.license = 'MIT license (MIT)'
14
14
  s.files = `git ls-files`.split(" ")
15
15
  s.require_paths << 'lib'
16
- s.has_rdoc = true
17
16
  s.extra_rdoc_files = ['README.rdoc','syclink.rdoc']
18
17
  s.rdoc_options << '--title' << 'test' << '--main' << 'README.rdoc' << '-ri'
19
18
  s.bindir = 'bin'
20
19
  s.executables << 'syclink'
21
20
  s.required_ruby_version = '>= 2.0'
22
- s.add_development_dependency('rspec', '3.3.0')
21
+ s.add_development_dependency('rspec', '>= 3.13')
23
22
  s.add_development_dependency('sass', '3.4.15')
24
- s.add_runtime_dependency('gli','2.13.1')
23
+ s.add_runtime_dependency('gli','>= 2.22.0')
25
24
  s.add_runtime_dependency('sqlite3','1.3.10')
26
25
  end
metadata CHANGED
@@ -1,29 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syclink
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Sugar
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2015-07-25 00:00:00.000000000 Z
10
+ date: 2025-01-04 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rspec
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - '='
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: 3.3.0
18
+ version: '3.13'
20
19
  type: :development
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - '='
23
+ - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: 3.3.0
25
+ version: '3.13'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: sass
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -42,16 +41,16 @@ dependencies:
42
41
  name: gli
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
- - - '='
44
+ - - ">="
46
45
  - !ruby/object:Gem::Version
47
- version: 2.13.1
46
+ version: 2.22.0
48
47
  type: :runtime
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
- - - '='
51
+ - - ">="
53
52
  - !ruby/object:Gem::Version
54
- version: 2.13.1
53
+ version: 2.22.0
55
54
  - !ruby/object:Gem::Dependency
56
55
  name: sqlite3
57
56
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +207,6 @@ homepage: https://github.com/sugaryourcoffee/syclink
208
207
  licenses:
209
208
  - MIT license (MIT)
210
209
  metadata: {}
211
- post_install_message:
212
210
  rdoc_options:
213
211
  - "--title"
214
212
  - test
@@ -229,9 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
227
  - !ruby/object:Gem::Version
230
228
  version: '0'
231
229
  requirements: []
232
- rubyforge_project:
233
- rubygems_version: 2.4.6
234
- signing_key:
230
+ rubygems_version: 3.6.2
235
231
  specification_version: 4
236
232
  summary: A link list html generator
237
233
  test_files: []