oliver 1.7.3 → 1.8

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: df3b5d6c2754e5047ac2a186c2a0929995b77d25
4
- data.tar.gz: 088f465ab3f3dde7ab4e042e456cc7c87a8fcea0
3
+ metadata.gz: d4d9ab49c3e31bdebe189d1a1c2f2bf705729f97
4
+ data.tar.gz: dbc1a02fdd998eadbe761238f56730583d2df8f4
5
5
  SHA512:
6
- metadata.gz: 1a46ea71140f8e81e1302126acc9b25dbde473dcbdcfa5b17e2085b0e6f9e656a77bf7a20878aa3e111783530204fdedc0a367b76dc0d9119aad9427a1e1ed91
7
- data.tar.gz: e0c48f5d7ca851f3d42fc645472a815ad4ef51eca80706a0f12102a763ca82a8b5958a9b4ca1751138a9e9ba8c81db8483482ef758d3ad5dc6cb20e9da1b52ac
6
+ metadata.gz: f208312d2be3f008d60880c88fc26434b91f7363c2537b9014dc3e50f6653834014095628660c5c0cadfe4eb9b843bf29e286dedc4d17b21260287dae6916ad9
7
+ data.tar.gz: 2fbb46e9e6812ef8cd71610868bb037c709ad17a848e5fdcd5b9a5d94dddc0ee75839e9ec3cd8c315a900e0fa5c0f78c420f8ca80685c3b458a60a6e1bfc13ae
data/IDEAS.md CHANGED
@@ -3,7 +3,7 @@ ideas
3
3
 
4
4
  ideas that should or have already been implemented.
5
5
 
6
- - [x] make the backup directory hidden (`.backup`)
6
+ - [x] ~~make the backup directory hidden (`.backup`)~~
7
7
 
8
8
  - [ ] add verbose mode (`--verbose`) so things like `olive install` will have output like
9
9
 
@@ -25,7 +25,7 @@ prefs:
25
25
  - "no colour" # this too :P
26
26
  ```
27
27
 
28
- - [ ] when running `olive list`, list the repos that are currently in the directory against
28
+ - [x] when running `olive list`, list the repos that are currently in the directory against
29
29
  the repos that are currently being tracked. repos that are in both (the `Olivefile` and the current directory)
30
30
  should be listed as green (using rainbow), and directories that are only found in one of the two options
31
31
  will be listed as red.
@@ -47,7 +47,7 @@ remove them from the list and run
47
47
  $ olive install
48
48
  ```
49
49
 
50
- I spent, like, 50 minutes on this and I can't figure out a good way
51
- to do it, though, so.. yeah
50
+ ~~I spent, like, 50 minutes on this and I can't figure out a good way
51
+ to do it, though, so.. yeah~~
52
52
 
53
- I'll add it as soon as I can figure it out.
53
+ ~~I'll add it as soon as I can figure it out.~~
data/README.md CHANGED
@@ -122,7 +122,7 @@ repos:
122
122
  istx25:
123
123
  - "Fluorescent"
124
124
  - "dotfiles"
125
- misc: # use the misc category for old syntax
125
+ misc: # use the misc category for old syntax. these don't really work, yet
126
126
  - "trommel/calkoolator"
127
127
  ---
128
128
 
@@ -155,7 +155,7 @@ this will add it to the tracking list
155
155
  ```bash
156
156
  $ olive add username/repo
157
157
  ```
158
- ### remove (move to `.backup`) and stop tracking a repo
158
+ ### remove (delete) and stop tracking a repo
159
159
 
160
160
  this will remove it from the tracking list
161
161
  and locally delete the repo
@@ -169,7 +169,7 @@ $ olive remove username/repo
169
169
  list all of the repos that're being tracked
170
170
 
171
171
  ```bash
172
- $ oliver list
172
+ $ olive list
173
173
  ```
174
174
 
175
175
  ### update (`git pull`) each repo
@@ -178,7 +178,7 @@ essentially `cd` into each individual
178
178
  repo and run `git pull`
