bundle_boss 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ # BundleBoss settings
2
+ settings:
3
+ # Show Growl notifications.
4
+ notifications: true
5
+ # Run 'bundle update' when required.
6
+ update: true
7
+
8
+ # Bundler settings. Can be any valid Bundler option.
9
+ bundler:
10
+ # Equivalent to: --binstubs
11
+ binstubs: true
12
+ # Equivalent to: --shebang ruby-local-exec
13
+ shebang: ruby-local-exec
14
+
15
+ # A list of your Bundler enabled projects.
16
+ projects:
17
+ - ~/src/omg
18
+ - ~/src/wtf
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.swp
19
+ *.swo
20
+ .DS_Store
@@ -0,0 +1 @@
1
+ 1.9.2-p290
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bundle_boss.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Mauro Pompilio
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,66 @@
1
+ BundleBoss
2
+ ==========
3
+
4
+ BundleBoss does all the dirty Bundler work for you. Watches your projects' Gemfiles for changes and automatically updates your bundle.
5
+
6
+ It's meant to run with [rbenv](https://github.com/sstephenson/rbenv) on Mac OS X.
7
+
8
+ It Just Works™.
9
+
10
+ How?
11
+ ----
12
+
13
+ Install BundleBoss:
14
+
15
+ $> gem install bundle_boss
16
+
17
+ Generate your .bundle_boss settings file in your $HOME:
18
+
19
+ # BundleBoss settings
20
+ settings:
21
+ # Show Growl notifications.
22
+ notifications: true
23
+ # Run 'bundle update' when required.
24
+ update: true
25
+
26
+ # Bundler settings. Can be any valid Bundler option.
27
+ bundler:
28
+ # Equivalent to: --binstubs
29
+ binstubs: true
30
+ # Equivalent to: --shebang ruby-local-exec
31
+ shebang: ruby-local-exec
32
+
33
+ # A list of your Bundler enabled projects.
34
+ projects:
35
+ - ~/src/omg
36
+ - ~/src/wtf
37
+
38
+ Start BundleBoss:
39
+
40
+ $> bundle_boss
41
+
42
+ License
43
+ -------
44
+
45
+ (The MIT license)
46
+
47
+ Copyright (c) 2011 Mauro Pompilio
48
+
49
+ Permission is hereby granted, free of charge, to any person obtaining
50
+ a copy of this software and associated documentation files (the
51
+ "Software"), to deal in the Software without restriction, including
52
+ without limitation the rights to use, copy, modify, merge, publish,
53
+ distribute, sublicense, and/or sell copies of the Software, and to
54
+ permit persons to whom the Software is furnished to do so, subject to
55
+ the following conditions:
56
+
57
+ The above copyright notice and this permission notice shall be
58
+ included in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
61
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
62
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
63
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
64
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
65
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
66
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundle_boss'
4
+
5
+ GrowlNotify.config do |config|
6
+ config.notifications = ["BundleBoss"]
7
+ config.default_notifications = ["BundleBoss"]
8
+ config.application_name = "BundleBoss"
9
+ end
10
+
11
+ # Load settings from ~/.bundleboss
12
+ settings_file = File.expand_path("~/.bundle_boss")
13
+ if File.exists? settings_file
14
+ settings = YAML::load(File.read(settings_file))
15
+ else
16
+ raise "Missing .bundle_boss settings file."
17
+ end
18
+
19
+ # Hardcode Bundle Action
20
+ BundleBoss::Watchdog.load settings
21
+ BundleBoss::Watchdog.run!
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/bundle_boss/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Mauro Pompilio"]
6
+ gem.email = ["hackers.are.rockstars@gmail.com"]
7
+ gem.description = %q{BundleBoss does all the dirty Bundler work for you.}
8
+ gem.summary = %q{BundleBoss. That is all.}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "bundle_boss"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = BundleBoss::VERSION
17
+
18
+ gem.add_dependency("bundler")
19
+ gem.add_dependency("rb-fsevent", "~> 0.4.3.1")
20
+ gem.add_dependency("growl_notify", "~> 0.0.3")
21
+ end
Binary file
Binary file
Binary file
@@ -0,0 +1,9 @@
1
+ require "rubygems"
2
+ require "yaml"
3
+ require "growl_notify"
4
+ require "rb-fsevent"
5
+ require "bundler"
6
+
7
+ require "bundle_boss/version"
8
+ require "bundle_boss/watchdog"
9
+ require "bundle_boss/project"
@@ -0,0 +1,80 @@
1
+ require 'digest/sha1'
2
+
3
+ module BundleBoss
4
+ class Project
5
+ attr_reader :path
6
+
7
+ def initialize(path, bundler_options = {}, settings = {})
8
+ @bundler_options = bundler_options
9
+ @settings = settings
10
+ @path = File.expand_path(path)
11
+ @hash = @path.hash
12
+ @sha1 = sha1
13
+ end
14
+
15
+ def sha1
16
+ Digest::SHA1.hexdigest File.read(@path + '/Gemfile')
17
+ end
18
+
19
+ def bundle_update
20
+ update_cmd = []
21
+ update_cmd << "cd #{@path};"
22
+ update_cmd << "#{bundle_path} update"
23
+ run update_cmd
24
+ end
25
+
26
+ def run(cmd)
27
+ stdout = nil
28
+ ::Bundler.with_clean_env do
29
+ ENV['RBENV_DIR'] = "#{@path}/"
30
+ stdout = `#{cmd.join(' ')}`
31
+ end
32
+ stdout
33
+ end
34
+
35
+ def bundle_install
36
+ install_cmd = []
37
+ install_cmd << "#{bundle_path} install"
38
+ install_cmd << "--gemfile #{@path}/Gemfile"
39
+ install_cmd << "--quiet"
40
+ @bundler_options.each do |key,value|
41
+ install_cmd << "--#{key}" if value
42
+ install_cmd << value if value.is_a? String
43
+ end
44
+ run install_cmd
45
+ end
46
+
47
+ def bundle_path
48
+ "#{ENV['HOME']}/.rbenv/shims/bundle"
49
+ end
50
+
51
+ def gemfile_changed?
52
+ @sha1 != sha1
53
+ end
54
+
55
+ def bundle
56
+ BundleBoss::Watchdog.info name, 'Hardcore Bundle Action'
57
+
58
+ stdout = bundle_install
59
+ if stdout =~ /bundle update/
60
+ if @settings['update']
61
+ BundleBoss::Watchdog.info name, 'Updating...'
62
+ bundle_update
63
+ stdout = bundle_install
64
+ end
65
+ end
66
+
67
+ if stdout.empty?
68
+ BundleBoss::Watchdog.success(name)
69
+ else
70
+ BundleBoss::Watchdog.error(name, "#{stdout.gsub(/\e\[\w{1,2}m/,'')}")
71
+ end
72
+
73
+ @sha1 = sha1
74
+ end
75
+
76
+ def name
77
+ @path.split('/').last
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,3 @@
1
+ module BundleBoss
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,59 @@
1
+ module BundleBoss
2
+ module Watchdog
3
+ class << self
4
+ def load(settings = {})
5
+ @settings = settings['settings']
6
+ @bundler = settings['bundler']
7
+ @projects = settings['projects'].map {|path| File.expand_path(path) }
8
+ end
9
+
10
+ def project_index
11
+ @index ||= @projects.inject({}) do |accum, path|
12
+ accum[path.hash] = BundleBoss::Project.new(path, @bundler, @settings)
13
+ accum
14
+ end
15
+ end
16
+
17
+ def info(name, msg)
18
+ p [:info, name, msg]
19
+ if @settings['notifications']
20
+ GrowlNotify.normal(:title => name,
21
+ :description => msg,
22
+ :icon => File.expand_path(File.dirname(__FILE__) + '/../../images/pending.png'))
23
+ end
24
+ end
25
+
26
+ def success(name)
27
+ p [:success, name]
28
+ if @settings['notifications']
29
+ GrowlNotify.very_low(:title => name,
30
+ :description => 'All systems go!',
31
+ :icon => File.expand_path(File.dirname(__FILE__) + '/../../images/success.png'))
32
+ end
33
+ end
34
+
35
+ def error(name, msg)
36
+ p [:error, msg]
37
+ if @settings['notifications']
38
+ GrowlNotify.sticky!(:title => name,
39
+ :description => msg,
40
+ :icon => File.expand_path(File.dirname(__FILE__) + '/../../images/failed.png'))
41
+ end
42
+ end
43
+
44
+ def run!
45
+ watchdog = FSEvent.new
46
+ watchdog.watch project_index.values.map(&:path) do |paths|
47
+ paths.each do |path|
48
+ hash = File.expand_path(path).hash
49
+ project = project_index[hash]
50
+ next unless project
51
+ project.bundle if project.gemfile_changed?
52
+ end
53
+ end
54
+ info('BundleBoss', 'Bundling like a boss.')
55
+ watchdog.run
56
+ end
57
+ end
58
+ end
59
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bundle_boss
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mauro Pompilio
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-14 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: &2152760220 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2152760220
25
+ - !ruby/object:Gem::Dependency
26
+ name: rb-fsevent
27
+ requirement: &2152759600 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.4.3.1
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2152759600
36
+ - !ruby/object:Gem::Dependency
37
+ name: growl_notify
38
+ requirement: &2152758980 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.0.3
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2152758980
47
+ description: BundleBoss does all the dirty Bundler work for you.
48
+ email:
49
+ - hackers.are.rockstars@gmail.com
50
+ executables:
51
+ - bundle_boss
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .bundle_boss.sample
56
+ - .gitignore
57
+ - .rbenv-version
58
+ - Gemfile
59
+ - LICENSE
60
+ - README.md
61
+ - Rakefile
62
+ - bin/bundle_boss
63
+ - bundle_boss.gemspec
64
+ - images/failed.png
65
+ - images/pending.png
66
+ - images/success.png
67
+ - lib/bundle_boss.rb
68
+ - lib/bundle_boss/project.rb
69
+ - lib/bundle_boss/version.rb
70
+ - lib/bundle_boss/watchdog.rb
71
+ homepage: ''
72
+ licenses: []
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 1.8.10
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: BundleBoss. That is all.
95
+ test_files: []