dotter_dotfiles 0.2.0 → 0.3.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.
@@ -0,0 +1,29 @@
1
+ require 'git'
2
+ require 'dotter/utilities'
3
+ module Dotter
4
+ class ForeignGitRepo < GitRepo
5
+ def initialize(package, init = false, source_repository = '')
6
+ @package = package
7
+ @project_path = package_path(package)
8
+ @origin = source_repository
9
+ unless init
10
+ open
11
+ else
12
+ self.init(source_repository)
13
+ end
14
+ end
15
+
16
+ def init(source_url)
17
+ @repo = Git.clone(source_url, @project_path.to_s)
18
+ end
19
+
20
+ def open
21
+ @repo = Git.open(@project_path)
22
+ @log = @repo.log
23
+ end
24
+
25
+ def update
26
+ @repo.pull
27
+ end
28
+ end
29
+ end
@@ -1,43 +1,52 @@
1
1
  require 'git'
2
2
  module Dotter
3
- require 'dotter/utilities'
4
- class GitRepo
5
- include Utilities
6
- def initialize(package,init=false)
7
- @package = package
8
- @project_path = package_path(package)
9
- @metadata_path = repo_path(package)
10
- @metadata_indexes_path = index_path(package)
11
- unless init
12
- self.open()
13
- else
14
- self.init()
15
- end
16
- end
17
- def open()
18
- @repo = Git.open(@project_path.to_s, { :repository => @metadata_path.to_s, :index => @metadata_indexes_path.to_s})
19
- @log = @repo.log
20
- end
21
- def init()
22
- @repo = Git.init(@project_path.to_s, { :repository => @metadata_path.to_s, :index => @metadata_indexes_path.to_s})
23
- end
24
- attr_reader :repo
25
- attr_reader :project_path
26
- attr_reader :package
27
- attr_reader :metadata_path
28
- attr_reader :metadata_indexes_path
29
- attr_reader :log
30
- def add(file)
31
- @repo.add(file)
32
- end
33
- def reset()
34
- @repo.reset()
35
- end
36
- def commit_all(commit_message)
37
- @repo.commit_all(commit_message)
38
- end
39
- def commit(commit_message)
40
- @repo.commit(commit_message)
41
- end
42
- end
3
+ require 'dotter/utilities'
4
+ class GitRepo
5
+ include Utilities
6
+ def initialize(package, init = false, bare = false)
7
+ @package = package
8
+ @project_path = package_path(package)
9
+ @metadata_path = repo_path(package)
10
+ @metadata_indexes_path = index_path(package)
11
+ unless init
12
+ open
13
+ else
14
+ self.init(bare)
15
+ end
16
+ end
17
+
18
+ def open
19
+ @repo = Git.open(@project_path.to_s, repository: @metadata_path.to_s, index: @metadata_indexes_path.to_s)
20
+ @log = @repo.log
21
+ end
22
+
23
+ def init(bare = false)
24
+ unless bare
25
+ @repo = Git.init(@project_path.to_s, repository: @metadata_path.to_s, index: @metadata_indexes_path.to_s)
26
+ else
27
+ @repo = Git.init(@project_path.to_s, repository: @metadata_path.to_s, index: @metadata_indexes_path.to_s, bare: true)
28
+ end
29
+ end
30
+ attr_reader :repo
31
+ attr_reader :project_path
32
+ attr_reader :package
33
+ attr_reader :metadata_path
34
+ attr_reader :metadata_indexes_path
35
+ attr_reader :log
36
+ def add(file)
37
+ @repo.add(file)
38
+ end
39
+
40
+ def reset
41
+ @repo.reset
42
+ end
43
+
44
+ def commit_all(commit_message)
45
+ @repo.commit_all(commit_message)
46
+ end
47
+
48
+ def commit(commit_message)
49
+ @repo.commit(commit_message)
50
+ end
51
+ end
43
52
  end
@@ -1,60 +1,81 @@
1
1
  require 'dotter/utilities'
2
2
  require 'dotter/configuration'
3
3
  require 'dotter/gitrepo'
4
+ require 'dotter/foreigngitrepo'
4
5
  module Dotter
