central 0.2.2 → 0.2.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/central.rb +23 -0
  3. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f09a5494f1121e5889aee183059d41319140ea3a
4
- data.tar.gz: 5532a00d795c9834d15d93c7b4eef85822ca0ecf
3
+ metadata.gz: c28cbd68d80c217678f5b6d81dc82cd2d4de4eed
4
+ data.tar.gz: 152e89721d347f991b177e6e81165619c3bfff70
5
5
  SHA512:
6
- metadata.gz: 0b065ed26599e71c9de8924aec7db1bd7e3052fba246ff6c65d61c87b968eb9523d798be83399a42c3930c25cbbf00fbfa58c192120ad8bf934311e20888888f
7
- data.tar.gz: 68afe51e029f493fe9247653c1d918c022e975117bb13b6cdac74483a0b2994db85df2bfe2113263485f68871525d66f3baadaaa33564d8817a604e6d68ccf6d
6
+ metadata.gz: b873dba32172c267f1419657c5d500736880dbcfe9f04b431984e489406e91ac55a809c9358bb71a361f1f5bf120e238cdf89dc5ee91d9fda7c8bd1c76070dcc
7
+ data.tar.gz: 70e5070de43a592bb09234e82e130025516139fbea193caf0cc6d1892ca9a90f98681b83be4118670a3ee01f0fdafcb6d738bf8f61ec2ae6e1a6d6e3a9796d4d
data/lib/central.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  # -------------------------------------------------------------------------
2
3
  # # central - dot files manager licensed under LGPLv3 (see LICENSE file) |
3
4
  # # written in Ruby by Dmitry Geurkov (d.geurkov@gmail.com) |
@@ -6,6 +7,7 @@
6
7
  require 'erb'
7
8
  require 'socket'
8
9
  require 'open3'
10
+ require 'fileutils'
9
11
 
10
12
  # get hostname
11
13
  def hostname
@@ -379,6 +381,27 @@ def ls(path,options={})
379
381
  return ls
380
382
  end
381
383
 
384
+ # copy
385
+ def copy(from,to)
386
+ from = abs(from)
387
+ to = abs(to)
388
+ if dir_exists?(from)
389
+ (Dir.entries(from).select { |f| f != "." and f != ".." }).each do |f|
390
+ FileUtils.mkdir_p(to)
391
+ copy("#{from}/#{f}","#{to}/#{f}")
392
+ end
393
+ else
394
+ unless file_exists?(from)
395
+ STDERR.puts "Couldn't access file #{from}..."
396
+ exit 1
397
+ end
398
+ if !file_exists?(to) or !FileUtils.compare_file(from,to)
399
+ FileUtils.copy_file(from,to)
400
+ puts "Copied file: #{from} → #{to}"
401
+ end
402
+ end
403
+ end
404
+
382
405
  # process erb template into an output_file
383
406
  def erb(file,output_file = nil)
384
407
  file = abs(file)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: central
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Geurkov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-11 00:00:00.000000000 Z
11
+ date: 2018-04-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: central dotfile management system
14
14
  email: d.geurkov@gmail.com
@@ -17,11 +17,11 @@ executables:
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - lib/central.rb
21
20
  - bin/central
21
+ - lib/central.rb
22
22
  homepage: https://github.com/troydm/central
23
23
  licenses:
24
- - LGPLv3
24
+ - LGPL-3.0
25
25
  metadata: {}
26
26
  post_install_message:
27
27
  rdoc_options: []
@@ -29,17 +29,17 @@ require_paths:
29
29
  - lib
30
30
  required_ruby_version: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  required_rubygems_version: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  requirements: []
41
41
  rubyforge_project:
42
- rubygems_version: 2.0.14.1
42
+ rubygems_version: 2.5.2
43
43
  signing_key:
44
44
  specification_version: 4
45
45
  summary: central dotfile management