rebuild 0.0.4.pre8 → 0.0.4.pre9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a38ea1e5ee724d661413c3074ed26aba2391494
4
- data.tar.gz: 038448bc67e603d094dd7f64efae853ae99db504
3
+ metadata.gz: 3333b513c20e335f6fc9cfb12d16f92b813f2fbe
4
+ data.tar.gz: edc08fd52d002bdabc5d45b205295c1ed3eac6e3
5
5
  SHA512:
6
- metadata.gz: 34e343442785e61a6860a79d4a07e7e588497e4230a164952d861b390a72614d044356c38bd1f8275d5c39acd716fa69829a432f21a1d7a79632cc02993359dd
7
- data.tar.gz: e2ec36a90fa56a6bd74dcdff6c10afbf37047272ccfed7f2267b7395034344211144595172ebd473fbfd52f52fd2525e0fbc12cc6e7f0cac600e716ca0d84c50
6
+ metadata.gz: aad027253df70ce5af212e406e91153405a70d43ea7ac14d10051b0a1b26575f30fcf150b6febbdff3bc6cd30b7d44933760b114f27e75f3a4c0e5acf93d31ee
7
+ data.tar.gz: 968ee4a3be166778d0c5a5c28d9708c26dfeb6a581cd6791bcc6a3562e588ed952cd8a55b5bea176d2f56ff5ef9a0cd4fd7f0c781efff5db9912bcf79344a336
@@ -1,5 +1,5 @@
1
- require 'rebuild/bootstrap'
2
1
  require 'rebuild/cli'
2
+ require 'rebuild/command_line_tools'
3
3
  require 'rebuild/repository'
4
4
  require 'rebuild/runner'
5
5
  require 'rebuild/version'
@@ -1,34 +1,43 @@
1
1
  require 'rebuild'
2
- require 'unindent'
3
2
 
4
3
  module Rebuild
5
4
  class CLI
6
5
  class << self
7
6
  def start
8
- bootstrap = Bootstrap.new
9
- if bootstrap.installed?
10
- show_usage if ARGV.empty?
11
- else
12
- bootstrap.install
7
+ return show_usage if ARGV.empty? && CommandLineTools.installed?
8
+
9
+ unless CommandLineTools.installed?
10
+ CommandLineTools.install
11
+ end
12
+
13
+ if ARGV.any?
14
+ stdin = STDIN.gets unless STDIN.isatty
15
+ bootstrap(ARGV, stdin)
13
16
  end
14
- return if ARGV.empty?
17
+ end
18
+
19
+ private
15
20
 
16
- repo_path = Repository.new(ARGV.first).fetch
17
- primary_scripts = STDIN.gets unless STDIN.isatty
21
+ def bootstrap(args, stdin)
22
+ repo_path = Repository.new(args.first).fetch
23
+ primary_scripts = stdin
18
24
 
19
25
  runner = Runner.new(repo_path, primary_scripts)
20
26
  runner.run
21
27
  end
22
28
 
23
- private
24
-
25
29
  def show_usage
26
- puts <<-EOS.unindent
30
+ puts unindent(<<-EOS)
27
31
  Commands:
28
32
  rebuild USER/PROJECT # execute all scripts in GitHub repo's root directory
29
33
 
30
34
  EOS
31
35
  end
