my_scripts 0.0.4 → 0.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/VERSION +1 -1
- data/bin/gitcp +2 -25
- data/bin/jew +2 -16
- data/bin/mybones +4 -14
- data/bin/rabbit +3 -18
- data/lib/my_scripts/cli.rb +24 -0
- data/lib/my_scripts/extensions.rb +11 -0
- data/lib/my_scripts/gitcp.rb +29 -0
- data/lib/my_scripts/jew.rb +17 -0
- data/lib/my_scripts/mybones.rb +17 -0
- data/lib/my_scripts/rabbit.rb +14 -0
- data/lib/my_scripts/script.rb +24 -0
- data/lib/my_scripts.rb +9 -0
- data/my_scripts.gemspec +10 -3
- data/spec/my_scripts/extensions_spec.rb +30 -0
- data/spec/spec_helper.rb +1 -1
- metadata +10 -3
- data/spec/my_scripts_spec.rb +0 -7
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/bin/gitcp
CHANGED
@@ -1,28 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
def usage
|
5
|
-
puts "Usage: #{__FILE__} [bump] Commit message goes here"
|
6
|
-
exit 1
|
7
|
-
end
|
3
|
+
require File.dirname(__FILE__) + '/../lib/my_scripts'
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
# If first Arg is a number, it indicates version bump
|
12
|
-
bump = ARGV[0].to_i > 0 ? ARGV.shift.to_i : 0
|
13
|
-
message = ARGV.empty? ? 'Commit' : ARGV.join(' ')
|
14
|
-
message += " #{Time.now.to_s[0..-6]}"
|
15
|
-
|
16
|
-
puts "Committing (versionup =#{bump}) with message: #{message}"
|
17
|
-
|
18
|
-
system %Q[git add --all]
|
19
|
-
system %Q[git commit -a -m "#{message}" --author arvicco]
|
20
|
-
case bump
|
21
|
-
when 1..9
|
22
|
-
system %Q[rake version:bump:patch]
|
23
|
-
when 10..99
|
24
|
-
system %Q[rake version:bump:minor]
|
25
|
-
when 10..99
|
26
|
-
system %Q[rake version:bump:major]
|
27
|
-
end
|
28
|
-
system %Q[git push]
|
5
|
+
MyScripts::CLI.run :gitcp, ARGV
|
data/bin/jew
CHANGED
@@ -1,19 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
def usage
|
5
|
-
puts "Usage: #{__FILE__} project_name Summary or description goes here"
|
6
|
-
exit 1
|
7
|
-
end
|
3
|
+
require File.dirname(__FILE__) + '/../lib/my_scripts'
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
# First Arg should be project name
|
12
|
-
project = ARGV.shift
|
13
|
-
|
14
|
-
# All the other args lumped into summary, or default summary
|
15
|
-
summary = ARGV.empty? ? "New project #{project}" : ARGV.join(' ')
|
16
|
-
|
17
|
-
puts "Creating Jeweler project #{project} with summary: #{summary}"
|
18
|
-
|
19
|
-
system %Q["jeweler --rspec --cucumber --create-repo --summary "#{summary}" --description "#{summary}" #{project}"]
|
5
|
+
MyScripts::CLI.run :jew, ARGV
|
data/bin/mybones
CHANGED
@@ -1,15 +1,5 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
project = ARGV[0]
|
7
|
-
system "bones create --github \"FIXME: Description for #{project}\" -s basic #{project}"
|
8
|
-
when 2 then
|
9
|
-
project = ARGV[0]
|
10
|
-
descr = ARGV[1]
|
11
|
-
system "bones create --github \"#{descr}\" -s basic #{project}"
|
12
|
-
else
|
13
|
-
puts "Usage: #{ARGV[0]} project_name \"description\""
|
14
|
-
exit 1
|
15
|
-
end
|
3
|
+
require File.dirname(__FILE__) + '/../lib/my_scripts'
|
4
|
+
|
5
|
+
MyScripts::CLI.run :mybones, ARGV
|
data/bin/rabbit
CHANGED
@@ -1,20 +1,5 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
def usage
|
5
|
-
puts "Usage:
|
6
|
-
#{__FILE__} start [args] - starts rabbitmq node
|
7
|
-
#{__FILE__} mqctl [args] - controls rabbitmq node"
|
8
|
-
exit 1
|
9
|
-
end
|
3
|
+
require File.dirname(__FILE__) + '/../lib/my_scripts'
|
10
4
|
|
11
|
-
|
12
|
-
|
13
|
-
case ARGV.shift
|
14
|
-
when /start/
|
15
|
-
system "%ERLANG_HOME%/lib/rabbitmq_server-1.7.0/sbin/rabbitmq-server.bat #{ARGV.join(' ')}"
|
16
|
-
when /ctl/
|
17
|
-
system "%ERLANG_HOME%/lib/rabbitmq_server-1.7.0/sbin/rabbitmqctl.bat #{ARGV.join(' ')}"
|
18
|
-
else
|
19
|
-
usage
|
20
|
-
end
|
5
|
+
MyScripts::CLI.run :rabbit, ARGV
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module MyScripts
|
2
|
+
class CLI
|
3
|
+
|
4
|
+
attr_accessor :stdout, :stdin
|
5
|
+
|
6
|
+
def self.run( script_name, argv )
|
7
|
+
new.run script_name, argv
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize( stdin=$stdin, stdout=$stdout )
|
11
|
+
@stdin = stdin
|
12
|
+
@stdout = stdout
|
13
|
+
end
|
14
|
+
|
15
|
+
def run( script_name, argv )
|
16
|
+
script = "MyScripts::#{script_name.capitalize}".to_class
|
17
|
+
script.new(script_name, argv, self).run
|
18
|
+
rescue => e
|
19
|
+
@stdout.puts e.backtrace
|
20
|
+
@stdout.puts e.message
|
21
|
+
exit 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class String
|
2
|
+
# Turns string into appropriate class constant, returns nil if class not found
|
3
|
+
def to_class
|
4
|
+
klass = self.split("::").inject(Kernel) do |namespace, const|
|
5
|
+
const == '' ? namespace : namespace.const_get(const)
|
6
|
+
end
|
7
|
+
klass.is_a?(Class) ? klass : nil
|
8
|
+
rescue NameError
|
9
|
+
nil
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module MyScripts
|
2
|
+
class Gitcp < Script
|
3
|
+
def run
|
4
|
+
usage "[bump] Commit message goes here" if @argv.empty?
|
5
|
+
|
6
|
+
# If first Arg is a number, it indicates version bump
|
7
|
+
bump = @argv[0].to_i > 0 ? @argv.shift.to_i : 0
|
8
|
+
|
9
|
+
# All the other args lumped into message, or default message
|
10
|
+
message = @argv.empty? ? 'Commit' : @argv.join(' ')
|
11
|
+
# Timestamp added to message
|
12
|
+
message += " #{Time.now.to_s[0..-6]}"
|
13
|
+
|
14
|
+
puts "Committing (versionup =#{bump}) with message: #{message}"
|
15
|
+
|
16
|
+
system %Q[git add --all]
|
17
|
+
system %Q[git commit -a -m "#{message}" --author arvicco]
|
18
|
+
case bump
|
19
|
+
when 1..9
|
20
|
+
system %Q[rake version:bump:patch]
|
21
|
+
when 10..99
|
22
|
+
system %Q[rake version:bump:minor]
|
23
|
+
when 10..99
|
24
|
+
system %Q[rake version:bump:major]
|
25
|
+
end
|
26
|
+
system %Q[git push]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module MyScripts
|
2
|
+
class Jew < Script
|
3
|
+
def run
|
4
|
+
usage "project_name Summary or description goes here" if @argv.empty?
|
5
|
+
|
6
|
+
# First Arg should be project name
|
7
|
+
project = @argv.shift
|
8
|
+
|
9
|
+
# All the other args lumped into summary, or default summary
|
10
|
+
summary = @argv.empty? ? "New project #{project}" : @argv.join(' ')
|
11
|
+
|
12
|
+
puts "Creating Jeweler project #{project} with summary: #{summary}"
|
13
|
+
|
14
|
+
system %Q[jeweler --rspec --cucumber --create-repo --summary "#{summary}" --description "#{summary}" #{project}]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module MyScripts
|
2
|
+
class Mybones < Script
|
3
|
+
def run
|
4
|
+
usage "project_name Summary or description goes here" if @argv.empty?
|
5
|
+
|
6
|
+
# First Arg should be project name
|
7
|
+
project = @argv.shift
|
8
|
+
|
9
|
+
# All the other args lumped into summary, or default summary
|
10
|
+
summary = @argv.empty? ? "New project #{project}" : @argv.join(' ')
|
11
|
+
|
12
|
+
puts "Creating Bones project #{project} with summary: #{summary}"
|
13
|
+
|
14
|
+
system %Q[bones create --github "#{summary}" -s basic #{project}]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module MyScripts
|
2
|
+
class Rabbit < Script
|
3
|
+
def run
|
4
|
+
case @argv.shift
|
5
|
+
when /start/
|
6
|
+
system "%ERLANG_HOME%/lib/rabbitmq_server-1.7.0/sbin/rabbitmq-server.bat #{ARGV.join(' ')}"
|
7
|
+
when /ctl/
|
8
|
+
system "%ERLANG_HOME%/lib/rabbitmq_server-1.7.0/sbin/rabbitmqctl.bat #{ARGV.join(' ')}"
|
9
|
+
else
|
10
|
+
usage ["start [args] - starts rabbitmq node", "mqctl [args] - controls rabbitmq node"]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module MyScripts
|
2
|
+
class Script # Base class for all scripts
|
3
|
+
def initialize( name, argv, cli )
|
4
|
+
@name = name
|
5
|
+
@argv = argv
|
6
|
+
@cli = cli
|
7
|
+
end
|
8
|
+
|
9
|
+
def puts *args
|
10
|
+
@cli.stdout.puts *args
|
11
|
+
end
|
12
|
+
|
13
|
+
def usage examples, explanation = nil
|
14
|
+
puts "Usage:"
|
15
|
+
puts (examples.respond_to?(:split) ? examples.split("\n") : examples).map {|line| " #{@name} #{line}"}
|
16
|
+
puts explanation if explanation
|
17
|
+
exit 1
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
"#{@name} #{@argv.join(' ')} -> #{self.class}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/my_scripts.rb
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
module MyScripts
|
2
|
+
def self.require_libs( filename, filemask )
|
3
|
+
file = ::File.expand_path(::File.join(::File.dirname(filename), filemask.gsub(/(?<!.rb)$/,'.rb')))
|
4
|
+
require file if File.exist?(file) && !File.directory?(file)
|
5
|
+
Dir.glob(file).sort.each {|rb| require rb}
|
6
|
+
end
|
7
|
+
end # module MyScripts
|
8
|
+
|
9
|
+
%W[my_scripts/script my_scripts/cli **/*].each {|rb| MyScripts.require_libs(__FILE__, rb)}
|
data/my_scripts.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{my_scripts}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["arvicco"]
|
@@ -32,8 +32,15 @@ Gem::Specification.new do |s|
|
|
32
32
|
"features/step_definitions/my_scripts_steps.rb",
|
33
33
|
"features/support/env.rb",
|
34
34
|
"lib/my_scripts.rb",
|
35
|
+
"lib/my_scripts/cli.rb",
|
36
|
+
"lib/my_scripts/extensions.rb",
|
37
|
+
"lib/my_scripts/gitcp.rb",
|
38
|
+
"lib/my_scripts/jew.rb",
|
39
|
+
"lib/my_scripts/mybones.rb",
|
40
|
+
"lib/my_scripts/rabbit.rb",
|
41
|
+
"lib/my_scripts/script.rb",
|
35
42
|
"my_scripts.gemspec",
|
36
|
-
"spec/
|
43
|
+
"spec/my_scripts/extensions_spec.rb",
|
37
44
|
"spec/spec.opts",
|
38
45
|
"spec/spec_helper.rb"
|
39
46
|
]
|
@@ -43,7 +50,7 @@ Gem::Specification.new do |s|
|
|
43
50
|
s.rubygems_version = %q{1.3.5}
|
44
51
|
s.summary = %q{A collection of ascripts}
|
45
52
|
s.test_files = [
|
46
|
-
"spec/
|
53
|
+
"spec/my_scripts/extensions_spec.rb",
|
47
54
|
"spec/spec_helper.rb"
|
48
55
|
]
|
49
56
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path(
|
2
|
+
File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
3
|
+
|
4
|
+
module MyScriptsTest
|
5
|
+
module A
|
6
|
+
class B
|
7
|
+
class C
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe String do
|
13
|
+
context '#to_class' do
|
14
|
+
it 'converts string into appropriate Class constant' do
|
15
|
+
"Fixnum".to_class.should == Fixnum
|
16
|
+
"MyScriptsTest::A::B::C".to_class.should == MyScriptsTest::A::B::C
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns nil if string is not convertible into class' do
|
20
|
+
"Math".to_class.should == nil
|
21
|
+
"Math::PI".to_class.should == nil
|
22
|
+
"Something".to_class.should == nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'deals with leading colons' do
|
26
|
+
"::MyScriptsTest::A::B::C".to_class.should == MyScriptsTest::A::B::C
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_scripts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- arvicco
|
@@ -59,8 +59,15 @@ files:
|
|
59
59
|
- features/step_definitions/my_scripts_steps.rb
|
60
60
|
- features/support/env.rb
|
61
61
|
- lib/my_scripts.rb
|
62
|
+
- lib/my_scripts/cli.rb
|
63
|
+
- lib/my_scripts/extensions.rb
|
64
|
+
- lib/my_scripts/gitcp.rb
|
65
|
+
- lib/my_scripts/jew.rb
|
66
|
+
- lib/my_scripts/mybones.rb
|
67
|
+
- lib/my_scripts/rabbit.rb
|
68
|
+
- lib/my_scripts/script.rb
|
62
69
|
- my_scripts.gemspec
|
63
|
-
- spec/
|
70
|
+
- spec/my_scripts/extensions_spec.rb
|
64
71
|
- spec/spec.opts
|
65
72
|
- spec/spec_helper.rb
|
66
73
|
has_rdoc: true
|
@@ -92,5 +99,5 @@ signing_key:
|
|
92
99
|
specification_version: 3
|
93
100
|
summary: A collection of ascripts
|
94
101
|
test_files:
|
95
|
-
- spec/
|
102
|
+
- spec/my_scripts/extensions_spec.rb
|
96
103
|
- spec/spec_helper.rb
|