tmbundle-manager 0.1.0.pre2 → 0.1.0.pre3

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: a6c5b22838e97783ac348b484db1b99f8b89a25a
4
- data.tar.gz: e2bf8d4a4919f63ebe5d79bf74015b9b938d25c8
3
+ metadata.gz: 77f32abf4b5ce55055841dbe347a9c715143146b
4
+ data.tar.gz: 07ab6f1206b3458849874a5239524d9157b3805c
5
5
  SHA512:
6
- metadata.gz: 67558ee5deb1342431e4c3bb3fae0e2e8e7d6fccb699951267e646435882272aa1717ca9d0ec947f2b209c7a51ba0108d9278ba5eda47bd8e5e927a784d959cb
7
- data.tar.gz: ef6b7a4181a713ddf570df6de626e4e32daabb5a5e98f6551f65a62578013c2718f108c56670f51f7b5130ef50315e7c9a532f02d4615605921fbea1dfef37a8
6
+ metadata.gz: 49de021c0e249769fea02108da7cf66a6b110231be5134de78dca0f58dfa2a2e672f85fe7a2166994ce5f48bf918f36b7b865332a8b1654ff1fd4ff958b259eb
7
+ data.tar.gz: 9c96a97acee53e0dd4c1b06d82a3a6db366630cc021fd047d8cd10eb468a656c17273ed5a81cfe7b4dae2997059cca51bf77345a763286574f1644cda181e502
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Install with RubyGems in your Terminal:
8
8
 
9
- gem install tmbundle-manager
9
+ gem install tmbundle-manager --pre
10
10
 
11
11
 
12
12
  ## Usage
data/bin/tmb CHANGED
@@ -1,100 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'pathname'
4
- require 'thor'
5
-
6
- class TMBundle < Thor
7
- desc 'edit PARTIAL_NAME', 'Edit an installed bundle (name will be matched against PARTIAL_NAME)'
8
- def edit partial_name
9
- matches = installed_bundles.select do |bundle|
10
- bundle.name =~ /^#{partial_name}/i
11
- end
12
-
13
- if matches.size > 1
14
- puts "please be more specific:"
15
- matches.each_with_index {|m,i| puts " #{i+1}) #{m.name}"}
16
- return false
17
- end
18
-
19
- if matches.empty?
20
- puts "nothing found"
21
- return false
22
- end
23
-
24
- bundle = matches.first
25
- mate bundle.path
26
- end
27
-
28
- desc 'update', 'Update installed bundles'
29
- def update
30
- require 'thread'
31
- signals = Queue.new
32
- trap('INT') { signals << :int }
33
-
34
- updated = []
35
- skipped = []
36
- errored = []
37
-
38
- installed_bundles[0..4].each do |bundle|
39
- within bundle do
40
- if not(File.exist?('./.git'))
41
- puts "------> Skipping #{bundle.name} (not a Git repo, delta bundle?)"
42
- skipped << bundle
43
- next
44
- end
45
-
46
- puts "------> Updating #{bundle.name}..."
47
- system *%w[git pull --ff-only]
48
- success = $? == 0
49
- updated << bundle if success
50
- errored << bundle unless success
51
- puts
52
- (puts 'Exiting…'; exit) if signals.pop == :int until signals.empty?
53
- end
54
- end
55
-
56
- puts
57
- puts
58
- puts '------> Summary'
59
- puts
60
- puts "Skipped (#{skipped.size})\n- #{skipped.map(&:name).join("\n- ")}\n\n" if skipped.any?
61
- puts "Updated (#{updated.size})\n- #{updated.map(&:name).join("\n- ")}\n\n" if updated.any?
62
- puts "Errored (#{errored.size})\n- #{errored.map(&:name).join("\n- ")}\n\n" if errored.any?
63
- end
64
-
65
- desc 'install', 'Install a bundle from GitHub'
66
- def install name
67
- full_name = name.gsub(/(\.tmbundle)$/i, '')+'.tmbundle'
68
- git_url = "https://github.com/#{full_name}.git"
69
- install_path = bundles_dir.join(full_name).to_s
70
- system *(%w[git clone] + [git_url, install_path])
71
- end
72
-
73
- private
74
-
75
- def within bundle
76
- Dir.chdir bundle.path do
77
- yield
78
- end
79
- end
80
-
81
- def installed_bundles
82
- @installed_bundles ||= Dir[bundles_dir.join('*').to_s].map {|path| Bundle.new(path)}
83
- end
84
-
85
- def bundles_dir
86
- @bundles_dir ||= Pathname('~/Library/Application Support/Avian/Bundles').expand_path
87
- end
88
-
89
- class Bundle < Struct.new(:path)
90
- def name
91
- @name ||= File.basename(path, '.tmbundle')
92
- end
93
- end
94
-
95
- def mate *args
96
- exec 'mate', *args
97
- end
98
- end
99
-
3
+ require 'tmbundle'
100
4
  TMBundle.start
@@ -1,5 +1,5 @@
1
1
  module Tmbundle
2
2
  module Manager
3
- VERSION = '0.1.0.pre2'
3
+ VERSION = '0.1.0.pre3'
4
4
  end
5
5
  end