5
- class Package
6
- include Utilities
7
- def initialize(name)
8
- @name = name
9
- @config = Configuration.new
10
- @our_config = @config.package_config(@name)
11
- if self.tracked?
12
- @repo = GitRepo.new(name)
13
- end
14
- end
15
- def stow
16
- go_to_dotfiles
17
- returned_output = `stow -v #{@name}`
18
- @config.set_state(@name, 'stowed')
19
- returned_output
20
- end
21
- def unstow
22
- go_to_dotfiles
23
- returned_output = `stow -Dv #{@name}`
24
- @config.set_state(@name, 'unstowed')
25
- returned_output
26
- end
27
- def track
28
- @repo = GitRepo.new(@name,true)
29
- @config.track(@name)
30
- end
31
- def update
32
- go_to_dotfiles
33
- returned_output = `stow -Rv #{@name}`
34
- end
35
- def stowed?
36
- @our_config['state'] == 'stowed'
37
- end
38
- def unstowed?
39
- !self.stowed?
40
- end
41
- def tracked?
42
- @our_config['tracked']
43
- end
44
- def untracked?
45
- !self.tracked?
46
- end
47
- def to_s
48
- @name
49
- end
50
- def public?
51
- @our_config['public'] = true
52
- end
53
- def private?
54
- !self.public?
55
- end
56
- attr_reader :name
57
- attr_accessor :config
58
- attr_reader :repo
59
- end
6
+ class Package
7
+ include Utilities
8
+ def initialize(name)
9
+ @name = name
10
+ @config = Configuration.new
11
+ @our_config = @config.package_config(@name)
12
+ if self.tracked?
13
+ unless self.foreign?
14
+ @repo = GitRepo.new(name)
15
+ else
16
+ @repo = ForeignGitRepo.new(name)
17
+ end
18
+ end
19
+ end
20
+
21
+ def stow
22
+ go_to_dotfiles
23
+ returned_output = `stow -v #{@name}`
24
+ @config.set_state(@name, 'stowed')
25
+ returned_output
26
+ end
27
+
28
+ def unstow
29
+ go_to_dotfiles
30
+ returned_output = `stow -Dv #{@name}`
31
+ @config.set_state(@name, 'unstowed')
32
+ returned_output
33
+ end
34
+
35
+ def track
36
+ @repo = GitRepo.new(@name, true)
37
+ @config.track(@name)
38
+ end
39
+
40
+ def update
41
+ go_to_dotfiles
42
+ @repo.update if self.foreign?
43
+ returned_output = `stow -Rv #{@name}`
44
+ end
45
+
46
+ def stowed?
47
+ @our_config['state'] == 'stowed'
48
+ end
49
+
50
+ def unstowed?
51
+ !self.stowed?
52
+ end
53
+
54
+ def tracked?
55
+ @our_config['tracked']
56
+ end
57
+
58
+ def untracked?
59
+ !self.tracked?
60
+ end
61
+
62
+ def foreign?
63
+ @our_config['type'] == 'git_repo'
64
+ end
65
+
66
+ def to_s
67
+ @name
68
+ end
69
+
70
+ def public?
71
+ @our_config['public'] == true
72
+ end
73
+
74
+ def private?
75
+ !self.public?
76
+ end
77
+ attr_reader :name
78
+ attr_accessor :config
79
+ attr_reader :repo
80
+ end
60
81
  end
@@ -2,41 +2,46 @@ require 'git'
2
2
  require 'dotter/utilities'
3
3
  require 'dotter/gitrepo'
4
4
  module Dotter
5
- class PublicGitRepo
6
- include Utilities
7
- def initialize(init=false)
8
- @project_path = package_path('public')
9
- unless init
10
- self.open()
11
- else
12
- self.init()
13
- end
14
- end
15
- def open
16
- @repo = Git.open(@project_path.to_s)
17
- end
18
- def init
19
- @repo = Git.init(@project_path.to_s)
20
- end
21
- def add_package(package)
22
- Dir.chdir(@project_path)
23
- packagerepo = GitRepo.new(package)
24
- package_repo = packagerepo.repo
25
- @repo.add_remote(package.to_s, package_repo)
26
- subtree_output = `git subtree add --prefix #{package.to_s} #{package.to_s} master`
27
- conf = Configuration.new
28
- conf.publish(package)
29
- subtree_output
30
- end
31
- def remove_package(package)
32
- Dir.chdir(@project_path)
33
- # This was broken with ruby-git. Someone else should check.
34
- `git remote remove #{package}`
35
- FileUtils.remove_dir(package)
36
- @repo.commit_all('Removed package #{package}')
37
- conf = Configuration.new
38
- conf.unpublish(package)
39
- end
40
- attr_reader :repo
41
- end
5
+ class PublicGitRepo
6
+ include Utilities
7
+ def initialize(init = false)
8
+ @project_path = package_path('public')
9
+ unless init
10
+ open
11
+ else
12
+ self.init
13
+ end
14
+ end
15
+
16
+ def open
17
+ @repo = Git.open(@project_path.to_s)
18
+ end
19
+
20
+ def init
21
+ @repo = Git.init(@project_path.to_s)
22
+ end
23
+
24
+ def add_package(package)
25
+ Dir.chdir(@project_path)
26
+ other_package = Package.new(package)
27
+ packagerepo = other_package.repo
28
+ package_repo = packagerepo.repo
29
+ @repo.add_remote(package.to_s, package_repo)
30
+ subtree_output = `git subtree add --prefix #{package.to_s} #{package.to_s} master`
31
+ conf = Configuration.new
32
+ conf.publish(package)
33
+ subtree_output
34
+ end
35
+
36
+ def remove_package(package)
37
+ Dir.chdir(@project_path)
38
+ # This was broken with ruby-git. Someone else should check.
39
+ `git remote remove #{package}`
40
+ FileUtils.remove_dir(package)
41
+ @repo.commit_all('Removed package #{package}')
42
+ conf = Configuration.new
43
+ conf.unpublish(package)
44
+ end
45
+ attr_reader :repo
46
+ end
42
47
  end
