oliver 1.6.3 → 1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a018083f29a78e5e8b047eecc3a7fc160c2f5298
4
- data.tar.gz: fea413d6340a753dca2932ba446c0859b5e75385
3
+ metadata.gz: 46f04ee1c2e862d1138be0d1b068b53779c45dad
4
+ data.tar.gz: 3ad99a979b36bcc0faa4917a331100b1f76fb16a
5
5
  SHA512:
6
- metadata.gz: 0e3ffb1f48aa28454e092c229f160759b3260299c6533cf7aa0c2e11da61bda17eda7efd980244d7d0698831d4c42c6e8a16006a46b31807c0edee7a367ccdeb
7
- data.tar.gz: b27bf4287ffd2436a09de7bba1186f699c14c6a16af1d4a47ae620af58316711a40a555ca703820e155780191272a6007b3d001d746804c55fcb604f323ba80b
6
+ metadata.gz: f9503166f657d4c93cc8b3eb961ffad04d1190dcc1d182ecade32e474b7dd95a4eeb7c24429e71006ec7cb5c5eb73f4c4a4cb98f42e096187917e5dd354e7fe7
7
+ data.tar.gz: 10e85d2abfc6a3acaade6e63f8237aeb23a8225628490f68dff2b44bd5b80ba59fe2efe45e81c64ffb1bcc7c893e32363df75ddc0e1c63ecbaac768024d7e070
data/README.md CHANGED
@@ -116,11 +116,15 @@ $ olive init
116
116
  ```yaml
117
117
  ---
118
118
  repos:
119
- - "trommel/oliver"
120
- - "istx25/dotfiles" # add any repo(s)
119
+ trommel:
120
+ - "oliver"
121
+ - "textymous"
122
+ istx25:
123
+ - "Fluorescent"
124
+ - "dotfiles"
121
125
  ---
122
126
 
123
- # use 3 spaces for indentation, not tabs!
127
+ # use 3 spaces for indentation, not tabs! :P
124
128
  # I spent, like, an hour trying to fix a non-existent bug because of this
125
129
  # smh so hard
126
130
  # by the way, this is YAML, for anyone interested
data/attempts/run.rb ADDED
@@ -0,0 +1,24 @@
1
+ # Require libraries
2
+ require 'awesome_print'
3
+ require 'yaml'
4
+
5
+ # Read and parse the YAML from the file
6
+ file = File.read('test.yml')
7
+ yaml = YAML.load(file)
8
+
9
+ # Map out the username and repos(array)
10
+ yaml['repos'].map do |username, repos|
11
+ # Assign individual repo from repos array
12
+ repos.each do |repo|
13
+ if !File.directory?(repo)
14
+ `git clone git://github.com/#{username}/#{repo} --quiet`
15
+ if File.directory?(repo)
16
+ puts "#{repo} was successfully cloned."
17
+ else
18
+ puts "An error occured while cloning #{repo}"
19
+ end
20
+ else
21
+ puts "#{repo} already exists."
22
+ end
23
+ end
24
+ end
data/attempts/test.yml ADDED
@@ -0,0 +1,10 @@
1
+ ---
2
+ repos:
3
+ trommel:
4
+ - "oliver"
5
+ - "calkoolator"
6
+
7
+ istx25:
8
+ - "dotfiles"
9
+ - "Fluorescent"
10
+ ---
@@ -15,7 +15,8 @@ def init
15
15
  if !File.file?(Name::OLIVER)
16
16
  File.open(Name::OLIVER, 'w') do |file|
17
17
  file.write("---\nrepos:\n")
18
- file.write(" - \"trommel/oliver\"\n---\n")
18
+ file.write(" trommel:\n - \"oliver\"\n---\n")
19
+ dir_name = '.' if dir_name.nil?
19
20
  puts "#{Rainbow(dir_name).green}/#{Rainbow(Name::OLIVER).green} has been created."
20
21
  end
21
22
  else
@@ -1,11 +1,11 @@
1
1
  def install
2
2
 
3
- # Back up your files, man
4
- # backup_directory_name = '.backup'
5
- # Dir.mkdir backup_directory_name unless File.directory? backup_directory_name
3
+ success = "#{Rainbow('Success').underline.green}:"
4
+ warning = "#{Rainbow('Warning').underline.yellow}:"
5
+ error = "#{Rainbow('Error').underline.red}:"
6
6
 
7
7
  # Fix this ASAP
8
- if $final['repos'].nil?
8
+ if $yaml['repos'].nil?
9
9
  message = "This will normally return a bug, so I'm just not going to do it.
10
10
  You have an empty repos list, though, and that's what's causing this bug.
11
11
  Try adding something to the list for the time being."
@@ -14,45 +14,42 @@ Try adding something to the list for the time being."
14
14
  end
15
15
 
16
16
  listed_repos = []
17
-
18
- $final['repos'].each do |what|
19
- listed_repos.push(what)
20
- end
21
- $final['repos'].each do |url|
22
-
23
- # Split the url in half
24
- splitted = url.split '/'
25
- repo = splitted[1]
26
- current_repos = Dir.entries '.'
27
- ['.', '..', '.backup', Name::OLIVER].each do |i|
28
- current_repos.delete(i)
17
+ $yaml['repos'].map do |username, repos|
18
+ repos.each do |repo|
19
+ listed_repos.push(repo)
29
20
  end
21
+ end
30
22
 
