flash 0.0.1
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/.gitignore +1 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +26 -0
- data/README.md +5 -0
- data/Rakefile +16 -0
- data/bin/run +44 -0
- data/example/Runfile +8 -0
- data/example/dancing/bouncing +1 -0
- data/example/salsa/cubana +1 -0
- data/example/school/fun +1 -0
- data/flash.gemspec +23 -0
- data/lib/flash.rb +4 -0
- data/lib/flash/runfile.rb +16 -0
- data/lib/flash/runner.rb +73 -0
- data/lib/flash/version.rb +3 -0
- data/spec/spec_helper.rb +7 -0
- metadata +70 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
flash (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.5)
|
10
|
+
rake (0.9.6)
|
11
|
+
rspec (2.14.1)
|
12
|
+
rspec-core (~> 2.14.0)
|
13
|
+
rspec-expectations (~> 2.14.0)
|
14
|
+
rspec-mocks (~> 2.14.0)
|
15
|
+
rspec-core (2.14.7)
|
16
|
+
rspec-expectations (2.14.4)
|
17
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
18
|
+
rspec-mocks (2.14.4)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
flash!
|
25
|
+
rake (~> 0.9)
|
26
|
+
rspec (~> 2.0)
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "rspec/core/rake_task"
|
2
|
+
|
3
|
+
RSpec::Core::RakeTask.new do |task|
|
4
|
+
task.name = 'spec'
|
5
|
+
task.rspec_opts = ['-c',' -f', 'd']
|
6
|
+
end
|
7
|
+
|
8
|
+
task :build do
|
9
|
+
system "gem build flash.gemspec"
|
10
|
+
end
|
11
|
+
|
12
|
+
task :release => :build do
|
13
|
+
system "gem push flash-#{Flash::VERSION}.gem"
|
14
|
+
end
|
15
|
+
|
16
|
+
task :default => :spec
|
data/bin/run
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'pathname'
|
5
|
+
require 'flash'
|
6
|
+
require 'flash/runner'
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
optparse = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: run [options] group"
|
11
|
+
|
12
|
+
opts.on("-c", "--command command", String, "Commands to run (semicolon separated)") do |command|
|
13
|
+
options[:commands] = command.split(';').map(&:strip)
|
14
|
+
end
|
15
|
+
|
16
|
+
opts.on("-d", "--debug", "Debug: print each command result") do |d|
|
17
|
+
options[:debug] = d
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on("-r", "--recipe recipe", "Run registered recipe if present") do |recipe|
|
21
|
+
options[:recipe] = recipe
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on("-l", "--list-recipes", "List registered recipes") do |l|
|
25
|
+
options[:list_recipes] = l
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on("-h", "--help", "Help documentation") do
|
29
|
+
puts opts ; exit
|
30
|
+
end
|
31
|
+
|
32
|
+
opts
|
33
|
+
end
|
34
|
+
|
35
|
+
if ARGV.empty?
|
36
|
+
puts "Group name is missing."
|
37
|
+
puts optparse ; exit
|
38
|
+
end
|
39
|
+
|
40
|
+
optparse.parse!
|
41
|
+
|
42
|
+
group = ARGV[0]
|
43
|
+
|
44
|
+
Flash::Runner.new(options, group).start
|
data/example/Runfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
test
|
@@ -0,0 +1 @@
|
|
1
|
+
test
|
data/example/school/fun
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
test
|
data/flash.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
require "flash/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "flash"
|
8
|
+
gem.license = "MIT"
|
9
|
+
gem.version = Flash::VERSION
|
10
|
+
|
11
|
+
gem.author = ["Marius Colacioiu"]
|
12
|
+
gem.email = ["marius.colacioiu@gmail.com"]
|
13
|
+
gem.homepage = "http://github.com/colmarius/flash"
|
14
|
+
gem.summary = %q{ Flash helps you run commands on multiple projects all defined in the Runfile }
|
15
|
+
|
16
|
+
gem.description = gem.summary
|
17
|
+
|
18
|
+
gem.rubyforge_project = "flash"
|
19
|
+
|
20
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
gem.files = `git ls-files`.split("\n")
|
22
|
+
gem.test_files = `git ls-files -- {spec}`.split("\n")
|
23
|
+
end
|
data/lib/flash.rb
ADDED
data/lib/flash/runner.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'flash'
|
2
|
+
require 'flash/runfile'
|
3
|
+
|
4
|
+
class Flash::Runner
|
5
|
+
attr_reader :options
|
6
|
+
attr_accessor :debug, :color, :dir_name, :group
|
7
|
+
|
8
|
+
def initialize(options = {}, group)
|
9
|
+
@options = options
|
10
|
+
@group = Flash::Runfile.new('Runfile')[group]
|
11
|
+
end
|
12
|
+
|
13
|
+
def pwd
|
14
|
+
Dir.pwd
|
15
|
+
end
|
16
|
+
|
17
|
+
def run(command, verbose=true)
|
18
|
+
say "#{ prompt }#{ command }" if verbose
|
19
|
+
system "cd #{ app_dir } && #{ command }"
|
20
|
+
say "[Debug] Result: #{ $?.inspect }" if verbose && debug
|
21
|
+
end
|
22
|
+
|
23
|
+
def recipes
|
24
|
+
@recipes ||= {
|
25
|
+
'update-master' => 'git stash ; git checkout master ; git pull ; git stash pop',
|
26
|
+
'status' => 'git status -s',
|
27
|
+
'branch' => 'git branch'
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def list_recipes
|
32
|
+
recipes.each_pair { |recipe, commands| puts %Q(#{ recipe }:\n\t"#{ commands }"\n\n) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def commands(recipe)
|
36
|
+
commands = recipes[recipe] ? recipes[recipe] : 'echo "Unknown recipe!"'
|
37
|
+
commands.split(';').map(&:strip)
|
38
|
+
end
|
39
|
+
|
40
|
+
def say(stuff)
|
41
|
+
prefix = "\e[38;5;#{ color }m"
|
42
|
+
suffix = "\e[0m"
|
43
|
+
system "echo '#{ prefix }#{ stuff }#{ suffix }'"
|
44
|
+
end
|
45
|
+
|
46
|
+
def change_color!
|
47
|
+
self.color = rand((1..22)) * 10 + 2
|
48
|
+
end
|
49
|
+
|
50
|
+
def app_dir
|
51
|
+
"#{ pwd }/#{ dir_name }"
|
52
|
+
end
|
53
|
+
|
54
|
+
def prompt
|
55
|
+
"#{ dir_name }> "
|
56
|
+
end
|
57
|
+
|
58
|
+
def start
|
59
|
+
list_recipes and exit if options[:list_recipes]
|
60
|
+
|
61
|
+
self.debug = options[:debug]
|
62
|
+
group.each do |dir_name|
|
63
|
+
change_color!
|
64
|
+
self.dir_name = dir_name
|
65
|
+
run "cd #{ pwd }/#{ dir_name }", false
|
66
|
+
|
67
|
+
commands = options[:recipe] ? commands(options[:recipe]) : options[:commands]
|
68
|
+
commands.each { |command| run(command) }\
|
69
|
+
|
70
|
+
say ""
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flash
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Marius Colacioiu
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-01-02 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Flash helps you run commands on multiple projects all defined in the
|
15
|
+
Runfile
|
16
|
+
email:
|
17
|
+
- marius.colacioiu@gmail.com
|
18
|
+
executables:
|
19
|
+
- run
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- .gitignore
|
24
|
+
- Gemfile
|
25
|
+
- Gemfile.lock
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/run
|
29
|
+
- example/Runfile
|
30
|
+
- example/dancing/bouncing
|
31
|
+
- example/salsa/cubana
|
32
|
+
- example/school/fun
|
33
|
+
- flash.gemspec
|
34
|
+
- lib/flash.rb
|
35
|
+
- lib/flash/runfile.rb
|
36
|
+
- lib/flash/runner.rb
|
37
|
+
- lib/flash/version.rb
|
38
|
+
- spec/spec_helper.rb
|
39
|
+
homepage: http://github.com/colmarius/flash
|
40
|
+
licenses:
|
41
|
+
- MIT
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
hash: 217996443338893832
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
hash: 217996443338893832
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project: flash
|
66
|
+
rubygems_version: 1.8.25
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: Flash helps you run commands on multiple projects all defined in the Runfile
|
70
|
+
test_files: []
|