@@ -1,34 +1,40 @@
1
- require 'pathname'
2
- module Dotter
3
- module Utilities
4
- @@dotfiles_path = Pathname(File.expand_path('~/dotfiles'))
5
- def dotfiles_path
6
- @@dotfiles_path
7
- end
8
- def go_to_dotfiles()
9
- Dir.chdir(@@dotfiles_path)
10
- end
11
- def package_path(package)
12
- @@dotfiles_path + package
13
- end
14
- @@dotter_path = @@dotfiles_path + 'dotter'
15
- def dotter_path
16
- @@dotter_path
17
- end
18
- def repo_path(package)
19
- @@dotter_path + '.dotter/gitrepos/' + package
20
- end
21
- def index_path(package)
22
- @@dotter_path + '.dotter/indexes/' + package
23
- end
24
- def all_package_names
25
- directory = Pathname.new(@@dotfiles_path)
26
- directories = directory.children.select { |c| c.directory? }
27
- package_names = []
28
- directories.each do |directory|
29
- package_names.push(directory.basename)
30
- end
31
- package_names
32
- end
33
- end
1
+ require 'pathname'
2
+ module Dotter
3
+ module Utilities
4
+ @@dotfiles_path = Pathname(File.expand_path('~/dotfiles'))
5
+ def dotfiles_path
6
+ @@dotfiles_path
7
+ end
8
+
9
+ def go_to_dotfiles
10
+ Dir.chdir(@@dotfiles_path)
11
+ end
12
+
13
+ def package_path(package)
14
+ @@dotfiles_path + package
15
+ end
16
+ @@dotter_path = @@dotfiles_path + 'dotter'
17
+ @@public_repo_path = @@dotfiles_path + 'public'
18
+ def dotter_path
19
+ @@dotter_path
20
+ end
21
+
22
+ def repo_path(package)
23
+ @@dotter_path + '.dotter/gitrepos/' + package
24
+ end
25
+
26
+ def index_path(package)
27
+ @@dotter_path + '.dotter/indexes/' + package
28
+ end
29
+
30
+ def all_package_names
31
+ directory = Pathname.new(@@dotfiles_path)
32
+ directories = directory.children.select(&:directory?)
33
+ package_names = []
34
+ directories.each do |directory|
35
+ package_names.push(directory.basename)
36
+ end
37
+ package_names
38
+ end
39
+ end
34
40
  end
@@ -1,4 +1,4 @@
1
1
  module Dotter
2
2
  # dotter version
3
- VERSION = "0.2.0"
3
+ VERSION = '0.3.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotter_dotfiles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Hodgkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-10 00:00:00.000000000 Z
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,9 +129,11 @@ executables:
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - ".codeclimate.yml"
132
133
  - ".document"
133
134
  - ".gitignore"
134
135
  - ".rdoc_options"
136
+ - ".rubocop.yml"
135
137
  - ChangeLog.md
136
138
  - Gemfile
137
139
  - LICENSE.txt
@@ -142,6 +144,7 @@ files:
142
144
  - lib/dotter.rb
143
145
  - lib/dotter/cli.rb
144
146
  - lib/dotter/configuration.rb
147
+ - lib/dotter/foreigngitrepo.rb
145
148
  - lib/dotter/gitrepo.rb
146
149
  - lib/dotter/package.rb
147
150
  - lib/dotter/publicgitrepo.rb