31
- # Clone the repo if it doesn't already exist
32
- if !File.directory?(repo)
33
- `git clone git://github.com/#{url} --quiet`
34
- if File.directory?(repo)
35
- puts "#{Rainbow(repo).green}/ has been successfully cloned."
36
- else
37
- puts "There was an error cloning #{Rainbow(repo).red}/."
38
- end
39
- else
40
- puts "#{Rainbow(repo).red}/ already exists."
41
- end
23
+ # Map out the username and repos(array)
24
+ $yaml['repos'].map do |username, repos|
25
+ # Assign individual repo from repos array
26
+ repos.each do |repo|
27
+ if !File.directory?(repo)
28
+ `git clone git://github.com/#{username}/#{repo} --quiet`
29
+ if File.directory?(repo)
30
+ puts "#{success} #{repo}/ has been cloned."
31
+ else
32
+ puts "#{error} Cloning #{repo}/ failed."
33
+ end
34
+ else
35
+ puts "#{warning} #{repo}/ already exists."
36
+ end
37
+ end
38
+ end
42
39
 
43
- # If the directory doesn't exist
44
- # in `Name::OLIVER`, move it to .backup
45
- current_repos.each do |directory_thing|
46
- if !listed_repos.to_s.include?(directory_thing) &&
47
- File.directory?(directory_thing)
48
- `yes | rm -r #{directory_thing}`
49
- # `mv #{directory_thing} .backup`
50
- else
51
- # do nothing at all
52
- # backup_color = Rainbow('.backup').red
53
- # repo_color = Rainbow(repo).red
54
- # puts "There was an error moving #{repo_color}/ to #{backup_color}/"
55
- end
40
+ # If the directory doesn't exist
41
+ # in `Name::OLIVER`, delete it
42
+ # This is an extreme hack
43
+ current_repos = Dir.entries '.'
44
+ ['.', '..', '.backup', Name::OLIVER].each do |i|
45
+ current_repos.delete(i)
46
+ end
47
+ current_repos.each do |directory|
48
+ unless listed_repos.to_s.include?(directory) &&
49
+ File.directory?(directory)
50
+ print "#{warning} Would you like to delete #{directory}/? (y/n) "
51
+ `yes | rm -r #{directory}` if STDIN.gets.chomp.downcase == 'y'
56
52
  end
57
53
  end
54
+
58
55
  end
@@ -4,7 +4,7 @@
4
4
  # # todo: if user has multiple repos,
5
5
  # # have one user key with an array of
6
6
  # # the user's repos
7
- # $final['repos'].each do |thing|
7
+ # $yaml['repos'].each do |thing|
8
8
  # new_thing = thing.split('/')
9
9
  # listed_repos.push(new_thing)
10
10
  # end
@@ -14,7 +14,7 @@
14
14
  # Simple enough :P
15
15
  def list
16
16
  counter = 0
17
- $final['repos'].each do |thing|
17
+ $yaml['repos'].each do |thing|
18
18
  repo = thing.split('/')[1] # might as well discard the username
19
19
  if File.directory?(repo)
20
20
  print Rainbow(repo).green
@@ -1,8 +1,8 @@
1
1
  def file_manager
2
2
  unless ARGV.nil?
3
3
  if File.file? Name::OLIVER
4
- body = File.read(Name::OLIVER.chomp)
5
- $final = YAML.load(body)
4
+ body = File.read(Name::OLIVER)
5
+ $yaml = YAML.load(body)
6
6
  else
7
7
  puts "#{Rainbow(Name::OLIVER).red} does not exist."
8
8
  end
@@ -1,5 +1,5 @@
1
1
  # The main module for
2
2
  # Oliver's version
3
3
  module Oliver
4
- VERSION = '1.6.3'
4
+ VERSION = '1.7'
5
5
  end
data/run.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'yaml'
2
+
3
+ file = File.read('test.yml')
4
+ $yaml = YAML.load(file)
5
+
6
+ def clone
7
+ $yaml['repos'].map do |username, repos|
8
+ repos.each do |repo|
9
+ if !File.directory?(repo)
10
+ `git clone git://github.com/#{username}/#{repo} --quiet`
11
+ if File.directory? repo
12
+ puts "Successfully cloned #{username}/#{repo}."
13
+ else
14
+ puts "There was an error while cloning #{repo}."
15
+ end
16
+ else
17
+ puts "#{repo} already exists."
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ clone
data/test.yml ADDED
@@ -0,0 +1,10 @@
1
+ ---
2
+ repos:
3
+ trommel:
4
+ - "oliver"
5
+ - "calkoolator"
6
+
7
+ istx25:
8
+ - "dotfiles"
9
+ - "Fluorescent"
10
+ ---
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oliver
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: '1.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh
@@ -68,6 +68,8 @@ files:
68
68
  - LICENSE
69
69
  - README.md
70
70
  - Rakefile
71
+ - attempts/run.rb
72
+ - attempts/test.yml
71
73
  - bin/olive
72
74
  - bin/oliver
73
75
  - lib/oliver.rb
@@ -83,7 +85,9 @@ files:
83
85
  - lib/oliver/oliver_file_name.rb
84
86
  - lib/oliver/version.rb
85
87
  - oliver.gemspec
88
+ - run.rb
86
89
  - spec/TESTING.md
90
+ - test.yml
87
91
  homepage: https://github.com/trommel/oliver
88
92
  licenses: []
89
93
  metadata: {}