brew-flight 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 84187cec81ce54b6adf2d93a36a06c504e60f215
4
+ data.tar.gz: 99d88bd2876afdfcfc6946d2cd3930ce0377569e
5
+ SHA512:
6
+ metadata.gz: 15460c44d76579ca596eebe3983fd6f7d385a772a127b5c01be71be8efd87f3f817d898f33fae212414e87857333a6a6c50043b795acac87f5e8e4ca9a4476c5
7
+ data.tar.gz: 574bc23b90d731e1f1c89d4757ff9e9ac6b2274a9a96475544c0209b194d5c557d38fd87c6f2bee20862ca6f84135e20b88f7b6b1792010504d459d3ec6f0f0e
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
@@ -0,0 +1 @@
1
+ brew 'git', '~> 2.2'
@@ -0,0 +1 @@
1
+ {"flight":{"version":"0.0.1","ruby_version":"2.0.0","brew_version":"0.9.5\n","last_flown":1419060077},"taps":[],"packages":["#<Flight::Package:0x007fc473132b78>"]}
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in flight.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Tom Scott.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,20 @@
1
+ .PHONY: all share/man/man.1/flight.1 man build install
2
+
3
+ all: man build
4
+
5
+ test:
6
+ bundle exec rspec
7
+
8
+ share/man/man.1/flight.1:
9
+ kramdown-man doc/man/flight.md share/man/man.1/flight.1
10
+
11
+ man: share/man/man.1/flight.1
12
+
13
+ dependencies:
14
+ bundle install --path=${PREFIX}/vendor/bundle --deployment
15
+
16
+ build: dependencies
17
+ bundle exec rake build
18
+
19
+ install: build
20
+ sudo gem install ${PREFIX}/pkg/*.gem
@@ -0,0 +1,77 @@
1
+ # Flight
2
+
3
+ **WARNING:** Flight is untested and probably doesn't work.
4
+
5
+ Flight helps manage your Homebrew packages in the same way
6
+ [Bundler][bundle] helps you manage gem dependencies. With your
7
+ `Brewfile`, you can tell Homebrew to install packages, configure build
8
+ options, and even install custom taps.
9
+
10
+ ## Installation
11
+
12
+ Flight is a RubyGem, and for now you can only install it _with_
13
+ RubyGems:
14
+
15
+ ```bash
16
+ $ gem install flight
17
+ ```
18
+
19
+ You can also include it as a dependency in your Ruby project with
20
+ Bundler. Just add this line to your Gemfile and run `bundle`:
21
+
22
+ ```ruby
23
+ gem 'flight'
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ First of all, you'll need a Brewfile before you do anything else.
29
+ Generate one with the following command:
30
+
31
+ ```bash
32
+ $ flight generate
33
+ ```
34
+
35
+ Next, edit the Brewfile with the packages you want to install. You can
36
+ specify version constraints in the same manner as [Bundler][bundle] and
37
+ [Berkshelf][berks].
38
+
39
+ ```ruby
40
+ brew 'vim'
41
+ brew 'git', '~> 2.2'
42
+ ```
43
+
44
+ Once you're all done figuring out the packages you wish to install, it's
45
+ time to actually run Homebrew. Run the following command to install
46
+ every package and build a `Brewfile.lock` which saves the state of the
47
+ current run.
48
+
49
+ ```bash
50
+ $ flight install
51
+ ```
52
+
53
+ Packages get updated over time, and Flight can handle managing updates
54
+ and outdated packages. Run the following command to see what's outdated:
55
+
56
+ ```bash
57
+ $ flight outdated
58
+ ```
59
+
60
+ This will inform you of any formulae that have been updated to build a
61
+ version past the one you already have installed. You can now run `bundle
62
+ update PACKAGE` to upgrade just that one package, or `bundle update` to
63
+ upgrade every package. Flight uses the `brew upgrade` command to update
64
+ packages.
65
+
66
+ ## Contributing
67
+
68
+ All contributions must include tests.
69
+
70
+ 1. Fork it ( https://github.com/tubbo/flight/fork )
71
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
72
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
73
+ 4. Push to the branch (`git push origin my-new-feature`)
74
+ 5. Create a new Pull Request
75
+
76
+ [bundle]: http://bundler.io
77
+ [berks]: http://berkshelf.com
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'flight'
4
+
5
+ Flight::Executable.start
@@ -0,0 +1,7 @@
1
+ tap 'tubbo/homebrew-git'
2
+
3
+ brew 'vim'
4
+ brew 'git', '~> 2.2'
5
+ brew 'chruby'
6
+ brew 'ruby-install'
7
+ brew 'homer'
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'flight/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "brew-flight"
8
+ spec.version = Flight::VERSION
9
+ spec.authors = ["Tom Scott"]
10
+ spec.email = ["tscott@telvue.com"]
11
+ spec.summary = %q{Flight is a Bundler for Homebrew.}
12
+ spec.description = "#{spec.summary} It helps you manage the Homebrew packages you want on your system."
13
+ spec.homepage = "http://github.com/tubbo/flight"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3"
24
+ spec.add_dependency "thor"
25
+ end
@@ -0,0 +1,20 @@
1
+ require "flight/version"
2
+ require "flight/executable"
3
+
4
+ # Flight is a dependency manager for your Homebrew packages. This is the
5
+ # base module that includes configuration, global attributes, and
6
+ # requires to the actual code. Most of the codebase lies in the data
7
+ # models of Package and Tap, with the Executable being the "controller"
8
+ # to the UI.
9
+
10
+ module Flight
11
+ DEBUG = ENV['FLIGHT_DEBUG']
12
+
13
+ def self.version
14
+ VERSION
15
+ end
16
+
17
+ def self.debug?
18
+ !!DEBUG
19
+ end
20
+ end
@@ -0,0 +1,83 @@
1
+ require 'flight/brewfile/dsl'
2
+ require 'flight/brewfile/lockfile'
3
+
4
+ require 'flight/package'
5
+ require 'flight/tap'
6
+
7
+ require 'json'
8
+
9
+ module Flight
10
+ # Parses a Brewfile, responsible for instantiating collections of
11
+ # Package objects.
12
+ class Brewfile
13
+ include DSL
14
+
15
+ attr_reader :filename
16
+
17
+ attr_reader :lockfile
18
+
19
+ attr_accessor :packages
20
+
21
+ attr_accessor :taps
22
+
23
+ DEFAULT_SOURCE = 'homebrew/homebrew'
24
+
25
+ attr_accessor :source_repository
26
+
27
+ def initialize(filename='./Brewfile')
28
+ @filename = File.expand_path(filename)
29
+ @lockfile = Lockfile.new filename, existing_lockfile_data
30
+ @packages = Package::Collection.new
31
+ @taps = Tap::Collection.new
32
+ @source_repository = DEFAULT_SOURCE
33
+ end
34
+
35
+ def self.parse!
36
+ file = new
37
+ file.parse
38
+ file.lock if file.changed?
39
+ file
40
+ end
41
+
42
+ def parse
43
+ instance_eval contents
44
+ end
45
+
46
+ def changed?
47
+ lockfile.taps != taps.to_json || lockfile.packages != packages.to_json
48
+ end
49
+
50
+ def default_source?
51
+ source_repository == DEFAULT_SOURCE
52
+ end
53
+
54
+ def lock
55
+ update_lockfile and write_lockfile
56
+ end
57
+
58
+ private
59
+ def update_lockfile
60
+ lockfile.taps = tap_attributes
61
+ lockfile.packages = package_attributes
62
+ lockfile.taps.any? && lockfile.packages.any?
63
+ end
64
+
65
+ def write_lockfile
66
+ File.write lockfile.path, lockfile.to_json
67
+ lockfile.exist?
68
+ end
69
+
70
+ private
71
+ def contents
72
+ @contents ||= File.read filename
73
+ rescue Errno::ENOENT
74
+ raise "You must have a Brewfile in this dir to proceed."
75
+ end
76
+
77
+ def lockfile_contents
78
+ JSON.parse File.read("#{filename}.lock")
79
+ rescue
80
+ nil
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,33 @@
1
+ require 'flight/tap'
2
+ require 'flight/package'
3
+
4
+ module Flight
5
+ class Brewfile
6
+ # The various commands you can use in a Brewfile.
7
+ module DSL
8
+ # Change the source of this Brewfile. Defaults to
9
+ # 'homebrew/homebrew', but you can supply your own fork here if
10
+ # necessary.
11
+ def source(path)
12
+ self.source_repository = "https://github.com/#{path}.git"
13
+ end
14
+
15
+ # Install a tap source.
16
+ def tap(repo)
17
+ self.taps << Tap.new(name: repo)
18
+ end
19
+
20
+ # Install a package.
21
+ def brew(name, *args)
22
+ options = args.last.is_a?(Hash) ? args.pop.dup : {}
23
+ version = args || [">= 0"]
24
+
25
+ self.packages << Package.new(
26
+ name: name,
27
+ version: version.join("\s"),
28
+ options: options
29
+ )
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,41 @@
1
+ require 'json'
2
+ require 'flight/version'
3
+
4
+ module Flight
5
+ class Brewfile
6
+ class Lockfile
7
+ attr_accessor :taps
8
+
9
+ attr_accessor :packages
10
+
11
+ attr_reader :path
12
+
13
+ def initialize(from_filename, and_json=nil)
14
+ @path = "#{from_filename}.lock"
15
+ @attributes = and_json
16
+ end
17
+
18
+ def exist?
19
+ File.exist? path
20
+ end
21
+
22
+ def attributes
23
+ @attributes ||= {
24
+ flight: {
25
+ version: Flight::VERSION,
26
+ ruby_version: RUBY_VERSION,
27
+ brew_version: `brew --version`,
28
+ locked_at: Time.now.to_i,
29
+ debug: (Flight.debug?) ? 'on' : 'off'
30
+ },
31
+ taps: taps
32
+ packages: packages
33
+ }
34
+ end
35
+
36
+ def to_json
37
+ attributes.to_json
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,78 @@
1
+ require 'thor'
2
+ require 'flight'
3
+ require 'flight/brewfile'
4
+
5
+ module Flight
6
+ class Executable < Thor
7
+ include Thor::Actions
8
+
9
+ source_root File.expand_path('../../templates', __FILE__)
10
+
11
+ desc :install, "Install Homebrew packages."
12
+ def install
13
+ update_brew and
14
+ brewfile.packages.each { |pkg| use pkg } and
15
+ say("Your flight is complete!\nPackages have been installed to #{prefix}.")
16
+ end
17
+
18
+ desc :update, "Update all Homebrew packages and edit the lockfile"
19
+ def update
20
+ update_brew and brewfile.packages.outdated.each { |pkg| use pkg }
21
+ end
22
+
23
+ desc :update, "List all outdated Homebrew packages"
24
+ def outdated
25
+ update_brew and brewfile.packages.outdated.each do |pkg|
26
+ say "Current #{pkg.name} is #{pkg.current}, you have #{pkg.version}"
27
+ end
28
+ end
29
+
30
+ desc :generate, "Create a Brewfile in this directory."
31
+ def generate
32
+ template 'Brewfile', 'Brewfile'
33
+ end
34
+
35
+ private
36
+ def use(package)
37
+ if package.installed?
38
+ say "Using #{package}"
39
+ else
40
+ brew :install, "#{package.name} #{package.options}"
41
+ say "Installed #{package}"
42
+ end
43
+ end
44
+
45
+ def brewfile
46
+ @brewfile ||= Brewfile.parse!
47
+ end
48
+
49
+ def update_brew
50
+ install_source unless brewfile.default_source?
51
+ brewfile.taps.unknown.each { |package| brew :tap, tap }
52
+ brew :update
53
+ end
54
+
55
+ def brew(command, arguments='')
56
+ if Flight.debug?
57
+ run "brew #{command} #{arguments} --quiet"
58
+ else
59
+ system "brew #{command} #{arguments} --quiet"
60
+ end
61
+ end
62
+
63
+ def prefix
64
+ `brew --prefix`.strip
65
+ end
66
+
67
+ private
68
+ def install_source
69
+ system %[
70
+ cd $(brew --prefix) &&
71
+ git remote rm flight-source;
72
+ git remote add flight-source #{brewfile.source_repository} &&
73
+ git branch --set-upstream-to=flight-source/master &&
74
+ git fetch flight-source
75
+ ] or raise "Source '#{brewfile.source_repository}' could not be loaded."
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,89 @@
1
+ require 'flight/package/collection'
2
+ require 'flight/package/options'
3
+
4
+ module Flight
5
+ # Represents a single Package in the Brewfile.
6
+ class Package
7
+ # Parameters passed in as options when instantiated.
8
+ attr_reader :params
9
+
10
+ # The name of this package
11
+ attr_accessor :name
12
+
13
+ # Any build options to be passed in
14
+ attr_writer :options
15
+
16
+ # Instantiate the object and assign any attributes.
17
+ def initialize(arguments={})
18
+ @params = arguments
19
+ @options = Options.new @params.delete(:options)
20
+ @version = Version.new @params.delete(:version)
21
+
22
+ params.each do |key, value|
23
+ setter = "#{key}="
24
+ send setter, value if respond_to? setter
25
+ end
26
+ end
27
+
28
+ def version=(new_version_string)
29
+ @version.string = new_version_string
30
+ end
31
+
32
+ def to_s
33
+ "#{name} at v#{version}"
34
+ end
35
+
36
+ # Render relevant attributes as a Hash.
37
+ def attributes
38
+ {
39
+ name: name,
40
+ version: version,
41
+ options: options.to_h
42
+ }
43
+ end
44
+
45
+ # The version of this package as defined by Homebrew.
46
+ def current_version
47
+ if info =~ /#{name}: stable (?<version>.*)(\(|,)/
48
+ $1.strip
49
+ end
50
+ end
51
+
52
+ def has_version?
53
+ @version != '>= 0'
54
+ end
55
+
56
+ def requested_version
57
+ @version
58
+ end
59
+
60
+ def version
61
+ if has_version?
62
+ requested_version
63
+ else
64
+ current_version
65
+ end
66
+ end
67
+
68
+ # Check if this package is installed with Homebrew. Actually, it
69
+ # checks if this package is not NOT installed with Homebrew. :)
70
+ def installed?
71
+ info !~ /Not Installed/
72
+ end
73
+
74
+ # Checks if this package is up-to-date by comparing the stored
75
+ # version with the latest version from Homebrew's info command.
76
+ def up_to_date?
77
+ info.split("\n").first.include? version
78
+ end
79
+
80
+ def outdated?
81
+ (not up_to_date?)
82
+ end
83
+
84
+ private
85
+ def info
86
+ @info ||= `brew info #{name}`
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,37 @@
1
+ module Flight
2
+ class Package
3
+ # Represents the entire Brewfile.
4
+ class Collection
5
+ include Enumerable
6
+
7
+ attr_accessor :all
8
+
9
+ def initialize(with_packages=[])
10
+ @all = with_packages
11
+ end
12
+
13
+ def each
14
+ all.each { |package| yield package }
15
+ end
16
+
17
+ # Filter out packages which are installed.
18
+ def installed
19
+ all.select(&:installed?)
20
+ end
21
+
22
+ # Filter out packages which are installed, but according to
23
+ # Homebrew are out of date.
24
+ def outdated
25
+ all.select(&:up_to_date?)
26
+ end
27
+
28
+ def <<(new_pkg)
29
+ @all << new_pkg
30
+ end
31
+
32
+ def to_json
33
+ all.map(&:attributes).to_json
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,30 @@
1
+ module Flight
2
+ class Package
3
+ # Stores command-line options for a Package as a Hash, and outputs
4
+ # said options to a String suitable for tacking onto the end of a
5
+ # `brew install` run.
6
+ class Options
7
+ def initialize(from_hash={})
8
+ @hash = from_hash
9
+ end
10
+
11
+ # Convert the hash of build options into a string of command-line
12
+ # arguments.
13
+ def to_s
14
+ @hash.map { |key, value|
15
+ option = key.to_s.gsub(/_/, '-')
16
+ if !!value == value
17
+ value ? "--#{option}" : "--no-#{option}"
18
+ else
19
+ "--#{option}=#{value}"
20
+ end
21
+ }.join("\s")
22
+ end
23
+
24
+ # Output options as a Hash.
25
+ def to_h
26
+ @hash
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ module Flight
2
+ class Package
3
+ class Version
4
+ attr_accessor :string
5
+
6
+ def initialize(with_string)
7
+ @string = with_string
8
+ end
9
+
10
+ def to_s
11
+ resolve string
12
+ end
13
+
14
+ private
15
+ def resolve(string)
16
+ string
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,37 @@
1
+ module Flight
2
+ # Represents a tap designated by the `tap` directive in Brewfile. This
3
+ # is a repo we should be pulling formulae from.
4
+ class Tap
5
+ attr_reader :name
6
+
7
+ def initialize(with_name)
8
+ @name = with_name
9
+ end
10
+
11
+ def installed?
12
+ `brew tap`.include? name
13
+ end
14
+
15
+ class Collection
16
+ attr_reader :all
17
+
18
+ def initialize(with_taps=[])
19
+ @all = with_taps
20
+ end
21
+
22
+ def unknown
23
+ all.reject do |tap|
24
+ known.include? tap.name
25
+ end
26
+ end
27
+
28
+ def known
29
+ `brew tap`.split("\n").map { |name| Tap.new(name) }
30
+ end
31
+
32
+ def <<(new_tap)
33
+ @all << new_tap
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module Flight
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,33 @@
1
+ # This is your Brewfile. Use the following command to install a new
2
+ # package from Homebrew source:
3
+ #
4
+ # brew 'git', '~> 2.2'
5
+ #
6
+ # You can also install packages from custom taps:
7
+ #
8
+ # tap 'neovim/neovim'
9
+ #
10
+ # brew 'neovim', HEAD: true
11
+ #
12
+ # Much like Bundler's `source`, you only need to specify a tap once.
13
+ # It's installed the first time you add it and checked every time you
14
+ # run `flight install`.
15
+ #
16
+ # Start by adding some packages and taps and run `flight install` to get
17
+ # them on your system! Here's a few good packages to get you started:
18
+
19
+ brew 'vim'
20
+ brew 'git', '~> 2.2'
21
+ brew 'chruby'
22
+ brew 'ruby-install'
23
+ brew 'zsh'
24
+ brew 'postgresql'
25
+ brew 'bats'
26
+ brew 'hub'
27
+ brew 'gist'
28
+ brew 'the_silver_searcher'
29
+
30
+ #tap 'tubbo/homebrew-tap'
31
+ #brew 'rails-template'
32
+ #brew 'antigen'
33
+ #brew 'homer'
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+ require 'flight'
3
+
4
+ module Flight
5
+ RSpec.describe Executable do
6
+ end
7
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+ require 'flight/package/options'
3
+
4
+ module Flight
5
+ class Package
6
+ RSpec.describe Options do
7
+ let :hash do
8
+ { with_ruby: true, perl: false }
9
+ end
10
+
11
+ subject do
12
+ Options.new hash
13
+ end
14
+
15
+ it "converts options into query parameters" do
16
+ expect(subject.to_s).to eq('--with-ruby --no-perl')
17
+ end
18
+
19
+ it "outputs options as a hash" do
20
+ expect(subject.to_h).to eq(hash)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+ require 'flight/package'
3
+
4
+ module Flight
5
+ RSpec.describe Package do
6
+ subject do
7
+ Package.new(
8
+ name: 'flight',
9
+ version: '1.0.0',
10
+ options: { with_ruby: true }
11
+ )
12
+ end
13
+
14
+ it "converts params into attributes" do
15
+ expect(subject.name).to eq('flight')
16
+ expect(subject.version).to eq('1.0.0')
17
+ end
18
+
19
+ it "converts options param hash into options object" do
20
+ expect(subject.options).to be_a(Package::Options)
21
+ end
22
+
23
+ it "finds current version from brew" do
24
+ allow(subject).to receive(:info).and_return("flight: #{subject.version} stable, HEAD")
25
+ expect(subject.current_version).to eq(subject.version)
26
+ end
27
+
28
+ it "is up to date when current_version matches version" do
29
+ allow(subject).to receive(:info).and_return("flight: #{subject.version} stable, HEAD")
30
+ expect(subject).to be_up_to_date
31
+ expect(subject).to_not be_outdated
32
+ end
33
+
34
+ it "is outdated when current_version does not match version" do
35
+ allow(subject).to receive(:info).and_return("flight: 2.0.0 (bottled)")
36
+ expect(subject.current_version).to eq('2.1.1')
37
+ expect(subject.current_version).to_not eq(subject.version)
38
+ expect(subject).to be_outdated
39
+ expect(subject).to_not be_up_to_date
40
+ end
41
+
42
+ it "is installed when 'Not Installed' can't be found in brew info" do
43
+ allow(subject).to receive(:info).and_return("/usr/local/Cellar")
44
+ expect(subject).to be_installed
45
+ end
46
+
47
+ it "is not installed when brew info tells us" do
48
+ allow(subject).to receive(:info).and_return("Not Installed")
49
+ expect(subject).to_not be_installed
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'flight'
3
+
4
+ RSpec.describe Flight do
5
+ it 'has a version number' do
6
+ expect(Flight::VERSION).not_to be nil
7
+ expect(Flight.version).to eq(Flight::VERSION)
8
+ end
9
+
10
+ it 'detects if we are in debug mode' do
11
+ expect(Flight::DEBUG).to be_nil
12
+ expect(Flight.debug?).to eq(false)
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'rspec'
4
+
5
+ RSpec.configure do |config|
6
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: brew-flight
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tom Scott
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Flight is a Bundler for Homebrew. It helps you manage the Homebrew packages
70
+ you want on your system.
71
+ email:
72
+ - tscott@telvue.com
73
+ executables:
74
+ - flight
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - .gitignore
79
+ - .rspec
80
+ - .travis.yml
81
+ - Brewfile
82
+ - Brewfile.lock
83
+ - Gemfile
84
+ - LICENSE.md
85
+ - Makefile
86
+ - README.md
87
+ - Rakefile
88
+ - bin/flight
89
+ - doc/man/flight.md
90
+ - etc/Brewfile
91
+ - flight.gemspec
92
+ - lib/flight.rb
93
+ - lib/flight/brewfile.rb
94
+ - lib/flight/brewfile/dsl.rb
95
+ - lib/flight/brewfile/lockfile.rb
96
+ - lib/flight/executable.rb
97
+ - lib/flight/package.rb
98
+ - lib/flight/package/collection.rb
99
+ - lib/flight/package/options.rb
100
+ - lib/flight/package/version.rb
101
+ - lib/flight/tap.rb
102
+ - lib/flight/version.rb
103
+ - lib/templates/Brewfile
104
+ - spec/flight/executable_spec.rb
105
+ - spec/flight/package/options_spec.rb
106
+ - spec/flight/package_spec.rb
107
+ - spec/flight_spec.rb
108
+ - spec/spec_helper.rb
109
+ homepage: http://github.com/tubbo/flight
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.0.14
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Flight is a Bundler for Homebrew.
133
+ test_files:
134
+ - spec/flight/executable_spec.rb
135
+ - spec/flight/package/options_spec.rb
136
+ - spec/flight/package_spec.rb
137
+ - spec/flight_spec.rb
138
+ - spec/spec_helper.rb