179
179
 
180
180
  ```bash
181
- $ oliver update
181
+ $ olive update
182
182
  ```
183
183
 
184
184
  extras
data/lib/oliver.rb CHANGED
@@ -1,25 +1,13 @@
1
- # holy shit, this is massive
2
- # twss
3
- require 'rainbow'
4
- require 'YAML'
5
- %w(oliver_file_name file_manager arguments version).each do |file|
6
- require_relative "oliver/#{file}"
7
- end
1
+ # Require files
2
+ %w(rainbow YAML).each { |file| require file }
3
+ require_relative 'oliver/version'
8
4
 
9
5
  # if the user doesn't want to use rainbow
10
6
  # just disable it completely
11
7
  Rainbow.enabled = false if ARGV[-1] == 'colour=off'
12
8
 
13
- # Right off the bat,
14
- # if the user doesn't specify even one argument
15
- # just give him some help and quit oliver
16
- if ARGV[0].nil?
17
- help
18
- exit
19
- end
20
-
21
9
  # Arguments
22
- arguments
10
+ require_relative 'oliver/arguments'
23
11
 
24
- # just exit at this point
12
+ # Just exit at this point
25
13
  exit
@@ -1,5 +1,2 @@
1
- def add
2
- argument?(1)
3
- puts "todo: add (#{ARGV[1]}) to #{Name::OLIVER}"
4
- # puts "added #{Rainbow(ARGV[1]).green} to #{Rainbow(Name::OLIVER).green}."
5
- end
1
+ require_relative '../oliver_file_name'
2
+ puts "TODO: add (#{ARGV[1]}) to #{Name::OLIVER}"
@@ -1,3 +1,4 @@
1
+ require_relative '../oliver_file_name'
1
2
  # Help the user with their heavy troubles
2
3
  def help