36
+
37
+ def unindent(text)
38
+ indent = text.split("\n").select {|line| !line.strip.empty? }.map {|line| line.index(/[^\s]/) }.compact.min || 0
39
+ text.gsub(/^[[:blank:]]{#{indent}}/, '')
40
+ end
32
41
  end
33
42
  end
34
43
  end
@@ -0,0 +1,42 @@
1
+ require 'rebuild'
2
+
3
+ module Rebuild
4
+ class CommandLineTools
5
+ DATABASE = '/Library/Application\ Support/com.apple.TCC/TCC.db'
6
+ BUNDLE_IDENTIFIER = 'com.apple.Terminal'
7
+
8
+ class << self
9
+ def installed?
10
+ system('xcode-select -p > /dev/null 2>&1')
11
+ end
12
+
13
+ def install
14
+ obtain_accesibility
15
+
16
+ `xcode-select --install`
17
+ execute_scpt('start_install')
18
+
19
+ sleep 5 until installed?
20
+ execute_scpt('click_finish')
21
+ end
22
+
23
+ private
24
+
25
+ # Enable Security & Privacy > Privacy > Accessibility for Terminal.app.
26
+ def obtain_accesibility
27
+ puts "Require accessibility for Terminal.app to click buttons"
28
+ sql = <<-SQL
29
+ INSERT OR REPLACE INTO access
30
+ VALUES('kTCCServiceAccessibility','#{BUNDLE_IDENTIFIER}',0,1,1,NULL);
31
+ SQL
32
+ `sudo sqlite3 #{DATABASE} "#{sql}"`
33
+ end
34
+
35
+ def execute_scpt(name)
36
+ script_dir = File.expand_path('../../../script', __FILE__)
37
+ script_path = File.join(script_dir, "#{name}.scpt")
38
+ `sudo osascript #{script_path}`
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module Rebuild
2
- VERSION = '0.0.4.pre8'
2
+ VERSION = '0.0.4.pre9'
3
3
  end
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "unindent", "~> 1.0"
22
21
  spec.add_development_dependency "bundler"
23
22
  spec.add_development_dependency "rake", "~> 10.0"
24
23
  end
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env osascript
2
2
 
3
3
  -- Fist: Click Install Button
4
- set timeoutSeconds to 8.0
4
+ set timeoutSeconds to 1.0
5
5
 
6
6
  my doWithTimeout("click UI Element \"Install\" of window 1 of application process \"Install Command Line Developer Tools\"", timeoutSeconds)
7
7
  my doWithTimeout("click UI Element \"Agree\" of window 1 of application process \"Install Command Line Developer Tools\"", timeoutSeconds)
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rebuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.pre8
4
+ version: 0.0.4.pre9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-24 00:00:00.000000000 Z
11
+ date: 2014-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: unindent
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -67,8 +53,8 @@ files:
67
53
  - Rakefile
68
54
  - bin/rebuild
69
55
  - lib/rebuild.rb
70
- - lib/rebuild/bootstrap.rb
71
56
  - lib/rebuild/cli.rb
57
+ - lib/rebuild/command_line_tools.rb
72
58
  - lib/rebuild/repository.rb
73
59
  - lib/rebuild/runner.rb
74
60
  - lib/rebuild/version.rb
@@ -1,42 +0,0 @@
1
- require 'rebuild'
2
- require 'open3'
3
-
4
- module Rebuild
5
- class Bootstrap
6
- DATABASE = '/Library/Application\ Support/com.apple.TCC/TCC.db'
7
- BUNDLE_IDENTIFIER = 'com.apple.Terminal'
8
-
9
- def installed?
10
- system('xcode-select -p > /dev/null 2>&1')
11
- end
12
-
13
- def install
14
- return if installed?
15
- obtain_accesibility
16
-
17
- `xcode-select --install`
18
- execute_scpt('start_install')
19
-
20
- sleep 5 until installed?
21
- execute_scpt('click_finish')
22
- end
23
-
24
- private
25
-
26
- # Enable Security & Privacy > Privacy > Accessibility for Terminal.app.
27
- def obtain_accesibility
28
- puts "Require accessibility for Terminal.app to click buttons"
29
- sql = <<-SQL
30
- INSERT OR REPLACE INTO access
31
- VALUES('kTCCServiceAccessibility','#{BUNDLE_IDENTIFIER}',0,1,0,NULL);
32
- SQL
33
- `sudo sqlite3 #{DATABASE} "#{sql}"`
34
- end
35
-
36
- def execute_scpt(name)
37
- script_dir = File.expand_path('../../../script', __FILE__)
38
- script_path = File.join(script_dir, "#{name}.scpt")
39
- `sudo osascript #{script_path}`
40
- end
41
- end
42
- end