2017-05-28 07:18:01 +00:00
|
|
|
class Fsql < Formula
|
|
|
|
desc "Search through your filesystem with SQL-esque queries."
|
|
|
|
homepage "https://github.com/kshvmdn/fsql"
|
2017-06-09 06:25:35 +00:00
|
|
|
url "https://github.com/kshvmdn/fsql/archive/v0.2.1.tar.gz"
|
|
|
|
sha256 "def6ddd2f9a5f64bc03821223f760250eecb775762e848f37fb105cf0254ad1c"
|
2017-05-28 07:18:01 +00:00
|
|
|
|
2017-05-28 09:51:49 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any_skip_relocation
|
2017-06-09 09:38:31 +00:00
|
|
|
sha256 "316420c1e4a7793fd5607b032be6b32ca67ed8851b53af9c3c410d65cca9a8a4" => :sierra
|
|
|
|
sha256 "530a6013f87796b1b2bd99b6e36f12ec4dc762f8431f4536bcdffcbfddacba04" => :el_capitan
|
|
|
|
sha256 "6869e98d96626f0b3eb25e89203ec08cd03468f833c7a0122e17c555d3181f4e" => :yosemite
|
2017-05-28 09:51:49 +00:00
|
|
|
end
|
|
|
|
|
2017-05-28 07:18:01 +00:00
|
|
|
depends_on "go" => :build
|
|
|
|
|
|
|
|
def install
|
|
|
|
ENV["GOPATH"] = buildpath
|
|
|
|
(buildpath/"src/github.com/kshvmdn").mkpath
|
|
|
|
ln_s buildpath, buildpath/"src/github.com/kshvmdn/fsql"
|
2017-06-09 06:25:35 +00:00
|
|
|
system "go", "build", "-o", bin/"fsql", "github.com/kshvmdn/fsql/cmd/fsql"
|
2017-05-28 07:18:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
|
|
|
(testpath/"bar.txt").write("hello")
|
|
|
|
(testpath/"foo/baz.txt").write("world")
|
|
|
|
expected = <<-EOS.undent
|
|
|
|
foo
|
|
|
|
foo/baz.txt
|
|
|
|
EOS
|
2017-06-09 06:25:35 +00:00
|
|
|
cmd = "#{bin}/fsql SELECT FULLPATH\\(name\\) FROM foo"
|
|
|
|
assert_equal expected, shell_output(cmd)
|
|
|
|
cmd = "#{bin}/fsql SELECT name FROM . WHERE name = bar.txt"
|
|
|
|
assert_equal "bar.txt", shell_output(cmd).chomp
|
|
|
|
cmd = "#{bin}/fsql SELECT name FROM . WHERE FORMAT\\(size\, GB\\) \\> 500"
|
|
|
|
assert_equal "", shell_output(cmd)
|
2017-05-28 07:18:01 +00:00
|
|
|
end
|
|
|
|
end
|