myosx 0.2.2 → 0.2.4

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
  SHA1:
3
- metadata.gz: b15858a0a89d514f175d4ef2765547599faf5f5d
4
- data.tar.gz: f7bb5f54c355738b3f3ce778209e593cd7992f8c
3
+ metadata.gz: 5452e9a2e38902cd1a893f6ede7202e367bf2baf
4
+ data.tar.gz: 725ffe4995b8f4e21a0295bfaff50865214febd4
5
5
  SHA512:
6
- metadata.gz: a88fe489da16a3cc974241f46e7a91777d26b8a5da20b4cd7ad71e71bd9c58453e9352670b7a93751dd2dec066b5fe79449f70d2a4beffdf920c05cdd4ffa64a
7
- data.tar.gz: 91fb8d1ec15874bad0aa905d4c34f97a8458d97ecc4d036e4901a2398c95b453804e154eb1111a9ed41eda4137d39460f7bae4e77e82ee62f0181f2e1c3b2b8a
6
+ metadata.gz: 0a2c76eece56bdfe1418e2f5afd498026bdc440593f57866d68df9ba9858c1a0c1e5be155bfa0d4ea4bdc2c5082ffc2d09380ccf3f1443744947e4b54e9361fd
7
+ data.tar.gz: c6a8f2ce2c54427a85fe2cb76d86fb047e837821ea2787af45a2ef9cd69b21ec3b6ad970b8adbd5b8c86ba50c65712ae6537c88408e6f858ab7ba69a75a48d2a
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ spec/stub/dotfiles/
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
- # Myosx
1
+ [![Build Status](https://travis-ci.org/surminus/myosx.svg?branch=master)](https://travis-ci.org/surminus/myosx)
2
+
3
+ # MyOSX
4
+
5
+ MyOSX configures OSX how I like it
2
6
 
3
- myosx configures osx how I like it.
4
7
 
5
8
  ## Setup
6
9
 
@@ -28,7 +31,7 @@ Use the example config file to set some things (`example.myosx.cnf`)
28
31
  `MYOSX_WORKSPACE`
29
32
 
30
33
  This is where everything is stored such as Brewfiles and any other repositories
31
- that it may pull. Default is '~/.myosx'
34
+ that it may pull. Default is `~/.myosx`
32
35
 
33
36
 
34
37
  ## Contributing
data/lib/myosx/config.rb CHANGED
@@ -5,23 +5,22 @@ require 'yaml'
5
5
  require 'git'
6
6
 
7
7
  class Config
8
- def initialize
9
- config_location = ENV['MYOSX_CONFIG'] || '~/.myosx.cnf'
10
- config_file = File.expand_path(config_location)
11
- raise "Cannot find config file: #{config_file}" unless File.exist?(config_file)
12
- $global_config = YAML.load_file(config_file)
13
- $workspace = workspace_directory
8
+ def config_file
9
+ ENV["MYOSX_CONFIG"] || File.expand_path('~/.myosx.cnf')
10
+ end
11
+
12
+ def global
13
+ YAML.load_file(config_file)
14
14
  end
15
15
 
16
16
  def workspace_directory
17
- workspace_dir_name = ENV['MYOSX_WORKSPACE'] || '~/.myosx/'
18
- return File.expand_path(workspace_dir_name)
17
+ ENV['MYOSX_WORKSPACE'] || File.expand_path('~/.myosx/')
19
18
  end
20
19
 
21
- def create_workspace
22
- unless Dir.exists?($workspace)
23
- puts "Creating workspace: #{workspace_directory}"
24
- Dir.mkdir("#{workspace_directory}", 0750)
20
+ def create_workspace(directory)
21
+ unless Dir.exists?(directory)
22
+ puts "Creating workspace: #{directory}"
23
+ Dir.mkdir("#{directory}", 0750)
25
24
  end
26
25
  end
27
26
  end
@@ -8,20 +8,20 @@ require_relative 'config'
8
8
 
9
9
  class Dotfiles < Config
10
10
  def config
11
- $global_config['dotfiles']
11
+ Config.new.global['dotfiles']
12
12
  end
13
13
 
14
14
  def dotfiledir
15
- File.join($workspace, 'dotfiles')
15
+ File.join(Config.new.workspace_directory, 'dotfiles')
16
16
  end
17
17
 
18
- def repo(repo)
18
+ def repo(repo, target, local_repo = 'dotfiles')
19
19
  if Git.ls_remote(repo)
20
- unless File.exist?(dotfiledir)
21
- puts "Cloning #{dotfile_repo}"
22
- Git.clone(repo, 'dotfiles', :path => $workspace)
20
+ unless File.exist?(target)
21
+ puts "Cloning #{repo}"
22
+ Git.clone(repo, local_repo, :path => File.dirname(target))
23
23
  else
24
- g = Git.init(dotfiledir)
24
+ g = Git.init(target)
25
25
  puts "Pulling latest #{repo}"
26
26
  g.pull
27
27
  end
@@ -29,23 +29,27 @@ class Dotfiles < Config
29
29
  end
30
30
 
31
31
  def link(file, dest)
32
- source_file = "#{dotfiledir}/#{file}"
33
-
34
32
  dest = File.expand_path(dest)
35
- raise "#{source_file} doesn't exist! Check your config or repo" unless File.exist?(source_file)
33
+ raise "#{file} doesn't exist! Check your config or repo" unless File.exist?(file)
36
34
 
37
35
  if File.exist?(dest)
36
+ backup_file = "#{dest}.#{Date.today.to_s}"
37
+ puts "Creating backup of #{dest} called: #{backup_file}"
38
+ File.rename(dest, backup_file)
39
+ end
40
+
41
+ if File.symlink?(dest)
38
42
  File.delete(dest)
39
43
  end
40
44
 
41
- puts "Linking #{source_file} to #{dest}"
42
- File.symlink(source_file, dest)
45
+ puts "Linking #{file} to #{dest}"
46
+ File.symlink(file, dest)
43
47
  end
44
48
 
45
49
  def exec
46
- if repo(config['repo'])
47
- config['files'].each do |k, v|
48
- link(k, v)
50
+ if repo(config['repo'], dotfiledir)
51
+ config['files'].each do |file, dest|
52
+ link("#{dotfiledir}/#{file}", dest)
49
53
  end
50
54
  end
51
55
  end
@@ -9,7 +9,7 @@ require_relative 'config'
9
9
  class Homebrew < Config
10
10
 
11
11
  def config
12
- $global_config['homebrew']
12
+ Config.new.global['homebrew']
13
13
  end
14
14
 
15
15
  def packages
@@ -17,7 +17,7 @@ class Homebrew < Config
17
17
  end
18
18
 
19
19
  def brewfile
20
- return File.join($workspace, 'Brewfile')
20
+ return File.join(Config.new.workspace_directory, 'Brewfile')
21
21
  end
22
22
 
23
23
  def brewfile_out(packages)
data/lib/myosx/rbenv.rb CHANGED
@@ -9,7 +9,7 @@ require_relative 'config'
9
9
 
10
10
  class Rbenv < Config
11
11
  def config
12
- $global_config['rbenv']
12
+ Config.new.global['rbenv']
13
13
  end
14
14
 
15
15
  def install
data/lib/myosx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Myosx
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.4"
3
3
  end
data/lib/myosx.rb CHANGED
@@ -7,17 +7,17 @@ require "myosx/rbenv"
7
7
  module Myosx
8
8
  class Exec < Config
9
9
  def initialize
10
- Config.new.create_workspace
10
+ Config.new.create_workspace(Config.new.workspace_directory)
11
11
 
12
- if $global_config['dotfiles']
12
+ if Config.new.global['dotfiles']
13
13
  Dotfiles.new.exec
14
14
  end
15
15
 
16
- if $global_config['homebrew']
16
+ if Config.new.global['homebrew']
17
17
  Homebrew.new.exec
18
18
  end
19
19
 
20
- if $global_config['rbenv']
20
+ if Config.new.global['rbenv']
21
21
  Rbenv.new.exec
22
22
  end
23
23
  end
data/myosx.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["surminus@gmail.com"]
11
11
 
12
12
  spec.summary = %q{myosx configures OSX how I like it}
13
- spec.homepage = "https://github.com/surminus/myosx."
13
+ spec.homepage = "https://github.com/surminus/myosx"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myosx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laura Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-25 00:00:00.000000000 Z
11
+ date: 2017-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -95,7 +95,7 @@ files:
95
95
  - lib/myosx/shell.rb
96
96
  - lib/myosx/version.rb
97
97
  - myosx.gemspec
98
- homepage: https://github.com/surminus/myosx.
98
+ homepage: https://github.com/surminus/myosx
99
99
  licenses:
100
100
  - MIT
101
101
  metadata: {}