3
4
  helper = [
@@ -1,32 +1,31 @@
1
- def init
2
- unless ARGV[1].nil?
3
- if ARGV[2].nil?
4
- dir_name = 'olives'
1
+ require_relative '../oliver_file_name'
2
+ unless ARGV[1].nil?
3
+ if ARGV[2].nil?
4
+ dir_name = 'olives'
5
+ else
6
+ dir_name = ARGV[2]
7
+ end
8
+ if ARGV[1].downcase == '--directory' || ARGV[1].downcase == '-d'
9
+ if !File.directory?(dir_name)
10
+ Dir.mkdir(dir_name)
11
+ Dir.chdir(dir_name)
5
12
  else
6
- dir_name = ARGV[2]
7
- end
8
- if ARGV[1].downcase == '--directory' || ARGV[1].downcase == '-d'
9
- if !File.directory?(dir_name)
10
- Dir.mkdir(dir_name)
11
- Dir.chdir(dir_name)
12
- else
13
- puts "#{Rainbow('Error').underline.red}: #{dir_name}/ already exists."
14
- exit
15
- end
16
- puts "#{Rainbow(dir_name).green}/ has been created."
13
+ puts "#{Rainbow('Error').underline.red}: #{dir_name}/ already exists."
14
+ exit
17
15
  end
16
+ puts "#{Rainbow(dir_name).green}/ has been created."
18
17
  end
18
+ end
19
19
 
20
- if !File.file?(Name::OLIVER)
21
- File.open(Name::OLIVER, 'w') do |file|
22
- file.write("---\nrepos:\n")
23
- file.write(" trommel:\n - \"oliver\"\n---\n")
24
- dir_name = '.' if dir_name.nil?
25
- green_dir_name = Rainbow(dir_name).green
26
- green_oliver_file_name = Rainbow(Name::OLIVER).green
27
- puts "#{green_dir_name}/#{green_oliver_file_name} has been created."
28
- end
29
- else
30
- puts "#{Rainbow(Name::OLIVER).red} already exists."
20
+ if !File.file?(Name::OLIVER)
21
+ File.open(Name::OLIVER, 'w') do |file|
22
+ file.write("---\nrepos:\n")
23
+ file.write(" trommel:\n - \"oliver\"\n---\n")
24
+ dir_name = '.' if dir_name.nil?
25
+ green_dir_name = Rainbow(dir_name).green
26
+ green_oliver_file_name = Rainbow(Name::OLIVER).green
27
+ puts "#{green_dir_name}/#{green_oliver_file_name} has been created."
31
28
  end
29
+ else
30
+ puts "#{Rainbow(Name::OLIVER).red} already exists."
32
31
  end
@@ -1,82 +1,80 @@
1
- def install
1
+ require_relative '../oliver_file_name'
2
+ # Make these public later :P
3
+ success = "#{Rainbow('Success').underline.green}:"
4
+ warning = "#{Rainbow('Warning').underline.yellow}:"
5
+ error = "#{Rainbow('Error').underline.red}:"
2
6
 
3
- # Make these public later :P
4
- success = "#{Rainbow('Success').underline.green}:"
5
- warning = "#{Rainbow('Warning').underline.yellow}:"
6
- error = "#{Rainbow('Error').underline.red}:"
7
-
8
- # Fix this ASAP
9
- if $yaml['repos'].nil?
10
- message = "This will normally return a bug, so I'm just not going to do it.
7
+ # Fix this ASAP
8
+ if $yaml['repos'].nil?
9
+ message = "This will normally return a bug, so I'm just not going to do it.
11
10
  You have an empty repos list, though, and that's what's causing this bug.
12
11
  Try adding something to the list for the time being."
13
- puts Rainbow(message).red
14
- exit
15
- end
12
+ puts Rainbow(message).red
13
+ exit
14
+ end
16
15
 
17
- # Create the empty listed_repos array for later
18
- listed_repos = []
16
+ # Create the empty listed_repos array for later
17
+ listed_repos = []
19
18
 
20
- # Map out the username and repos(array)
21
- $yaml['repos'].map do |username, repos|
22
- # Exit with error if the username or repos is empty
23
- if username.nil?
24
- puts "#{error} Your usernames look a little nil."
25
- exit
26
- end
27
- if repos.nil?
28
- puts "#{error} Your repos look a little nil."
29
- exit
19
+ # Map out the username and repos(array)
20
+ $yaml['repos'].map do |username, repos|
21
+ # Exit with error if the username or repos is empty
22
+ if username.nil?
23
+ puts "#{error} Your usernames look a little nil."
24
+ exit
25
+ end
26
+ if repos.nil?
27
+ puts "#{error} Your repos look a little nil."
28
+ exit
29
+ end
30
+ # Assign individual repo from repos array
31
+ repos.each do |repo|
32
+ # Add each repo to the listed_repos array
33
+ repos.each do |repo|
34
+ listed_repos.push(repo)
30
35
  end
31
- # Assign individual repo from repos array
32
- repos.each do |repo|
33
- # Add each repo to the listed_repos array
34
- repos.each do |repo|
35
- listed_repos.push(repo)
36
- end
37
- if username.downcase == 'misc'
38
- split = repo.split('/')
39
- if !File.directory?(split[1])
40
- `git clone git://github.com/#{repo} --quiet`
41
- if File.directory?(split[1])
42
- puts "#{success} #{split[1]}/ was cloned."
43
- else
44
- puts "#{error} #{split[1]} was not cloned."
45
- end
36
+ if username.downcase == 'misc'
37
+ split = repo.split('/')
38
+ if !File.directory?(split[1])
39
+ `git clone git://github.com/#{repo} --quiet`
40
+ if File.directory?(split[1])
41
+ puts "#{success} #{split[1]}/ was cloned."
42
+ else
43
+ puts "#{error} #{split[1]} was not cloned."
46
44
  end
47
- exit
48
45
  end
49
- if !File.directory?(repo)
50
- # Clone the repo if the directory doesn't already exist
51
- `git clone git://github.com/#{username}/#{repo} --quiet`
52
- if File.directory?(repo)
53
- # If the directory exists after the repo
54
- # has been cloned, give a success message
55
- puts "#{success} #{repo}/ has been cloned."
56
- else
57
- # If the directory doesn't exist after the
58
- # has been cloned, give an error message
59
- puts "#{error} Cloning #{repo}/ failed."
60
- end
61
- else
62
- # Give a warning message if the repo already exists
63
- puts "#{warning} #{repo}/ already exists."
64
- end
65
- end
66
- end
67
-
68
- # If the directory doesn't exist
69
- # in `Name::OLIVER`, delete it
70
- # This is an extreme hack
71
- current_repos = Dir.entries '.'
72
- ['.', '..', '.backup', Name::OLIVER].each do |i|
73
- current_repos.delete(i)
74
- end
75
- current_repos.each do |directory|
76
- unless listed_repos.to_s.include?(directory) &&
77
- File.directory?(directory)
78
- print "#{warning} Would you like to delete #{directory}/? (y/n): "
79
- `yes | rm -r #{directory}` if STDIN.gets.chomp.downcase == 'y'
46
+ exit
80
47
  end
48
+ if !File.directory?(repo)
49
+ # Clone the repo if the directory doesn't already exist
50
+ `git clone git://github.com/#{username}/#{repo} --quiet`
51
+ if File.directory?(repo)
52
+ # If the directory exists after the repo
53
+ # has been cloned, give a success message
54
+ puts "#{success} #{repo}/ has been cloned."
55
+ else
56
+ # If the directory doesn't exist after the
57
+ # has been cloned, give an error message
58
+ puts "#{error} Cloning #{repo}/ failed."
59
+ end
60
+ else
61
+ # Give a warning message if the repo already exists
62
+ puts "#{warning} #{repo}/ already exists."
63
+ end
64
+ end
65
+ end
66
+
67
+ # If the directory doesn't exist
68
+ # in `Name::OLIVER`, delete it
69
+ # This is an extreme hack
70
+ current_repos = Dir.entries '.'
71
+ ['.', '..', '.backup', Name::OLIVER].each do |i|
72
+ current_repos.delete(i)
73
+ end
74
+ current_repos.each do |directory|
75
+ unless listed_repos.to_s.include?(directory) &&
76
+ File.directory?(directory)
77
+ print "#{warning} Would you like to delete #{directory}/? (y/n): "
78
+ `yes | rm -r #{directory}` if STDIN.gets.chomp.downcase == 'y'
81
79
  end
82
80
  end
@@ -1,28 +1,12 @@
1
- # For later (possible) Hash implementation
2
- # def list
3
- # listed_repos = []
4
- # # todo: if user has multiple repos,
5
- # # have one user key with an array of
6
- # # the user's repos
7
- # $yaml['repos'].each do |thing|
8
- # new_thing = thing.split('/')
9
- # listed_repos.push(new_thing)
10
- # end
11
- # puts listed_repos.to_h
12
- # end
13
-
14
- # Simple enough :P
15
- def list
16
- counter = 0
17
- $yaml['repos'].each do |thing|
18
- repo = thing.split('/')[1] # might as well discard the username
19
- if File.directory?(repo)
20
- print Rainbow(repo).green
21
- else
22
- print Rainbow(repo).red
23
- end
24
- print "\t" if counter % 4 == 0
25
- counter += 1
1
+ counter = 0
2
+ $yaml['repos'].each do |thing|
3
+ repo = thing.split('/')[1] # might as well discard the username
4
+ if File.directory?(repo)
5
+ print Rainbow(repo).green
6
+ else
7
+ print Rainbow(repo).red
26
8
  end
27
- puts
9
+ print "\t" if counter % 4 == 0
10
+ counter += 1
28
11
  end
12
+ puts
@@ -1,4 +1,2 @@
1
- def remove
2
- argument?(1)
3
- puts "todo: remove (#{ARGV[1]}) to #{Name::OLIVER}"
4
- end
1
+ require_relative '../oliver_file_name'
2
+ puts "TODO: remove (#{ARGV[1]}) to #{Name::OLIVER}"
@@ -1,3 +1,2 @@
1
- def update
2
- puts 'todo: pull updates from each tracked repo on the Olivefile'
3
- end
1
+ require_relative '../oliver_file_name'
2
+ puts "TODO: pull updates from each tracked repo on the #{Name::OLIVER}"
@@ -1,48 +1,38 @@
1
- # Assign 'files' variable to all of the argument files
2
- # (Make this automatic later on, but for some reason
3
- # automatic isn't working right now, and I don't
4
- # know why :P)
5
- files = %w(add init install list remove update help)
6
- files.each do |file|
7
- require_relative "argument_files/#{file}"
8
- end
1
+ # Require files
2
+ require 'optparse'
3
+ require_relative 'oliver_file_name'
4
+ require_relative 'argument_files/help'
9
5
 
10
- # `argument?` returns help if the
11
- # specified argument is nonexistant
12
- def argument?(argument_number)
13
- help if ARGV[argument_number].nil?
6
+ def load_file_and_exit(path)
7
+ require_relative path
8
+ exit 1
14
9
  end
15
10
 
16
- # Different arguments
17
- # (Make this into a case statement asap)
18
- # (It'll be way easier and cleaner to work with later)
19
- def arguments
20
- case ARGV[0].downcase
21
- when 'install'
22
- file_manager
23
- install
24
- when 'init'
25
- file_manager
26
- init
27
- when 'list'
28
- file_manager
29
- list
30
- when 'update'
31
- file_manager
32
- update
33
- when 'add'
34
- file_manager
35
- add
36
- when 'remove'
37
- file_manager
38
- remove
39
- when 'help'
40
- help
41
- when '-v' || '--version'
42
- puts "#{Rainbow('oliver').red} #{Rainbow("v#{Oliver::VERSION}").green}"
43
- exit
44
- else
45
- puts "#{Rainbow('Error').underline.red}: Unknown argument: #{ARGV[0]}"
46
- end
11
+ # Default options
12
+ options = {
13
+ :verbose => true,
14
+ :silent => false,
15
+ :directory => false
16
+ }
17
+
18
+ case ARGV[0].downcase
19
+ when 'install'
20
+ require_relative 'argument_files/install'
21
+ when 'init'
22
+ require_relative 'argument_files/init'
23
+ when 'list'
24
+ require_relative 'argument_files/list'
25
+ when 'update'
26
+ require_relative 'argument_files/update'
27
+ when 'add'
28
+ require_relative 'argument_files/add'
29
+ when 'remove'
30
+ require_relative 'argument_files/remove'
31
+ when 'help'
32
+ help
33
+ when '-v' || '--version'
34
+ puts "#{Rainbow('oliver').red} #{Rainbow("v#{Oliver::VERSION}").green}"
47
35
  exit
36
+ else
37
+ puts "#{Rainbow('Error').underline.red}: Unknown argument: #{ARGV[0]}"
48
38
  end
@@ -1,10 +1,6 @@
1
- def file_manager
2
- unless ARGV.nil?
3
- if File.file? Name::OLIVER
4
- body = File.read(Name::OLIVER)
5
- $yaml = YAML.load(body)
6
- else
7
- puts "#{Rainbow(Name::OLIVER).red} does not exist."
8
- end
9
- end
1
+ if File.file? Name::OLIVER
2
+ body = File.read(Name::OLIVER)
3
+ $yaml = YAML.load(body)
4
+ else
5
+ puts "#{Rainbow(Name::OLIVER).red} does not exist."
10
6
  end
@@ -1,5 +1,5 @@
1
1
  # The main module for
2
2
  # Oliver's version
3
3
  module Oliver
4
- VERSION = '1.7.3'
4
+ VERSION = '1.8'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oliver
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.3
4
+ version: '1.8'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-08 00:00:00.000000000 Z
11
+ date: 2014-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler