rebuild 0.3.1 → 0.3.2

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: 343b48b597539921a27a9987311d27a768e3e215
4
- data.tar.gz: fbf1d04ef67f928035c26173f089be49f9ebf2b1
3
+ metadata.gz: 9fdcc09677d6ab49d227c5b4a978498af058ba99
4
+ data.tar.gz: d1b805d6e750eb4a40008ae8994aec305d8730f4
5
5
  SHA512:
6
- metadata.gz: a59dbc58f12a2066d0bc9889be8e2c1b9164c0854a00152ffc3a8bc4d8153367dbe9b71ef601e252aa43f9a6323b42081af53aa25c8b717baf82444a8597c888
7
- data.tar.gz: 5fbfe3e2545d5d4f12dc612214c977d8a95514a62986fa369b559c9086a45ea87d080ed52abe0438fc859fe22cd8dd6fa7cde51c9beba4400f0d1df2728f9f48
6
+ metadata.gz: 5dbe1af4dc3033dd024037c83ee2b5349e6616b3b500d1e4b03cdefef78eb7c93aff1a6b64da30cef3011d552537fb8b2dcf3fa96d0031591dc45c0b9b1f51cc
7
+ data.tar.gz: d03a0d50cac8d0aadc9b9752fedb524b2324b332b6f4e555120d2399f7344df0559d6feb81bba1b0da865edebdacc61e6e15013eb9dd12473b84c5e750dde459
data/README.md CHANGED
@@ -44,6 +44,13 @@ $ rebuild -d ~/src/github.com/k0kubun/dotfiles
44
44
 
45
45
  # Run /tmp/k0kubun/dotfiles/script/*.sh instead of /tmp/k0kubun/dotfiles/*.sh
46
46
  $ rebuild -s script
47
+
48
+ # You can choose which script to run first by shell pipeline
49
+ echo "first.sh second.sh" | rebuild
50
+ rebuild <<-EOS
51
+ first.sh
52
+ second.sh
53
+ EOS
47
54
  ```
48
55
 
49
56
  ## Supported OS
@@ -29,7 +29,7 @@ module Rebuild
29
29
  command = args.first
30
30
 
31
31
  if command.include?('/')
32
- stdin = STDIN.gets unless STDIN.isatty
32
+ stdin = STDIN.read unless STDIN.isatty
33
33
  bootstrap(command, stdin, options)
34
34
  else
35
35
  run_command(command)
@@ -40,7 +40,7 @@ module Rebuild
40
40
 
41
41
  def bootstrap(repo, stdin, options)
42
42
  repo_path = Repository.new(repo, options).fetch
43
- primary_scripts = stdin
43
+ primary_scripts = (stdin || '').split
44
44
 
45
45
  runner = Runner.new(repo_path, primary_scripts, options[:scriptdir])
46
46
  runner.run
@@ -16,10 +16,13 @@ module Rebuild
16
16
  def install
17
17
  obtain_accesibility
18
18
 
19
+ Logger.info('Running command line tools installation...')
19
20
  `xcode-select --install`
21
+
20
22
  Script.execute_scpt('start_install')
21
23
  sleep 5 until installed?
22
24
  Script.execute_scpt('click_done')
25
+ Logger.success('Finished to install command line tools')
23
26
  end
24
27
 
25
28
  private
@@ -3,6 +3,7 @@ require 'rebuild'
3
3
  module Rebuild
4
4
  class Logger
5
5
  COLOR_CODE = {
6
+ red: 31,
6
7
  green: 32,
7
8
  cyan: 36,
8
9
  }
@@ -16,8 +17,17 @@ module Rebuild
16
17
  puts cyan(text)
17
18
  end
18
19
 
20
+ def fatal(text)
21
+ puts red("Error: #{text}")
22
+ exit(1)
23
+ end
24
+
19
25
  private
20
26
 
27
+ def red(text)
28
+ color_with(text, :red)
29
+ end
30
+
21
31
  def green(text)
22
32
  color_with(text, :green)
23
33
  end
@@ -1,4 +1,5 @@
1
1
  require 'rebuild'
2
+ require 'set'
2
3
 
3
4
  module Rebuild
4
5
  class Runner
@@ -11,9 +12,10 @@ module Rebuild
11
12
  def run
12
13
  return no_script_found if script_paths.empty?
13
14
 
14
- script_paths.each do |path|
15
- Logger.info("Running #{path}...")
16
- system('sh', path)
15
+ ordered_scripts.each do |script|
16
+ absolute_path = File.join(absolute_script_directory, script)
17
+ Logger.info("Running #{absolute_path}...")
18
+ system('sh', absolute_path)
17
19
  end
18
20
 
19
21
  Logger.finish("Finished to rebuild #{absolute_script_directory}")
@@ -21,6 +23,23 @@ module Rebuild
21
23
 
22
24
  private
23
25
 
26
+ def ordered_scripts
27
+ inexistent_scripts = @primary_scripts - existent_scripts
28
+ if inexistent_scripts.any?
29
+ Logger.fatal("#{inexistent_scripts.join(', ')} can't be found in #{absolute_script_directory}")
30
+ end
31
+
32
+ @primary_scripts + (existent_scripts - @primary_scripts)
33
+ end
34
+
35
+ def existent_scripts
36
+ target = File.join(absolute_script_directory, '*.sh')
37
+
38
+ Dir.glob(target).map do |full_path|
39
+ File.basename(full_path)
40
+ end
41
+ end
42
+
24
43
  def script_paths
25
44
  target = File.join(absolute_script_directory, '*.sh')
26
45
  Dir.glob(target)
@@ -1,3 +1,3 @@
1
1
  module Rebuild
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rebuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun