tmbundle-manager 0.1.0.pre3 → 0.1.0.pre4

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: 77f32abf4b5ce55055841dbe347a9c715143146b
4
- data.tar.gz: 07ab6f1206b3458849874a5239524d9157b3805c
3
+ metadata.gz: d6accee3952ebad16c5001d8a4d95b5487a45eac
4
+ data.tar.gz: 3b7abf9cba143af3e6f1ac3739139382ddb88202
5
5
  SHA512:
6
- metadata.gz: 49de021c0e249769fea02108da7cf66a6b110231be5134de78dca0f58dfa2a2e672f85fe7a2166994ce5f48bf918f36b7b865332a8b1654ff1fd4ff958b259eb
7
- data.tar.gz: 9c96a97acee53e0dd4c1b06d82a3a6db366630cc021fd047d8cd10eb468a656c17273ed5a81cfe7b4dae2997059cca51bf77345a763286574f1644cda181e502
6
+ metadata.gz: 266e073302e2c961c2008003bd4fd21b1f39ae5bcfa85aa4ae3da0e7afb03aab35b2355a856fca962e45112167f795b95479df483ff69ffaaf28385b881a1658
7
+ data.tar.gz: f386c44ff200a7e230ba97e34a8e43029400d54e6cbcf766463179dce04218556b6e9ebedd1435d7915a735ec293aea71eeccfbaa81ca8fa9a2ad3842300be76
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # TM Bundles/Package manager
2
2
 
3
+ Install bundle from github easily:
4
+
5
+ ```shell
6
+ tmb install elia/avian-missing
7
+ ```
3
8
 
4
9
 
5
10
  ## Installation
@@ -17,16 +22,17 @@ Use the `tmb` executable:
17
22
  $ tmb help
18
23
 
19
24
  Commands:
20
- tmb edit PARTIAL_NAME # Edit an installed bundle (name will be matched against PARTIAL_NAME)
21
- tmb help [COMMAND] # Describe available commands or one specific command
22
- tmb update # Update installed bundles
25
+ tmb edit PARTIAL_NAME # Edit an installed bundle (name will be matched against PARTIAL_NAME)
26
+ tmb help [COMMAND] # Describe available commands or one specific command
27
+ tmb install USER/BUNDLE # Install a bundle from GitHub (e.g. tmb install elia/bundler)
28
+ tmb update # Update installed bundles
23
29
 
24
30
  ```
25
31
 
26
32
 
27
33
  ## Contributing
28
34
 
29
- 1. Fork it ( https://github.com/[my-github-username]/tmbundle-manager/fork )
35
+ 1. Fork it ( https://github.com/elia/tmbundle-manager/fork )
30
36
  2. Create your feature branch (`git checkout -b my-new-feature`)
31
37
  3. Commit your changes (`git commit -am 'Add some feature'`)
32
38
  4. Push to the branch (`git push origin my-new-feature`)
@@ -0,0 +1,22 @@
1
+ module TMBundle
2
+ class BundleName
3
+ def initialize(name)
4
+ @name = name
5
+ end
6
+
7
+ attr_reader :name
8
+ private :name
9
+
10
+ def install_name
11
+ File.basename(name.gsub(/([\.\-_]tmbundle)?$/i, '.tmbundle'))
12
+ end
13
+
14
+ def repo_name
15
+ name+'.tmbundle' unless name =~ /([\.\-_]tmbundle)$/i
16
+ end
17
+
18
+ def git_url
19
+ "https://github.com/#{repo_name}.git"
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  module Tmbundle
2
2
  module Manager
3
- VERSION = '0.1.0.pre3'
3
+ VERSION = '0.1.0.pre4'
4
4
  end
5
5
  end
data/lib/tmbundle.rb CHANGED
@@ -4,23 +4,10 @@ require 'thor'
4
4
  class TMBundle < Thor
5
5
  desc 'edit PARTIAL_NAME', 'Edit an installed bundle (name will be matched against PARTIAL_NAME)'
6
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
7
+ bundle = find_bundle(partial_name)
23
8
  mate bundle.path
9
+ rescue NotFound
10
+ return false
24
11
  end
25
12
 
26
13
  desc 'update', 'Update installed bundles'
@@ -42,7 +29,7 @@ class TMBundle < Thor
42
29
  end
43
30
 
44
31
  puts "------> Updating #{bundle.name}..."
45
- system *%w[git pull --ff-only]
32
+ system(*%w[git pull --ff-only])
46
33
  success = $? == 0
47
34
  updated << bundle if success
48
35
  errored << bundle unless success
@@ -60,35 +47,90 @@ class TMBundle < Thor
60
47
  puts "Errored (#{errored.size})\n- #{errored.map(&:name).join("\n- ")}\n\n" if errored.any?
61
48
  end
62
49
 
63
- desc 'install', 'Install a bundle from GitHub'
50
+ desc 'install USER/BUNDLE', 'Install a bundle from GitHub (e.g. tmb install elia/bundler)'
64
51
  def install name
65
52
  name = BundleName.new(name)
66
53
  install_path = bundles_dir.join(name.install_name).to_s
67
54
  system('git', 'clone', name.git_url, install_path)
68
55
  end
69
56
 
70
- class BundleName
71
- def initialize(name)
72
- @name = name
57
+ desc 'path NAME', 'print path to bundle dir'
58
+ def path name
59
+ puts find_bundle(name).path
60
+ rescue NotFound
61
+ return false
62
+ end
63
+
64
+ desc 'status [BUNDLE]', 'Check the status of your local copy of the bundle'
65
+ def status name = nil
66
+ justification = 50
67
+ bundles_list.all.each do |bundle|
68
+ within bundle do
69
+ print "- #{bundle.name}...".ljust(justification)
70
+ # puts "-> fetching updates from remote..."
71
+ `git fetch -aq 2> /dev/null`
72
+ fetch_successful = $?.success?
73
+ # puts "-> checking status..."
74
+ branch_info, *changes = `git status -zb`.split("\0")
75
+ branch, remote, branch_status, = branch_info.scan(/^## (\S+)\.\.\.(\S+)(?: \[(.+)\])?/).flatten
76
+ cd_hint = false
77
+
78
+ if changes.any?
79
+ cd_hint = true
80
+ print "✘ #{changes.size} changed/new file#{:s if changes.size != 0}.".ljust(justification)
81
+ else
82
+ case branch_status.to_s
83
+ when /^ahead (\d+)/
84
+ ahead_commits = $1
85
+ cd_hint = true
86
+ print "✘ #{ahead_commits} commits ahead of #{remote}. ".ljust(justification)
87
+ when /^behind (\d+)/
88
+ behind_commits = $1
89
+ cd_hint = true
90
+ print "❍ behind remote (#{remote}) by #{behind_commits}. ".ljust(justification)
91
+ else
92
+ print "✔︎ up-to-date"
93
+ end
94
+ end
95
+ print "$ cd \"#{bundle.path}\" # to enter the bundle directory" if cd_hint
96
+ puts
97
+ puts "#{' '*justification}✘✘✘ Something went wrong while fetching from remote #{remote}" unless fetch_successful
98
+ end
99
+ end
100
+ end
101
+
102
+ desc 'list', 'lists all installed bundles'
103
+ def list
104
+ bundles_list.all.each do |bundle|
105
+ puts "- #{bundle.name.ljust(30)} (#{bundle.path})"
73
106
  end
107
+ end
108
+
74
109
 
75
- attr_reader :name
76
- private :name
77
110
 
78
- def install_name
79
- File.basename(name.gsub(/([\.\-_]tmbundle)?$/i, '.tmbundle'))
111
+ private
112
+
113
+ def find_bundle(partial_name)
114
+ matches = installed_bundles.select do |bundle|
115
+ bundle.name =~ /^#{partial_name}/i
80
116
  end
81
117
 
82
- def repo_name
83
- name+'.tmbundle' unless name =~ /([\.\-_]tmbundle)$/i
118
+ if matches.size > 1
119
+ puts "please be more specific:"
120
+ matches.each_with_index {|m,i| puts " #{i+1}) #{m.name}"}
121
+ raise NotFound
84
122
  end
85
123
 
86
- def git_url
87
- "https://github.com/#{repo_name}.git"
124
+ if matches.empty?
125
+ puts "nothing found"
126
+ raise NotFound
88
127
  end
128
+
129
+ matches.first
89
130
  end
90
131
 
91
- private
132
+ class NotFound < StandardError
133
+ end
92
134
 
93
135
  def within bundle
94
136
  Dir.chdir bundle.path do
@@ -97,13 +139,25 @@ class TMBundle < Thor
97
139
  end
98
140
 
99
141
  def installed_bundles
100
- @installed_bundles ||= Dir[bundles_dir.join('*').to_s].map {|path| Bundle.new(path)}
142
+ bundles_list.all
143
+ end
144
+
145
+ def bundles_list
146
+ @bundles_list ||= BundlesList.new(bundles_dir)
101
147
  end
102
148
 
103
149
  def bundles_dir
104
150
  @bundles_dir ||= Pathname('~/Library/Application Support/Avian/Bundles').expand_path
105
151
  end
106
152
 
153
+ class BundlesList < Struct.new(:dir)
154
+ def all
155
+ @all ||= Dir[dir.join('*/.git').to_s].map do |path|
156
+ Bundle.new(Pathname(path).join('..').to_s)
157
+ end
158
+ end
159
+ end
160
+
107
161
  class Bundle < Struct.new(:path)
108
162
  def name
109
163
  @name ||= File.basename(path, '.tmbundle')
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.pre3
4
+ version: 0.1.0.pre4
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-05-07 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -97,6 +97,7 @@ files:
97
97
  - Rakefile
98
98
  - bin/tmb
99
99
  - lib/tmbundle.rb
100
+ - lib/tmbundle/bundle_name.rb
100
101
  - lib/tmbundle/manager.rb
101
102
  - lib/tmbundle/manager/server.rb
102
103
  - lib/tmbundle/manager/version.rb
@@ -124,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
125
  version: 1.3.1
125
126
  requirements: []
126
127
  rubyforge_project:
127
- rubygems_version: 2.2.2
128
+ rubygems_version: 2.3.0
128
129
  signing_key:
129
130
  specification_version: 4
130
131
  summary: TextMate 2 Bundle/Package Manager