mycommands 1.0.5 → 1.0.6
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.
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/bin/mycommands +2 -8
- data/lib/mycommands/application.rb +16 -10
- data/lib/mycommands/controllers/application_controller.rb +28 -0
- data/lib/mycommands/controllers/controller.rb +1 -1
- data/lib/mycommands/models/model.rb +1 -1
- data/lib/mycommands/version.rb +1 -1
- data/lib/mycommands/views/application_view.rb +15 -0
- metadata +14 -14
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -37,6 +37,7 @@ About the yml files
|
|
37
37
|
|
38
38
|
If the script finds categories.yml or commands.yml in ~/Mycommands
|
39
39
|
those files will be used instead of the default ones.
|
40
|
+
You can run "mycommands --copy" to copy the default ones to ~/Mycommands.
|
40
41
|
|
41
42
|
Categories in categories.yml that has no subcategories has to end with a trailing blank space.
|
42
43
|
|
data/bin/mycommands
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require_relative '../lib/mycommands'
|
4
|
-
|
5
3
|
module Mycommands
|
6
4
|
|
7
5
|
DEBUG = ARGV.include? '-d'
|
8
6
|
TEST = ARGV.include? '-t'
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
action = :sort_yaml_files if ARGV.include?('-s')
|
13
|
-
|
14
|
-
action ||= :run
|
8
|
+
require_relative '../lib/mycommands'
|
15
9
|
|
16
|
-
Factory::get(:Application).
|
10
|
+
Factory::get(:Application).run
|
17
11
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
module Mycommands
|
2
2
|
class Application
|
3
|
+
OPTIONS = [
|
4
|
+
{short: 'v', verbose: 'version', route: [:Application, :print_version], input: false, description: 'Prints the version'},
|
5
|
+
{short: 's', verbose: 'sort', route: [:Application, :sort_yaml_files], input: false, description: 'Sorts categories.yml and commands.yml alphabetically'},
|
6
|
+
{short: 'c', verbose: 'copy', route: [:Application, :copy_yaml_files], input: false, description: 'Copies categories.yml and commands.yml to ~/Mycommands/ so that they overrides the default ones'},
|
7
|
+
{short: 'h', verbose: 'help', route: [:Application, :help], input: false, description: 'Shows this help'}
|
8
|
+
]
|
9
|
+
|
3
10
|
def initialize
|
4
11
|
@router = Factory::get(:Router)
|
5
12
|
end
|
6
13
|
|
7
|
-
def print_version
|
8
|
-
puts "Mycommands #{VERSION}"
|
9
|
-
end
|
10
|
-
|
11
|
-
def sort_yaml_files
|
12
|
-
dispatch ['Application', 'sort_yaml_files']
|
13
|
-
end
|
14
|
-
|
15
14
|
def run
|
16
|
-
|
17
|
-
|
15
|
+
route, input = check_options
|
16
|
+
dispatch route
|
17
|
+
get_input if input
|
18
18
|
end
|
19
19
|
|
20
20
|
def dispatch args
|
@@ -28,6 +28,12 @@ module Mycommands
|
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
31
|
+
def check_options
|
32
|
+
option = OPTIONS.select {|option| "-" + option[:short] == ARGV.first || "--" + option[:verbose] == ARGV.first}.first
|
33
|
+
return [option[:route], option[:input]] if option
|
34
|
+
[[:Category, :index], true]
|
35
|
+
end
|
36
|
+
|
31
37
|
def get_input
|
32
38
|
while input = Readline.readline('--> ', true)
|
33
39
|
route = @router.route input
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module Mycommands
|
2
4
|
class ApplicationController < Controller
|
3
5
|
def sort_yaml_files
|
@@ -6,6 +8,32 @@ module Mycommands
|
|
6
8
|
render
|
7
9
|
end
|
8
10
|
|
11
|
+
def copy_yaml_files
|
12
|
+
Dir.chdir(YMLPATH)
|
13
|
+
@path = "#{ENV['HOME']}/Mycommands"
|
14
|
+
@copied = []
|
15
|
+
@skipped = []
|
16
|
+
FileUtils.mkdir(@path) unless File.exist?(@path)
|
17
|
+
Dir.glob('*.yml').each do |file|
|
18
|
+
unless File.exists?("#{@path}/#{file}")
|
19
|
+
FileUtils.cp(file, @path)
|
20
|
+
@copied << file
|
21
|
+
else
|
22
|
+
@skipped << file
|
23
|
+
end
|
24
|
+
end
|
25
|
+
render
|
26
|
+
end
|
27
|
+
|
28
|
+
def print_version
|
29
|
+
puts "Mycommands #{VERSION}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def help
|
33
|
+
@options = Application::OPTIONS
|
34
|
+
render
|
35
|
+
end
|
36
|
+
|
9
37
|
private
|
10
38
|
def set_model
|
11
39
|
false
|
@@ -9,7 +9,7 @@ module Mycommands
|
|
9
9
|
|
10
10
|
def render action = nil
|
11
11
|
instance_variables.each do |i|
|
12
|
-
@view.instance_variable_set i, eval(i.to_s) unless %w(
|
12
|
+
@view.instance_variable_set i, eval(i.to_s) unless %w(model view application).include? i
|
13
13
|
end
|
14
14
|
if action
|
15
15
|
@view.send(action)
|
data/lib/mycommands/version.rb
CHANGED
@@ -1,8 +1,23 @@
|
|
1
1
|
module Mycommands
|
2
2
|
class ApplicationView < View
|
3
|
+
def copy_yaml_files
|
4
|
+
for file in @copied
|
5
|
+
print "#{file} has been copied to #{@path}."
|
6
|
+
end
|
7
|
+
for file in @skipped
|
8
|
+
print "#{file} was skipped as it already exist."
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
3
12
|
def sort_yaml_files
|
4
13
|
print "#{@category_file} has been sorted."
|
5
14
|
print "#{@command_file} has been sorted."
|
6
15
|
end
|
16
|
+
|
17
|
+
def help
|
18
|
+
for option in @options
|
19
|
+
print "-#{option[:short]}, --#{option[:verbose]} \t\t #{option[:description]}"
|
20
|
+
end
|
21
|
+
end
|
7
22
|
end
|
8
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mycommands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70355802204540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.3.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70355802204540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: clipboard
|
27
|
-
requirement: &
|
27
|
+
requirement: &70355802204020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70355802204020
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: minitest
|
38
|
-
requirement: &
|
38
|
+
requirement: &70355802203560 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 4.5.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70355802203560
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: pry
|
49
|
-
requirement: &
|
49
|
+
requirement: &70355802203020 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.9.11.4
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70355802203020
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &70355802202560 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 10.0.3
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70355802202560
|
69
69
|
description: Small console app to manage your favourite commands
|
70
70
|
email:
|
71
71
|
- nils.epost@gmail.com
|
@@ -127,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
segments:
|
129
129
|
- 0
|
130
|
-
hash:
|
130
|
+
hash: 2622909617991334818
|
131
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
132
|
none: false
|
133
133
|
requirements:
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
segments:
|
138
138
|
- 0
|
139
|
-
hash:
|
139
|
+
hash: 2622909617991334818
|
140
140
|
requirements: []
|
141
141
|
rubyforge_project:
|
142
142
|
rubygems_version: 1.8.10
|