rebuild 0.2.1 → 0.2.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: 1d1d8b1006fc9b0b374450736840721459dd9813
4
- data.tar.gz: caaa6b97f4539931a7815689775ce153da7a8b7f
3
+ metadata.gz: 2891f67ffcdba95f4dcb3f9dd6231ce53496b72c
4
+ data.tar.gz: 8ce6ba5068b06c065c3f0017096786ea2e6160d3
5
5
  SHA512:
6
- metadata.gz: 00fe864ce92da6d09e299baa326babc0c2708e8076ccb3ce408d301d89264724c7b712c4e55616c3314f1bd6c17cd664d29b43333ac8a1322b005cf196b02219
7
- data.tar.gz: 3dbaccef58ff0ceaa7d70cc54618e07fa75e678e034d072843224cbd0f10909646863eeaa7e1000fae0b67f84d72bb073ab1e3fb9de849b2c1f0e6d5e10adb0e
6
+ metadata.gz: 8c7d8e88235b631955f2452a05cf5862a4cd656bd920452fae65cd023d3395d2a1aba2df366515ac5e1a25628dd2aba37658ca3121da273c601326bf23f0c6dc
7
+ data.tar.gz: fa82f426ed853245657fd25c1c38842861ca2ae0adf3aa112c8267639a32c00d11818fe4aa7451cb156761bc6e7fc323b51d2265dc0e302878c7cacdd4ef2e68
data/README.md CHANGED
@@ -42,8 +42,8 @@ Prior to 10.8 Mountain Lion, features except command line tools installation are
42
42
  ## TODO
43
43
 
44
44
  - revision lock
45
- - clone directory change option
46
45
  - support script directory to put scripts
46
+ - more flexible upstream pull
47
47
 
48
48
  ## License
49
49
 
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative './lib/rebuild/version'
4
+ `gem build rebuild.gemspec`
5
+ `gem push rebuild-#{Rebuild::VERSION}.gem`
@@ -1,24 +1,31 @@
1
1
  require 'rebuild'
2
+ require 'optparse'
2
3
 
3
4
  module Rebuild
4
5
  class CLI
5
6
  class << self
6
7
  def start
7
- return show_usage if ARGV.empty? && CommandLineTools.installed?
8
+ options = {}
9
+
10
+ opt = OptionParser.new
11
+ opt.on('-d', '--directory=VAL') { |v| options[:directory] = v }
12
+
13
+ args = opt.parse!(ARGV)
14
+ return show_usage if args.empty? && CommandLineTools.installed?
8
15
 
9
16
  CommandLineTools.install unless CommandLineTools.installed?
10
17
  License.agree unless License.agreed?
11
18
 
12
- if ARGV.any?
19
+ if args.any?
13
20
  stdin = STDIN.gets unless STDIN.isatty
14
- bootstrap(ARGV, stdin)
21
+ bootstrap(args, stdin, options)
15
22
  end
16
23
  end
17
24
 
18
25
  private
19
26
 
20
- def bootstrap(args, stdin)
21
- repo_path = Repository.new(args.first).fetch
27
+ def bootstrap(args, stdin, options)
28
+ repo_path = Repository.new(args.first, options[:directory]).fetch
22
29
  primary_scripts = stdin
23
30
 
24
31
  runner = Runner.new(repo_path, primary_scripts)
@@ -30,6 +37,9 @@ module Rebuild
30
37
  Commands:
31
38
  rebuild USER/PROJECT # execute all scripts in GitHub repo's root directory
32
39
 
40
+ Options:
41
+ -d, [--directory=/path/to/clone] # Default: /tmp/USER/PROJECT
42
+
33
43
  EOS
34
44
  end
35
45
 
@@ -2,8 +2,11 @@ require 'rebuild'
2
2
 
3
3
  module Rebuild
4
4
  class CommandLineTools
5
- DATABASE = '/Library/Application\ Support/com.apple.TCC/TCC.db'
6
- BUNDLE_IDENTIFIER = 'com.apple.Terminal'
5
+ DATABASE = '/Library/Application\ Support/com.apple.TCC/TCC.db'
6
+ SUPPORTED_TERMINALS = %w[
7
+ com.apple.Terminal
8
+ com.googlecode.iterm2
9
+ ]
7
10
 
8
11
  class << self
9
12
  def installed?
@@ -23,12 +26,14 @@ module Rebuild
23
26
 
24
27
  # Enable Security & Privacy > Privacy > Accessibility for Terminal.app.
25
28
  def obtain_accesibility
26
- puts "Require accessibility for Terminal.app to click buttons"
27
- sql = <<-SQL
28
- INSERT OR REPLACE INTO access
29
- VALUES('kTCCServiceAccessibility','#{BUNDLE_IDENTIFIER}',0,1,0,NULL);
30
- SQL
31
- `sudo sqlite3 #{DATABASE} "#{sql}"`
29
+ puts 'Require accessibility for terminal to click buttons'
30
+ SUPPORTED_TERMINALS.each do |bundle_identifier|
31
+ sql = <<-SQL
32
+ INSERT OR REPLACE INTO access
33
+ VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,0,NULL);
34
+ SQL
35
+ `sudo sqlite3 #{DATABASE} "#{sql}"`
36
+ end
32
37
  end
33
38
 
34
39
  def execute_scpt(name)
@@ -3,12 +3,11 @@ require 'fileutils'
3
3
 
4
4
  module Rebuild
5
5
  class Repository
6
- FETCH_REFERENCE = 'master'
7
- FETCH_DIRECTORY = '/tmp'
6
+ DEFAULT_DIRECTORY = '/tmp'
8
7
 
9
- def initialize(path)
8
+ def initialize(path, directory)
10
9
  @user, @repo = path.split('/')
11
- @reference = FETCH_REFERENCE
10
+ @directory = directory
12
11
 
13
12
  abort "Invalid repository `#{path}`" if @repo.nil?
14
13
  end
@@ -26,7 +25,7 @@ module Rebuild
26
25
  private
27
26
 
28
27
  def clone_repository
29
- FileUtils.mkdir_p(user_path)
28
+ FileUtils.mkdir_p(upper_directory)
30
29
  `git clone #{github_repository} #{repo_path}`
31
30
  end
32
31
 
@@ -54,11 +53,27 @@ module Rebuild
54
53
  end
55
54
 
56
55
  def repo_path
57
- File.join(user_path, @repo)
56
+ File.join(upper_directory, root_directory)
57
+ end
58
+
59
+ def root_directory
60
+ if @directory
61
+ @directory.gsub(/\/$/, '').match(/[^\/]+$/).to_s
62
+ else
63
+ @repo
64
+ end
65
+ end
66
+
67
+ def upper_directory
68
+ if @directory
69
+ @directory.gsub(/[^\/]+\/?$/, '')
70
+ else
71
+ user_path
72
+ end
58
73
  end
59
74
 
60
75
  def user_path
61
- File.join(FETCH_DIRECTORY, @user)
76
+ File.join(DEFAULT_DIRECTORY, @user)
62
77
  end
63
78
  end
64
79
  end
@@ -1,3 +1,3 @@
1
1
  module Rebuild
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.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.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
@@ -55,6 +55,7 @@ files:
55
55
  - README.md
56
56
  - Rakefile
57
57
  - bin/rebuild
58
+ - gempush.rb
58
59
  - lib/rebuild.rb
59
60
  - lib/rebuild/cli.rb
60
61
  - lib/rebuild/command_line_tools.rb