Class: BundleBoss::Project
- Inherits:
-
Object
- Object
- BundleBoss::Project
- Defined in:
- lib/bundle_boss/project.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #bundle ⇒ Object
- #bundle_install ⇒ Object
- #bundle_path ⇒ Object
- #bundle_update ⇒ Object
- #gemfile_changed? ⇒ Boolean
-
#initialize(path, bundler_options = {}, settings = {}) ⇒ Project
constructor
A new instance of Project.
- #name ⇒ Object
- #run(cmd) ⇒ Object
- #sha1 ⇒ Object
Constructor Details
#initialize(path, bundler_options = {}, settings = {}) ⇒ Project
Returns a new instance of Project.
7 8 9 10 11 12 13 |
# File 'lib/bundle_boss/project.rb', line 7 def initialize(path, = {}, settings = {}) @bundler_options = @settings = settings @path = File.(path) @hash = @path.hash @sha1 = sha1 end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/bundle_boss/project.rb', line 5 def path @path end |
Instance Method Details
#bundle ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/bundle_boss/project.rb', line 55 def bundle BundleBoss::Watchdog.info name, 'Hardcore Bundle Action' stdout = bundle_install if stdout =~ /bundle update/ if @settings['update'] BundleBoss::Watchdog.info name, 'Updating...' bundle_update stdout = bundle_install end end if stdout.empty? BundleBoss::Watchdog.success(name) else BundleBoss::Watchdog.error(name, "#{stdout.gsub(/\e\[\w{1,2}m/,'')}") end @sha1 = sha1 end |
#bundle_install ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bundle_boss/project.rb', line 35 def bundle_install install_cmd = [] install_cmd << "#{bundle_path} install" install_cmd << "--gemfile #{@path}/Gemfile" install_cmd << "--quiet" @bundler_options.each do |key,value| install_cmd << "--#{key}" if value install_cmd << value if value.is_a? String end run install_cmd end |
#bundle_path ⇒ Object
47 48 49 |
# File 'lib/bundle_boss/project.rb', line 47 def bundle_path "#{ENV['HOME']}/.rbenv/shims/bundle" end |
#bundle_update ⇒ Object
19 20 21 22 23 24 |
# File 'lib/bundle_boss/project.rb', line 19 def bundle_update update_cmd = [] update_cmd << "cd #{@path};" update_cmd << "#{bundle_path} update" run update_cmd end |
#gemfile_changed? ⇒ Boolean
51 52 53 |
# File 'lib/bundle_boss/project.rb', line 51 def gemfile_changed? @sha1 != sha1 end |
#name ⇒ Object
76 77 78 |
# File 'lib/bundle_boss/project.rb', line 76 def name @path.split('/').last end |
#run(cmd) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/bundle_boss/project.rb', line 26 def run(cmd) stdout = nil ::Bundler.with_clean_env do ENV['RBENV_DIR'] = "#{@path}/" stdout = `#{cmd.join(' ')}` end stdout end |
#sha1 ⇒ Object
15 16 17 |
# File 'lib/bundle_boss/project.rb', line 15 def sha1 Digest::SHA1.hexdigest File.read(@path + '/Gemfile') end |