data/lib/tmbundle.rb ADDED
@@ -0,0 +1,117 @@
1
+ require 'pathname'
2
+ require 'thor'
3
+
4
+ class TMBundle < Thor
5
+ desc 'edit PARTIAL_NAME', 'Edit an installed bundle (name will be matched against PARTIAL_NAME)'
6
+ def edit partial_name
7
+ matches = installed_bundles.select do |bundle|
8
+ bundle.name =~ /^#{partial_name}/i
9
+ end
10
+
11
+ if matches.size > 1
12
+ puts "please be more specific:"
13
+ matches.each_with_index {|m,i| puts " #{i+1}) #{m.name}"}
14
+ return false
15
+ end
16
+
17
+ if matches.empty?
18
+ puts "nothing found"
19
+ return false
20
+ end
21
+
22
+ bundle = matches.first
23
+ mate bundle.path
24
+ end
25
+
26
+ desc 'update', 'Update installed bundles'
27
+ def update
28
+ require 'thread'
29
+ signals = Queue.new
30
+ trap('INT') { signals << :int }
31
+
32
+ updated = []
33
+ skipped = []
34
+ errored = []
35
+
36
+ installed_bundles[0..4].each do |bundle|
37
+ within bundle do
38
+ if not(File.exist?('./.git'))
39
+ puts "------> Skipping #{bundle.name} (not a Git repo, delta bundle?)"
40
+ skipped << bundle
41
+ next
42
+ end
43
+
44
+ puts "------> Updating #{bundle.name}..."
45
+ system *%w[git pull --ff-only]
46
+ success = $? == 0
47
+ updated << bundle if success
48
+ errored << bundle unless success
49
+ puts
50
+ (puts 'Exiting…'; exit) if signals.pop == :int until signals.empty?
51
+ end
52
+ end
53
+
54
+ puts
55
+ puts
56
+ puts '------> Summary'
57
+ puts
58
+ puts "Skipped (#{skipped.size})\n- #{skipped.map(&:name).join("\n- ")}\n\n" if skipped.any?
59
+ puts "Updated (#{updated.size})\n- #{updated.map(&:name).join("\n- ")}\n\n" if updated.any?
60
+ puts "Errored (#{errored.size})\n- #{errored.map(&:name).join("\n- ")}\n\n" if errored.any?
61
+ end
62
+
63
+ desc 'install', 'Install a bundle from GitHub'
64
+ def install name
65
+ name = BundleName.new(name)
66
+ install_path = bundles_dir.join(name.install_name).to_s
67
+ system('git', 'clone', name.git_url, install_path)
68
+ end
69
+
70
+ class BundleName
71
+ def initialize(name)
72
+ @name = name
73
+ end
74
+
75
+ attr_reader :name
76
+ private :name
77
+
78
+ def install_name
79
+ File.basename(name.gsub(/([\.\-_]tmbundle)?$/i, '.tmbundle'))
80
+ end
81
+
82
+ def repo_name
83
+ name+'.tmbundle' unless name =~ /([\.\-_]tmbundle)$/i
84
+ end
85
+
86
+ def git_url
87
+ "https://github.com/#{repo_name}.git"
88
+ end
89
+ end
90
+
91
+ private
92
+
93
+ def within bundle
94
+ Dir.chdir bundle.path do
95
+ yield
96
+ end
97
+ end
98
+
99
+ def installed_bundles
100
+ @installed_bundles ||= Dir[bundles_dir.join('*').to_s].map {|path| Bundle.new(path)}
101
+ end
102
+
103
+ def bundles_dir
104
+ @bundles_dir ||= Pathname('~/Library/Application Support/Avian/Bundles').expand_path
105
+ end
106
+
107
+ class Bundle < Struct.new(:path)
108
+ def name
109
+ @name ||= File.basename(path, '.tmbundle')
110
+ end
111
+ end
112
+
113
+ def mate *args
114
+ exec 'mate', *args
115
+ end
116
+ end
117
+
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe TMBundle::BundleName do
4
+ subject(:bundle_name) { }
5
+
6
+ context 'with a dashed name' do
7
+ let(:name) { 'textmate/ruby-on-rails-tmbundle' }
8
+ end
9
+ end
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'bundler', '~> 1.6'
24
24
  spec.add_development_dependency 'rake'
25
25
  spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'spectator', '~> 1.3'
26
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmbundle-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre2
4
+ version: 0.1.0.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elia Schito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-28 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: spectator
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
69
83
  description:
70
84
  email:
71
85
  - elia@schito.me
@@ -82,11 +96,13 @@ files:
82
96
  - README.md
83
97
  - Rakefile
84
98
  - bin/tmb
99
+ - lib/tmbundle.rb
85
100
  - lib/tmbundle/manager.rb
86
101
  - lib/tmbundle/manager/server.rb
87
102
  - lib/tmbundle/manager/version.rb
88
103
  - spec/spec_helper.rb
89
104
  - spec/tmbundle/manager_spec.rb
105
+ - spec/tmbundle_spec.rb
90
106
  - tmbundle-manager.gemspec
91
107
  homepage: ''
92
108
  licenses:
@@ -115,3 +131,4 @@ summary: TextMate 2 Bundle/Package Manager
115
131
  test_files:
116
132
  - spec/spec_helper.rb
117
133
  - spec/tmbundle/manager_spec.rb
134
+ - spec/tmbundle_spec.rb