CombinedText
stringlengths
4
3.42M
class Avian < Formula desc "Lightweight VM and class library for a subset of Java features" homepage "https://readytalk.github.io/avian/" url "https://github.com/ReadyTalk/avian/archive/v1.2.0.tar.gz" sha256 "e3639282962239ce09e4f79f327c679506d165810f08c92ce23e53e86e1d621c" license "ISC" head "https://github.com/ReadyTalk/avian.git" bottle do cellar :any rebuild 1 sha256 "07a5c761ffc3bc57db4a5b0dbd952a47fcb2b62f1083eee3106be50031adfa5e" => :mojave sha256 "ee881641717eed4a61ab64f832ab420401ed7a814fd32e546ae0765b5b27de6b" => :high_sierra sha256 "ef092ec60093190857b558fd9a663ca0c6d0356bb9af7798be21cf466678f27e" => :sierra sha256 "d2719509725f4c1fad3a53c32de18aff5d45685fb35ae352f1d51fc61e566f4a" => :el_capitan sha256 "d002876c03742fc7ec4157fff598e7c11ed1e62f97ce1b217f8b089db87e43ed" => :yosemite sha256 "20dd7125d138e05021b473d026190d8f4652e807afcfe057614e5c2e66ce0ed1" => :mavericks end depends_on :java => "1.8" uses_from_macos "zlib" def install system "make", "use-clang=true" bin.install Dir["build/macosx-*/avian*"] lib.install Dir["build/macosx-*/*.dylib", "build/macosx-*/*.a"] end test do (testpath/"Test.java").write <<~EOS public class Test { public static void main(String arg[]) { System.out.print("OK"); } } EOS system "javac", "Test.java" assert_equal "OK", shell_output("#{bin}/avian Test") end end avian: fix RuboCop style. See https://github.com/Homebrew/brew/pull/7867. class Avian < Formula desc "Lightweight VM and class library for a subset of Java features" homepage "https://readytalk.github.io/avian/" url "https://github.com/ReadyTalk/avian/archive/v1.2.0.tar.gz" sha256 "e3639282962239ce09e4f79f327c679506d165810f08c92ce23e53e86e1d621c" license "ISC" head "https://github.com/ReadyTalk/avian.git" bottle do cellar :any rebuild 1 sha256 "07a5c761ffc3bc57db4a5b0dbd952a47fcb2b62f1083eee3106be50031adfa5e" => :mojave sha256 "ee881641717eed4a61ab64f832ab420401ed7a814fd32e546ae0765b5b27de6b" => :high_sierra sha256 "ef092ec60093190857b558fd9a663ca0c6d0356bb9af7798be21cf466678f27e" => :sierra sha256 "d2719509725f4c1fad3a53c32de18aff5d45685fb35ae352f1d51fc61e566f4a" => :el_capitan sha256 "d002876c03742fc7ec4157fff598e7c11ed1e62f97ce1b217f8b089db87e43ed" => :yosemite sha256 "20dd7125d138e05021b473d026190d8f4652e807afcfe057614e5c2e66ce0ed1" => :mavericks end depends_on java: "1.8" uses_from_macos "zlib" def install system "make", "use-clang=true" bin.install Dir["build/macosx-*/avian*"] lib.install Dir["build/macosx-*/*.dylib", "build/macosx-*/*.a"] end test do (testpath/"Test.java").write <<~EOS public class Test { public static void main(String arg[]) { System.out.print("OK"); } } EOS system "javac", "Test.java" assert_equal "OK", shell_output("#{bin}/avian Test") end end
class Aview < Formula desc "ASCII-art image browser and animation viewer" homepage "https://aa-project.sourceforge.io/" url "https://downloads.sourceforge.net/project/aa-project/aview/1.3.0rc1/aview-1.3.0rc1.tar.gz" sha256 "42d61c4194e8b9b69a881fdde698c83cb27d7eda59e08b300e73aaa34474ec99" license "GPL-2.0" livecheck do url :stable regex(%r{url=.*?/aview[._-]v?(\d+(?:\.\d+)+(?:[a-z]+\d*)?)\.t}i) end bottle do sha256 cellar: :any_skip_relocation, arm64_big_sur: "4616c937f328391a9ad212bbdd51818d97c629eeaa649ddcdf97e0332e7964bf" sha256 cellar: :any_skip_relocation, big_sur: "7a32c517ba508c6febe9605d4c9f4d8bde9200393cd8e4dd51adeb7c6e85fb6f" sha256 cellar: :any_skip_relocation, catalina: "ad92a0e964ccbebe685edf9c595efd420475490d255caed072985cb128a8230b" sha256 cellar: :any_skip_relocation, mojave: "fe70cf7dbd1d2e1473da3818b96d3a94d811e93d52ecbb6ecfc1c1e1ccb8b12a" sha256 cellar: :any_skip_relocation, high_sierra: "4f5fa09318475fca46c584b52e5d5b845cd4d331df04744ca41d6789575b32ec" sha256 cellar: :any_skip_relocation, sierra: "95cbb14a2a5cb4d8d11d9ca3621e81705df77f47d85f89383913e3a02da56041" sha256 cellar: :any_skip_relocation, el_capitan: "cb20b8513b3b7d2977943d7ba14f2627892697e9a6b69c4366563786810ca95c" sha256 cellar: :any_skip_relocation, yosemite: "886a6800deefcf7a1e377db57c9df0579b6f1fcb4b491a6262171411bce3517b" end depends_on "aalib" patch do url "https://raw.githubusercontent.com/Homebrew/formula-patches/85fa66a9/aview/1.3.0rc1.patch" sha256 "72a979eff325056f709cee49f5836a425635bd72078515a5949a812aa68741aa" end def install system "./configure", "--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}", "--mandir=#{man}" system "make", "install" end test do system "#{bin}/aview", "--version" end end aview: update 1.3.0rc1 bottle. class Aview < Formula desc "ASCII-art image browser and animation viewer" homepage "https://aa-project.sourceforge.io/" url "https://downloads.sourceforge.net/project/aa-project/aview/1.3.0rc1/aview-1.3.0rc1.tar.gz" sha256 "42d61c4194e8b9b69a881fdde698c83cb27d7eda59e08b300e73aaa34474ec99" license "GPL-2.0" livecheck do url :stable regex(%r{url=.*?/aview[._-]v?(\d+(?:\.\d+)+(?:[a-z]+\d*)?)\.t}i) end bottle do sha256 cellar: :any_skip_relocation, arm64_big_sur: "4616c937f328391a9ad212bbdd51818d97c629eeaa649ddcdf97e0332e7964bf" sha256 cellar: :any_skip_relocation, big_sur: "7a32c517ba508c6febe9605d4c9f4d8bde9200393cd8e4dd51adeb7c6e85fb6f" sha256 cellar: :any_skip_relocation, catalina: "ad92a0e964ccbebe685edf9c595efd420475490d255caed072985cb128a8230b" sha256 cellar: :any_skip_relocation, mojave: "fe70cf7dbd1d2e1473da3818b96d3a94d811e93d52ecbb6ecfc1c1e1ccb8b12a" sha256 cellar: :any_skip_relocation, high_sierra: "4f5fa09318475fca46c584b52e5d5b845cd4d331df04744ca41d6789575b32ec" sha256 cellar: :any_skip_relocation, sierra: "95cbb14a2a5cb4d8d11d9ca3621e81705df77f47d85f89383913e3a02da56041" sha256 cellar: :any_skip_relocation, el_capitan: "cb20b8513b3b7d2977943d7ba14f2627892697e9a6b69c4366563786810ca95c" sha256 cellar: :any_skip_relocation, yosemite: "886a6800deefcf7a1e377db57c9df0579b6f1fcb4b491a6262171411bce3517b" sha256 cellar: :any_skip_relocation, x86_64_linux: "f2a611a1c3b2b1c76816dffcef6b3aff9f4ea88f6fbd87729dc987c39bd7cc2a" end depends_on "aalib" patch do url "https://raw.githubusercontent.com/Homebrew/formula-patches/85fa66a9/aview/1.3.0rc1.patch" sha256 "72a979eff325056f709cee49f5836a425635bd72078515a5949a812aa68741aa" end def install system "./configure", "--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}", "--mandir=#{man}" system "make", "install" end test do system "#{bin}/aview", "--version" end end
require 'spec_helper' # Tests to ensure ntp is locked down describe file('/boot/loader.conf') do it { should be_file } it { should contain "autoboot_delay=\"5\"" } end Add new boot loader settings require 'spec_helper' describe file('/boot/loader.conf') do it { should be_file } it { should contain "autoboot_delay=\"5\"" } it { should contain "verbose_loading=\"YES\"" } it { should contain "hw.usb.disable_enumeration=1" } it { should contain "hw.usb.no_boot_wait=1" } it { should contain "hw.usb.no_shutdown_wait=1" } end
require "language/node" require "json" class Babel < Formula desc "Compiler for writing next generation JavaScript" homepage "https://babeljs.io/" url "https://registry.npmjs.org/@babel/core/-/core-7.11.4.tgz" sha256 "e471ae013e691c2d7088c4a001ef03c8b5cb85c9c2ea06f04768a05fa126d497" license "MIT" bottle do sha256 "3823028884c32087ac82203fe0c9335f00dcb1a4b91a8cc0fbf128eba1d88482" => :catalina sha256 "96ba8b759ba61a6724df9b8015104eb992bf1543591f57c0e4178864854aef49" => :mojave sha256 "b79721e92717534cf2b54a974d1dff694fd0c1c8a750a4b223654724018da228" => :high_sierra end depends_on "node" resource "babel-cli" do url "https://registry.npmjs.org/@babel/cli/-/cli-7.10.5.tgz" sha256 "cebcdfc983c5dd3c3535bd6a0ea1f2f550cb3339d76284114d51c5b3cd80d5ce" end def install (buildpath/"node_modules/@babel/core").install Dir["*"] buildpath.install resource("babel-cli") # declare babel-core as a bundledDependency of babel-cli pkg_json = JSON.parse(IO.read("package.json")) pkg_json["dependencies"]["@babel/core"] = version pkg_json["bundledDependencies"] = ["@babel/core"] IO.write("package.json", JSON.pretty_generate(pkg_json)) system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do (testpath/"script.js").write <<~EOS [1,2,3].map(n => n + 1); EOS system bin/"babel", "script.js", "--out-file", "script-compiled.js" assert_predicate testpath/"script-compiled.js", :exist?, "script-compiled.js was not generated" end end babel: update 7.11.4 bottle. require "language/node" require "json" class Babel < Formula desc "Compiler for writing next generation JavaScript" homepage "https://babeljs.io/" url "https://registry.npmjs.org/@babel/core/-/core-7.11.4.tgz" sha256 "e471ae013e691c2d7088c4a001ef03c8b5cb85c9c2ea06f04768a05fa126d497" license "MIT" bottle do sha256 "3823028884c32087ac82203fe0c9335f00dcb1a4b91a8cc0fbf128eba1d88482" => :catalina sha256 "96ba8b759ba61a6724df9b8015104eb992bf1543591f57c0e4178864854aef49" => :mojave sha256 "b79721e92717534cf2b54a974d1dff694fd0c1c8a750a4b223654724018da228" => :high_sierra sha256 "edb19f89369485e25e456225eaa1f526817e4a66caf726ae1a4550e5a67ce1cf" => :x86_64_linux end depends_on "node" resource "babel-cli" do url "https://registry.npmjs.org/@babel/cli/-/cli-7.10.5.tgz" sha256 "cebcdfc983c5dd3c3535bd6a0ea1f2f550cb3339d76284114d51c5b3cd80d5ce" end def install (buildpath/"node_modules/@babel/core").install Dir["*"] buildpath.install resource("babel-cli") # declare babel-core as a bundledDependency of babel-cli pkg_json = JSON.parse(IO.read("package.json")) pkg_json["dependencies"]["@babel/core"] = version pkg_json["bundledDependencies"] = ["@babel/core"] IO.write("package.json", JSON.pretty_generate(pkg_json)) system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do (testpath/"script.js").write <<~EOS [1,2,3].map(n => n + 1); EOS system bin/"babel", "script.js", "--out-file", "script-compiled.js" assert_predicate testpath/"script-compiled.js", :exist?, "script-compiled.js was not generated" end end
require 'spec_helper' describe FrontMatterParser do it 'has a version number' do expect(FrontMatterParser::VERSION).to_not be_nil end describe "#parse" do context "when an empty string is supplied" do let(:parsed) { FrontMatterParser.parse('') } it "returns a Parsed instance with an empty hash as front_matter" do expect(parsed.front_matter).to eq({}) end it "returns a Parsed instance with an empty string as content" do expect(parsed.content).to eq('') end end context "when an empty front matter is supplied" do let(:string) { %Q(Hello) } let(:parsed) { FrontMatterParser.parse(string) } it "returns an empty hash as front matter" do expect(parsed.front_matter).to eq({}) end it "returns the whole string as content" do expect(parsed.content).to eq(string) end end end end when empty front matter, the content is the whole string require 'spec_helper' describe FrontMatterParser do it 'has a version number' do expect(FrontMatterParser::VERSION).to_not be_nil end describe "#parse" do context "when an empty string is supplied" do let(:parsed) { FrontMatterParser.parse('') } it "the parsed front matter is an empty hash" do expect(parsed.front_matter).to eq({}) end it "the parsed content is an empty string" do expect(parsed.content).to eq('') end end context "when an empty front matter is supplied" do let(:string) { %Q(Hello) } let(:parsed) { FrontMatterParser.parse(string) } it "the parsed front matter is an empty hash" do expect(parsed.front_matter).to eq({}) end it "the parsed content is the whole string" do expect(parsed.content).to eq(string) end end end end
class Bazel < Formula desc "Google's own build tool" homepage "https://bazel.build/" url "https://github.com/bazelbuild/bazel/releases/download/0.22.0/bazel-0.22.0-dist.zip" sha256 "6860a226c8123770b122189636fb0c156c6e5c9027b5b245ac3b2315b7b55641" bottle do cellar :any_skip_relocation sha256 "84d26821f6cbc1b7a68fc3892101174a8ef0df30df8173912c22db9910222a2f" => :mojave sha256 "804cefe10084d6a382892e9b1e461ed3779a128cf406da366867ff769252d4e9" => :high_sierra sha256 "42362d88106d47f7358813540fe11d97be44b3e5d11d004b2e0f4dada83d0390" => :sierra end depends_on :java => "1.8" depends_on :macos => :yosemite def install ENV["EMBED_LABEL"] = "#{version}-homebrew" # Force Bazel ./compile.sh to put its temporary files in the buildpath ENV["BAZEL_WRKDIR"] = buildpath/"work" (buildpath/"sources").install buildpath.children cd "sources" do system "./compile.sh" system "./output/bazel", "--output_user_root", buildpath/"output_user_root", "build", "--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8", "--java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8", "--host_javabase=@bazel_tools//tools/jdk:jdk", "--javabase=@bazel_tools//tools/jdk:jdk", "scripts:bash_completion" bin.install "scripts/packages/bazel.sh" => "bazel" bin.install "output/bazel" => "bazel-real" bin.env_script_all_files(libexec/"bin", Language::Java.java_home_env("1.8")) bash_completion.install "bazel-bin/scripts/bazel-complete.bash" zsh_completion.install "scripts/zsh_completion/_bazel" prefix.install_metafiles end end test do touch testpath/"WORKSPACE" (testpath/"ProjectRunner.java").write <<~EOS public class ProjectRunner { public static void main(String args[]) { System.out.println("Hi!"); } } EOS (testpath/"BUILD").write <<~EOS java_binary( name = "bazel-test", srcs = glob(["*.java"]), main_class = "ProjectRunner", ) EOS system bin/"bazel", "build", "--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8", "--java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8", "--host_javabase=@bazel_tools//tools/jdk:jdk", "--javabase=@bazel_tools//tools/jdk:jdk", "//:bazel-test" assert_equal "Hi!\n", pipe_output("bazel-bin/bazel-test") end end bazel: fix build Closes #36943. Signed-off-by: FX Coudert <c329953660db96eae534be5bbf1a735c2baf69b5@gmail.com> class Bazel < Formula desc "Google's own build tool" homepage "https://bazel.build/" url "https://github.com/bazelbuild/bazel/releases/download/0.22.0/bazel-0.22.0-dist.zip" sha256 "6860a226c8123770b122189636fb0c156c6e5c9027b5b245ac3b2315b7b55641" revision 1 bottle do cellar :any_skip_relocation sha256 "84d26821f6cbc1b7a68fc3892101174a8ef0df30df8173912c22db9910222a2f" => :mojave sha256 "804cefe10084d6a382892e9b1e461ed3779a128cf406da366867ff769252d4e9" => :high_sierra sha256 "42362d88106d47f7358813540fe11d97be44b3e5d11d004b2e0f4dada83d0390" => :sierra end depends_on :java => "1.8" depends_on :macos => :yosemite def install ENV["EMBED_LABEL"] = "#{version}-homebrew" # Force Bazel ./compile.sh to put its temporary files in the buildpath ENV["BAZEL_WRKDIR"] = buildpath/"work" (buildpath/"sources").install buildpath.children cd "sources" do system "./compile.sh" system "./output/bazel", "--output_user_root", buildpath/"output_user_root", "build", "--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8", "--java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8", "--host_javabase=@bazel_tools//tools/jdk:jdk", "--javabase=@bazel_tools//tools/jdk:jdk", "scripts:bash_completion" bin.install "scripts/packages/bazel.sh" => "bazel" (libexec/"bin").install "output/bazel" => "bazel-real" bin.env_script_all_files(libexec/"bin", Language::Java.java_home_env("1.8")) bash_completion.install "bazel-bin/scripts/bazel-complete.bash" zsh_completion.install "scripts/zsh_completion/_bazel" prefix.install_metafiles end end test do touch testpath/"WORKSPACE" (testpath/"ProjectRunner.java").write <<~EOS public class ProjectRunner { public static void main(String args[]) { System.out.println("Hi!"); } } EOS (testpath/"BUILD").write <<~EOS java_binary( name = "bazel-test", srcs = glob(["*.java"]), main_class = "ProjectRunner", ) EOS system bin/"bazel", "build", "--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8", "--java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8", "--host_javabase=@bazel_tools//tools/jdk:jdk", "--javabase=@bazel_tools//tools/jdk:jdk", "//:bazel-test" assert_equal "Hi!\n", pipe_output("bazel-bin/bazel-test") end end
# frozen_string_literal: true require "spec_helper" describe GraphQL::Schema::List do let(:of_type) { Jazz::Musician } let(:list_type) { GraphQL::Schema::List.new(of_type) } it "returns list? to be true" do assert list_type.list? end it "returns non_null? to be false" do refute list_type.non_null? end it "returns kind to be GraphQL::TypeKinds::LIST" do assert_equal GraphQL::TypeKinds::LIST, list_type.kind end it "returns correct type signature" do assert_equal "[Musician]", list_type.to_type_signature end describe "comparison operator" do it "will return false if list types 'of_type' are different" do new_of_type = Jazz::InspectableKey new_list_type = GraphQL::Schema::List.new(new_of_type) refute_equal list_type, new_list_type end it "will return true if list types 'of_type' are the same" do new_of_type = Jazz::Musician new_list_type = GraphQL::Schema::List.new(new_of_type) assert_equal list_type, new_list_type end end describe "to_graphql" do it "will return a list type" do assert_kind_of GraphQL::ListType, list_type.to_graphql end end describe "handling null" do class ListNullHandlingSchema < GraphQL::Schema class Query < GraphQL::Schema::Object field :strings, [String, null: true], null: true do argument :strings, [String, null: true], required: false end def strings(strings:) strings end end use GraphQL::Execution::Interpreter use GraphQL::Analysis::AST query(Query) end it "passes `nil` as `nil`" do str = "query($strings: [String]){ strings(strings: $strings) }" res = ListNullHandlingSchema.execute(str, variables: { strings: nil }) assert_nil res["data"]["strings"] end end describe "validation" do class ListEnumValidationSchema < GraphQL::Schema class Item < GraphQL::Schema::Enum value "A" value "B" end class Query < GraphQL::Schema::Object field :echo, [Item], null: false do argument :items, [Item], required: true end def echo(items:) items end end query(Query) end it "checks non-null lists of enums" do res = ListEnumValidationSchema.execute "{ echo(items: [A, B, \"C\"]) }" expected_error = "Argument 'items' on Field 'echo' has an invalid value ([A, B, \"C\"]). Expected type '[Item!]!'." assert_equal [expected_error], res["errors"].map { |e| e["message"] } end it "works with #valid_input?" do assert ListEnumValidationSchema::Item.to_list_type.valid_isolated_input?(["A", "B"]) refute ListEnumValidationSchema::Item.to_list_type.valid_isolated_input?(["A", "B", "C"]) end end end test single-item coercion; fixes #2652 # frozen_string_literal: true require "spec_helper" describe GraphQL::Schema::List do let(:of_type) { Jazz::Musician } let(:list_type) { GraphQL::Schema::List.new(of_type) } it "returns list? to be true" do assert list_type.list? end it "returns non_null? to be false" do refute list_type.non_null? end it "returns kind to be GraphQL::TypeKinds::LIST" do assert_equal GraphQL::TypeKinds::LIST, list_type.kind end it "returns correct type signature" do assert_equal "[Musician]", list_type.to_type_signature end describe "comparison operator" do it "will return false if list types 'of_type' are different" do new_of_type = Jazz::InspectableKey new_list_type = GraphQL::Schema::List.new(new_of_type) refute_equal list_type, new_list_type end it "will return true if list types 'of_type' are the same" do new_of_type = Jazz::Musician new_list_type = GraphQL::Schema::List.new(new_of_type) assert_equal list_type, new_list_type end end describe "to_graphql" do it "will return a list type" do assert_kind_of GraphQL::ListType, list_type.to_graphql end end describe "handling null" do class ListNullHandlingSchema < GraphQL::Schema class Query < GraphQL::Schema::Object field :strings, [String, null: true], null: true do argument :strings, [String, null: true], required: false end def strings(strings:) strings end end use GraphQL::Execution::Interpreter use GraphQL::Analysis::AST query(Query) end it "passes `nil` as `nil`" do str = "query($strings: [String]){ strings(strings: $strings) }" res = ListNullHandlingSchema.execute(str, variables: { strings: nil }) assert_nil res["data"]["strings"] end end describe "validation" do class ListValidationSchema < GraphQL::Schema class Item < GraphQL::Schema::Enum value "A" value "B" end class ItemInput < GraphQL::Schema::InputObject argument :item, Item, required: true end class Query < GraphQL::Schema::Object field :echo, [Item], null: false do argument :items, [Item], required: true end def echo(items:) items end field :echoes, [Item], null: false do argument :items, [ItemInput], required: true end def echoes(items:) items.map { |i| i[:item] } end end query(Query) end it "checks non-null lists of enums" do res = ListValidationSchema.execute "{ echo(items: [A, B, \"C\"]) }" expected_error = "Argument 'items' on Field 'echo' has an invalid value ([A, B, \"C\"]). Expected type '[Item!]!'." assert_equal [expected_error], res["errors"].map { |e| e["message"] } end it "works with #valid_input?" do assert ListValidationSchema::Item.to_list_type.valid_isolated_input?(["A", "B"]) refute ListValidationSchema::Item.to_list_type.valid_isolated_input?(["A", "B", "C"]) end it "coerces single-item lists of input objects" do results = { "default value" => ListValidationSchema.execute("query($items: [ItemInput!] = {item: A}) { echoes(items: $items) }"), "literal value" => ListValidationSchema.execute("{ echoes(items: { item: A }) }"), "variable value" => ListValidationSchema.execute("query($items: [ItemInput!]!) { echoes(items: $items) }", variables: { items: { item: "A" } }), } results.each do |r_desc, r| assert_equal({"data" => { "echoes" => ["A"]}}, r, "It works for #{r_desc}") end end end end
require "language/haskell" class Bench < Formula include Language::Haskell::Cabal desc "Command-line benchmark tool" homepage "https://github.com/Gabriel439/bench" url "https://hackage.haskell.org/package/bench-1.0.6/bench-1.0.6.tar.gz" sha256 "09c37660d68d103553b79336bfe20383d608cdbaedebfbe289e1b87055a4456b" depends_on "cabal-install" => :build depends_on "ghc" => :build def install install_cabal_package end test do assert_match /time\s+[0-9.]+/, shell_output("#{bin}/bench pwd") end end bench: add 1.0.6 bottle. require "language/haskell" class Bench < Formula include Language::Haskell::Cabal desc "Command-line benchmark tool" homepage "https://github.com/Gabriel439/bench" url "https://hackage.haskell.org/package/bench-1.0.6/bench-1.0.6.tar.gz" sha256 "09c37660d68d103553b79336bfe20383d608cdbaedebfbe289e1b87055a4456b" bottle do cellar :any_skip_relocation sha256 "b8d3039bacf0a9fa9b10188779b8c79bf7b309f79b7a98495cf04e7ef7f5f99b" => :high_sierra sha256 "5b668c20f1e2ec14f81aee4c84df692741f46d5b1663cebac949c769eeb04ec3" => :sierra sha256 "bad9f0285cc2f6307e001dc62950b35afd940f38ff1f6157bab2757aca8b9a3c" => :el_capitan end depends_on "cabal-install" => :build depends_on "ghc" => :build def install install_cabal_package end test do assert_match /time\s+[0-9.]+/, shell_output("#{bin}/bench pwd") end end
require 'spec_helper' describe user("itamae") do it { should exist } it { should have_uid 1234 } it { should have_home_directory '/home/itamae' } it { should have_login_shell '/bin/dash' } end describe file('/tmp/included_recipe') do it { should be_file } end describe package('dstat') do it { should be_installed } end describe package('sl') do it { should be_installed } end describe package('resolvconf') do it { should_not be_installed } end %w!/tmp/remote_file /tmp/remote_file_auto!.each do |f| describe file(f) do it { should be_file } its(:content) { should match(/Hello Itamae/) } end end describe file('/tmp/directory') do it { should be_directory } it { should be_mode 700 } it { should be_owned_by "itamae" } it { should be_grouped_into "itamae" } end describe file('/tmp/directory_never_exist1') do it { should_not be_directory } end %w!/tmp/template /tmp/template_auto!.each do |f| describe file(f) do it { should be_file } its(:content) { should match(/Hello/) } its(:content) { should match(/Good bye/) } its(:content) { should match(/^total memory: \d+kB$/) } its(:content) { should match(/^uninitialized node key: $/) } end end describe file('/tmp/file') do it { should be_file } its(:content) { should match(/Hello World/) } it { should be_mode 777 } end describe file('/tmp/file_with_suid') do it { should be_file } it { should be_mode 4755 } it { should be_owned_by "itamae" } it { should be_grouped_into "itamae" } end describe file('/tmp/execute') do it { should be_file } its(:content) { should match(/Hello Execute/) } end describe file('/tmp/never_exist1') do it { should_not be_file } end describe file('/tmp/never_exist2') do it { should_not be_file } end describe file('/tmp/http_request.html') do it { should be_file } its(:content) { should match(/"from": "itamae"/) } end describe file('/tmp/http_request_delete.html') do it { should be_file } its(:content) { should match(/"from": "itamae"/) } end describe file('/tmp/http_request_post.html') do it { should be_file } its(:content) do should match(/"from": "itamae"/) should match(/"love": "sushi"/) end end describe file('/tmp/http_request_put.html') do it { should be_file } its(:content) do should match(/"from": "itamae"/) should match(/"love": "sushi"/) end end describe file('/tmp/http_request_headers.html') do it { should be_file } its(:content) { should match(/"User-Agent": "Itamae"/) } end describe file('/tmp/http_request_redirect.html') do it { should be_file } its(:content) { should match(/"from": "itamae"/) } end describe file('/tmp/notifies') do it { should be_file } its(:content) { should eq("2431") } end describe file('/tmp/subscribes') do it { should be_file } its(:content) { should eq("2431") } end describe file('/tmp/cron_stopped') do it { should be_file } its(:content) do expect(subject.content.lines.size).to eq 1 end end describe file('/tmp/cron_running') do it { should be_file } its(:content) do expect(subject.content.lines.size).to eq 2 end end describe file('/tmp-link') do it { should be_linked_to '/tmp' } its(:content) do expect(subject.content.lines.size).to eq 0 end end describe file('/tmp-link-force') do it { should be_linked_to '/tmp' } end describe file('/tmp/link-force-no-dereference') do it { should be_linked_to 'link-force-no-dereference2' } end describe file('/tmp/link-force-no-dereference/link-force-no-dereference2') do it { should_not exist } end describe command('cd /tmp/git_repo && git rev-parse HEAD') do its(:stdout) { should match(/3116e170b89dc0f7315b69c1c1e1fd7fab23ac0d/) } end describe command('cd /tmp/git_repo_submodule/empty_repo && cat README.md') do its(:stdout) { should match(/Empty Repo/) } end describe command('cd /tmp/git_repo_depth_1 && git rev-list --count HEAD') do its(:stdout) { should eq "1\n" } end describe file('/tmp/created_by_itamae_user') do it { should be_file } it { should be_owned_by 'itamae' } its(:content) { should eq("/home/itamae\n/home/itamae") } end describe file('/tmp/created_in_default2') do it { should be_file } end describe file('/tmp/never_exist3') do it { should_not be_file } end describe file('/tmp/never_exist4') do it { should_not be_file } end describe file('/tmp/created_in_redefine') do it { should be_file } its(:content) { should match(/first/) } end describe command('gem list') do its(:stdout) { should include('tzinfo (1.2.2, 1.1.0)') } end describe command('gem list') do its(:stdout) { should include('rake (11.1.0)') } end describe command('gem list') do its(:stdout) { should_not include('test-unit') } end describe command('ri Bundler') do its(:stderr) { should eq("Nothing known about Bundler\n") } end describe file('/tmp/created_by_definition') do it { should be_file } its(:content) { should eq("name:name,key:value,message:Hello, Itamae\n") } end describe file('/tmp/remote_file_in_definition') do it { should be_file } its(:content) { should eq("definition_example\n") } end describe file('/tmp/multi_delayed_notifies') do it { should be_file } its(:content) { should eq("1\n2\n3\n4\n") } end describe file('/tmp/multi_immediately_notifies') do it { should be_file } its(:content) { should eq("1\n2\n3\n4\n") } end describe file('/tmp/file_edit_sample') do it { should be_file } its(:content) { should eq("Hello, Itamae") } it { should be_mode 400 } it { should be_owned_by "itamae2" } it { should be_grouped_into "itamae2" } end describe file('/tmp/file_edit_with_suid') do it { should be_file } it { should be_mode 4755 } it { should be_owned_by "itamae2" } it { should be_grouped_into "itamae2" } end describe file('/tmp/file_edit_keeping_mode_owner') do it { should be_file } its(:content) { should eq("Hello, Itamae") } it { should be_mode 444 } it { should be_owned_by "itamae" } it { should be_grouped_into "itamae" } end describe file('/tmp/file_edit_with_content_change_updates_timestamp') do its(:mtime) { should be > DateTime.iso8601("2016-05-02T01:23:45Z") } end describe file('/tmp/file_edit_without_content_change_keeping_timestamp') do its(:mtime) { should eq(DateTime.iso8601("2016-05-02T12:34:56Z")) } end describe file('/home/itamae2') do it { should be_directory } it { should be_owned_by "itamae2" } it { should be_grouped_into "itamae2" } end describe file('/tmp/file_create_without_content') do its(:content) { should eq("Hello, World") } it { should be_mode 600 } it { should be_owned_by "itamae" } it { should be_grouped_into "itamae" } end describe file('/tmp/file_edit_notifies') do its(:content) { should eq("1") } end describe file('/tmp/file_without_content_change_updates_mode_and_owner') do its(:content) { should eq("Hello, world") } it { should be_mode 666 } it { should be_owned_by "itamae2" } it { should be_grouped_into "itamae2" } end describe file('/tmp/file_with_content_change_updates_timestamp') do its(:mtime) { should be > DateTime.iso8601("2016-05-01T01:23:45Z") } end describe file('/tmp/file_without_content_change_keeping_timestamp') do its(:mtime) { should eq(DateTime.iso8601("2016-05-01T12:34:56Z")) } end describe file('/tmp/subscribed_from_parent') do it { should be_file } end Fix spec response format of https://httpbin.org/ was changed require 'spec_helper' describe user("itamae") do it { should exist } it { should have_uid 1234 } it { should have_home_directory '/home/itamae' } it { should have_login_shell '/bin/dash' } end describe file('/tmp/included_recipe') do it { should be_file } end describe package('dstat') do it { should be_installed } end describe package('sl') do it { should be_installed } end describe package('resolvconf') do it { should_not be_installed } end %w!/tmp/remote_file /tmp/remote_file_auto!.each do |f| describe file(f) do it { should be_file } its(:content) { should match(/Hello Itamae/) } end end describe file('/tmp/directory') do it { should be_directory } it { should be_mode 700 } it { should be_owned_by "itamae" } it { should be_grouped_into "itamae" } end describe file('/tmp/directory_never_exist1') do it { should_not be_directory } end %w!/tmp/template /tmp/template_auto!.each do |f| describe file(f) do it { should be_file } its(:content) { should match(/Hello/) } its(:content) { should match(/Good bye/) } its(:content) { should match(/^total memory: \d+kB$/) } its(:content) { should match(/^uninitialized node key: $/) } end end describe file('/tmp/file') do it { should be_file } its(:content) { should match(/Hello World/) } it { should be_mode 777 } end describe file('/tmp/file_with_suid') do it { should be_file } it { should be_mode 4755 } it { should be_owned_by "itamae" } it { should be_grouped_into "itamae" } end describe file('/tmp/execute') do it { should be_file } its(:content) { should match(/Hello Execute/) } end describe file('/tmp/never_exist1') do it { should_not be_file } end describe file('/tmp/never_exist2') do it { should_not be_file } end describe file('/tmp/http_request.html') do it { should be_file } its(:content) { should match(/"from":"itamae"/) } end describe file('/tmp/http_request_delete.html') do it { should be_file } its(:content) { should match(/"from":"itamae"/) } end describe file('/tmp/http_request_post.html') do it { should be_file } its(:content) do should match(/"from":"itamae"/) should match(/"love":"sushi"/) end end describe file('/tmp/http_request_put.html') do it { should be_file } its(:content) do should match(/"from":"itamae"/) should match(/"love":"sushi"/) end end describe file('/tmp/http_request_headers.html') do it { should be_file } its(:content) { should match(/"User-Agent":"Itamae"/) } end describe file('/tmp/http_request_redirect.html') do it { should be_file } its(:content) { should match(/"from":"itamae"/) } end describe file('/tmp/notifies') do it { should be_file } its(:content) { should eq("2431") } end describe file('/tmp/subscribes') do it { should be_file } its(:content) { should eq("2431") } end describe file('/tmp/cron_stopped') do it { should be_file } its(:content) do expect(subject.content.lines.size).to eq 1 end end describe file('/tmp/cron_running') do it { should be_file } its(:content) do expect(subject.content.lines.size).to eq 2 end end describe file('/tmp-link') do it { should be_linked_to '/tmp' } its(:content) do expect(subject.content.lines.size).to eq 0 end end describe file('/tmp-link-force') do it { should be_linked_to '/tmp' } end describe file('/tmp/link-force-no-dereference') do it { should be_linked_to 'link-force-no-dereference2' } end describe file('/tmp/link-force-no-dereference/link-force-no-dereference2') do it { should_not exist } end describe command('cd /tmp/git_repo && git rev-parse HEAD') do its(:stdout) { should match(/3116e170b89dc0f7315b69c1c1e1fd7fab23ac0d/) } end describe command('cd /tmp/git_repo_submodule/empty_repo && cat README.md') do its(:stdout) { should match(/Empty Repo/) } end describe command('cd /tmp/git_repo_depth_1 && git rev-list --count HEAD') do its(:stdout) { should eq "1\n" } end describe file('/tmp/created_by_itamae_user') do it { should be_file } it { should be_owned_by 'itamae' } its(:content) { should eq("/home/itamae\n/home/itamae") } end describe file('/tmp/created_in_default2') do it { should be_file } end describe file('/tmp/never_exist3') do it { should_not be_file } end describe file('/tmp/never_exist4') do it { should_not be_file } end describe file('/tmp/created_in_redefine') do it { should be_file } its(:content) { should match(/first/) } end describe command('gem list') do its(:stdout) { should include('tzinfo (1.2.2, 1.1.0)') } end describe command('gem list') do its(:stdout) { should include('rake (11.1.0)') } end describe command('gem list') do its(:stdout) { should_not include('test-unit') } end describe command('ri Bundler') do its(:stderr) { should eq("Nothing known about Bundler\n") } end describe file('/tmp/created_by_definition') do it { should be_file } its(:content) { should eq("name:name,key:value,message:Hello, Itamae\n") } end describe file('/tmp/remote_file_in_definition') do it { should be_file } its(:content) { should eq("definition_example\n") } end describe file('/tmp/multi_delayed_notifies') do it { should be_file } its(:content) { should eq("1\n2\n3\n4\n") } end describe file('/tmp/multi_immediately_notifies') do it { should be_file } its(:content) { should eq("1\n2\n3\n4\n") } end describe file('/tmp/file_edit_sample') do it { should be_file } its(:content) { should eq("Hello, Itamae") } it { should be_mode 400 } it { should be_owned_by "itamae2" } it { should be_grouped_into "itamae2" } end describe file('/tmp/file_edit_with_suid') do it { should be_file } it { should be_mode 4755 } it { should be_owned_by "itamae2" } it { should be_grouped_into "itamae2" } end describe file('/tmp/file_edit_keeping_mode_owner') do it { should be_file } its(:content) { should eq("Hello, Itamae") } it { should be_mode 444 } it { should be_owned_by "itamae" } it { should be_grouped_into "itamae" } end describe file('/tmp/file_edit_with_content_change_updates_timestamp') do its(:mtime) { should be > DateTime.iso8601("2016-05-02T01:23:45Z") } end describe file('/tmp/file_edit_without_content_change_keeping_timestamp') do its(:mtime) { should eq(DateTime.iso8601("2016-05-02T12:34:56Z")) } end describe file('/home/itamae2') do it { should be_directory } it { should be_owned_by "itamae2" } it { should be_grouped_into "itamae2" } end describe file('/tmp/file_create_without_content') do its(:content) { should eq("Hello, World") } it { should be_mode 600 } it { should be_owned_by "itamae" } it { should be_grouped_into "itamae" } end describe file('/tmp/file_edit_notifies') do its(:content) { should eq("1") } end describe file('/tmp/file_without_content_change_updates_mode_and_owner') do its(:content) { should eq("Hello, world") } it { should be_mode 666 } it { should be_owned_by "itamae2" } it { should be_grouped_into "itamae2" } end describe file('/tmp/file_with_content_change_updates_timestamp') do its(:mtime) { should be > DateTime.iso8601("2016-05-01T01:23:45Z") } end describe file('/tmp/file_without_content_change_keeping_timestamp') do its(:mtime) { should eq(DateTime.iso8601("2016-05-01T12:34:56Z")) } end describe file('/tmp/subscribed_from_parent') do it { should be_file } end
class Bison < Formula desc "Parser generator" homepage "https://www.gnu.org/software/bison/" url "https://ftp.gnu.org/gnu/bison/bison-3.2.3.tar.gz" mirror "https://ftpmirror.gnu.org/bison/bison-3.2.3.tar.gz" sha256 "4a96f8349b094d18c23cdabad76c93f7084b9ff1926cdd57fedafaf295445f92" bottle do sha256 "cef69c115b08aa4e5322c5ec94809161fb0d7692b7bed17efb9d462ea03dbe2a" => :mojave sha256 "5db2e33394468af0e2b944289ea4f05a83bf14639c293215e0bae40a20e740a4" => :high_sierra sha256 "7c5c15c1a4936853995e2501216027c1f33739259a3cf02edadfbb7d5c117a15" => :sierra end keg_only :provided_by_macos, "some formulae require a newer version of bison" def install system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}" system "make", "install" end test do (testpath/"test.y").write <<~EOS %{ #include <iostream> using namespace std; extern void yyerror (char *s); extern int yylex (); %} %start prog %% prog: // empty | prog expr '\\n' { cout << "pass"; exit(0); } ; expr: '(' ')' | '(' expr ')' | expr expr ; %% char c; void yyerror (char *s) { cout << "fail"; exit(0); } int yylex () { cin.get(c); return c; } int main() { yyparse(); } EOS system "#{bin}/bison", "test.y" system ENV.cxx, "test.tab.c", "-o", "test" assert_equal "pass", shell_output("echo \"((()(())))()\" | ./test") assert_equal "fail", shell_output("echo \"())\" | ./test") end end bison 3.2.4 Closes #35444. Signed-off-by: Jan Viljanen <15d570f5591572cb420df95d36f61f7b9e9e0533@users.noreply.github.com> class Bison < Formula desc "Parser generator" homepage "https://www.gnu.org/software/bison/" url "https://ftp.gnu.org/gnu/bison/bison-3.2.4.tar.gz" mirror "https://ftpmirror.gnu.org/bison/bison-3.2.4.tar.gz" sha256 "cb673e2298d34b5e46ba7df0641afa734da1457ce47de491863407a587eec79a" bottle do sha256 "cef69c115b08aa4e5322c5ec94809161fb0d7692b7bed17efb9d462ea03dbe2a" => :mojave sha256 "5db2e33394468af0e2b944289ea4f05a83bf14639c293215e0bae40a20e740a4" => :high_sierra sha256 "7c5c15c1a4936853995e2501216027c1f33739259a3cf02edadfbb7d5c117a15" => :sierra end keg_only :provided_by_macos, "some formulae require a newer version of bison" def install system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}" system "make", "install" end test do (testpath/"test.y").write <<~EOS %{ #include <iostream> using namespace std; extern void yyerror (char *s); extern int yylex (); %} %start prog %% prog: // empty | prog expr '\\n' { cout << "pass"; exit(0); } ; expr: '(' ')' | '(' expr ')' | expr expr ; %% char c; void yyerror (char *s) { cout << "fail"; exit(0); } int yylex () { cin.get(c); return c; } int main() { yyparse(); } EOS system "#{bin}/bison", "test.y" system ENV.cxx, "test.tab.c", "-o", "test" assert_equal "pass", shell_output("echo \"((()(())))()\" | ./test") assert_equal "fail", shell_output("echo \"())\" | ./test") end end
require 'spec_helper' module Librato describe Metrics do before(:all) { prep_integration_tests } describe "#fetch" do before(:all) do delete_all_metrics Metrics.submit :my_counter => {:type => :counter, :value => 0} 1.upto(2).each do |i| sleep 1 Metrics.submit :my_counter => {:type => :counter, :value => i} Metrics.submit :my_counter => {:source => 'baz', :type => :counter, :value => i+1} end end context "without arguments" do it "should get metric attributes" do metric = Metrics.fetch :my_counter metric['name'].should == 'my_counter' metric['type'].should == 'counter' end end context "with a start_time" do it "should return entries since that time" do data = Metrics.fetch :my_counter, :start_time => Time.now-3600 # 1 hr ago data['unassigned'].length.should == 3 data['baz'].length.should == 2 end end context "with a count limit" do it "should return that number of entries per source" do data = Metrics.fetch :my_counter, :count => 2 data['unassigned'].length.should == 2 data['baz'].length.should == 2 end end context "with a source limit" do it "should only return that source" do data = Metrics.fetch :my_counter, :source => 'baz', :start_time => Time.now-3600 data['baz'].length.should == 2 data['unassigned'].should be_nil end end end describe "#list" do before(:all) do delete_all_metrics Metrics.submit :foo => 123, :bar => 345, :baz => 678, :foo_2 => 901 end context "without arguments" do it "should list all metrics" do metric_names = Metrics.list.map { |metric| metric['name'] } metric_names.sort.should == %w{foo bar baz foo_2}.sort end end context "with a name argument" do it "should list metrics that match" do metric_names = Metrics.list(:name => 'foo').map { |metric| metric['name'] } metric_names.sort.should == %w{foo foo_2}.sort end end end describe "#submit" do context "with a gauge" do before(:all) do delete_all_metrics Metrics.submit :foo => 123 end it "should create the metrics" do metric = Metrics.list[0] metric['name'].should == 'foo' metric['type'].should == 'gauge' end it "should store their data" do data = Metrics.fetch :foo, :count => 1 data.should_not be_empty data['unassigned'][0]['value'] == 123.0 end end context "with a counter" do before(:all) do delete_all_metrics Metrics.submit :bar => {:type => :counter, :source => 'baz', :value => 456} end it "should create the metrics" do metric = Metrics.list[0] metric['name'].should == 'bar' metric['type'].should == 'counter' end it "should store their data" do data = Metrics.fetch :bar, :count => 1 data.should_not be_empty data['baz'][0]['value'] == 456.0 end end end end end Make sure there's always more than a second betwen requests. require 'spec_helper' module Librato describe Metrics do before(:all) { prep_integration_tests } describe "#fetch" do before(:all) do delete_all_metrics Metrics.submit :my_counter => {:type => :counter, :value => 0} 1.upto(2).each do |i| sleep 1.1 Metrics.submit :my_counter => {:type => :counter, :value => i} Metrics.submit :my_counter => {:source => 'baz', :type => :counter, :value => i+1} end end context "without arguments" do it "should get metric attributes" do metric = Metrics.fetch :my_counter metric['name'].should == 'my_counter' metric['type'].should == 'counter' end end context "with a start_time" do it "should return entries since that time" do data = Metrics.fetch :my_counter, :start_time => Time.now-3600 # 1 hr ago data['unassigned'].length.should == 3 data['baz'].length.should == 2 end end context "with a count limit" do it "should return that number of entries per source" do data = Metrics.fetch :my_counter, :count => 2 data['unassigned'].length.should == 2 data['baz'].length.should == 2 end end context "with a source limit" do it "should only return that source" do data = Metrics.fetch :my_counter, :source => 'baz', :start_time => Time.now-3600 data['baz'].length.should == 2 data['unassigned'].should be_nil end end end describe "#list" do before(:all) do delete_all_metrics Metrics.submit :foo => 123, :bar => 345, :baz => 678, :foo_2 => 901 end context "without arguments" do it "should list all metrics" do metric_names = Metrics.list.map { |metric| metric['name'] } metric_names.sort.should == %w{foo bar baz foo_2}.sort end end context "with a name argument" do it "should list metrics that match" do metric_names = Metrics.list(:name => 'foo').map { |metric| metric['name'] } metric_names.sort.should == %w{foo foo_2}.sort end end end describe "#submit" do context "with a gauge" do before(:all) do delete_all_metrics Metrics.submit :foo => 123 end it "should create the metrics" do metric = Metrics.list[0] metric['name'].should == 'foo' metric['type'].should == 'gauge' end it "should store their data" do data = Metrics.fetch :foo, :count => 1 data.should_not be_empty data['unassigned'][0]['value'] == 123.0 end end context "with a counter" do before(:all) do delete_all_metrics Metrics.submit :bar => {:type => :counter, :source => 'baz', :value => 456} end it "should create the metrics" do metric = Metrics.list[0] metric['name'].should == 'bar' metric['type'].should == 'counter' end it "should store their data" do data = Metrics.fetch :bar, :count => 1 data.should_not be_empty data['baz'][0]['value'] == 456.0 end end end end end
class App < Sinatra::Base register Sinatra::Namespace # Begin users namespace namespace '/users' do # Create new user post '/?' do begin body_params = JSON.parse(request.body.read) required_fields = {"required" => ["email", "first_name", "last_name", "role"]} schema = User::SCHEMA.merge(required_fields) JSON::Validator.validate!(schema, body_params) rescue Exception => e give_error(400, ERROR_INVALID_BODY, "The body is not valid.").to_json end user = case body_params["role"].downcase when "blind" Blind.new when "helper" Helper.new else give_error(400, ERROR_UNDEFINED_ROLE, "Undefined role.").to_json end if !body_params['password'].nil? password = decrypted_password(body_params['password']) user.update_attributes body_params.merge({ "password" => password }) elsif !body_params['user_id'].nil? user.update_attributes body_params.merge({ "user_id" => body_params['user_id'] }) else give_error(400, ERROR_INVALID_BODY, "Missing parameter 'user_id' for registering a Facebook user or parameter 'password' for registering a regular user.").to_json end begin user.save! rescue Exception => e puts e.message give_error(400, ERROR_USER_EMAIL_ALREADY_REGISTERED, "The e-mail is already registered.").to_json if e.message.match /email/i end return user_from_id(user.id2) end # Logout, thereby deleting the token put '/logout' do begin body_params = JSON.parse(request.body.read) token_repr = body_params["token"] rescue Exception => e give_error(400, ERROR_INVALID_BODY, "The body is not valid.").to_json end token = token_from_representation(token_repr) if !token.valid? give_error(400, ERROR_USER_TOKEN_EXPIRED, "Token has expired.").to_json end token.delete return { "success" => true }.to_json end # Login, thereby creating an ew token post '/login' do begin body_params = JSON.parse(request.body.read) rescue Exception => e give_error(400, ERROR_INVALID_BODY, "The body is not valid.").to_json end secure_password = body_params["password"] user_id = body_params["user_id"] # We need either a password or a user ID to login if secure_password.nil? && user_id.nil? give_error(400, ERROR_INVALID_BODY, "Missing password or user ID.").to_json end # We need either an e-mail to login if body_params['email'].nil? give_error(400, ERROR_INVALID_BODY, "Missing e-mail.").to_json end if !secure_password.nil? # Login using e-mail and password password = decrypted_password(secure_password) user = User.authenticate_using_email(body_params['email'], password) # Check if we managed to log in if user.nil? give_error(400, ERROR_USER_INCORRECT_CREDENTIALS, "No user found matching the credentials.").to_json end elsif !user_id.nil? # Login using user ID user = User.authenticate_using_user_id(body_params['email'], body_params['user_id']) # Check if we managed to log in if user.nil? give_error(400, ERROR_USER_FACEBOOK_USER_NOT_FOUND, "The Facebook user was not found.").to_json end end # We did log in, create token token = Token.new token.valid_time = 365.days user.tokens.push(token) token.save! return { "token" => JSON.parse(token.to_json), "user" => JSON.parse(token.user.to_json) }.to_json end # Login with a token put '/login/token' do begin body_params = JSON.parse(request.body.read) token_repr = body_params["token"] rescue Exception => e give_error(400, ERROR_INVALID_BODY, "The body is not valid.").to_json end token = token_from_representation(token_repr) if !token.valid? give_error(400, ERROR_USER_TOKEN_EXPIRED, "Token has expired.").to_json end return { "user" => JSON.parse(token.user.to_json) }.to_json end # Get user by id get '/:user_id' do content_type 'application/json' return user_from_id(params[:user_id].to_i).to_json end #days param get '/helper_points/:user_id' do days = params[:days]|| 30 helper = helper_from_id(params[:user_id].to_i) days = days.to_i sums = HelperPointDateHelper.get_aggregated_points_for_each_day(helper, days) return sums.to_json end get '/helper_points_sum/:user_id' do helper = helper_from_id(params[:user_id].to_i) if(helper.helper_points.count == 0) return 0.to_json return helper.helper_points.sum.point.to_json end # Update a user put '/:user_id' do user = user_from_id(params[:user_id].to_i) begin body_params = JSON.parse(request.body.read) JSON::Validator.validate!(User::SCHEMA, body_params) user.update_attributes!(body_params) rescue Exception => e puts e.message give_error(400, ERROR_INVALID_BODY, "The body is not valid.").to_json end return user end put '/:user_id/snooze/:period' do puts params[:period] raise Sinatra::NotFound unless params[:period].match /^(1h|3h|1d|3d|1w|stop)$/ user = user_from_id(params[:user_id].to_i) #Stores it in UTC, perhaps change it using timezone info later on. current_time = Time.now.utc #TODO refactor this case... new_time = case params[:period] when '1h' current_time + 1.hour when '3h' current_time + 3.hour when '1d' current_time + 1.day when '3d' current_time + 3.day when '1w' current_time + 1.week when 'stop' current_time end user.update_attributes!({:snooze_period => params[:period], :available_from => new_time}) return user.to_json end end # End namespace /users # Get user from ID def user_from_id(user_id) user = User.first(:id2 => user_id) if user.nil? give_error(400, ERROR_USER_NOT_FOUND, "No user found.").to_json end return user end def helper_from_id(user_id) helper = Helper.first(:id2 => user_id) if helper.nil? give_error(400, ERROR_USER_NOT_FOUND, "No helper found.").to_json end return helper end # Find token by representation of the token def token_from_representation(repr) token = Token.first(:token => repr) if token.nil? give_error(400, ERROR_USER_TOKEN_NOT_FOUND, "Token not found.").to_json end return token end # Decrypt the password def decrypted_password(secure_password) begin return AESCrypt.decrypt(secure_password, settings.config["security_salt"]) rescue Exception => e give_error(400, ERROR_INVALID_PASSWORD, "The password is invalid.").to_json end end end fixing syntax error class App < Sinatra::Base register Sinatra::Namespace # Begin users namespace namespace '/users' do # Create new user post '/?' do begin body_params = JSON.parse(request.body.read) required_fields = {"required" => ["email", "first_name", "last_name", "role"]} schema = User::SCHEMA.merge(required_fields) JSON::Validator.validate!(schema, body_params) rescue Exception => e give_error(400, ERROR_INVALID_BODY, "The body is not valid.").to_json end user = case body_params["role"].downcase when "blind" Blind.new when "helper" Helper.new else give_error(400, ERROR_UNDEFINED_ROLE, "Undefined role.").to_json end if !body_params['password'].nil? password = decrypted_password(body_params['password']) user.update_attributes body_params.merge({ "password" => password }) elsif !body_params['user_id'].nil? user.update_attributes body_params.merge({ "user_id" => body_params['user_id'] }) else give_error(400, ERROR_INVALID_BODY, "Missing parameter 'user_id' for registering a Facebook user or parameter 'password' for registering a regular user.").to_json end begin user.save! rescue Exception => e puts e.message give_error(400, ERROR_USER_EMAIL_ALREADY_REGISTERED, "The e-mail is already registered.").to_json if e.message.match /email/i end return user_from_id(user.id2) end # Logout, thereby deleting the token put '/logout' do begin body_params = JSON.parse(request.body.read) token_repr = body_params["token"] rescue Exception => e give_error(400, ERROR_INVALID_BODY, "The body is not valid.").to_json end token = token_from_representation(token_repr) if !token.valid? give_error(400, ERROR_USER_TOKEN_EXPIRED, "Token has expired.").to_json end token.delete return { "success" => true }.to_json end # Login, thereby creating an ew token post '/login' do begin body_params = JSON.parse(request.body.read) rescue Exception => e give_error(400, ERROR_INVALID_BODY, "The body is not valid.").to_json end secure_password = body_params["password"] user_id = body_params["user_id"] # We need either a password or a user ID to login if secure_password.nil? && user_id.nil? give_error(400, ERROR_INVALID_BODY, "Missing password or user ID.").to_json end # We need either an e-mail to login if body_params['email'].nil? give_error(400, ERROR_INVALID_BODY, "Missing e-mail.").to_json end if !secure_password.nil? # Login using e-mail and password password = decrypted_password(secure_password) user = User.authenticate_using_email(body_params['email'], password) # Check if we managed to log in if user.nil? give_error(400, ERROR_USER_INCORRECT_CREDENTIALS, "No user found matching the credentials.").to_json end elsif !user_id.nil? # Login using user ID user = User.authenticate_using_user_id(body_params['email'], body_params['user_id']) # Check if we managed to log in if user.nil? give_error(400, ERROR_USER_FACEBOOK_USER_NOT_FOUND, "The Facebook user was not found.").to_json end end # We did log in, create token token = Token.new token.valid_time = 365.days user.tokens.push(token) token.save! return { "token" => JSON.parse(token.to_json), "user" => JSON.parse(token.user.to_json) }.to_json end # Login with a token put '/login/token' do begin body_params = JSON.parse(request.body.read) token_repr = body_params["token"] rescue Exception => e give_error(400, ERROR_INVALID_BODY, "The body is not valid.").to_json end token = token_from_representation(token_repr) if !token.valid? give_error(400, ERROR_USER_TOKEN_EXPIRED, "Token has expired.").to_json end return { "user" => JSON.parse(token.user.to_json) }.to_json end # Get user by id get '/:user_id' do content_type 'application/json' return user_from_id(params[:user_id].to_i).to_json end #days param get '/helper_points/:user_id' do days = params[:days]|| 30 helper = helper_from_id(params[:user_id].to_i) days = days.to_i sums = HelperPointDateHelper.get_aggregated_points_for_each_day(helper, days) return sums.to_json end get '/helper_points_sum/:user_id' do helper = helper_from_id(params[:user_id].to_i) if(helper.helper_points.count == 0) return 0.to_json end return helper.helper_points.sum.point.to_json end # Update a user put '/:user_id' do user = user_from_id(params[:user_id].to_i) begin body_params = JSON.parse(request.body.read) JSON::Validator.validate!(User::SCHEMA, body_params) user.update_attributes!(body_params) rescue Exception => e puts e.message give_error(400, ERROR_INVALID_BODY, "The body is not valid.").to_json end return user end put '/:user_id/snooze/:period' do puts params[:period] raise Sinatra::NotFound unless params[:period].match /^(1h|3h|1d|3d|1w|stop)$/ user = user_from_id(params[:user_id].to_i) #Stores it in UTC, perhaps change it using timezone info later on. current_time = Time.now.utc #TODO refactor this case... new_time = case params[:period] when '1h' current_time + 1.hour when '3h' current_time + 3.hour when '1d' current_time + 1.day when '3d' current_time + 3.day when '1w' current_time + 1.week when 'stop' current_time end user.update_attributes!({:snooze_period => params[:period], :available_from => new_time}) return user.to_json end end # End namespace /users # Get user from ID def user_from_id(user_id) user = User.first(:id2 => user_id) if user.nil? give_error(400, ERROR_USER_NOT_FOUND, "No user found.").to_json end return user end def helper_from_id(user_id) helper = Helper.first(:id2 => user_id) if helper.nil? give_error(400, ERROR_USER_NOT_FOUND, "No helper found.").to_json end return helper end # Find token by representation of the token def token_from_representation(repr) token = Token.first(:token => repr) if token.nil? give_error(400, ERROR_USER_TOKEN_NOT_FOUND, "Token not found.").to_json end return token end # Decrypt the password def decrypted_password(secure_password) begin return AESCrypt.decrypt(secure_password, settings.config["security_salt"]) rescue Exception => e give_error(400, ERROR_INVALID_PASSWORD, "The password is invalid.").to_json end end end
class Blast < Formula desc "Basic Local Alignment Search Tool" homepage "https://blast.ncbi.nlm.nih.gov/" url "https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/2.10.0/ncbi-blast-2.10.0+-src.tar.gz" version "2.10.0" sha256 "3acdd9cec01c4f43e56aeaf89049cb8f8013d60b9c1705eced10166967f1d926" bottle do rebuild 1 sha256 "71ebf77b85de24cac6384b796b7b6a70fcaaeded84e1534bbfc4ba86030289d8" => :catalina sha256 "4da358f7b8d0fdc4b3d3a47ee16e0f6345c0846d76a692bdfeb7a7e0f84a12dd" => :mojave sha256 "0f8ce869239db65218854d9897bc47108d08a33d4f35d7afb56c22f1dc4a24ba" => :high_sierra end depends_on "lmdb" uses_from_macos "bzip2" uses_from_macos "zlib" conflicts_with "proj", :because => "both install a `libproj.a` library" def install cd "c++" do # Use ./configure --without-boost to fix # error: allocating an object of abstract class type 'ncbi::CNcbiBoostLogger' # Boost is used only for unit tests. # See https://github.com/Homebrew/homebrew-science/pull/3537#issuecomment-220136266 system "./configure", "--prefix=#{prefix}", "--without-debug", "--without-boost" # Fix the error: install: ReleaseMT/lib/*.*: No such file or directory system "make" system "make", "install" end end test do output = shell_output("#{bin}/update_blastdb.pl --showall") assert_match "nt", output (testpath/"test.fasta").write <<~EOS >U00096.2:1-70 AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC EOS output = shell_output("#{bin}/blastn -query test.fasta -subject test.fasta") assert_match "Identities = 70/70", output # Create BLAST database output = shell_output("#{bin}/makeblastdb -in test.fasta -out testdb -dbtype nucl") assert_match "Adding sequences from FASTA", output # Check newly created BLAST database output = shell_output("#{bin}/blastdbcmd -info -db testdb") assert_match "Database: test", output end end blast 2.10.1 Closes #57042. Signed-off-by: chenrui <5fd29470147430022ff146db88de16ee91dea376@gmail.com> class Blast < Formula desc "Basic Local Alignment Search Tool" homepage "https://blast.ncbi.nlm.nih.gov/" url "https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/2.10.1/ncbi-blast-2.10.1+-src.tar.gz" version "2.10.1" sha256 "110729decf082f69b90b058c0cabaea38f771983a564308ae19cb30a68ce7b86" bottle do rebuild 1 sha256 "71ebf77b85de24cac6384b796b7b6a70fcaaeded84e1534bbfc4ba86030289d8" => :catalina sha256 "4da358f7b8d0fdc4b3d3a47ee16e0f6345c0846d76a692bdfeb7a7e0f84a12dd" => :mojave sha256 "0f8ce869239db65218854d9897bc47108d08a33d4f35d7afb56c22f1dc4a24ba" => :high_sierra end depends_on "lmdb" uses_from_macos "bzip2" uses_from_macos "zlib" conflicts_with "proj", :because => "both install a `libproj.a` library" def install cd "c++" do # Use ./configure --without-boost to fix # error: allocating an object of abstract class type 'ncbi::CNcbiBoostLogger' # Boost is used only for unit tests. # See https://github.com/Homebrew/homebrew-science/pull/3537#issuecomment-220136266 system "./configure", "--prefix=#{prefix}", "--without-debug", "--without-boost" # Fix the error: install: ReleaseMT/lib/*.*: No such file or directory system "make" system "make", "install" end end test do output = shell_output("#{bin}/update_blastdb.pl --showall") assert_match "nt", output (testpath/"test.fasta").write <<~EOS >U00096.2:1-70 AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC EOS output = shell_output("#{bin}/blastn -query test.fasta -subject test.fasta") assert_match "Identities = 70/70", output # Create BLAST database output = shell_output("#{bin}/makeblastdb -in test.fasta -out testdb -dbtype nucl") assert_match "Adding sequences from FASTA", output # Check newly created BLAST database output = shell_output("#{bin}/blastdbcmd -info -db testdb") assert_match "Database: test", output end end
require 'spec_helper' PManager = Hashie::Mash.new({ :provider => 'facebook', :uid => '123545', :info => { :email => "manager@test.site", :name => "Manager Person", :image => "face.jpg" }, :credentials => { :token => "abc123" } }) PCustomer = Hashie::Mash.new({ :provider => 'facebook', :uid => '123546', :info => { :email => "customer@test.site", :name => "Customer Person", :image => "face.jpg" }, :credentials => { :token => "abc124" } }) describe "Project management", :type => :request do it "Creates a new project using the big Add button" do # Manager creates project OmniAuth.config.mock_auth[:facebook] = PManager visit '/' click_on "facebook-login" page.should have_content("manager@test.site") click_on "Add a project" page.has_css?("form#new_project") fill_in('Project Name', :with => "A new pony") fill_in('Collection amount', :with => "35") fill_in('Funding due', :with => 5.days.from_now) click_on "Save Details" page.should have_content("This project is not published.") click_on "Publish" page.should have_content("Publish Project") click_on "Publish" page.should have_content("Project now published!") click_on "logout" # Customer donates OmniAuth.config.mock_auth[:facebook] = PCustomer visit '/' click_on "facebook-login" page.should have_content("customer@test.site") visit '/projects/a-new-pony' page.should have_content("Contribute to this project") fill_in("Amount", :with => "10") click_on "Give" page.should have_content("Contribute $10.00 to") #click_on "Continue to Amazon Payments" end end payment callback, recording of contribution require 'spec_helper' PManager = Hashie::Mash.new({ :provider => 'facebook', :uid => '123545', :info => { :email => "manager@test.site", :name => "Manager Person", :image => "face.jpg" }, :credentials => { :token => "abc123" } }) PCustomer = Hashie::Mash.new({ :provider => 'facebook', :uid => '123546', :info => { :email => "customer@test.site", :name => "Customer Person", :image => "face.jpg" }, :credentials => { :token => "abc124" } }) describe "Project management", :type => :request do it "Creates a new project using the big Add button" do # Manager creates project OmniAuth.config.mock_auth[:facebook] = PManager visit '/' click_on "facebook-login" page.should have_content("manager@test.site") click_on "Add a project" page.has_css?("form#new_project") fill_in('Project Name', :with => "A new pony") fill_in('Collection amount', :with => "35") fill_in('Funding due', :with => 5.days.from_now) click_on "Save Details" page.should have_content("This project is not published.") click_on "Publish" page.should have_content("Publish Project") click_on "Publish" page.should have_content("Project now published!") click_on "logout" # Customer donates OmniAuth.config.mock_auth[:facebook] = PCustomer visit '/' click_on "facebook-login" page.should have_content("customer@test.site") visit '/projects/a-new-pony' page.should have_content("Contribute to this project") fill_in("Amount", :with => "10") click_on "Give" page.should have_content("Contribute $10.00 to") #click_on "Continue to Amazon Payments" reference = find(:xpath, "//input[@name='callerReference']")["value"] #Amazon callback visit "/payment/receive?callerReference=#{reference}&tokenID=abczzz&status=SC" within(".contributors") do page.should have_content("Customer Person $10") end end end
class Users < Cuba define do user = current_user on "dashboard" do on get, root do render("user/dashboard", title: "Dashboard") end on(default) { not_found! } end on "edit" do on post, param("user") do |params| params.delete("password") if params["password"].empty? edit = EditUser.new(params) on edit.valid? do params.delete("password_confirmation") on user.email != edit.email && User.with(:email, edit.email) do session[:error] = "This e-mail is already registered" render("user/edit", title: "Edit profile", edit: edit, user: user) end on user.username != edit.username && User.with(:username, edit.username) do session[:error] = "This username is already taken" render("user/edit", title: "Edit profile", edit: edit, user: user) end on default do if user.name != params["name"] ballots = Ballot.find(created_by: user.name) choices = Choice.find(added_by: user.name) comments = Comment.find(added_by: user.name) ballots.each do |ballot| ballot.update(created_by: params["name"]) end choices.each do |choice| choice.update(added_by: params["name"]) end comments.each do |comment| comment.update(added_by: params["name"]) end end user.update(params) if !params["password"].nil? Ost[:password_changed].push(user.id) end session[:success] = "Your account was successfully updated!" res.redirect "/dashboard" end end on default do render("user/edit", title: "Edit profile", edit: edit, user: user) end end on default do edit = EditUser.new({}) render("user/edit", title: "Edit profile", edit: edit, user: user) end end on "logout" do logout(User) session[:success] = "You have successfully logged out!" res.redirect "/" end on "delete" do UserRemovedLog.create(user) logout(User) session[:success] = "You have successfully deleted your account" Ost[:user_deleted].push(user.id) res.redirect "/" end on "group/new" do on post, param("group") do |params| new_group = NewGroup.new(params) on new_group.valid? do params["user_id"] = user.id group = Group.create(params) user.groups.add(group) session[:success] = "You have successfully created a new group!" res.redirect "/group/#{group.id}" end on default do render("group/new", title: "Create new group", group: new_group) end end on get, root do render("group/new", title: "Create new group") end on default do not_found! end end on "group/:id/voters/add" do |id| group = user.groups[id] on group do on post, param("voter") do |params| voter = NewVoter.new(params) on voter.valid? do new_voter = User.with(:email, voter.email) on new_voter && new_voter.email == user.email do session[:error] = "You are already a voter! No need to include yourself in the group. :-)" render("group/info", title: "Group", group: group, new_voter: voter) end on new_voter && group.voters.include?(new_voter) do session[:error] = "Voter already added" render("group/info", title: "Group", group: group, new_voter: voter) end on new_voter do group.voters.add(new_voter) session[:success] = "Voter successfully added!" res.redirect "/group/#{id}" end on default do session[:error] = "The email you entered is not registered in Team Ballots" message = NewMessage.new(email: voter.email) render("group/invite", title: "Invite", group: group, message: message) end end on default do render("group/info", title: "Group", group: group, new_voter: voter) end end on get, root do render("group/info", title: "Group", group: group, new_voter: NewVoter.new({})) end end on default do not_found! end end on "group/:group_id/voters/:voter_id/remove" do |group_id, voter_id| group = user.groups[group_id] on group do voter = User[voter_id] on get do group.voters.delete(voter) session[:success] = "Voter successfully removed" res.redirect "/group/#{group_id}" end end on default do not_found! end end on "group/:id/remove" do |id| group = user.groups[id] on group do on get do user.groups.delete(group) group.delete session[:success] = "Group successfully removed" res.redirect "/dashboard" end end on default do not_found! end end on "group/:id/invite" do |id| group = user.groups[id] on group do on post, param("message") do |params| message = NewMessage.new(params) on message.valid? do json = JSON.dump( from_user: user.name, email: message.email, body: message.body) Ost[:send_invitation].push(json) session[:success] = "You have successfully send an invitation!" res.redirect "/group/#{id}" end on default do render("group/invite", title: "Invite", group: group, message: message) end end end on default do not_found! end end on "group/:id" do |id| group = user.groups[id] on group do on get, root do render("group/info", title: "Group", group: group, new_voter: NewVoter.new({})) end end on default do not_found! end end on "ballot/new" do on post, param("ballot") do |params| params["start_date"] = Time.new.to_i if params["end_choices_date"] != "" params["end_choices_date"] = cal_to_unix(params["end_choices_date"]) else params["end_choices_date"] = nil end if params["end_date"] != "" params["end_date"] = cal_to_unix(params["end_date"]) else params["end_date"] = nil end new_ballot = NewBallot.new(params) on new_ballot.valid? do params["user_id"] = user.id params["created_by"] = user.name ballot = Ballot.create(params) user.ballots.add(ballot) ballot.voters.add(user) session[:success] = "You have successfully posted a new ballot!" res.redirect "/dashboard" end on default do if new_ballot.end_choices_date != nil new_ballot.end_choices_date = unix_to_cal(new_ballot.end_choices_date) else new_ballot.end_choices_date = "" end if new_ballot.end_date != nil new_ballot.end_date = unix_to_cal(new_ballot.end_date) else new_ballot.end_date = "" end render("ballot/new", title: "Create new ballot", ballot: new_ballot) end end on get, root do new_ballot = NewBallot.new({}) render("ballot/new", title: "Create new ballot", ballot: new_ballot, end_choices_date: nil, end_date: nil) end on default do not_found! end end on "ballot/:id/edit" do |id| ballot = user.ballots[id] on ballot do if ballot.status == "Active" && ballot.user_id == user.id on post do on req.post?, param("ballot") do |params| if valid_date?(params["end_choices_date"]) && valid_date?(params["end_date"]) if params["end_choices_date"] != "" params["end_choices_date"] = cal_to_unix(params["end_choices_date"]) else params["end_choices_date"] = unix_to_cal(ballot.end_choices_date) end if params["end_date"] != "" params["end_date"] = cal_to_unix(params["end_date"]) else params["end_date"] = unix_to_cal(ballot.end_date) end edit = NewBallot.new(params) edit.start_date = Time.new.to_i on edit.valid? do if ballot.title != params["title"] || ballot.description != params["description"] || ballot.end_choices_date.to_i != params["end_choices_date"] || ballot.end_date.to_i != params["end_date"] BallotEditedLog.create(user, ballot, params) end ballot.update(params) session[:success] = "Ballot successfully edited!" res.redirect "/ballot/#{id}" end on default do ballot.end_choices_date = unix_to_cal(ballot.end_choices_date) ballot.end_date = unix_to_cal(ballot.end_date) render("ballot/edit", title: "Edit ballot", ballot: ballot, edit: edit) end else session[:error] = "Invalid date format" res.redirect "/ballot/#{id}/edit" end end on default do ballot.end_choices_date = unix_to_cal(ballot.end_choices_date) ballot.end_date = unix_to_cal(ballot.end_date) render("ballot/edit", title: "Edit ballot", ballot: ballot, edit: NewBallot.new({})) end end on get, root do ballot.end_choices_date = unix_to_cal(ballot.end_choices_date) ballot.end_date = unix_to_cal(ballot.end_date) render("ballot/edit", title: "Edit ballot", ballot: ballot) end elsif ballot.status == "Active" && ballot.user_id != user.id session[:error] = "Ballot can be edited only by the creator of the ballot only (#{ballot.created_by})" res.redirect "/ballot/#{id}" else session[:error] = "Ballot cannot be edited anymore" res.redirect "/ballot/#{id}" end end on default do not_found! end end on "ballot/:id/choices/add" do |id| ballot = user.ballots[id] on ballot do if ballot.status == "Active" on post, param("choice") do |params| params["date"] = Time.new.to_i choice = NewChoice.new(params) on choice.valid? do params["user_id"] = user.id params["ballot_id"] = ballot.id params["added_by"] = user.name choice_added = Choice.create(params) ChoiceAddedLog.create(user, ballot, choice_added) session[:success] = "You have successfully added a choice!" res.redirect "/ballot/#{id}/choices" end on default do render("ballot/add_choice", title: "Add choice", ballot: ballot, choice: choice) end end on get, root do render("ballot/add_choice", title: "Add choice", ballot: ballot, choice: NewChoice.new({})) end else session[:error] = "Ballot cannot be edited anymore" res.redirect "/ballot/#{id}" end end on default do not_found! end end on "ballot/:ballot_id/choices/:choice_id/remove" do |ballot_id, choice_id| ballot = user.ballots[ballot_id] on ballot do if ballot.status == "Active" choice = ballot.choices[choice_id] on get do on choice.user_id != user.id do session[:error] = "You can only remove choices added by you" res.redirect "/ballot/#{ballot_id}/choices" end on default do ChoiceRemovedLog.create(user, ballot, choice) choice.delete session[:success] = "Choice successfully removed" res.redirect "/ballot/#{ballot_id}/choices" end end else session[:error] = "Ballot cannot be edited anymore" res.redirect "/ballot/#{ballot_id}" end end on default do not_found! end end on "ballots/closed" do closed_ballots = [] user.ballots.each do |ballot| if ballot.status == "Closed" closed_ballots << ballot end end on !closed_ballots.empty? do on get, root do render("ballot/closed_ballots", title: "Closed ballots", closed_ballots: closed_ballots) end end on default do not_found! end end on "ballot/:id/choices" do |id| ballot = user.ballots[id] on ballot do on get, root do render("ballot/choices", title: "Choices", ballot: ballot, choice: NewChoice.new({})) end end on default do not_found! end end on "ballot/:ballot_id/voters/:voter_id/remove" do |ballot_id, voter_id| ballot = user.ballots[ballot_id] on ballot do voter = User[voter_id] on get do on voter != user do session[:error] = "You can't remove other users, just yourself." res.redirect "/ballot/#{ballot_id}/voters" end on voter == user && ballot.voters.size == 1 do ballot.delete session[:success] = "You have removed yourself and deleted the ballot (as you were the only one voter)." res.redirect "/dashboard" end on default do VoterRemovedLog.create(user, ballot, voter) ballot.voters.delete(voter) voter.ballots.delete(ballot) session[:success] = "You have removed yourself from the ballot." res.redirect "/dashboard" end end end on default do not_found! end end on "ballot/:id/voters/add" do |id| ballot = user.ballots[id] on ballot && ballot.user_id != user.id do session[:error] = "Voters can be added by the creator of the ballot only (#{ballot.created_by})" res.redirect "/ballot/#{id}" end on ballot do if ballot.status != "Closed" on post, param("voter") do |params| voter = NewVoter.new(params) on voter.valid? do new_voter = User.with(:email, voter.email) on new_voter && new_voter.email == user.email do session[:error] = "You are already a voter! :-)" render("ballot/add_voter", title: "Add voter", ballot: ballot, voter: voter) end on new_voter && ballot.voters.include?(new_voter) do session[:error] = "Voter already added" render("ballot/add_voter", title: "Add voter", ballot: ballot, voter: voter) end on new_voter do ballot.voters.add(new_voter) new_voter.ballots.add(ballot) VoterAddedLog.create(user, ballot, new_voter) json = JSON.dump( email: new_voter.email, name: new_voter.name, ballot_title: ballot.title, ballot_description: ballot.description, end_date: cal_utc(ballot.end_date)) Ost[:voter_added].push(json) session[:success] = "Voter successfully added!" res.redirect "/ballot/#{id}/voters" end on default do session[:error] = "The email you entered is not registered in Team Ballots" message = NewMessage.new(email: voter.email) render("ballot/invite", title: "Invite", ballot: ballot, message: message) end end on default do render("ballot/add_voter", title: "Add voter", ballot: ballot, voter: voter) end end on post, param("voters") do |params| if params["group"] != "" group = user.groups.include?(Group[params["group"]]) end on group do group = Group[params["group"]] voters = group.voters voters.each do |voter| if !ballot.voters.include?(voter) VoterAddedLog.create(user, ballot, voter) end ballot.voters.add(voter) voter.ballots.add(ballot) json = JSON.dump( email: voter.email, name: voter.name, ballot_title: ballot.title, ballot_description: ballot.description, end_date: cal_utc(ballot.end_date)) Ost[:voter_added].push(json) end session[:success] = "Voters group successfully added!" res.redirect "/ballot/#{id}/voters" end on default do session[:error] = "The voters group selected was not valid" res.redirect "/ballot/#{id}/voters/add" end end on get, root do render("ballot/add_voter", title: "Add voter", ballot: ballot, voter: NewVoter.new({})) end else session[:error] = "Ballot cannot be edited anymore" res.redirect "/ballot/#{id}" end end on default do not_found! end end on "ballot/:id/voters" do |id| ballot = user.ballots[id] on ballot do on get, root do render("ballot/voters", title: "Voters", ballot: ballot, voter: NewVoter.new({})) end end on default do not_found! end end on "ballot/:id/add_comment" do |id| ballot = user.ballots[id] on ballot do if ballot.status != "Closed" on post, param("comment") do |params| params["date"] = Time.new.to_i comment = NewComment.new(params) on comment.valid? do params["user_id"] = user.id params["ballot_id"] = ballot.id params["added_by"] = user.name Comment.create(params) session[:success] = "You have successfully added a comment!" res.redirect "/ballot/#{id}" end on default do render("ballot/info", title: "Add comment", ballot: ballot, comment: comment) end end else session[:error] = "Comments cannot be added anymore. Ballot is closed." res.redirect "/ballot/#{id}" end end on default do not_found! end end on "ballot/:id/vote" do |id| ballot = user.ballots[id] on ballot do choices_voted = [] ballot.choices.each do |choice| choice_voted = choice.votes.find(user_id: user.id) if !choice_voted.empty? choices_voted << choice.id end end if ballot.status != "Closed" on post, param("vote") do |votes| valid_votes = [] votes.each do |rating| params = {} params["rating"] = rating[1].to_i # if it's converted into integer, when choosing "--" it validates because it takes it as "0" vote = NewVote.new(params) if vote.valid? if choices_voted.include?(rating[0]) choice = Choice[rating[0]] vote_to_update = Vote[choice.votes.find(user_id: user.id).ids[0]] updated = vote_to_update.update(params) valid_votes << updated else params["date"] = Time.new.to_i params["choice_id"] = rating[0] params["user_id"] = user.id new_vote = Vote.create(params) valid_votes << new_vote end else session[:error] = "The vote wasn't valid. Please try again." res.redirect "/ballot/#{id}" end end on valid_votes.size == votes.size do session[:success] = "You have successfully voted!" res.redirect "/ballot/#{id}" end on default do session[:error] = "Vote wasn't valid. Please try again." res.redirect "/ballot/#{id}" end end on get, root do render("ballot/update_vote", title: "Vote", ballot: ballot, voter: NewVote.new({})) end else session[:error] = "Ballot is closed." res.redirect "/ballot/#{id}" end end on default do not_found! end end on "ballot/:id/invite" do |id| ballot = user.ballots[id] on ballot do if ballot.status != "Closed" on post, param("message") do |params| message = NewMessage.new(params) on message.valid? do json = JSON.dump( from_user: user.name, email: message.email, body: message.body) Ost[:send_invitation].push(json) session[:success] = "You have successfully send an invitation!" res.redirect "/ballot/#{id}/voters/add" end on default do render("ballot/invite", title: "Invite", ballot: ballot, message: message) end end else session[:error] = "Ballot is closed." res.redirect "/ballot/#{id}" end end on default do not_found! end end on "ballot/:id" do |id| ballot = user.ballots[id] on ballot do on get, root do render("ballot/info", title: ballot.title, ballot: ballot) end end on default do not_found! end end on "/" do res.write "hola" end on default do not_found! end end end Fix bug on users route. class Users < Cuba define do user = current_user on "dashboard" do on get, root do render("user/dashboard", title: "Dashboard") end on(default) { not_found! } end on "edit" do on post, param("user") do |params| params.delete("password") if params["password"].empty? edit = EditUser.new(params) on edit.valid? do params.delete("password_confirmation") on user.email != edit.email && User.with(:email, edit.email) do session[:error] = "This e-mail is already registered" render("user/edit", title: "Edit profile", edit: edit, user: user) end on user.username != edit.username && User.with(:username, edit.username) do session[:error] = "This username is already taken" render("user/edit", title: "Edit profile", edit: edit, user: user) end on default do if user.name != params["name"] ballots = Ballot.find(created_by: user.name) choices = Choice.find(added_by: user.name) comments = Comment.find(added_by: user.name) ballots.each do |ballot| ballot.update(created_by: params["name"]) end choices.each do |choice| choice.update(added_by: params["name"]) end comments.each do |comment| comment.update(added_by: params["name"]) end end user.update(params) if !params["password"].nil? Ost[:password_changed].push(user.id) end session[:success] = "Your account was successfully updated!" res.redirect "/dashboard" end end on default do render("user/edit", title: "Edit profile", edit: edit, user: user) end end on default do edit = EditUser.new({}) render("user/edit", title: "Edit profile", edit: edit, user: user) end end on "logout" do logout(User) session[:success] = "You have successfully logged out!" res.redirect "/" end on "delete" do UserRemovedLog.create(user) logout(User) session[:success] = "You have successfully deleted your account" Ost[:user_deleted].push(user.id) res.redirect "/" end on "group/new" do on post, param("group") do |params| new_group = NewGroup.new(params) on new_group.valid? do params["user_id"] = user.id group = Group.create(params) user.groups.add(group) session[:success] = "You have successfully created a new group!" res.redirect "/group/#{group.id}" end on default do render("group/new", title: "Create new group", group: new_group) end end on get, root do render("group/new", title: "Create new group") end on default do not_found! end end on "group/:id/voters/add" do |id| group = user.groups[id] on group do on post, param("voter") do |params| voter = NewVoter.new(params) on voter.valid? do new_voter = User.with(:email, voter.email) on new_voter && new_voter.email == user.email do session[:error] = "You are already a voter! No need to include yourself in the group. :-)" render("group/info", title: "Group", group: group, new_voter: voter) end on new_voter && group.voters.include?(new_voter) do session[:error] = "Voter already added" render("group/info", title: "Group", group: group, new_voter: voter) end on new_voter do group.voters.add(new_voter) session[:success] = "Voter successfully added!" res.redirect "/group/#{id}" end on default do session[:error] = "The email you entered is not registered in Team Ballots" message = NewMessage.new(email: voter.email) render("group/invite", title: "Invite", group: group, message: message) end end on default do render("group/info", title: "Group", group: group, new_voter: voter) end end on get, root do render("group/info", title: "Group", group: group, new_voter: NewVoter.new({})) end end on default do not_found! end end on "group/:group_id/voters/:voter_id/remove" do |group_id, voter_id| group = user.groups[group_id] voter = User[voter_id] on group && voter do on get do group.voters.delete(voter) session[:success] = "Voter successfully removed" res.redirect "/group/#{group_id}" end end on default do not_found! end end on "group/:id/remove" do |id| group = user.groups[id] on group do on get do user.groups.delete(group) group.delete session[:success] = "Group successfully removed" res.redirect "/dashboard" end end on default do not_found! end end on "group/:id/invite" do |id| group = user.groups[id] on group do on post, param("message") do |params| message = NewMessage.new(params) on message.valid? do json = JSON.dump( from_user: user.name, email: message.email, body: message.body) Ost[:send_invitation].push(json) session[:success] = "You have successfully send an invitation!" res.redirect "/group/#{id}" end on default do render("group/invite", title: "Invite", group: group, message: message) end end end on default do not_found! end end on "group/:id" do |id| group = user.groups[id] on group do on get, root do render("group/info", title: "Group", group: group, new_voter: NewVoter.new({})) end end on default do not_found! end end on "ballot/new" do on post, param("ballot") do |params| params["start_date"] = Time.new.to_i if params["end_choices_date"] != "" params["end_choices_date"] = cal_to_unix(params["end_choices_date"]) else params["end_choices_date"] = nil end if params["end_date"] != "" params["end_date"] = cal_to_unix(params["end_date"]) else params["end_date"] = nil end new_ballot = NewBallot.new(params) on new_ballot.valid? do params["user_id"] = user.id params["created_by"] = user.name ballot = Ballot.create(params) user.ballots.add(ballot) ballot.voters.add(user) session[:success] = "You have successfully posted a new ballot!" res.redirect "/dashboard" end on default do if new_ballot.end_choices_date != nil new_ballot.end_choices_date = unix_to_cal(new_ballot.end_choices_date) else new_ballot.end_choices_date = "" end if new_ballot.end_date != nil new_ballot.end_date = unix_to_cal(new_ballot.end_date) else new_ballot.end_date = "" end render("ballot/new", title: "Create new ballot", ballot: new_ballot) end end on get, root do new_ballot = NewBallot.new({}) render("ballot/new", title: "Create new ballot", ballot: new_ballot, end_choices_date: nil, end_date: nil) end on default do not_found! end end on "ballot/:id/edit" do |id| ballot = user.ballots[id] on ballot do if ballot.status == "Active" && ballot.user_id == user.id on post do on req.post?, param("ballot") do |params| if valid_date?(params["end_choices_date"]) && valid_date?(params["end_date"]) if params["end_choices_date"] != "" params["end_choices_date"] = cal_to_unix(params["end_choices_date"]) else params["end_choices_date"] = unix_to_cal(ballot.end_choices_date) end if params["end_date"] != "" params["end_date"] = cal_to_unix(params["end_date"]) else params["end_date"] = unix_to_cal(ballot.end_date) end edit = NewBallot.new(params) edit.start_date = Time.new.to_i on edit.valid? do if ballot.title != params["title"] || ballot.description != params["description"] || ballot.end_choices_date.to_i != params["end_choices_date"] || ballot.end_date.to_i != params["end_date"] BallotEditedLog.create(user, ballot, params) end ballot.update(params) session[:success] = "Ballot successfully edited!" res.redirect "/ballot/#{id}" end on default do ballot.end_choices_date = unix_to_cal(ballot.end_choices_date) ballot.end_date = unix_to_cal(ballot.end_date) render("ballot/edit", title: "Edit ballot", ballot: ballot, edit: edit) end else session[:error] = "Invalid date format" res.redirect "/ballot/#{id}/edit" end end on default do ballot.end_choices_date = unix_to_cal(ballot.end_choices_date) ballot.end_date = unix_to_cal(ballot.end_date) render("ballot/edit", title: "Edit ballot", ballot: ballot, edit: NewBallot.new({})) end end on get, root do ballot.end_choices_date = unix_to_cal(ballot.end_choices_date) ballot.end_date = unix_to_cal(ballot.end_date) render("ballot/edit", title: "Edit ballot", ballot: ballot) end elsif ballot.status == "Active" && ballot.user_id != user.id session[:error] = "Ballot can be edited only by the creator of the ballot only (#{ballot.created_by})" res.redirect "/ballot/#{id}" else session[:error] = "Ballot cannot be edited anymore" res.redirect "/ballot/#{id}" end end on default do not_found! end end on "ballot/:id/choices/add" do |id| ballot = user.ballots[id] on ballot do if ballot.status == "Active" on post, param("choice") do |params| params["date"] = Time.new.to_i choice = NewChoice.new(params) on choice.valid? do params["user_id"] = user.id params["ballot_id"] = ballot.id params["added_by"] = user.name choice_added = Choice.create(params) ChoiceAddedLog.create(user, ballot, choice_added) session[:success] = "You have successfully added a choice!" res.redirect "/ballot/#{id}/choices" end on default do render("ballot/add_choice", title: "Add choice", ballot: ballot, choice: choice) end end on get, root do render("ballot/add_choice", title: "Add choice", ballot: ballot, choice: NewChoice.new({})) end else session[:error] = "Ballot cannot be edited anymore" res.redirect "/ballot/#{id}" end end on default do not_found! end end on "ballot/:ballot_id/choices/:choice_id/remove" do |ballot_id, choice_id| ballot = user.ballots[ballot_id] choice = ballot.choices.ids.include?(choice_id) on ballot && choice do if ballot.status == "Active" choice = ballot.choices[choice_id] on get do on choice.user_id != user.id do session[:error] = "You can only remove choices added by you" res.redirect "/ballot/#{ballot_id}/choices" end on default do ChoiceRemovedLog.create(user, ballot, choice) choice.delete session[:success] = "Choice successfully removed" res.redirect "/ballot/#{ballot_id}/choices" end end else session[:error] = "Ballot cannot be edited anymore" res.redirect "/ballot/#{ballot_id}" end end on default do not_found! end end on "ballots/closed" do closed_ballots = [] user.ballots.each do |ballot| if ballot.status == "Closed" closed_ballots << ballot end end on !closed_ballots.empty? do on get, root do render("ballot/closed_ballots", title: "Closed ballots", closed_ballots: closed_ballots) end end on default do not_found! end end on "ballot/:id/choices" do |id| ballot = user.ballots[id] on ballot do on get, root do render("ballot/choices", title: "Choices", ballot: ballot, choice: NewChoice.new({})) end end on default do not_found! end end on "ballot/:ballot_id/voters/:voter_id/remove" do |ballot_id, voter_id| ballot = user.ballots[ballot_id] voter = User[voter_id] on ballot && voter do on get do on voter != user do session[:error] = "You can't remove other users, just yourself." res.redirect "/ballot/#{ballot_id}/voters" end on voter == user && ballot.voters.size == 1 do ballot.delete session[:success] = "You have removed yourself and deleted the ballot (as you were the only one voter)." res.redirect "/dashboard" end on default do VoterRemovedLog.create(user, ballot, voter) ballot.voters.delete(voter) voter.ballots.delete(ballot) session[:success] = "You have removed yourself from the ballot." res.redirect "/dashboard" end end end on default do not_found! end end on "ballot/:id/voters/add" do |id| ballot = user.ballots[id] on ballot && ballot.user_id != user.id do session[:error] = "Voters can be added by the creator of the ballot only (#{ballot.created_by})" res.redirect "/ballot/#{id}" end on ballot do if ballot.status != "Closed" on post, param("voter") do |params| voter = NewVoter.new(params) on voter.valid? do new_voter = User.with(:email, voter.email) on new_voter && new_voter.email == user.email do session[:error] = "You are already a voter! :-)" render("ballot/add_voter", title: "Add voter", ballot: ballot, voter: voter) end on new_voter && ballot.voters.include?(new_voter) do session[:error] = "Voter already added" render("ballot/add_voter", title: "Add voter", ballot: ballot, voter: voter) end on new_voter do ballot.voters.add(new_voter) new_voter.ballots.add(ballot) VoterAddedLog.create(user, ballot, new_voter) json = JSON.dump( email: new_voter.email, name: new_voter.name, ballot_title: ballot.title, ballot_description: ballot.description, end_date: cal_utc(ballot.end_date)) Ost[:voter_added].push(json) session[:success] = "Voter successfully added!" res.redirect "/ballot/#{id}/voters" end on default do session[:error] = "The email you entered is not registered in Team Ballots" message = NewMessage.new(email: voter.email) render("ballot/invite", title: "Invite", ballot: ballot, message: message) end end on default do render("ballot/add_voter", title: "Add voter", ballot: ballot, voter: voter) end end on post, param("voters") do |params| if params["group"] != "" group = user.groups.include?(Group[params["group"]]) end on group do group = Group[params["group"]] voters = group.voters voters.each do |voter| if !ballot.voters.include?(voter) VoterAddedLog.create(user, ballot, voter) end ballot.voters.add(voter) voter.ballots.add(ballot) json = JSON.dump( email: voter.email, name: voter.name, ballot_title: ballot.title, ballot_description: ballot.description, end_date: cal_utc(ballot.end_date)) Ost[:voter_added].push(json) end session[:success] = "Voters group successfully added!" res.redirect "/ballot/#{id}/voters" end on default do session[:error] = "The voters group selected was not valid" res.redirect "/ballot/#{id}/voters/add" end end on get, root do render("ballot/add_voter", title: "Add voter", ballot: ballot, voter: NewVoter.new({})) end else session[:error] = "Ballot cannot be edited anymore" res.redirect "/ballot/#{id}" end end on default do not_found! end end on "ballot/:id/voters" do |id| ballot = user.ballots[id] on ballot do on get, root do render("ballot/voters", title: "Voters", ballot: ballot, voter: NewVoter.new({})) end end on default do not_found! end end on "ballot/:id/add_comment" do |id| ballot = user.ballots[id] on ballot do if ballot.status != "Closed" on post, param("comment") do |params| params["date"] = Time.new.to_i comment = NewComment.new(params) on comment.valid? do params["user_id"] = user.id params["ballot_id"] = ballot.id params["added_by"] = user.name Comment.create(params) session[:success] = "You have successfully added a comment!" res.redirect "/ballot/#{id}" end on default do render("ballot/info", title: "Add comment", ballot: ballot, comment: comment) end end else session[:error] = "Comments cannot be added anymore. Ballot is closed." res.redirect "/ballot/#{id}" end end on default do not_found! end end on "ballot/:id/vote" do |id| ballot = user.ballots[id] on ballot do choices_voted = [] ballot.choices.each do |choice| choice_voted = choice.votes.find(user_id: user.id) if !choice_voted.empty? choices_voted << choice.id end end if ballot.status != "Closed" on post, param("vote") do |votes| valid_votes = [] votes.each do |rating| params = {} params["rating"] = rating[1].to_i # if it's converted into integer, when choosing "--" it validates because it takes it as "0" vote = NewVote.new(params) if vote.valid? if choices_voted.include?(rating[0]) choice = Choice[rating[0]] vote_to_update = Vote[choice.votes.find(user_id: user.id).ids[0]] updated = vote_to_update.update(params) valid_votes << updated else params["date"] = Time.new.to_i params["choice_id"] = rating[0] params["user_id"] = user.id new_vote = Vote.create(params) valid_votes << new_vote end else session[:error] = "The vote wasn't valid. Please try again." res.redirect "/ballot/#{id}" end end on valid_votes.size == votes.size do session[:success] = "You have successfully voted!" res.redirect "/ballot/#{id}" end on default do session[:error] = "Vote wasn't valid. Please try again." res.redirect "/ballot/#{id}" end end on get, root do render("ballot/update_vote", title: "Vote", ballot: ballot, voter: NewVote.new({})) end else session[:error] = "Ballot is closed." res.redirect "/ballot/#{id}" end end on default do not_found! end end on "ballot/:id/invite" do |id| ballot = user.ballots[id] on ballot do if ballot.status != "Closed" on post, param("message") do |params| message = NewMessage.new(params) on message.valid? do json = JSON.dump( from_user: user.name, email: message.email, body: message.body) Ost[:send_invitation].push(json) session[:success] = "You have successfully send an invitation!" res.redirect "/ballot/#{id}/voters/add" end on default do render("ballot/invite", title: "Invite", ballot: ballot, message: message) end end else session[:error] = "Ballot is closed." res.redirect "/ballot/#{id}" end end on default do not_found! end end on "ballot/:id" do |id| ballot = user.ballots[id] on ballot do on get, root do render("ballot/info", title: ballot.title, ballot: ballot) end end on default do not_found! end end on "/" do res.write "hola" end on default do not_found! end end end
class Bmake < Formula desc "Portable version of NetBSD make(1)" homepage "http://www.crufty.net/help/sjg/bmake.html" url "http://www.crufty.net/ftp/pub/sjg/bmake-20160818.tar.gz" sha256 "d64b23e3e4013b6d4ea590b05251874ffa9d841299b4e5344a6edf45ea7e1141" bottle do sha256 "25e8cf1c38ece0c9dc4f55cb65dc61812ef74ab18af60f92f5aae0fa5a0e3517" => :el_capitan sha256 "d902fd473759c625fff2a6303a8b2a881f6e7eee050957bed8e5715531b00569" => :yosemite sha256 "cc1978660d087797042a19efe067a902fad1c4081851d57f331790278868fcd9" => :mavericks sha256 "3ca7512237d38d75a745b23e90e8fa6c1b4e572ebea7f4d0454e4cf8f7b017bf" => :mountain_lion end def install # The first, an oversight upstream; the second, don't pre-roff cat pages. inreplace "bmake.1", ".Dt MAKE", ".Dt BMAKE" inreplace "mk/man.mk", "MANTARGET?", "MANTARGET" # -DWITHOUT_PROG_LINK means "don't symlink as bmake-VERSION." args = ["--prefix=#{prefix}", "-DWITHOUT_PROG_LINK", "--install"] system "sh", "boot-strap", *args man1.install "bmake.1" end test do (testpath/"Makefile").write <<-EOS.undent all: hello hello: \t@echo 'Test successful.' clean: \trm -rf Makefile EOS system bin/"bmake" system bin/"bmake", "clean" end end bmake: update 20160818 bottle. class Bmake < Formula desc "Portable version of NetBSD make(1)" homepage "http://www.crufty.net/help/sjg/bmake.html" url "http://www.crufty.net/ftp/pub/sjg/bmake-20160818.tar.gz" sha256 "d64b23e3e4013b6d4ea590b05251874ffa9d841299b4e5344a6edf45ea7e1141" bottle do sha256 "38e0b7712c5ae20b9a2639f21aa46c96e7893e3a44ce8956d1c64f5efb16ed66" => :sierra sha256 "6964daaba5e8b288e9b39ee9439821bac54f3babbc619fe9db5c6ae7d81284e8" => :el_capitan sha256 "74d7a6b8f7fb23383762be1440171f50336283eebe1f48d7163ae5b81ae4489f" => :yosemite end def install # The first, an oversight upstream; the second, don't pre-roff cat pages. inreplace "bmake.1", ".Dt MAKE", ".Dt BMAKE" inreplace "mk/man.mk", "MANTARGET?", "MANTARGET" # -DWITHOUT_PROG_LINK means "don't symlink as bmake-VERSION." args = ["--prefix=#{prefix}", "-DWITHOUT_PROG_LINK", "--install"] system "sh", "boot-strap", *args man1.install "bmake.1" end test do (testpath/"Makefile").write <<-EOS.undent all: hello hello: \t@echo 'Test successful.' clean: \trm -rf Makefile EOS system bin/"bmake" system bin/"bmake", "clean" end end
Begin testing of machine class. require 'spec_helper' require 'mutator/machine' class Stateholder attr_writer :state def state @state ||= :initial_state end end module Mutator class Stateholder < Machine def self.transitions [ { from: [:initial_state], to: :second_state }, { from: [:second_state], to: :third_state } ] end end end describe Mutator::Stateholder do subject { Mutator::Stateholder.new(stateholder) } let(:stateholder) { Stateholder.new } it 'should initialize without error' do expect { subject }.to_not raise_error end describe '#stateholder' do it 'should return the stateholder it was passed' do expect(subject.stateholder).to eq stateholder end end describe '#states' do it 'should respond to states' do expect(subject).to respond_to :states end it 'should extract states from transitions' do expect(subject.states.sort).to eq [ :initial_state, :second_state, :third_state ].sort end end describe '#transitions' do it 'should respond to' do expect(subject).to respond_to :transitions end end describe '#current_state' do it 'should return the stateholder state' do expect(subject.current_state).to eq stateholder.state end end describe '#valid?' do it 'should be valid if the state exists in states list' do subject.stateholder.state = :initial_state expect(subject).to be_valid end it 'should not be valid for a state not in states list' do subject.stateholder.state = :foobar expect(subject).to_not be_valid end end end
class Bmake < Formula desc "Portable version of NetBSD make(1)" homepage "http://www.crufty.net/help/sjg/bmake.html" url "http://www.crufty.net/ftp/pub/sjg/bmake-20171028.tar.gz" sha256 "543983e6137614ed7b92376b1f27066ba40a0808a714954ff3439dfa14a5675a" bottle do sha256 "8ebb9de2730548b157c50f3c8e3b6967e69670488a50b6859b84a8b9572e38c2" => :high_sierra sha256 "a35614fd313244edb770ee88213548e0554a10f06c33ce0ee5b45df149e81488" => :sierra sha256 "16068a18813d7c2598350ae5360914539a29d4fcd9963d9186c766cc7b3843d3" => :el_capitan end def install # Don't pre-roff cat pages. inreplace "mk/man.mk", "MANTARGET?", "MANTARGET" # -DWITHOUT_PROG_LINK means "don't symlink as bmake-VERSION." args = ["--prefix=#{prefix}", "-DWITHOUT_PROG_LINK", "--install"] system "sh", "boot-strap", *args chmod "u+w", man1/"bmake.1" man1.install "bmake.1" end test do (testpath/"Makefile").write <<~EOS all: hello hello: \t@echo 'Test successful.' clean: \trm -rf Makefile EOS system bin/"bmake" system bin/"bmake", "clean" end end bmake: update 20171028 bottle for Linuxbrew. class Bmake < Formula desc "Portable version of NetBSD make(1)" homepage "http://www.crufty.net/help/sjg/bmake.html" url "http://www.crufty.net/ftp/pub/sjg/bmake-20171028.tar.gz" sha256 "543983e6137614ed7b92376b1f27066ba40a0808a714954ff3439dfa14a5675a" bottle do sha256 "8ebb9de2730548b157c50f3c8e3b6967e69670488a50b6859b84a8b9572e38c2" => :high_sierra sha256 "a35614fd313244edb770ee88213548e0554a10f06c33ce0ee5b45df149e81488" => :sierra sha256 "16068a18813d7c2598350ae5360914539a29d4fcd9963d9186c766cc7b3843d3" => :el_capitan sha256 "c96a11840e432e870f4e8dc347a4055c27ae3b16a5cd6ccaea4acd9a0a18688d" => :x86_64_linux end def install # Don't pre-roff cat pages. inreplace "mk/man.mk", "MANTARGET?", "MANTARGET" # -DWITHOUT_PROG_LINK means "don't symlink as bmake-VERSION." args = ["--prefix=#{prefix}", "-DWITHOUT_PROG_LINK", "--install"] system "sh", "boot-strap", *args chmod "u+w", man1/"bmake.1" man1.install "bmake.1" end test do (testpath/"Makefile").write <<~EOS all: hello hello: \t@echo 'Test successful.' clean: \trm -rf Makefile EOS system bin/"bmake" system bin/"bmake", "clean" end end
# encoding: utf-8 # require 'spec_helper' describe 'country descriptions' do def self.it_splits number, expected it { Phony.split(number).should == expected } end describe 'regression' do it_splits '33630588659', ["33", "6", "30", "58", "86", "59"] end describe 'splitting' do describe 'Ascension Island' do it_splits '2473551', ['247', false, '3551'] end describe 'Afghanistan' do it_splits '93201234567', ['93', '20', '1234567'] # Kabul end describe 'Albania' do it_splits '355691234567', ['355', '69', '123', '4567'] # Mobile 7 digits it_splits '35569123456', ['355', '69', '123', '456'] # Mobile 6 digits it_splits '35541234567', ['355', '4', '123', '4567'] # Tirana end describe 'Algeria' do it_splits '213211231234', ['213', '21', '123', '1234'] # Algiers it_splits '213331231234', ['213', '33', '123', '1234'] # Batna end describe 'Argentina' do it_splits '541112345678', ['54', '11', '1234', '5678'] it_splits '542911234567', ['54', '291', '123', '4567'] it_splits '542965123456', ['54', '2965', '12', '3456'] it_splits '5491112345678', ['54', '911', '1234', '5678'] it_splits '5492201234567', ['54', '9220', '123', '4567'] it_splits '5492221123456', ['54', '92221', '12', '3456'] it_splits '548001234567', ['54', '800', '123', '4567'] end describe 'Austria' do it_splits '43198110', %w( 43 1 98110 ) # Vienna it_splits '4310000000', %w( 43 1 0000000 ) # Vienna it_splits '43800123456789', %w( 43 800 123456789 ) # Free it_splits '436780000000', %w( 43 678 0000 000 ) # Mobile it_splits '4368100000000', %w( 43 681 0000 0000 ) # Mobile it_splits '436880000000', %w( 43 688 0000 000 ) # Mobile it_splits '4366900000000', %w( 43 669 0000 0000 ) # Mobile it_splits '4367000000000', %w( 43 670 0000 0000 ) # Mobile it_splits '4369000000000', %w( 43 690 0000 0000 ) # Mobile it_splits '433161234567891', %w( 43 316 1234567891 ) # Graz it_splits '432164123456789', %w( 43 2164 123456789 ) # Rohrau it_splits '43720116987', %w( 43 720 116987 ) # VoIP # mobile numbers can have from 7 to 10 digits in the subscriber number it_splits '436641234567', %w( 43 664 1234 567 ) it_splits '4366412345678', %w( 43 664 1234 5678 ) it_splits '43664123456789', %w( 43 664 1234 56789 ) it_splits '436641234567890', %w( 43 664 1234 567890 ) end describe 'Australia' do it_splits '61512341234', ['61', '5', '1234', '1234'] # Landline it_splits '61423123123', ['61', '423', '123', '123'] # Mobile it_splits '61131212', ['61', '13', '12', '12'] # 13 local rate it_splits '611300123123', ['61', '1300', '123', '123'] # 1300 local rate it_splits '611800123123', ['61', '1800', '123', '123'] # 1800 free call end describe 'Bahrain' do it_splits '97312345678', ['973', false, '1234', '5678'] end describe 'Bangladesh' do it_splits '88021234567', %w(880 2 1234567) it_splits '8805112345', %w(880 51 12345) it_splits '88031123456', %w(880 31 123456) it_splits '88032112345', %w(880 321 12345) it_splits '8804311234567', %w(880 431 1234567) it_splits '880902012345', %w(880 9020 12345) end describe 'Belarus' do it_splits '375152123456', %w(375 152 123456) it_splits '375151512345', %w(375 1515 12345) it_splits '375163423456', %w(375 163 423456) it_splits '375163112345', %w(375 1631 12345) it_splits '375291234567', %w(375 29 1234567) it_splits '375800123', %w(375 800 123) it_splits '3758001234', %w(375 800 1234) it_splits '3758001234567', %w(375 800 1234567) it_splits '37582012345678', %w(375 820 12345678) end describe 'Belgium' do it_splits '3235551212', ['32', '3', '555', '12', '12'] # Antwerpen it_splits '3250551212', ['32', '50', '55', '12', '12'] # Brugge it_splits '3225551212', ['32', '2', '555', '12', '12'] # Brussels it_splits '3295551914', ['32', '9', '555', '19', '14'] # Gent it_splits '3245551414', ['32', '4', '555', '14', '14'] # Liège it_splits '3216473200', ['32', '16', '47', '32', '00'] # Leuven it_splits '32475279584', ['32', '475', '27', '95', '84'] # mobile it_splits '32468279584', ['32', '468', '27', '95', '84'] # mobile (Telenet) it_splits '3270123123', ['32', '70', '123', '123'] # Bus Service? it_splits '3278123123', ['32', '78', '123', '123'] # National rate service it_splits '3290123123', ['32', '901', '23', '123'] # National rate service it_splits '3280080404', ['32', '800', '80', '404'] # Apple support end describe 'Belize' do it_splits '5012051234', %w(501 205 1234) end describe 'Benin' do it_splits '22912345678', ['229', false, '1234', '5678'] end describe 'Bolivia' do it_splits '59122772266', %w(591 2 277 2266) end describe 'Botswana' do it_splits '26780123456', %w(267 80 123 456) it_splits '2672956789', %w(267 29 567 89) it_splits '2674634567', %w(267 463 4567) it_splits '2675812345', %w(267 58 123 45) it_splits '26776712345', %w(267 7 6712 345) it_splits '26781234567', %w(267 8 1234 567) end describe 'Bosnia and Herzegovina' do it_splits '38766666666', %w(387 66 666 666) it_splits '38733123456', %w(387 33 123 456) end describe 'Brazil' do it_splits '551112341234', ['55', '11', '1234', '1234'] it_splits '5511981231234', ['55', '11', '98123', '1234'] # São Paulo's 9 digits mobile it_splits '552181231234', ['55', '21', '8123', '1234'] it_splits '5521981231234', ['55', '21', '98123', '1234'] # Rio de Janeiro's 9 digits mobile it_splits '551931311234', ['55', '19', '3131', '1234'] it_splits '5531991311234', ['55', '31', '99131', '1234'] # Belo Horizonte's 9th digit it_splits '5571991311234', ['55', '71', '99131', '1234'] # Salvador's 9th digit it_splits '5579991311234', ['55', '79', '99131', '1234'] # Sergipe's 9th digit it_splits '5547991311234', ['55', '47', '99131', '1234'] # Santa Catarina's 9th digit it_splits '5541991311234', ['55', '41', '99131', '1234'] # Parana's 9th digit context 'mobile numbers' do %w{ 11 12 13 14 15 16 17 18 19 21 22 24 27 28 31 32 33 34 35 37 38 61 62 63 64 65 66 67 68 69 71 73 74 75 77 79 81 82 83 84 85 86 87 88 89 91 92 93 94 95 96 97 98 99 41 42 43 44 45 46 47 48 49 51 53 54 55 }.each do |state_code| it_splits "55#{state_code}993051123", ['55', state_code, '99305', '1123'] end end context "special numbers" do it_splits '5508002221234', ['55', '0800', '222', '1234'] it_splits '5530032221', ['55', '3003', '2221'] it_splits '5540209999', ['55', '4020', '9999'] it_splits '5540038999', ['55', '4003', '8999'] it_splits '5540048999', ['55', '4004', '8999'] end context "service numbers" do it_splits '55100', ['55', '100', ""] it_splits '55199', ['55', '199', ""] end end describe "Bulgaria" do it_splits '35929284000', ['359', '2', '928', '4000'] # Sofia it_splits '359878357523', ['359', '87', '8357', '523'] it_splits '3593012345', ['359', '30', '12345'] it_splits '35930123456', ['359', '30', '12', '3456'] it_splits '35943312345', ['359', '433', '12345'] it_splits '3596012345', ['359', '60', '12345'] it_splits '35969123456', ['359', '69', '123456'] it_splits '35970512345', ['359', '705', '12345'] it_splits '3597051234', ['359', '705', '1234'] it_splits '3597112345', ['359', '71', '12345'] it_splits '35979123456', ['359', '79', '123456'] it_splits '35980112345', ['359', '801', '12345'] it_splits '3598112345', ['359', '81', '12345'] it_splits '35986123456', ['359', '86', '123456'] it_splits '359881234567', ['359', '88', '1234', '567'] it_splits '35990123456', ['359', '90', '123456'] it_splits '359988123456', ['359', '988', '123456'] it_splits '359998123456', ['359', '998', '123456'] end describe 'Cambodia' do it_splits '85512236142', ["855", "12", "236", "142"] # mobile (Mobitel) it_splits '855977100872', ["855", "97", "710", "0872"] # mobile (Metfone) it_splits '855234601183', ["855", "23", "460", "1183"] # Long fixed line (Phnom Penh) it_splits '85533234567', ["855", "33", "234", "567"] # Regular fixed line (Kampot) end describe 'Chile' do it_splits '5621234567', ['56', '2', '1234567'] # Santiago it_splits '5675123456', ['56', '75', '123456'] # Curico it_splits '56912345678', ['56', '9', '12345678'] # Mobile it_splits '56137123456', ['56', '137', '123', '456'] # Service end describe 'China' do it_splits '862112345678', ['86', '21', '1234', '5678'] # Shanghai it_splits '8675582193447', ['86', '755', '8219', '3447'] # Shenzhen end describe 'Colombia' do it_splits '5711234567', ['57', '1', '123', '4567'] it_splits '573101234567', ['57', '310', '123', '4567'] # mobile end describe 'Croatia' do it_splits '38521695900', %w( 385 21 695 900 ) # Landline it_splits '38514566666', %w( 385 1 4566 666 ) # Landline (Zagreb) it_splits '38599444999', %w( 385 99 444 999 ) # Mobile it_splits '385918967509', %w( 385 91 896 7509 ) # Mobile it_splits '3858001234', %w( 385 800 1234 ) # Toll free it_splits '385800123456', %w( 385 800 123 456 ) # Toll free it_splits '3856012345', %w( 385 60 12 345 ) # Premium rate it_splits '38562123456', %w( 385 62 123 456 ) # Premium, personal and UAN end describe 'Cuba' do it_splits '5351231234', ['53', '5123', '1234'] # Mobile it_splits '5371234567', ['53', '7', '1234567'] # Havana it_splits '5342123456', ['53', '42', '123456'] # Villa Clara end describe 'Cyprus' do it_splits '35712322123456', ['357', '123', '22', '123456'] # Voicemail it_splits '35722123456', ['357', '22', '123456'] # Fixed it_splits '35791123456', ['357', '91', '123456'] # Mobile end describe 'Denmark' do it_splits '4532121212', ['45', false, '32', '12', '12', '12'] end describe 'Egypt' do it_splits '20212345678', ['20', '2', '12345678'] it_splits '20921234567', ['20', '92', '1234567'] it_splits '20951234567', ['20', '95', '1234567'] end describe 'Equatorial Guinea' do it_splits '240222201123', ['240', false, '222', '201', '123'] it_splits '240335201123', ['240', false, '335', '201', '123'] end describe 'Estonia' do it_splits '3723212345', ['372', '321', '2345'] # Landline it_splits '37251231234', ['372', '5123', '1234'] # Mobile it_splits '3728001234', ['372', '800', '1234'] # Freephone it_splits '37281231234', ['372', '8123', '1234'] # Mobile it_splits '37282231234', ['372', '8223', '1234'] # Mobile it_splits '37252212345', ['372', '5221', '2345'] # Mobile it_splits '3725221234', ['372', '5221', '234'] # Mobile it_splits '37270121234', ['372', '7012', '1234'] # Premium end describe 'Finland' do it_splits '3589123123', ['358', '9', '123', '123'] # Helsinki it_splits '3581912312', ['358', '19', '123', '12'] # Nylandia it_splits '3585012312', ['358', '50', '123', '12'] # Mobile it_splits '35860012345', ['358', '6001', '23', '45'] # Service end describe 'France' do it_splits '33112345678', ['33', '1', '12','34','56','78'] # Paris it_splits '33812345678', ['33', '8', '12','34','56','78'] # Service number end describe 'Georgia' do it_splits '99522012345', %w(995 220 123 45) it_splits '995321234567', %w(995 32 123 4567) it_splits '995342123456', %w(995 342 123 456) it_splits '995596123456', %w(995 596 123 456) end describe 'Germany' do it_splits '493038625454', ['49', '30', '386', '25454'] # Berlin it_splits '4932221764542', ['49', '32', '221', '764542'] # Non-Geographical it_splits '4922137683323', ['49', '221', '376', '83323'] # Cologne it_splits '497614767676', ['49', '761', '476', '7676'] # Freiburg im Breisgau it_splits '4921535100', ['49', '2153', '510', '0'] # Nettetal-Lobberich it_splits '493434144602', ['49', '34341', '446', '02'] # Geithain it_splits '491805878323', ['49', '180', '587', '8323'] # Service number it_splits '491815878323', ['49', '181', '587', '8323'] # Service number it_splits '498001234567', ['49', '800', '123', '4567'] # Service number it_splits '49800222340010', ['49', '800', '222', '340010'] # Service number it_splits '4915111231234', ['49', '151', '1123', '1234'] # Mobile number it_splits '4915771231234', ['49', '157', '7123', '1234'] # Mobile number it_splits '491601234567', ['49', '160', '1234', '567'] # Mobile number it_splits '4916312345678', ['49', '163', '1234', '5678'] # Mobile number it_splits '4915211231234', ['49', '1521', '123', '1234'] # Mobile number end describe 'Ghana' do it_splits '233302123456', ['233', '30', '212', '3456'] # Mobile Vodafone, Accra end describe 'Gibraltar' do it_splits '35020012345', ['350', '200', '12345'] # Fixed it_splits '35021112345', ['350', '211', '12345'] # Fixed it_splits '35022212345', ['350', '222', '12345'] # Fixed it_splits '35054123456', ['350', '54', '123456'] # Mobile it_splits '35056123456', ['350', '56', '123456'] # Mobile it_splits '35057123456', ['350', '57', '123456'] # Mobile it_splits '35058123456', ['350', '58', '123456'] # Mobile it_splits '35060123456', ['350', '60', '123456'] # Mobile it_splits '3508012', ['350', '8012', '' ] # Freephone end describe 'Greece' do it_splits '302142345678', %w(30 21 4234 5678) it_splits '302442345678', %w(30 24 4234 5678) it_splits '305034571234', %w(30 50 3457 1234) it_splits '306901234567', %w(30 690 123 4567) it_splits '307001234567', %w(30 70 0123 4567) it_splits '308001001234', %w(30 800 100 1234) it_splits '308011001234', %w(30 801 100 1234) it_splits '308071001234', %w(30 807 100 1234) it_splits '308961001234', %w(30 896 100 1234) it_splits '309011234565', %w(30 901 123 4565) it_splits '309091234565', %w(30 909 123 4565) end describe 'Haiti' do it_splits '50922121234', ['509', '22', '12', '1234'] end describe 'Hong Kong' do it_splits '85212341234', ['852', false, '1234', '1234'] #Other Numbers it_splits '852800121234', ['852', '800', '12', '1234'] #Toll Free end describe 'Hungary' do it_splits'3612345678', ['36', '1', '234', '5678'] it_splits'3622123456', ['36', '22', '123', '456'] end describe 'Iceland' do it_splits '354112', ['354', false, '112'] # Emergency TODO it_splits '3544211234', ['354', false, '421', '1234'] # Keflavík it_splits '3544621234', ['354', false, '462', '1234'] # Akureyri it_splits '3545511234', ['354', false, '551', '1234'] # Reykjavík end describe 'Indonesia' do it_splits '6242323032', ["62", "4", "2323", "032"] it_splits '6285220119289', ['62', '852', '2011', '9289'] it_splits '62217815263', %w(62 21 781 5263) it_splits '6213123', %w(62 13 123) it_splits '6213123456', %w(62 13 123 456) it_splits '6217412', %w(62 174 12) it_splits '6217412345', %w(62 174 12 345) it_splits '6217712', %w(62 177 12) it_splits '6217712123456', %w(62 177 1212 3456) it_splits '62178123', %w(62 178 123) it_splits '6217812345', %w(62 178 123 45) it_splits '622112345', %w(62 21 123 45) it_splits '622112345567', %w(62 21 1234 5567) it_splits '622212345', %w(62 22 123 45) it_splits '62221234567', %w(62 22 123 4567) it_splits '622200000000', %w(62 22 0000 0000) it_splits '6222000000000', %w(62 22 000 000 000) it_splits '624311234', %w(62 4 311 234) it_splits '62431123456', %w(62 4 3112 3456) it_splits '6262212345', %w(62 6 221 2345) it_splits '62622123456', %w(62 6 2212 3456) it_splits '6270123456', %w(62 70 123 456) it_splits '6271123456', %w(62 71 123 456) it_splits '62711234567', %w(62 71 123 4567) it_splits '62810123456', %w(62 810 123 456) it_splits '6281012345678', %w(62 810 1234 5678) it_splits '628151234567', %w(62 815 123 4567) it_splits '62820123456', %w(62 820 123 456) it_splits '628231234567', %w(62 823 123 4567) it_splits '6282312345678', %w(62 823 1234 5678) it_splits '6287012345', %w(62 870 123 45) it_splits '62877123456', %w(62 877 123 456) it_splits '62881123456', %w(62 881 123 456) it_splits '6288112345656', %w(62 881 1234 5656) it_splits '62881123456567', %w(62 881 1234 56567) it_splits '628990344805', %w(62 899 034 4805) it_splits '6291234567', %w(62 9 1234 567) it_splits '629123456789', %w(62 9 123 456 789) end describe 'India' do it_splits '919911182111', ['91', '99', '111', '82', '111'] # mobile it_splits '912212345678', ['91', '22', '123', '45', '678'] # New Delhi it_splits '911411234567', ['91', '141', '123', '45', '67'] # Jaipur it_splits '913525123456', ['91', '3525', '123', '456'] # DALKHOLA it_splits '914433993939', ['91', '44', '339', '93', '939'] # end describe 'Iran' do it_splits '982112341234', ['98', '21', '1234', '1234'] # Teheran it_splits '989191231234', ['98', '919', '123', '1234'] # Example Cell Phone end describe 'Ireland' do it_splits '35311234567', ['353', '1', '123', '4567'] # Dublin, 7 digit subscriber # it_splits '353539233333', ['353', '53', '923', '3333'] # Wexford, 7 digit subscriber it_splits '3532212345', ['353', '22', '12345'] # Mallow, 5 digit subscriber # it_splits '353441234567', ['353', '44', '123', '4567'] # Mullingar, Castlepollard, Tyrellspass 7 digit subscriber # it_splits '35345123456', ['353', '45', '123456'] # Naas, 6 digit subscriber # it_splits '353801234567', ['353', '80', '123', '4567'] # Mobile it_splits '353761234567', ['353', '76', '123', '4567'] # VoIP it_splits '353800123456', ['353', '800', '123456'] # Freefone it_splits '353000123456', ['353', '000', '123456'] # Default fixed 3 split for unrecognized end describe 'Israel (972)' do it_splits '972100', ['972', '1', '00'] # Police it_splits '97221231234', ['972', '2', '123', '1234'] # Jerusalem Area it_splits '97282411234', ['972', '8', '241', '1234'] # Gaza Strip (Palestine) it_splits '97291231234', ['972', '9', '123', '1234'] # Sharon Area it_splits '972501231234', ['972', '50', '123', '1234'] # Mobile (Pelephone) it_splits '972591231234', ['972', '59', '123', '1234'] # Mobile Jawwal (Palestine) it_splits '972771231234', ['972', '77', '123', '1234'] # Cable Phone Services it_splits '9721700123123', ['972', '1', '700', '123', '123'] # Cable Phone Services end describe 'Israel (970)' do it_splits '97021231234', ['970', '2', '123', '1234'] # Jerusalem Area it_splits '97082411234', ['970', '8', '241', '1234'] # Gaza Strip (Palestine) it_splits '97091231234', ['970', '9', '123', '1234'] # Sharon Area it_splits '970501231234', ['970', '50', '123', '1234'] # Mobile (Pelephone) it_splits '970591231234', ['970', '59', '123', '1234'] # Mobile Jawwal (Palestine) it_splits '970771231234', ['970', '77', '123', '1234'] # Cable Phone Services it_splits '9701700123123', ['970', '1', '700', '123', '123'] # Cable Phone Services end describe 'Italy' do it_splits '39348695281', ['39', '348', '695', '281'] # Mobile (6-digit subscriber no. - rare, but still used) it_splits '393486952812', ['39', '348', '695', '2812'] # Mobile (7-digit subscriber no. - common) it_splits '3934869528123',['39', '348', '695', '2812', '3'] # Mobile (8-digit subscriber no - new) it_splits '393357210488', ['39', '335', '721', '0488'] # Mobile it_splits '393248644272', ['39', '324', '864', '4272'] # Mobile it_splits '3906123412', ['39', '06', '1234', '12'] # Roma 6 digit it_splits '39061234123', ['39', '06', '1234', '123'] # Roma 7 digit it_splits '390612341234', ['39', '06', '1234', '1234'] # Roma 8 digit it_splits '3902888388', ['39', '02', '8883', '88'] # Milano 6 digit it_splits '39028883888', ['39', '02', '8883', '888'] # Milano 7 digit it_splits '390288838883', ['39', '02', '8883', '8883'] # Milano 8 digit it_splits '390141595661', ['39', '0141', '595', '661'] # Asti it_splits '3903123391', ['39', '031', '23391'] # Como it_splits '390909709511', ['39', '090', '9709511'] # Barcellona it_splits '390471811353', ['39', '0471', '811', '353'] # Bolzano end describe 'Japan' do it_splits '81312345678', %w(81 3 1234 5678) # Tokyo it_splits '81612345678', %w(81 6 1234 5678) # Osaka it_splits '818001001234', %w(81 800 100 1234) # Freephone it_splits '81120123456', %w(81 120 123 456) # Freephone it_splits '81111234567', %w(81 11 123 4567) it_splits '81123123456', %w(81 123 12 3456) it_splits '81126712345', %w(81 1267 1 2345) it_splits '812012345678', %w(81 20 1234 5678) # Pager(Calling Party Pay) it_splits '815012345678', %w(81 50 1234 5678) # IP Telephone it_splits '816012345678', %w(81 60 1234 5678) # UPT it_splits '817012345678', %w(81 70 1234 5678) # PHS it_splits '818012345678', %w(81 80 1234 5678) # Cellular it_splits '819012345678', %w(81 90 1234 5678) # Cellular end describe 'Kenya' do it_splits '254201234567', ['254', '20', '1234567'] # Nairobi it_splits '254111234567', ['254', '11', '1234567'] # Mombasa it_splits '254723100220', ['254', '723', '100220'] # Mombasa end describe 'Kosovo' do it_splits '38329000000', ['383', '29', '000', '000'] # Landline it_splits '38344000000', ['383', '44', '000', '000'] # Mobile end describe 'Kyrgyzstan' do it_splits '996312212345', %w(996 312 212 345) it_splits '996315212345', %w(996 315 212 345) it_splits '996313121234', %w(996 3131 212 34) it_splits '996394621234', %w(996 3946 212 34) it_splits '996501234567', %w(996 50 123 4567) it_splits '996521234567', %w(996 52 123 4567) it_splits '996581234567', %w(996 58 123 4567) it_splits '996800123456', %w(996 800 123 456) end describe 'Lithuania' do it_splits '37070012123', ['370', '700', '12', '123'] # Service it_splits '37061212123', ['370', '612', '12', '123'] # Mobile it_splits '37051231212', ['370', '5', '123', '12', '12'] # Vilnius it_splits '37037121212', ['370', '37', '12', '12', '12'] # Kaunas it_splits '37044011212', ['370', '440', '1', '12', '12'] # Skuodas end describe 'Luxembourg' do it_splits '352222809', ['352', '22', '28', '09'] it_splits '35226222809', ['352', '2622', '28', '09'] it_splits '352621123456', ['352', '621', '123', '456'] it_splits '3524123456', ['352', '41', '23', '45', '6'] it_splits '352602112345678', ['352', '6021', '12', '34', '56', '78'] it_splits '352370431', ['352', '37', '04', '31'] it_splits '35227855', ['352', '27', '85', '5'] it_splits '352445566', ['352', '44', '55', '66'] it_splits '352545258', ['352', '54', '52', '58'] it_splits '352818181', ['352', '81', '81', '81'] it_splits '3523572141', ['352', '35', '72', '14', '1'] end describe 'Macedonia' do it_splits '38921234567', ['389', '2', '123', '4567'] # Skopje it_splits '38931234567', ['389', '3', '123', '4567'] # Eastern Macedonia it_splits '38941234567', ['389', '4', '123', '4567'] # Western Macedonia it_splits '38951234567', ['389', '5', '123', '4567'] # Premium it_splits '38971234567', ['389', '7', '123', '4567'] # Mobile end describe 'Macao' do it_splits '85328123456', ["853", "28", "12", "3456"] # Landline it_splits '85381234567', ["853", "8", "123", "4567"] # Landline it_splits '85361234567', ["853", "6", "123", "4567"] # Mobile end describe 'Malaysia' do it_splits '6082123456', ['60', '82', '123456'] # Kuching it_splits '60312345678', ['60', '3', '12345678'] # Kuala Lumpur it_splits '60212345678', ['60', '2', '12345678'] # Singapore it_splits '60111231234', ['60', '11', '123', '1234'] # Mobile it_splits '601112312345', ['60', '11', '123', '12345'] # Mobile it_splits '60800121234', ['60', '800', '12', '1234'] # Freephone # it_splits '60112', ['60', '112'] # Service end describe 'Malta' do it_splits '35621231234', ['356', '2123', '1234'] # Fixed it_splits '35677123456', ['356', '77', '123456'] # Mobile it_splits '35698123456', ['356', '98', '123456'] # Mobile it_splits '35651231234', ['356', '5123', '1234'] # Voice Mail end describe 'Mexico' do it_splits '525512121212', ['52', '55', '1212', '1212'] # Mexico City it_splits '5215512121212', ['52', '1', '55', '1212', '1212'] # Mexico City cell phone from abroad it_splits '526641231212', ['52', '664', '123', '1212'] # Tijuana it_splits '5216641231212', ['52', '1', '664', '123', '1212'] # Tijuana cell phone from abroad it_splits '520446641231212', ['52', '044', '664', '123', '1212'] # Tijuana cell phone local from landline end describe 'Monaco' do it_splits '37741123456', ['377', '41', '12', '34', '56'] # Mobile it_splits '377612345678', ['377', '6', '12', '34', '56', '78'] # Mobile end describe 'Montenegro' do it_splits '38280123456', %w(382 80 123 456) it_splits '3822012345', %w(382 20 123 45) it_splits '38220123456', %w(382 20 123 456) it_splits '38232123456', %w(382 32 123 456) it_splits '38278103456', %w(382 78 103 456) it_splits '38263123', %w(382 63 123) it_splits '382631234567890', %w(382 63 123 456 7890) it_splits '38277103456', %w(382 77 103 456) it_splits '38294103456', %w(382 94 103 456) it_splits '38288103456', %w(382 88 103 456) it_splits '3826812', %w(382 68 12) it_splits '382681212345678', %w(382 68 12 1234 5678) it_splits '38270123', %w(382 70 123) it_splits '382701234567890', %w(382 70 123 456 7890) end describe 'Morocco' do it_splits '212537718685', ['212', '53', '7718', '685'] it_splits '212612345678', ['212', '6', '12', '34', '56', '78'] end describe 'The Netherlands' do it_splits '31612345678', ['31', '6', '12', '34', '56', '78'] # mobile it_splits '31201234567', ['31', '20', '123', '4567'] it_splits '31222123456', ['31', '222', '123', '456'] it_splits '3197012345678', ['31', '970', '1234', '5678'] # machine-to-machine end describe 'Norway' do it_splits '4721234567', ['47',false,'21','23','45','67'] it_splits '4731234567', ['47',false,'31','23','45','67'] it_splits '4741234567', ['47',false,'412','34','567'] it_splits '4751234567', ['47',false,'51','23','45','67'] it_splits '4761234567', ['47',false,'61','23','45','67'] it_splits '4771234567', ['47',false,'71','23','45','67'] it_splits '4781234567', ['47',false,'812','34','567'] it_splits '4791234567', ['47',false,'912','34','567'] end describe 'Oman' do it_splits '96824423123', %w(968 24 423 123) it_splits '96825423123', %w(968 25 423 123) end describe 'Pakistan' do it_splits '922112345678', %w(92 21 1234 5678) it_splits '92221234567', %w(92 22 1234 567) it_splits '92232123456', %w(92 232 123 456) it_splits '923012345678', %w(92 30 1234 5678) end describe 'Paraguay (Republic of)' do it_splits '59521123456', %w(595 21 123 456) it_splits '595211234567', %w(595 21 123 4567) it_splits '595345123456', %w(595 345 123 456) it_splits '595961611234', %w(595 96 161 1234) end describe 'Peru' do it_splits '5111231234', ['51', '1', '123', '1234'] # Lima it_splits '51912341234', ['51', '9', '1234', '1234'] # mobile it_splits '5184123123', ['51', '84', '123', '123'] # Cuzco, best effort end describe 'Philippines' do it_splits '6321234567', ['63', '2', '1234567'] it_splits '6321234567890', ['63', '2', '1234567890'] it_splits '632123456789012', ['63', '2', '123456789012'] it_splits '639121234567', ['63', '912', '1234567'] it_splits '63881234567', ['63', '88', '1234567'] end describe 'Poland' do it_splits '48123456789', ['48', '12', '345', '67', '89'] # Landline it_splits '48501123456', ['48', '501', '123', '456'] # Mobile it_splits '48571123456', ['48', '571', '123', '456'] # Mobile it_splits '48451123456', ['48', '451', '123', '456'] # Mobile it_splits '48800123456', ['48', '800', '123', '456'] # Free it_splits '48801123456', ['48', '801', '123', '456'] # Shared cost it_splits '48701123456', ['48', '701', '123', '456'] # Premium end describe 'Portugal' do it_splits '351211231234', ['351', '21', '123', '1234'] # Lisboa it_splits '351241123123', ['351', '241', '123', '123'] # Abrantes it_splits '351931231234', ['351', '93', '123', '1234'] # mobile end describe 'Qatar' do it_splits '9741245123456', %w(974 1245 123 456) it_splits '9742613456', %w(974 26 134 56) it_splits '97433123456', %w(974 33 123 456) it_splits '97444412456', %w(974 44 412 456) it_splits '9748001234', %w(974 800 12 34) it_splits '9749001234', %w(974 900 12 34) it_splits '97492123', %w(974 92 123) it_splits '97497123', %w(974 97 123) end describe 'Romania' do it_splits '40211231234', ['40', '21', '123', '1234'] # Bucureşti it_splits '40721231234', ['40', '72', '123', '1234'] # mobile it_splits '40791231234', ['40', '79', '123', '1234'] # mobile it_splits '40249123123', ['40', '249', '123', '123'] # Olt end describe 'Russia' do it_splits '78122345678', ['7', '812', '234', '56', '78'] # Russia 3-digit it_splits '74012771077', ['7', '4012', '77', '10', '77'] # Russia 4-digit it_splits '78402411212', ['7', '84024', '1', '12', '12'] # Russia 5-digit it_splits '79296119119', ['7', '929', '611', '91', '19'] # Russia 3-digit, Megafon Mobile it_splits '79691234567', ['7', '969', '123', '45', '67'] # Russia 3-digit, Beeline it_splits '79771234567', ['7', '977', '123', '45', '67'] # Russia 3-digit it_splits '79961234567', ['7', '996', '123', '45', '67'] # Russia 3-digit it_splits '79991234567', ['7', '999', '123', '45', '67'] # Russia 3-digit it_splits '7840121212', ['7', '840', '12', '1212'] # Abhasia it_splits '7799121212', ['7', '799', '12', '1212'] # Kazachstan it_splits '7995344121212', ['7', '995', '344','12','1212'] # South Osetia it_splits '7209175276', ['7', '209', '17', '5276'] # Fantasy number end describe 'Rwanda' do it_splits '250781234567', ['250', '78', '1234567'] # mobile it_splits '250721234567', ['250', '72', '1234567'] # mobile it_splits '250731234567', ['250', '73', '1234567'] # mobile it_splits '250251234567', ['250', '25', '1234567'] # fixed it_splits '25006123456', ['250', '06', '123456'] # fixed end describe 'Sao Tome and Principe' do it_splits '2392220012', %w(239 2 220 012) it_splits '2399920012', %w(239 9 920 012) end describe 'South Korea' do it_splits '82212345678', ['82', '2', '1234', '5678'] # Seoul (8 digits) it_splits '8227111222', ['82', '2', '711', '1222'] # Seoul (7 digits) it_splits '825112345678', ['82', '51', '1234', '5678'] # Busan (8 digits) it_splits '82511234567', ['82', '51', '123', '4567'] # Busan (7 digits) it_splits '821027975588', ['82', '10', '2797', '5588'] # mobile it_splits '821087971234', ['82', '10', '8797', '1234'] # mobile end describe 'Serbia' do it_splits '38163512529', ['381', '63', '512', '529'] end describe 'South Sudan' do it_splits '211123212345', ['211', '123', '212', '345'] it_splits '211973212345', ['211', '973', '212', '345'] end describe 'Sudan' do it_splits '249187171100', ['249', '18', '717', '1100'] end describe 'Thailand' do it_splits '6621231234', ['66', '2', '123', '1234'] # Bangkok it_splits '6636123123', ['66', '36', '123', '123'] # Lop Buri it_splits '66851234567', ['66', '851', '234', '567'] # Lop Buri it_splits '66921234567', ['66', '921', '234', '567'] # mobile end describe 'Tunesia' do it_splits '21611231234', ['216', '1', '123', '1234'] # Ariana it_splits '21621231234', ['216', '2', '123', '1234'] # Bizerte end describe 'Salvador (El)' do it_splits '50321121234', ['503', '2112', '1234'] # Fixed number it_splits '50361121234', ['503', '6112', '1234'] # Mobile number end describe 'Singapore' do it_splits '6561231234', ['65', false, '6123', '1234'] # Fixed line it_splits '658008521234', ['65', false, '800', '852', '1234'] # International Toll Free Service (ITFS) and Home Country Direct Service (HCDS) Numbers end describe 'Slovakia' do it_splits '421912123456', ['421', '912', '123456'] # Mobile it_splits '421212345678', ['421', '2', '12345678'] # Bratislava it_splits '4212123', ['421', '2', '123'] # Bratislava Short it_splits '421371234567', ['421', '37', '1234567'] # Nitra / Other it_splits '42137123', ['421', '37', '123'] # Nitra / Other Short end describe 'Slovenia' do it_splits '38651234567', ['386', '51', '234', '567'] # Mobile it_splits '38611234567', ['386', '1', '123', '4567'] # LJUBLJANA end describe 'Spain' do it_splits '34600123456', ['34', '600', '123', '456'] # Mobile it_splits '34900123456', ['34', '900', '123', '456'] # Special it_splits '34931234567', ['34', '93', '123', '45', '67'] # Landline large regions it_splits '34975123456', ['34', '975', '12', '34', '56'] # Landline it_splits '34123456789', ['34', '123', '456', '789'] # Default end describe 'Sri Lanka' do it_splits '94711231212', ['94', '71', '123', '12', '12'] # Mobile end describe 'Sweden' do it_splits '46812345678', ['46', '8', '123', '45', '678'] # Stockholm it_splits '46111234567', ['46', '11', '123', '45', '67'] it_splits '46721234567', ['46', '72', '123', '45', '67'] # mobile it_splits '46791234567', ['46', '79', '123', '45', '67'] # mobile it_splits '46125123456', ['46', '125', '12', '34', '56'] it_splits '46770820180', ['46', '77', '082', '01', '80'] it_splits '4641712345', ['46', '417', '123', '45'] it_splits '46513123456', ['46', '513', '12', '34', '56'] end describe 'Switzerland' do it_splits '41443643532', ['41', '44', '364', '35', '32'] # Zurich (usually) it_splits '41800334455', ['41', '800', '334', '455'] # Service number it_splits '41900123456', ['41', '900', '123', '456'] # Business Number it_splits '41901123456', ['41', '901', '123', '456'] # Business Number Entertainment it_splits '41906123456', ['41', '906', '123', '456'] # Business Number Adult Entertainment end describe 'Tanzania' do it_splits '255221231234', ['255', '22', '123', '1234'] # Dar Es Salaam it_splits '255651231234', ['255', '65', '123', '1234'] # TIGO it_splits '255861123123', ['255', '861', '123', '123'] # Special Rates end describe 'Turkey' do it_splits '903121234567', ['90', '312', '123', '4567'] # Ankara end describe 'Uganda' do it_splits '256414123456', ['256', '41', '4123456'] # Kampania it_splits '256464441234', ['256', '464', '441234'] # Mubende end describe 'The UK' do it_splits '442075671113', ['44', '20', '7567', '1113'] # [2+8] London it_splits '442920229901', ['44', '29', '2022', '9901'] # [2+8] Cardiff it_splits '441134770011', ['44', '113', '477', '0011'] # [3+7] Leeds it_splits '441412770022', ['44', '141', '277', '0022'] # [3+7] Glasgow it_splits '441204500532', ['44', '1204', '500532'] # [4+6] Bolton it_splits '44120462532', ['44', '1204', '62532'] # [4+5] Bolton it_splits '441333247700', ['44', '1333', '247700'] # [4+6] Leven (Fife) it_splits '441382229845', ['44', '1382', '229845'] # [4+6] Dundee it_splits '441420700378', ['44', '1420', '700378'] # [4+6] Alton it_splits '44142080378', ['44', '1420', '80378'] # [4+5] Alton it_splits '441475724688', ['44', '1475', '724688'] # [4+6] Greenock it_splits '441539248756', ['44', '1539', '248756'] # [4+6] Kendal (Mixed area) it_splits '441539648788', ['44', '15396', '48788'] # [5+5] Sedbergh (Mixed area) it_splits '441652757248', ['44', '1652', '757248'] # [4+6] Brigg it_splits '441664333456', ['44', '1664', '333456'] # [4+6] Melton Mowbray it_splits '441697222555', ['44', '1697', '222555'] # [4+6] Brampton (Mixed area) it_splits '441697388555', ['44', '16973', '88555'] # [5+5] Wigton (Mixed area) it_splits '441697433777', ['44', '16974', '33777'] # [5+5] Raughton Head (Mixed area) it_splits '44169772333', ['44', '16977', '2333'] # [5+4] Brampton (Mixed area) it_splits '441697744888', ['44', '16977', '44888'] # [5+5] Brampton (Mixed area) it_splits '441757850526', ['44', '1757', '850526'] # [4+6] Selby it_splits '441890234567', ['44', '1890', '234567'] # [4+6] Coldstream (ELNS area) it_splits '441890595378', ['44', '1890', '595378'] # [4+6] Ayton (ELNS area) it_splits '441931306526', ['44', '1931', '306526'] # [4+6] Shap it_splits '441946555777', ['44', '1946', '555777'] # [4+6] Whitehaven (Mixed area) it_splits '44194662888', ['44', '1946', '62888'] # [4+5] Whitehaven (Mixed area) it_splits '441946722444', ['44', '19467', '22444'] # [5+5] Gosforth (Mixed area) it_splits '441987705337', ['44', '1987', '705337'] # [4+6] Ebbsfleet it_splits '443005828323', ['44', '300', '582', '8323'] # Non-geographic (NTS) it_splits '443334253344', ['44', '333', '425', '3344'] # Non-geographic (NTS) it_splits '443437658834', ['44', '343', '765', '8834'] # Non-geographic (NTS) it_splits '443452273512', ['44', '345', '227', '3512'] # Non-geographic (NTS) it_splits '443707774444', ['44', '370', '777', '4444'] # Non-geographic (NTS) it_splits '443725247722', ['44', '372', '524', '7722'] # Non-geographic (NTS) it_splits '44500557788', ['44', '500', '557788'] # Freefone (500 + 6) it_splits '445575671113', ['44', '55', '7567', '1113'] # Corporate numbers it_splits '445644775533', ['44', '56', '4477', '5533'] # LIECS/VoIP it_splits '447020229901', ['44', '70', '2022', '9901'] # Personal numbers it_splits '447688554246', ['44', '76', '8855', '4246'] # Pager it_splits '447180605207', ['44', '7180', '605207'] # Mobile it_splits '447480605207', ['44', '7480', '605207'] # Mobile it_splits '447624605207', ['44', '7624', '605207'] # Mobile (Isle of Man) it_splits '447780605207', ['44', '7780', '605207'] # Mobile it_splits '447980605207', ['44', '7980', '605207'] # Mobile it_splits '44800557788', ['44', '800', '557788'] # Freefone (800 + 6) it_splits '448084682355', ['44', '808', '468', '2355'] # Freefone (808 + 7) it_splits '448005878323', ['44', '800', '587', '8323'] # Freefone (800 + 7), regression it_splits '448437777334', ['44', '843', '777', '7334'] # Non-geographic (NTS) it_splits '448457777334', ['44', '845', '777', '7334'] # Non-geographic (NTS) it_splits '448707777334', ['44', '870', '777', '7334'] # Non-geographic (NTS) it_splits '448727777334', ['44', '872', '777', '7334'] # Non-geographic (NTS) it_splits '449052463456', ['44', '905', '246', '3456'] # Non-geographic (PRS) it_splits '449122463456', ['44', '912', '246', '3456'] # Non-geographic (PRS) it_splits '449832463456', ['44', '983', '246', '3456'] # Non-geographic (SES) end describe 'US' do it_splits '15551115511', ['1', '555', '111', '5511'] end describe 'Venezuela' do it_splits '582121234567', ['58', '212', '1234567'] end describe 'Vietnam' do it_splits '8498123456', ['84', '98', '123456'] # Viettel Mobile it_splits '8499612345', ['84', '99', '612345'] # GTel it_splits '842421234567', ['84', '24', '2123', '4567'] # Hanoi it_splits '842841234567', ['84', '28', '4123', '4567'] # Ho Chi Minh City it_splits '84341234567', ['84', '34', '1234567'] # Viettel it_splits '84841234567', ['84', '84', '1234567'] # Vinaphone end describe 'Zambia' do it_splits '260211123456', ['260', '211', '123456'] # Fixed it_splits '260955123456', ['260', '955', '123456'] # Mobile it_splits '260967123456', ['260', '967', '123456'] # Mobile it_splits '260978123456', ['260', '978', '123456'] # Mobile it_splits '260800123456', ['260', '800', '123', '456'] # Toll free end describe 'New Zealand' do it_splits '6491234567', ['64', '9', '123', '4567'] it_splits '64800123123', ['64', '800', '123', '123'] it_splits '648001231234', ['64', '800', '123', '1234'] end describe 'Bhutan (Kingdom of)' do it_splits '9759723642', %w(975 9 723 642) end describe 'Brunei Darussalam' do it_splits '6737932744', %w(673 7 932 744) end describe 'Burkina Faso' do it_splits '22667839323', ['226', false, '6783', '9323'] end describe 'Burundi' do it_splits '25712345678', ['257', false, '1234', '5678'] end describe 'Cameroon' do it_splits '237276593812', ['237', false, '276', '59', '38', '12'] end describe 'Cape Verde' do it_splits '2385494177', ['238', false, '549', '4177'] end describe 'Central African Republic' do it_splits '23612345678', ['236', false, '1234', '5678'] end describe 'Chad' do it_splits '23512345678', ['235', false, '1234', '5678'] end describe 'Comoros' do it_splits '2693901234', ['269', false, '3901', '234'] it_splits '2693401234', ['269', false, '3401', '234'] end describe 'Congo' do it_splits '242123456789', ['242', false, '1234', '56789'] end describe 'Cook Islands' do it_splits '68251475', ['682', false, '51', '475'] end describe 'Costa Rica' do it_splits '50622345678', %w(506 2 234 5678) end describe "Côte d'Ivoire" do it_splits '22507335518', ['225', '07', '33', '55', '18'] it_splits '22537335518', ['225', '37', '33', '55', '18'] end describe 'Democratic Republic of Timor-Leste' do it_splits '6701742945', ['670', false, '174', '2945'] end describe 'Democratic Republic of the Congo' do it_splits '243121995381', %w(243 12 199 5381) end describe 'Diego Garcia' do it_splits '2461234683', ['246', false, '123', '4683'] end describe 'Djibouti' do it_splits '25349828978', ['253', false, '4982', '8978'] end describe 'Ecuador' do it_splits '593220000000', %w(593 22 000 0000) it_splits '59322000000', %w(593 2 200 0000) it_splits '593230000000', %w(593 23 000 0000) it_splits '59323000000', %w(593 2 300 0000) it_splits '59324000000', %w(593 2 400 0000) it_splits '59325000000', %w(593 2 500 0000) it_splits '593260000000', %w(593 26 000 0000) it_splits '59327000000', %w(593 2 700 0000) it_splits '593270000000', %w(593 27 000 0000) it_splits '59330000000', %w(593 3 000 0000) it_splits '59340000000', %w(593 4 000 0000) it_splits '593440000000', %w(593 44 000 0000) it_splits '593450000000', %w(593 45 000 0000) it_splits '59345000000', %w(593 4 500 0000) it_splits '59346000000', %w(593 4 600 0000) it_splits '593470000000', %w(593 47 000 0000) it_splits '59352000000', %w(593 5 200 0000) it_splits '59353000000', %w(593 5 300 0000) it_splits '59362000000', %w(593 6 200 0000) it_splits '59372000000', %w(593 7 200 0000) it_splits '59373000000', %w(593 7 300 0000) it_splits '59374000000', %w(593 7 400 0000) it_splits '59376000000', %w(593 7 600 0000) it_splits '593900000000', %w(593 9 0000 0000) end describe 'Eritrea' do it_splits '2916537192', %w(291 6 537 192) end describe 'Ethiopia' do it_splits '251721233486', %w(251 72 123 3486) end describe 'Falkland Islands (Malvinas)' do it_splits '50014963', ['500', false, '14', '963'] end describe 'Faroe Islands' do it_splits '298997986', ['298', false, '997', '986'] end describe 'Fiji (Republic of)' do it_splits '6798668123', ['679', false, '866', '8123'] end describe 'French Guiana (French Department of)' do it_splits '594594123456', %w(594 594 123 456) end describe "French Polynesia (Territoire français d'outre-mer)" do it_splits '68921988900', ['689', false, '21', '98', '89', '00'] end describe 'Gabonese Republic' do it_splits '2411834375', ['241', '1', '834', '375'] end describe 'Gambia' do it_splits '2206683355', ['220', false, '668', '3355'] end describe 'Greenland' do it_splits '299314185', ['299', '31', '4185'] it_splits '299691123', ['299', '691', '123'] end describe 'Guadeloupe (French Department of)' do it_splits '590590456789', %w(590 590 45 67 89) end describe 'Guatemala (Republic of)' do it_splits '50219123456789', ['502', '19', '123', '456', '789'] it_splits '50221234567', ['502', '2', '123', '4567'] end describe 'Guinea' do it_splits '22430311234', ['224', '3031', '12', '34'] it_splits '224662123456', ['224', '662', '12', '34', '56'] end describe 'Guinea-Bissau' do it_splits '245443837652', ['245', false, '44', '383', '7652'] end describe 'Guyana' do it_splits '5922631234', %w(592 263 1234) end describe 'Honduras (Republic of)' do it_splits '50412961637', %w(504 12 961 637) end describe 'Iraq' do it_splits '96411234567', %w(964 1 123 4567) it_splits '96421113456', %w(964 21 113 456) it_splits '9647112345678', %w(964 71 1234 5678) end describe 'Jordan (Hashemite Kingdom of)' do it_splits '96280012345', %w(962 800 123 45) it_splits '96226201234', %w(962 2 620 1234) it_splits '962712345678', %w(962 7 1234 5678) it_splits '962746612345', %w(962 7 4661 2345) it_splits '96290012345', %w(962 900 123 45) it_splits '96285123456', %w(962 85 123 456) it_splits '96270123456', %w(962 70 123 456) it_splits '96262501456', %w(962 6250 1456) it_splits '96287901456', %w(962 8790 1456) end describe 'Kiribati (Republic of)' do it_splits '68634814', ['686', false, '34', '814'] end describe "Democratic People's Republic of Korea" do it_splits '850212345', %w(850 2 123 45) it_splits '8502123456789', %w(850 2 123 456 789) it_splits '85023812356', %w(850 2 381 2356) #it_splits '85028801123456781256', %w(850 2 8801 1234 5678 1256) it_splits '8501911234567', %w(850 191 123 4567) end describe 'Kuwait (State of)' do it_splits '96523456789', ['965', false, '2345', '6789'] it_splits '9651812345', ['965', false, '181', '2345'] end describe "Lao People's Democratic Republic" do it_splits '85697831195', %w(856 97 831 195) end describe 'Latvia' do it_splits '37180123456', %w(371 801 234 56) it_splits '37163723456', %w(371 637 234 56) it_splits '37129412345', %w(371 294 123 45) end describe 'Lebanon' do it_splits '9611123456', %w(961 1 123 456) it_splits '9614123456', %w(961 4 123 456) it_splits '9613123456', %w(961 3 123 456) it_splits '96170123456', %w(961 70 123 456) it_splits '96190123456', %w(961 90 123 456) it_splits '96181123456', %w(961 81 123 456) end describe 'Lesotho' do it_splits '26623592495', ['266', false, '2359', '2495'] end describe 'Liberia' do it_splits '23121234567', ['231', false, '2123', '4567'] it_splits '2314123456', ['231', false, '4123', '456'] it_splits '231771234567', ['231', false, '77', '123', '4567'] end describe 'Libya' do it_splits '21820512345', %w(218 205 123 45) it_splits '21822123456', %w(218 22 123 456) it_splits '218211234456', %w(218 21 1234 456) it_splits '218911234456', %w(218 91 1234 456) end describe 'Madagascar' do it_splits '26120012345678', ['261', false, '20', '012', '345', '678'] it_splits '261201243456', ['261', false, *%w(20 124 3456)] it_splits '261512345678', ['261', false, *%w(512 345 678)] end describe 'Malawi' do it_splits '2651725123', ['265', false, '1725', '123'] it_splits '265213456789',[ '265', false, '213', '456', '789'] it_splits '2659123456', ['265', false, '9123', '456'] it_splits '265991123456', ['265', false, '991', '123', '456'] end describe 'Maldives (Republic of)' do it_splits '9606568279', ['960', '656', '8279'] end describe 'Mali' do it_splits '22379249349', ['223', false, '7924', '9349'] end describe 'Marshall Islands (Republic of the)' do it_splits '6924226536', ['692', false, '422', '6536'] end describe 'Martinique (French Department of)' do it_splits '596596123456', %w(596 596 12 34 56) end describe 'Mauritania' do it_splits '22212345678', ['222', false, '1234', '5678'] end describe 'Mauritius' do it_splits '23059518919', ['230', false, '5951', '8919'] end describe 'Micronesia (Federated States of)' do it_splits '6911991754', ['691', false, '199', '1754'] end describe 'Moldova' do it_splits '37380012345', %w(373 800 123 45) it_splits '37322123345', %w(373 22 123 345) it_splits '37324112345', %w(373 241 123 45) it_splits '37360512345', %w(373 605 123 45) it_splits '37380312345', %w(373 803 123 45) end describe 'Mongolia' do it_splits '9761112345', %w(976 11 123 45) it_splits '9761211234', %w(976 121 12 34) it_splits '97612112345', %w(976 121 12 345) it_splits '97670123456', %w(976 70 123 456) it_splits '97675123456', %w(976 75 123 456) it_splits '97688123456', %w(976 88 123 456) it_splits '97650123456', %w(976 50 123 456) end describe 'Mozambique' do it_splits '258600123456', %w(258 600 123 456) it_splits '25825112345', %w(258 251 123 45) it_splits '258821234456', %w(258 82 1234 456) it_splits '258712344567', %w(258 7 1234 4567) end describe 'Namibia' do it_splits '264675161324', %w(264 6751 613 24) it_splits '26467175890', %w(264 67 175 890) it_splits '26463088612345', %w(264 63 088 612 345) it_splits '264851234567', %w(264 85 1234 567) end describe 'Nauru (Republic of)' do it_splits '6741288739', ['674', false, '128', '8739'] end describe 'Nepal' do it_splits '97714345678', %w(977 1 434 5678) it_splits '97710123456', %w(977 10 123 456) it_splits '9779812345678', %w(977 98 1234 5678) end describe "New Caledonia (Territoire français d'outre-mer)" do it_splits '687747184', ['687', false, '747', '184'] end describe 'Nicaragua' do it_splits '50512345678', ['505', '12', '345', '678'] end describe 'Niger' do it_splits '22712345678', ['227', false, '1234', '5678'] end describe 'Nigeria' do it_splits '23411231234', %w(234 1 123 1234) # Lagos # mobile numbers it_splits '2347007661234', %w(234 700 766 1234) it_splits '2347017661234', %w(234 701 766 1234) it_splits '2347027661234', %w(234 702 766 1234) it_splits '2347037661234', %w(234 703 766 1234) it_splits '2347047661234', %w(234 704 766 1234) it_splits '2347057661234', %w(234 705 766 1234) it_splits '2347067661234', %w(234 706 766 1234) it_splits '2347077661234', %w(234 707 766 1234) it_splits '2347087661234', %w(234 708 766 1234) it_splits '2347097661234', %w(234 709 766 1234) it_splits '2348007661234', %w(234 800 766 1234) it_splits '2348017661234', %w(234 801 766 1234) it_splits '2348027661234', %w(234 802 766 1234) it_splits '2348037661234', %w(234 803 766 1234) it_splits '2348047661234', %w(234 804 766 1234) it_splits '2348057661234', %w(234 805 766 1234) it_splits '2348067661234', %w(234 806 766 1234) it_splits '2348077661234', %w(234 807 766 1234) it_splits '2348087661234', %w(234 808 766 1234) it_splits '2348097661234', %w(234 809 766 1234) it_splits '2349007661234', %w(234 900 766 1234) it_splits '2349017661234', %w(234 901 766 1234) it_splits '2349027661234', %w(234 902 766 1234) it_splits '2349037661234', %w(234 903 766 1234) it_splits '2349047661234', %w(234 904 766 1234) it_splits '2349057661234', %w(234 905 766 1234) it_splits '2349067661234', %w(234 906 766 1234) it_splits '2349077661234', %w(234 907 766 1234) it_splits '2349087661234', %w(234 908 766 1234) it_splits '2349097661234', %w(234 909 766 1234) it_splits '2348107661234', %w(234 810 766 1234) it_splits '2348117661234', %w(234 811 766 1234) it_splits '2348127661234', %w(234 812 766 1234) it_splits '2348137661234', %w(234 813 766 1234) it_splits '2348147661234', %w(234 814 766 1234) it_splits '2348157661234', %w(234 815 766 1234) it_splits '2348167661234', %w(234 816 766 1234) it_splits '2348177661234', %w(234 817 766 1234) it_splits '2348187661234', %w(234 818 766 1234) it_splits '2348197661234', %w(234 819 766 1234) end describe 'Niue' do it_splits '6833651', ['683', false, '3651'] end describe 'Palau (Republic of)' do it_splits '6804873653', ['680', false, '487', '3653'] end describe 'Panama (Republic of)' do it_splits '5078001234', %w(507 800 1234) it_splits '50761234567', %w(507 6 123 4567) it_splits '5072123456', %w(507 2 123 456) end describe 'Papua New Guinea' do it_splits '6753123567', %w(675 3 123 567) it_splits '6751801234', %w(675 180 1234) it_splits '67580123456', %w(675 80 123 456) it_splits '67591123456', %w(675 91 123 456) it_splits '6751612345', %w(675 16 123 45) it_splits '67518412345678', %w(675 184 1234 5678) it_splits '67517012', %w(675 170 12) it_splits '6751891', %w(675 189 1) it_splits '6752701234', %w(675 270 1234) it_splits '6752751234', %w(675 275 1234) it_splits '67527912', %w(675 279 12) it_splits '67511512345678', %w(675 115 1234 5678) it_splits '67574123456', %w(675 74 123 456) it_splits '67573123456', %w(675 731 23 456) it_splits '67577301234', %w(675 7730 1 234) end describe 'Reunion / Mayotte (new)' do it_splits '262594399265', ['262', '594', '39', '92', '65'] end describe 'Saint Helena' do it_splits '2903614', ['290', false, '3614'] end describe 'Saint Pierre and Miquelon (Collectivité territoriale de la République française)' do it_splits '508418826', ['508', false, '418', '826'] end describe 'Samoa (Independent State of)' do it_splits '685800123', ['685', false, '800', '123'] it_splits '68561123', ['685', false, '61', '123'] it_splits '6857212345', ['685', false, '721', '2345'] it_splits '685830123', ['685', false, '830', '123'] it_splits '685601234', ['685', false, '601', '234'] it_splits '6858412345', ['685', false, '841', '2345'] end describe 'San Marino' do it_splits '378800123', ['378', false, '800', '123'] it_splits '3788001234567', ['378', false, '800', '123', '4567'] it_splits '378012345', ['378', false, '012', '345'] it_splits '3780123456789', ['378', false, '012', '345', '6789'] it_splits '378512345', ['378', false, '512', '345'] it_splits '3785123456789', ['378', false, '512', '345', '6789'] end describe 'Saudi Arabia (Kingdom of)' do it_splits '9660208528423', %w(966 020 852 8423) # Fixed it_splits '966506306201', %w(966 50 630 6201) # NDC Mobile it_splits '966112345678', %w(966 11 234 5678) # NDC Region it_splits '9668001234567', %w(966 800 123 4567) # Toll Free it_splits '966920012345', %w(966 9200 12345) # Univeral Access end describe 'Senegal' do it_splits '221123456789', ['221', false, '1234', '56789'] end describe 'Serbia' do it_splits '38180012345', %w(381 800 123 45) it_splits '3811012345', %w(381 10 123 45) it_splits '38110123456', %w(381 10 123 456) it_splits '38111123456', %w(381 11 123 456) it_splits '381111234567', %w(381 11 123 4567) it_splits '381721234567', %w(381 72 123 4567) it_splits '38160123', %w(381 60 123) it_splits '381601234567', %w(381 60 123 4567) it_splits '38142123456', %w(381 42 123 456) it_splits '38191234567', %w(381 9 123 4567) it_splits '38160123', %w(381 60 123) it_splits '381601234567890', %w(381 60 123 456 7890) it_splits '38170123456', %w(381 70 123 456) it_splits '38163123456', %w(381 63 123 456) end describe 'Sierra Leone' do it_splits '23264629769', %w(232 64 629 769) end describe 'Solomon Islands' do it_splits '67754692', ['677', false, '54', '692'] it_splits '6777546921', ['677', false, '7546', '921'] end describe 'Somalia' do it_splits '252103412345', %w(252 1034 123 45) it_splits '2521313123', %w(252 1313 123) it_splits '2521601234', %w(252 160 12 34) it_splits '25250012345', %w(252 500 123 45) it_splits '252612345678', %w(252 61 234 5678) # Hormuud it_splits '252622345678', %w(252 62 234 5678) # Somtel Mogadishu it_splits '252634000613', %w(252 63 400 0613) # Telesom it_splits '252642345678', %w(252 64 234 5678) # Hormuud it_splits '252652345678', %w(252 65 234 5678) # Somtel it_splits '252662345678', %w(252 66 234 5678) # Somtel Puntland it_splits '252672345678', %w(252 67 234 5678) # Nationlink Mogadishu it_splits '252682345678', %w(252 68 234 5678) # Nationlink Mogadishu it_splits '252692345678', %w(252 69 234 5678) # Nationlink it_splits '252902345678', %w(252 90 234 5678) # Golis end describe 'Suriname (Republic of)' do it_splits '597958434', ['597', false, '958', '434'] it_splits '597212345', ['597', false, '212', '345'] it_splits '5976123456', ['597', false, '612', '3456'] end describe 'Swaziland' do it_splits '26822071234', ['268', false, '2207', '1234'] it_splits '2685501234', ['268', false, '550', '1234'] end describe 'Syrian Arab Republic' do it_splits '963111234567', %w(963 11 123 4567) it_splits '963311234567', %w(963 31 123 4567) it_splits '96315731234', %w(963 15 731 234) it_splits '963912345678', %w(963 9 1234 5678) end describe 'Taiwan' do it_splits '886212345678', %w(886 2 1234 5678) it_splits '88631234567', %w(886 3 123 4567) it_splits '88651234567', %w(886 5 123 4567) it_splits '88661234567', %w(886 6 123 4567) it_splits '88671234567', %w(886 7 123 4567) it_splits '88633123456', %w(886 3 312 3456) it_splits '88637123456', %w(886 37 12 3456) it_splits '88682712345', %w(886 82 71 2345) it_splits '88689712345', %w(886 89 71 2345) it_splits '88682672345', %w(886 826 7 2345) it_splits '88683672345', %w(886 836 7 2345) it_splits '88641212345', %w(886 4 121 2345) it_splits '886412123456', %w(886 4 1212 3456) it_splits '886491234567', %w(886 49 123 4567) it_splits '886901234567', %w(886 901 234 567) end describe 'Togolese Republic' do it_splits '22812345678', ['228', false, '1234', '5678'] end describe 'Tajikistan' do it_splits '992313012345', %w(992 3130 123 45) it_splits '992331700123', %w(992 331700 123) it_splits '992372123345', %w(992 372 123 345) it_splits '992505123456', %w(992 505 123 456) it_splits '992973123456', %w(992 973 123 456) it_splits '992474456123', %w(992 474 456 123) end describe 'Tokelau' do it_splits '6901371', %w(690 1 371) end describe 'Tonga (Kingdom of)' do it_splits '67620123', ['676', false, '20', '123'] it_splits '67684123', ['676', false, '84', '123'] it_splits '6767712345', ['676', false, '77', '123', '45'] it_splits '6768912345', ['676', false, '89', '123', '45'] end describe 'Tuvalu' do it_splits '68893741', ['688', false, '93741'] end describe 'Turkmenistan' do it_splits '99312456789', %w(993 12 456 789) it_splits '99313145678', %w(993 131 456 78) it_splits '99313924567', %w(993 1392 4567) it_splits '99361234567', %w(993 6 123 4567) end describe 'Ukraine' do it_splits '380800123456', %w(380 800 123 456) it_splits '380312123456', %w(380 312 123 456) it_splits '380320123456', %w(380 32 0123 456) it_splits '380325912345', %w(380 3259 123 45) it_splits '380326061234', %w(380 32606 1234) it_splits '380391234567', %w(380 39 123 45 67) it_splits '380501234567', %w(380 50 123 45 67) it_splits '380631234567', %w(380 63 123 45 67) it_splits '380661234567', %w(380 66 123 45 67) it_splits '380671234567', %w(380 67 123 45 67) it_splits '380681234567', %w(380 68 123 45 67) it_splits '380911234567', %w(380 91 123 45 67) it_splits '380921234567', %w(380 92 123 45 67) it_splits '380931234567', %w(380 93 123 45 67) it_splits '380731234567', %w(380 73 123 45 67) it_splits '380941234567', %w(380 94 123 45 67) it_splits '380951234567', %w(380 95 123 45 67) it_splits '380961234567', %w(380 96 123 45 67) it_splits '380971234567', %w(380 97 123 45 67) it_splits '380981234567', %w(380 98 123 45 67) it_splits '380991234567', %w(380 99 123 45 67) end describe 'United Arab Emirates' do it_splits '97180012', %w(971 800 12) it_splits '971800123456789', %w(971 800 12 345 6789) it_splits '97180012345678', %w(971 800 12 345 678) it_splits '9718001234567', %w(971 800 12 345 67) it_splits '97121234567', %w(971 2 123 4567) it_splits '971506412345', %w(971 50 641 2345) it_splits '971600641234', %w(971 600 641 234) it_splits '971500641234', %w(971 500 641 234) it_splits '971200641234', %w(971 200 641 234) it_splits '971549999999', %w(971 54 999 9999) it_splits '971589999999', %w(971 58 999 9999) end describe 'Uruguay (Eastern Republic of)' do it_splits '59880012345', %w(598 800 123 45) it_splits '59820123456', %w(598 2 012 3456) it_splits '59821123456', %w(598 21 123 456) it_splits '59890912345', %w(598 909 123 45) it_splits '59893123456', %w(598 93 123 456) it_splits '59890812345', %w(598 908 123 45) it_splits '59880512345', %w(598 805 123 45) end describe 'Uzbekistan (Republic of)' do it_splits '998433527869', %w(998 43 352 7869) end describe 'Vanuatu (Republic of)' do it_splits '67889683', ['678', false, '89', '683'] end describe 'Yemen' do it_splits '9671234567', %w(967 1 234 567) it_splits '96712345678', %w(967 1 234 5678) it_splits '9677234567', %w(967 7 234 567) it_splits '967771234567', %w(967 77 123 4567) it_splits '967581234', %w(967 58 1234) end describe 'Zimbabwe' do it_splits '2632582123456', %w(263 2582 123 456) it_splits '2632582123', %w(263 2582 123) it_splits '263147123456', %w(263 147 123 456) it_splits '263147123', %w(263 147 123) it_splits '263270123456', %w(263 270 123 456) it_splits '26327012345', %w(263 270 123 45) it_splits '2638612354567', %w(263 86 1235 4567) # mobile numbers (see http://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000E90002PDFE.pdf, Table 4, Page 25) %w(71 73 77 78).each do |prefix| number = "263#{prefix}2345678" it_splits number, ['263', prefix, '234', '5678'] end end end end updated prefixes for Israeli phone numbers: added 051 and removed 057 according to https://en.wikipedia.org/wiki/Telephone_numbers_in_Israel\#Cellular_and_mobile_devices_area_code_05 # encoding: utf-8 # require 'spec_helper' describe 'country descriptions' do def self.it_splits number, expected it { Phony.split(number).should == expected } end describe 'regression' do it_splits '33630588659', ["33", "6", "30", "58", "86", "59"] end describe 'splitting' do describe 'Ascension Island' do it_splits '2473551', ['247', false, '3551'] end describe 'Afghanistan' do it_splits '93201234567', ['93', '20', '1234567'] # Kabul end describe 'Albania' do it_splits '355691234567', ['355', '69', '123', '4567'] # Mobile 7 digits it_splits '35569123456', ['355', '69', '123', '456'] # Mobile 6 digits it_splits '35541234567', ['355', '4', '123', '4567'] # Tirana end describe 'Algeria' do it_splits '213211231234', ['213', '21', '123', '1234'] # Algiers it_splits '213331231234', ['213', '33', '123', '1234'] # Batna end describe 'Argentina' do it_splits '541112345678', ['54', '11', '1234', '5678'] it_splits '542911234567', ['54', '291', '123', '4567'] it_splits '542965123456', ['54', '2965', '12', '3456'] it_splits '5491112345678', ['54', '911', '1234', '5678'] it_splits '5492201234567', ['54', '9220', '123', '4567'] it_splits '5492221123456', ['54', '92221', '12', '3456'] it_splits '548001234567', ['54', '800', '123', '4567'] end describe 'Austria' do it_splits '43198110', %w( 43 1 98110 ) # Vienna it_splits '4310000000', %w( 43 1 0000000 ) # Vienna it_splits '43800123456789', %w( 43 800 123456789 ) # Free it_splits '436780000000', %w( 43 678 0000 000 ) # Mobile it_splits '4368100000000', %w( 43 681 0000 0000 ) # Mobile it_splits '436880000000', %w( 43 688 0000 000 ) # Mobile it_splits '4366900000000', %w( 43 669 0000 0000 ) # Mobile it_splits '4367000000000', %w( 43 670 0000 0000 ) # Mobile it_splits '4369000000000', %w( 43 690 0000 0000 ) # Mobile it_splits '433161234567891', %w( 43 316 1234567891 ) # Graz it_splits '432164123456789', %w( 43 2164 123456789 ) # Rohrau it_splits '43720116987', %w( 43 720 116987 ) # VoIP # mobile numbers can have from 7 to 10 digits in the subscriber number it_splits '436641234567', %w( 43 664 1234 567 ) it_splits '4366412345678', %w( 43 664 1234 5678 ) it_splits '43664123456789', %w( 43 664 1234 56789 ) it_splits '436641234567890', %w( 43 664 1234 567890 ) end describe 'Australia' do it_splits '61512341234', ['61', '5', '1234', '1234'] # Landline it_splits '61423123123', ['61', '423', '123', '123'] # Mobile it_splits '61131212', ['61', '13', '12', '12'] # 13 local rate it_splits '611300123123', ['61', '1300', '123', '123'] # 1300 local rate it_splits '611800123123', ['61', '1800', '123', '123'] # 1800 free call end describe 'Bahrain' do it_splits '97312345678', ['973', false, '1234', '5678'] end describe 'Bangladesh' do it_splits '88021234567', %w(880 2 1234567) it_splits '8805112345', %w(880 51 12345) it_splits '88031123456', %w(880 31 123456) it_splits '88032112345', %w(880 321 12345) it_splits '8804311234567', %w(880 431 1234567) it_splits '880902012345', %w(880 9020 12345) end describe 'Belarus' do it_splits '375152123456', %w(375 152 123456) it_splits '375151512345', %w(375 1515 12345) it_splits '375163423456', %w(375 163 423456) it_splits '375163112345', %w(375 1631 12345) it_splits '375291234567', %w(375 29 1234567) it_splits '375800123', %w(375 800 123) it_splits '3758001234', %w(375 800 1234) it_splits '3758001234567', %w(375 800 1234567) it_splits '37582012345678', %w(375 820 12345678) end describe 'Belgium' do it_splits '3235551212', ['32', '3', '555', '12', '12'] # Antwerpen it_splits '3250551212', ['32', '50', '55', '12', '12'] # Brugge it_splits '3225551212', ['32', '2', '555', '12', '12'] # Brussels it_splits '3295551914', ['32', '9', '555', '19', '14'] # Gent it_splits '3245551414', ['32', '4', '555', '14', '14'] # Liège it_splits '3216473200', ['32', '16', '47', '32', '00'] # Leuven it_splits '32475279584', ['32', '475', '27', '95', '84'] # mobile it_splits '32468279584', ['32', '468', '27', '95', '84'] # mobile (Telenet) it_splits '3270123123', ['32', '70', '123', '123'] # Bus Service? it_splits '3278123123', ['32', '78', '123', '123'] # National rate service it_splits '3290123123', ['32', '901', '23', '123'] # National rate service it_splits '3280080404', ['32', '800', '80', '404'] # Apple support end describe 'Belize' do it_splits '5012051234', %w(501 205 1234) end describe 'Benin' do it_splits '22912345678', ['229', false, '1234', '5678'] end describe 'Bolivia' do it_splits '59122772266', %w(591 2 277 2266) end describe 'Botswana' do it_splits '26780123456', %w(267 80 123 456) it_splits '2672956789', %w(267 29 567 89) it_splits '2674634567', %w(267 463 4567) it_splits '2675812345', %w(267 58 123 45) it_splits '26776712345', %w(267 7 6712 345) it_splits '26781234567', %w(267 8 1234 567) end describe 'Bosnia and Herzegovina' do it_splits '38766666666', %w(387 66 666 666) it_splits '38733123456', %w(387 33 123 456) end describe 'Brazil' do it_splits '551112341234', ['55', '11', '1234', '1234'] it_splits '5511981231234', ['55', '11', '98123', '1234'] # São Paulo's 9 digits mobile it_splits '552181231234', ['55', '21', '8123', '1234'] it_splits '5521981231234', ['55', '21', '98123', '1234'] # Rio de Janeiro's 9 digits mobile it_splits '551931311234', ['55', '19', '3131', '1234'] it_splits '5531991311234', ['55', '31', '99131', '1234'] # Belo Horizonte's 9th digit it_splits '5571991311234', ['55', '71', '99131', '1234'] # Salvador's 9th digit it_splits '5579991311234', ['55', '79', '99131', '1234'] # Sergipe's 9th digit it_splits '5547991311234', ['55', '47', '99131', '1234'] # Santa Catarina's 9th digit it_splits '5541991311234', ['55', '41', '99131', '1234'] # Parana's 9th digit context 'mobile numbers' do %w{ 11 12 13 14 15 16 17 18 19 21 22 24 27 28 31 32 33 34 35 37 38 61 62 63 64 65 66 67 68 69 71 73 74 75 77 79 81 82 83 84 85 86 87 88 89 91 92 93 94 95 96 97 98 99 41 42 43 44 45 46 47 48 49 51 53 54 55 }.each do |state_code| it_splits "55#{state_code}993051123", ['55', state_code, '99305', '1123'] end end context "special numbers" do it_splits '5508002221234', ['55', '0800', '222', '1234'] it_splits '5530032221', ['55', '3003', '2221'] it_splits '5540209999', ['55', '4020', '9999'] it_splits '5540038999', ['55', '4003', '8999'] it_splits '5540048999', ['55', '4004', '8999'] end context "service numbers" do it_splits '55100', ['55', '100', ""] it_splits '55199', ['55', '199', ""] end end describe "Bulgaria" do it_splits '35929284000', ['359', '2', '928', '4000'] # Sofia it_splits '359878357523', ['359', '87', '8357', '523'] it_splits '3593012345', ['359', '30', '12345'] it_splits '35930123456', ['359', '30', '12', '3456'] it_splits '35943312345', ['359', '433', '12345'] it_splits '3596012345', ['359', '60', '12345'] it_splits '35969123456', ['359', '69', '123456'] it_splits '35970512345', ['359', '705', '12345'] it_splits '3597051234', ['359', '705', '1234'] it_splits '3597112345', ['359', '71', '12345'] it_splits '35979123456', ['359', '79', '123456'] it_splits '35980112345', ['359', '801', '12345'] it_splits '3598112345', ['359', '81', '12345'] it_splits '35986123456', ['359', '86', '123456'] it_splits '359881234567', ['359', '88', '1234', '567'] it_splits '35990123456', ['359', '90', '123456'] it_splits '359988123456', ['359', '988', '123456'] it_splits '359998123456', ['359', '998', '123456'] end describe 'Cambodia' do it_splits '85512236142', ["855", "12", "236", "142"] # mobile (Mobitel) it_splits '855977100872', ["855", "97", "710", "0872"] # mobile (Metfone) it_splits '855234601183', ["855", "23", "460", "1183"] # Long fixed line (Phnom Penh) it_splits '85533234567', ["855", "33", "234", "567"] # Regular fixed line (Kampot) end describe 'Chile' do it_splits '5621234567', ['56', '2', '1234567'] # Santiago it_splits '5675123456', ['56', '75', '123456'] # Curico it_splits '56912345678', ['56', '9', '12345678'] # Mobile it_splits '56137123456', ['56', '137', '123', '456'] # Service end describe 'China' do it_splits '862112345678', ['86', '21', '1234', '5678'] # Shanghai it_splits '8675582193447', ['86', '755', '8219', '3447'] # Shenzhen end describe 'Colombia' do it_splits '5711234567', ['57', '1', '123', '4567'] it_splits '573101234567', ['57', '310', '123', '4567'] # mobile end describe 'Croatia' do it_splits '38521695900', %w( 385 21 695 900 ) # Landline it_splits '38514566666', %w( 385 1 4566 666 ) # Landline (Zagreb) it_splits '38599444999', %w( 385 99 444 999 ) # Mobile it_splits '385918967509', %w( 385 91 896 7509 ) # Mobile it_splits '3858001234', %w( 385 800 1234 ) # Toll free it_splits '385800123456', %w( 385 800 123 456 ) # Toll free it_splits '3856012345', %w( 385 60 12 345 ) # Premium rate it_splits '38562123456', %w( 385 62 123 456 ) # Premium, personal and UAN end describe 'Cuba' do it_splits '5351231234', ['53', '5123', '1234'] # Mobile it_splits '5371234567', ['53', '7', '1234567'] # Havana it_splits '5342123456', ['53', '42', '123456'] # Villa Clara end describe 'Cyprus' do it_splits '35712322123456', ['357', '123', '22', '123456'] # Voicemail it_splits '35722123456', ['357', '22', '123456'] # Fixed it_splits '35791123456', ['357', '91', '123456'] # Mobile end describe 'Denmark' do it_splits '4532121212', ['45', false, '32', '12', '12', '12'] end describe 'Egypt' do it_splits '20212345678', ['20', '2', '12345678'] it_splits '20921234567', ['20', '92', '1234567'] it_splits '20951234567', ['20', '95', '1234567'] end describe 'Equatorial Guinea' do it_splits '240222201123', ['240', false, '222', '201', '123'] it_splits '240335201123', ['240', false, '335', '201', '123'] end describe 'Estonia' do it_splits '3723212345', ['372', '321', '2345'] # Landline it_splits '37251231234', ['372', '5123', '1234'] # Mobile it_splits '3728001234', ['372', '800', '1234'] # Freephone it_splits '37281231234', ['372', '8123', '1234'] # Mobile it_splits '37282231234', ['372', '8223', '1234'] # Mobile it_splits '37252212345', ['372', '5221', '2345'] # Mobile it_splits '3725221234', ['372', '5221', '234'] # Mobile it_splits '37270121234', ['372', '7012', '1234'] # Premium end describe 'Finland' do it_splits '3589123123', ['358', '9', '123', '123'] # Helsinki it_splits '3581912312', ['358', '19', '123', '12'] # Nylandia it_splits '3585012312', ['358', '50', '123', '12'] # Mobile it_splits '35860012345', ['358', '6001', '23', '45'] # Service end describe 'France' do it_splits '33112345678', ['33', '1', '12','34','56','78'] # Paris it_splits '33812345678', ['33', '8', '12','34','56','78'] # Service number end describe 'Georgia' do it_splits '99522012345', %w(995 220 123 45) it_splits '995321234567', %w(995 32 123 4567) it_splits '995342123456', %w(995 342 123 456) it_splits '995596123456', %w(995 596 123 456) end describe 'Germany' do it_splits '493038625454', ['49', '30', '386', '25454'] # Berlin it_splits '4932221764542', ['49', '32', '221', '764542'] # Non-Geographical it_splits '4922137683323', ['49', '221', '376', '83323'] # Cologne it_splits '497614767676', ['49', '761', '476', '7676'] # Freiburg im Breisgau it_splits '4921535100', ['49', '2153', '510', '0'] # Nettetal-Lobberich it_splits '493434144602', ['49', '34341', '446', '02'] # Geithain it_splits '491805878323', ['49', '180', '587', '8323'] # Service number it_splits '491815878323', ['49', '181', '587', '8323'] # Service number it_splits '498001234567', ['49', '800', '123', '4567'] # Service number it_splits '49800222340010', ['49', '800', '222', '340010'] # Service number it_splits '4915111231234', ['49', '151', '1123', '1234'] # Mobile number it_splits '4915771231234', ['49', '157', '7123', '1234'] # Mobile number it_splits '491601234567', ['49', '160', '1234', '567'] # Mobile number it_splits '4916312345678', ['49', '163', '1234', '5678'] # Mobile number it_splits '4915211231234', ['49', '1521', '123', '1234'] # Mobile number end describe 'Ghana' do it_splits '233302123456', ['233', '30', '212', '3456'] # Mobile Vodafone, Accra end describe 'Gibraltar' do it_splits '35020012345', ['350', '200', '12345'] # Fixed it_splits '35021112345', ['350', '211', '12345'] # Fixed it_splits '35022212345', ['350', '222', '12345'] # Fixed it_splits '35054123456', ['350', '54', '123456'] # Mobile it_splits '35056123456', ['350', '56', '123456'] # Mobile it_splits '35057123456', ['350', '57', '123456'] # Mobile it_splits '35058123456', ['350', '58', '123456'] # Mobile it_splits '35060123456', ['350', '60', '123456'] # Mobile it_splits '3508012', ['350', '8012', '' ] # Freephone end describe 'Greece' do it_splits '302142345678', %w(30 21 4234 5678) it_splits '302442345678', %w(30 24 4234 5678) it_splits '305034571234', %w(30 50 3457 1234) it_splits '306901234567', %w(30 690 123 4567) it_splits '307001234567', %w(30 70 0123 4567) it_splits '308001001234', %w(30 800 100 1234) it_splits '308011001234', %w(30 801 100 1234) it_splits '308071001234', %w(30 807 100 1234) it_splits '308961001234', %w(30 896 100 1234) it_splits '309011234565', %w(30 901 123 4565) it_splits '309091234565', %w(30 909 123 4565) end describe 'Haiti' do it_splits '50922121234', ['509', '22', '12', '1234'] end describe 'Hong Kong' do it_splits '85212341234', ['852', false, '1234', '1234'] #Other Numbers it_splits '852800121234', ['852', '800', '12', '1234'] #Toll Free end describe 'Hungary' do it_splits'3612345678', ['36', '1', '234', '5678'] it_splits'3622123456', ['36', '22', '123', '456'] end describe 'Iceland' do it_splits '354112', ['354', false, '112'] # Emergency TODO it_splits '3544211234', ['354', false, '421', '1234'] # Keflavík it_splits '3544621234', ['354', false, '462', '1234'] # Akureyri it_splits '3545511234', ['354', false, '551', '1234'] # Reykjavík end describe 'Indonesia' do it_splits '6242323032', ["62", "4", "2323", "032"] it_splits '6285220119289', ['62', '852', '2011', '9289'] it_splits '62217815263', %w(62 21 781 5263) it_splits '6213123', %w(62 13 123) it_splits '6213123456', %w(62 13 123 456) it_splits '6217412', %w(62 174 12) it_splits '6217412345', %w(62 174 12 345) it_splits '6217712', %w(62 177 12) it_splits '6217712123456', %w(62 177 1212 3456) it_splits '62178123', %w(62 178 123) it_splits '6217812345', %w(62 178 123 45) it_splits '622112345', %w(62 21 123 45) it_splits '622112345567', %w(62 21 1234 5567) it_splits '622212345', %w(62 22 123 45) it_splits '62221234567', %w(62 22 123 4567) it_splits '622200000000', %w(62 22 0000 0000) it_splits '6222000000000', %w(62 22 000 000 000) it_splits '624311234', %w(62 4 311 234) it_splits '62431123456', %w(62 4 3112 3456) it_splits '6262212345', %w(62 6 221 2345) it_splits '62622123456', %w(62 6 2212 3456) it_splits '6270123456', %w(62 70 123 456) it_splits '6271123456', %w(62 71 123 456) it_splits '62711234567', %w(62 71 123 4567) it_splits '62810123456', %w(62 810 123 456) it_splits '6281012345678', %w(62 810 1234 5678) it_splits '628151234567', %w(62 815 123 4567) it_splits '62820123456', %w(62 820 123 456) it_splits '628231234567', %w(62 823 123 4567) it_splits '6282312345678', %w(62 823 1234 5678) it_splits '6287012345', %w(62 870 123 45) it_splits '62877123456', %w(62 877 123 456) it_splits '62881123456', %w(62 881 123 456) it_splits '6288112345656', %w(62 881 1234 5656) it_splits '62881123456567', %w(62 881 1234 56567) it_splits '628990344805', %w(62 899 034 4805) it_splits '6291234567', %w(62 9 1234 567) it_splits '629123456789', %w(62 9 123 456 789) end describe 'India' do it_splits '919911182111', ['91', '99', '111', '82', '111'] # mobile it_splits '912212345678', ['91', '22', '123', '45', '678'] # New Delhi it_splits '911411234567', ['91', '141', '123', '45', '67'] # Jaipur it_splits '913525123456', ['91', '3525', '123', '456'] # DALKHOLA it_splits '914433993939', ['91', '44', '339', '93', '939'] # end describe 'Iran' do it_splits '982112341234', ['98', '21', '1234', '1234'] # Teheran it_splits '989191231234', ['98', '919', '123', '1234'] # Example Cell Phone end describe 'Ireland' do it_splits '35311234567', ['353', '1', '123', '4567'] # Dublin, 7 digit subscriber # it_splits '353539233333', ['353', '53', '923', '3333'] # Wexford, 7 digit subscriber it_splits '3532212345', ['353', '22', '12345'] # Mallow, 5 digit subscriber # it_splits '353441234567', ['353', '44', '123', '4567'] # Mullingar, Castlepollard, Tyrellspass 7 digit subscriber # it_splits '35345123456', ['353', '45', '123456'] # Naas, 6 digit subscriber # it_splits '353801234567', ['353', '80', '123', '4567'] # Mobile it_splits '353761234567', ['353', '76', '123', '4567'] # VoIP it_splits '353800123456', ['353', '800', '123456'] # Freefone it_splits '353000123456', ['353', '000', '123456'] # Default fixed 3 split for unrecognized end describe 'Israel (972)' do it_splits '972100', ['972', '1', '00'] # Police it_splits '97221231234', ['972', '2', '123', '1234'] # Jerusalem Area it_splits '97282411234', ['972', '8', '241', '1234'] # Gaza Strip (Palestine) it_splits '97291231234', ['972', '9', '123', '1234'] # Sharon Area it_splits '972501231234', ['972', '50', '123', '1234'] # Mobile (Pelephone) it_splits '972591231234', ['972', '59', '123', '1234'] # Mobile Jawwal (Palestine) it_splits '972771231234', ['972', '77', '123', '1234'] # Cable Phone Services it_splits '9721700123123', ['972', '1', '700', '123', '123'] # Cable Phone Services it_splits '972511234567', ['972', '51', '123', '4567'] # Mobile (We4G) end describe 'Israel (970)' do it_splits '97021231234', ['970', '2', '123', '1234'] # Jerusalem Area it_splits '97082411234', ['970', '8', '241', '1234'] # Gaza Strip (Palestine) it_splits '97091231234', ['970', '9', '123', '1234'] # Sharon Area it_splits '970501231234', ['970', '50', '123', '1234'] # Mobile (Pelephone) it_splits '970591231234', ['970', '59', '123', '1234'] # Mobile Jawwal (Palestine) it_splits '970771231234', ['970', '77', '123', '1234'] # Cable Phone Services it_splits '9701700123123', ['970', '1', '700', '123', '123'] # Cable Phone Services end describe 'Italy' do it_splits '39348695281', ['39', '348', '695', '281'] # Mobile (6-digit subscriber no. - rare, but still used) it_splits '393486952812', ['39', '348', '695', '2812'] # Mobile (7-digit subscriber no. - common) it_splits '3934869528123',['39', '348', '695', '2812', '3'] # Mobile (8-digit subscriber no - new) it_splits '393357210488', ['39', '335', '721', '0488'] # Mobile it_splits '393248644272', ['39', '324', '864', '4272'] # Mobile it_splits '3906123412', ['39', '06', '1234', '12'] # Roma 6 digit it_splits '39061234123', ['39', '06', '1234', '123'] # Roma 7 digit it_splits '390612341234', ['39', '06', '1234', '1234'] # Roma 8 digit it_splits '3902888388', ['39', '02', '8883', '88'] # Milano 6 digit it_splits '39028883888', ['39', '02', '8883', '888'] # Milano 7 digit it_splits '390288838883', ['39', '02', '8883', '8883'] # Milano 8 digit it_splits '390141595661', ['39', '0141', '595', '661'] # Asti it_splits '3903123391', ['39', '031', '23391'] # Como it_splits '390909709511', ['39', '090', '9709511'] # Barcellona it_splits '390471811353', ['39', '0471', '811', '353'] # Bolzano end describe 'Japan' do it_splits '81312345678', %w(81 3 1234 5678) # Tokyo it_splits '81612345678', %w(81 6 1234 5678) # Osaka it_splits '818001001234', %w(81 800 100 1234) # Freephone it_splits '81120123456', %w(81 120 123 456) # Freephone it_splits '81111234567', %w(81 11 123 4567) it_splits '81123123456', %w(81 123 12 3456) it_splits '81126712345', %w(81 1267 1 2345) it_splits '812012345678', %w(81 20 1234 5678) # Pager(Calling Party Pay) it_splits '815012345678', %w(81 50 1234 5678) # IP Telephone it_splits '816012345678', %w(81 60 1234 5678) # UPT it_splits '817012345678', %w(81 70 1234 5678) # PHS it_splits '818012345678', %w(81 80 1234 5678) # Cellular it_splits '819012345678', %w(81 90 1234 5678) # Cellular end describe 'Kenya' do it_splits '254201234567', ['254', '20', '1234567'] # Nairobi it_splits '254111234567', ['254', '11', '1234567'] # Mombasa it_splits '254723100220', ['254', '723', '100220'] # Mombasa end describe 'Kosovo' do it_splits '38329000000', ['383', '29', '000', '000'] # Landline it_splits '38344000000', ['383', '44', '000', '000'] # Mobile end describe 'Kyrgyzstan' do it_splits '996312212345', %w(996 312 212 345) it_splits '996315212345', %w(996 315 212 345) it_splits '996313121234', %w(996 3131 212 34) it_splits '996394621234', %w(996 3946 212 34) it_splits '996501234567', %w(996 50 123 4567) it_splits '996521234567', %w(996 52 123 4567) it_splits '996581234567', %w(996 58 123 4567) it_splits '996800123456', %w(996 800 123 456) end describe 'Lithuania' do it_splits '37070012123', ['370', '700', '12', '123'] # Service it_splits '37061212123', ['370', '612', '12', '123'] # Mobile it_splits '37051231212', ['370', '5', '123', '12', '12'] # Vilnius it_splits '37037121212', ['370', '37', '12', '12', '12'] # Kaunas it_splits '37044011212', ['370', '440', '1', '12', '12'] # Skuodas end describe 'Luxembourg' do it_splits '352222809', ['352', '22', '28', '09'] it_splits '35226222809', ['352', '2622', '28', '09'] it_splits '352621123456', ['352', '621', '123', '456'] it_splits '3524123456', ['352', '41', '23', '45', '6'] it_splits '352602112345678', ['352', '6021', '12', '34', '56', '78'] it_splits '352370431', ['352', '37', '04', '31'] it_splits '35227855', ['352', '27', '85', '5'] it_splits '352445566', ['352', '44', '55', '66'] it_splits '352545258', ['352', '54', '52', '58'] it_splits '352818181', ['352', '81', '81', '81'] it_splits '3523572141', ['352', '35', '72', '14', '1'] end describe 'Macedonia' do it_splits '38921234567', ['389', '2', '123', '4567'] # Skopje it_splits '38931234567', ['389', '3', '123', '4567'] # Eastern Macedonia it_splits '38941234567', ['389', '4', '123', '4567'] # Western Macedonia it_splits '38951234567', ['389', '5', '123', '4567'] # Premium it_splits '38971234567', ['389', '7', '123', '4567'] # Mobile end describe 'Macao' do it_splits '85328123456', ["853", "28", "12", "3456"] # Landline it_splits '85381234567', ["853", "8", "123", "4567"] # Landline it_splits '85361234567', ["853", "6", "123", "4567"] # Mobile end describe 'Malaysia' do it_splits '6082123456', ['60', '82', '123456'] # Kuching it_splits '60312345678', ['60', '3', '12345678'] # Kuala Lumpur it_splits '60212345678', ['60', '2', '12345678'] # Singapore it_splits '60111231234', ['60', '11', '123', '1234'] # Mobile it_splits '601112312345', ['60', '11', '123', '12345'] # Mobile it_splits '60800121234', ['60', '800', '12', '1234'] # Freephone # it_splits '60112', ['60', '112'] # Service end describe 'Malta' do it_splits '35621231234', ['356', '2123', '1234'] # Fixed it_splits '35677123456', ['356', '77', '123456'] # Mobile it_splits '35698123456', ['356', '98', '123456'] # Mobile it_splits '35651231234', ['356', '5123', '1234'] # Voice Mail end describe 'Mexico' do it_splits '525512121212', ['52', '55', '1212', '1212'] # Mexico City it_splits '5215512121212', ['52', '1', '55', '1212', '1212'] # Mexico City cell phone from abroad it_splits '526641231212', ['52', '664', '123', '1212'] # Tijuana it_splits '5216641231212', ['52', '1', '664', '123', '1212'] # Tijuana cell phone from abroad it_splits '520446641231212', ['52', '044', '664', '123', '1212'] # Tijuana cell phone local from landline end describe 'Monaco' do it_splits '37741123456', ['377', '41', '12', '34', '56'] # Mobile it_splits '377612345678', ['377', '6', '12', '34', '56', '78'] # Mobile end describe 'Montenegro' do it_splits '38280123456', %w(382 80 123 456) it_splits '3822012345', %w(382 20 123 45) it_splits '38220123456', %w(382 20 123 456) it_splits '38232123456', %w(382 32 123 456) it_splits '38278103456', %w(382 78 103 456) it_splits '38263123', %w(382 63 123) it_splits '382631234567890', %w(382 63 123 456 7890) it_splits '38277103456', %w(382 77 103 456) it_splits '38294103456', %w(382 94 103 456) it_splits '38288103456', %w(382 88 103 456) it_splits '3826812', %w(382 68 12) it_splits '382681212345678', %w(382 68 12 1234 5678) it_splits '38270123', %w(382 70 123) it_splits '382701234567890', %w(382 70 123 456 7890) end describe 'Morocco' do it_splits '212537718685', ['212', '53', '7718', '685'] it_splits '212612345678', ['212', '6', '12', '34', '56', '78'] end describe 'The Netherlands' do it_splits '31612345678', ['31', '6', '12', '34', '56', '78'] # mobile it_splits '31201234567', ['31', '20', '123', '4567'] it_splits '31222123456', ['31', '222', '123', '456'] it_splits '3197012345678', ['31', '970', '1234', '5678'] # machine-to-machine end describe 'Norway' do it_splits '4721234567', ['47',false,'21','23','45','67'] it_splits '4731234567', ['47',false,'31','23','45','67'] it_splits '4741234567', ['47',false,'412','34','567'] it_splits '4751234567', ['47',false,'51','23','45','67'] it_splits '4761234567', ['47',false,'61','23','45','67'] it_splits '4771234567', ['47',false,'71','23','45','67'] it_splits '4781234567', ['47',false,'812','34','567'] it_splits '4791234567', ['47',false,'912','34','567'] end describe 'Oman' do it_splits '96824423123', %w(968 24 423 123) it_splits '96825423123', %w(968 25 423 123) end describe 'Pakistan' do it_splits '922112345678', %w(92 21 1234 5678) it_splits '92221234567', %w(92 22 1234 567) it_splits '92232123456', %w(92 232 123 456) it_splits '923012345678', %w(92 30 1234 5678) end describe 'Paraguay (Republic of)' do it_splits '59521123456', %w(595 21 123 456) it_splits '595211234567', %w(595 21 123 4567) it_splits '595345123456', %w(595 345 123 456) it_splits '595961611234', %w(595 96 161 1234) end describe 'Peru' do it_splits '5111231234', ['51', '1', '123', '1234'] # Lima it_splits '51912341234', ['51', '9', '1234', '1234'] # mobile it_splits '5184123123', ['51', '84', '123', '123'] # Cuzco, best effort end describe 'Philippines' do it_splits '6321234567', ['63', '2', '1234567'] it_splits '6321234567890', ['63', '2', '1234567890'] it_splits '632123456789012', ['63', '2', '123456789012'] it_splits '639121234567', ['63', '912', '1234567'] it_splits '63881234567', ['63', '88', '1234567'] end describe 'Poland' do it_splits '48123456789', ['48', '12', '345', '67', '89'] # Landline it_splits '48501123456', ['48', '501', '123', '456'] # Mobile it_splits '48571123456', ['48', '571', '123', '456'] # Mobile it_splits '48451123456', ['48', '451', '123', '456'] # Mobile it_splits '48800123456', ['48', '800', '123', '456'] # Free it_splits '48801123456', ['48', '801', '123', '456'] # Shared cost it_splits '48701123456', ['48', '701', '123', '456'] # Premium end describe 'Portugal' do it_splits '351211231234', ['351', '21', '123', '1234'] # Lisboa it_splits '351241123123', ['351', '241', '123', '123'] # Abrantes it_splits '351931231234', ['351', '93', '123', '1234'] # mobile end describe 'Qatar' do it_splits '9741245123456', %w(974 1245 123 456) it_splits '9742613456', %w(974 26 134 56) it_splits '97433123456', %w(974 33 123 456) it_splits '97444412456', %w(974 44 412 456) it_splits '9748001234', %w(974 800 12 34) it_splits '9749001234', %w(974 900 12 34) it_splits '97492123', %w(974 92 123) it_splits '97497123', %w(974 97 123) end describe 'Romania' do it_splits '40211231234', ['40', '21', '123', '1234'] # Bucureşti it_splits '40721231234', ['40', '72', '123', '1234'] # mobile it_splits '40791231234', ['40', '79', '123', '1234'] # mobile it_splits '40249123123', ['40', '249', '123', '123'] # Olt end describe 'Russia' do it_splits '78122345678', ['7', '812', '234', '56', '78'] # Russia 3-digit it_splits '74012771077', ['7', '4012', '77', '10', '77'] # Russia 4-digit it_splits '78402411212', ['7', '84024', '1', '12', '12'] # Russia 5-digit it_splits '79296119119', ['7', '929', '611', '91', '19'] # Russia 3-digit, Megafon Mobile it_splits '79691234567', ['7', '969', '123', '45', '67'] # Russia 3-digit, Beeline it_splits '79771234567', ['7', '977', '123', '45', '67'] # Russia 3-digit it_splits '79961234567', ['7', '996', '123', '45', '67'] # Russia 3-digit it_splits '79991234567', ['7', '999', '123', '45', '67'] # Russia 3-digit it_splits '7840121212', ['7', '840', '12', '1212'] # Abhasia it_splits '7799121212', ['7', '799', '12', '1212'] # Kazachstan it_splits '7995344121212', ['7', '995', '344','12','1212'] # South Osetia it_splits '7209175276', ['7', '209', '17', '5276'] # Fantasy number end describe 'Rwanda' do it_splits '250781234567', ['250', '78', '1234567'] # mobile it_splits '250721234567', ['250', '72', '1234567'] # mobile it_splits '250731234567', ['250', '73', '1234567'] # mobile it_splits '250251234567', ['250', '25', '1234567'] # fixed it_splits '25006123456', ['250', '06', '123456'] # fixed end describe 'Sao Tome and Principe' do it_splits '2392220012', %w(239 2 220 012) it_splits '2399920012', %w(239 9 920 012) end describe 'South Korea' do it_splits '82212345678', ['82', '2', '1234', '5678'] # Seoul (8 digits) it_splits '8227111222', ['82', '2', '711', '1222'] # Seoul (7 digits) it_splits '825112345678', ['82', '51', '1234', '5678'] # Busan (8 digits) it_splits '82511234567', ['82', '51', '123', '4567'] # Busan (7 digits) it_splits '821027975588', ['82', '10', '2797', '5588'] # mobile it_splits '821087971234', ['82', '10', '8797', '1234'] # mobile end describe 'Serbia' do it_splits '38163512529', ['381', '63', '512', '529'] end describe 'South Sudan' do it_splits '211123212345', ['211', '123', '212', '345'] it_splits '211973212345', ['211', '973', '212', '345'] end describe 'Sudan' do it_splits '249187171100', ['249', '18', '717', '1100'] end describe 'Thailand' do it_splits '6621231234', ['66', '2', '123', '1234'] # Bangkok it_splits '6636123123', ['66', '36', '123', '123'] # Lop Buri it_splits '66851234567', ['66', '851', '234', '567'] # Lop Buri it_splits '66921234567', ['66', '921', '234', '567'] # mobile end describe 'Tunesia' do it_splits '21611231234', ['216', '1', '123', '1234'] # Ariana it_splits '21621231234', ['216', '2', '123', '1234'] # Bizerte end describe 'Salvador (El)' do it_splits '50321121234', ['503', '2112', '1234'] # Fixed number it_splits '50361121234', ['503', '6112', '1234'] # Mobile number end describe 'Singapore' do it_splits '6561231234', ['65', false, '6123', '1234'] # Fixed line it_splits '658008521234', ['65', false, '800', '852', '1234'] # International Toll Free Service (ITFS) and Home Country Direct Service (HCDS) Numbers end describe 'Slovakia' do it_splits '421912123456', ['421', '912', '123456'] # Mobile it_splits '421212345678', ['421', '2', '12345678'] # Bratislava it_splits '4212123', ['421', '2', '123'] # Bratislava Short it_splits '421371234567', ['421', '37', '1234567'] # Nitra / Other it_splits '42137123', ['421', '37', '123'] # Nitra / Other Short end describe 'Slovenia' do it_splits '38651234567', ['386', '51', '234', '567'] # Mobile it_splits '38611234567', ['386', '1', '123', '4567'] # LJUBLJANA end describe 'Spain' do it_splits '34600123456', ['34', '600', '123', '456'] # Mobile it_splits '34900123456', ['34', '900', '123', '456'] # Special it_splits '34931234567', ['34', '93', '123', '45', '67'] # Landline large regions it_splits '34975123456', ['34', '975', '12', '34', '56'] # Landline it_splits '34123456789', ['34', '123', '456', '789'] # Default end describe 'Sri Lanka' do it_splits '94711231212', ['94', '71', '123', '12', '12'] # Mobile end describe 'Sweden' do it_splits '46812345678', ['46', '8', '123', '45', '678'] # Stockholm it_splits '46111234567', ['46', '11', '123', '45', '67'] it_splits '46721234567', ['46', '72', '123', '45', '67'] # mobile it_splits '46791234567', ['46', '79', '123', '45', '67'] # mobile it_splits '46125123456', ['46', '125', '12', '34', '56'] it_splits '46770820180', ['46', '77', '082', '01', '80'] it_splits '4641712345', ['46', '417', '123', '45'] it_splits '46513123456', ['46', '513', '12', '34', '56'] end describe 'Switzerland' do it_splits '41443643532', ['41', '44', '364', '35', '32'] # Zurich (usually) it_splits '41800334455', ['41', '800', '334', '455'] # Service number it_splits '41900123456', ['41', '900', '123', '456'] # Business Number it_splits '41901123456', ['41', '901', '123', '456'] # Business Number Entertainment it_splits '41906123456', ['41', '906', '123', '456'] # Business Number Adult Entertainment end describe 'Tanzania' do it_splits '255221231234', ['255', '22', '123', '1234'] # Dar Es Salaam it_splits '255651231234', ['255', '65', '123', '1234'] # TIGO it_splits '255861123123', ['255', '861', '123', '123'] # Special Rates end describe 'Turkey' do it_splits '903121234567', ['90', '312', '123', '4567'] # Ankara end describe 'Uganda' do it_splits '256414123456', ['256', '41', '4123456'] # Kampania it_splits '256464441234', ['256', '464', '441234'] # Mubende end describe 'The UK' do it_splits '442075671113', ['44', '20', '7567', '1113'] # [2+8] London it_splits '442920229901', ['44', '29', '2022', '9901'] # [2+8] Cardiff it_splits '441134770011', ['44', '113', '477', '0011'] # [3+7] Leeds it_splits '441412770022', ['44', '141', '277', '0022'] # [3+7] Glasgow it_splits '441204500532', ['44', '1204', '500532'] # [4+6] Bolton it_splits '44120462532', ['44', '1204', '62532'] # [4+5] Bolton it_splits '441333247700', ['44', '1333', '247700'] # [4+6] Leven (Fife) it_splits '441382229845', ['44', '1382', '229845'] # [4+6] Dundee it_splits '441420700378', ['44', '1420', '700378'] # [4+6] Alton it_splits '44142080378', ['44', '1420', '80378'] # [4+5] Alton it_splits '441475724688', ['44', '1475', '724688'] # [4+6] Greenock it_splits '441539248756', ['44', '1539', '248756'] # [4+6] Kendal (Mixed area) it_splits '441539648788', ['44', '15396', '48788'] # [5+5] Sedbergh (Mixed area) it_splits '441652757248', ['44', '1652', '757248'] # [4+6] Brigg it_splits '441664333456', ['44', '1664', '333456'] # [4+6] Melton Mowbray it_splits '441697222555', ['44', '1697', '222555'] # [4+6] Brampton (Mixed area) it_splits '441697388555', ['44', '16973', '88555'] # [5+5] Wigton (Mixed area) it_splits '441697433777', ['44', '16974', '33777'] # [5+5] Raughton Head (Mixed area) it_splits '44169772333', ['44', '16977', '2333'] # [5+4] Brampton (Mixed area) it_splits '441697744888', ['44', '16977', '44888'] # [5+5] Brampton (Mixed area) it_splits '441757850526', ['44', '1757', '850526'] # [4+6] Selby it_splits '441890234567', ['44', '1890', '234567'] # [4+6] Coldstream (ELNS area) it_splits '441890595378', ['44', '1890', '595378'] # [4+6] Ayton (ELNS area) it_splits '441931306526', ['44', '1931', '306526'] # [4+6] Shap it_splits '441946555777', ['44', '1946', '555777'] # [4+6] Whitehaven (Mixed area) it_splits '44194662888', ['44', '1946', '62888'] # [4+5] Whitehaven (Mixed area) it_splits '441946722444', ['44', '19467', '22444'] # [5+5] Gosforth (Mixed area) it_splits '441987705337', ['44', '1987', '705337'] # [4+6] Ebbsfleet it_splits '443005828323', ['44', '300', '582', '8323'] # Non-geographic (NTS) it_splits '443334253344', ['44', '333', '425', '3344'] # Non-geographic (NTS) it_splits '443437658834', ['44', '343', '765', '8834'] # Non-geographic (NTS) it_splits '443452273512', ['44', '345', '227', '3512'] # Non-geographic (NTS) it_splits '443707774444', ['44', '370', '777', '4444'] # Non-geographic (NTS) it_splits '443725247722', ['44', '372', '524', '7722'] # Non-geographic (NTS) it_splits '44500557788', ['44', '500', '557788'] # Freefone (500 + 6) it_splits '445575671113', ['44', '55', '7567', '1113'] # Corporate numbers it_splits '445644775533', ['44', '56', '4477', '5533'] # LIECS/VoIP it_splits '447020229901', ['44', '70', '2022', '9901'] # Personal numbers it_splits '447688554246', ['44', '76', '8855', '4246'] # Pager it_splits '447180605207', ['44', '7180', '605207'] # Mobile it_splits '447480605207', ['44', '7480', '605207'] # Mobile it_splits '447624605207', ['44', '7624', '605207'] # Mobile (Isle of Man) it_splits '447780605207', ['44', '7780', '605207'] # Mobile it_splits '447980605207', ['44', '7980', '605207'] # Mobile it_splits '44800557788', ['44', '800', '557788'] # Freefone (800 + 6) it_splits '448084682355', ['44', '808', '468', '2355'] # Freefone (808 + 7) it_splits '448005878323', ['44', '800', '587', '8323'] # Freefone (800 + 7), regression it_splits '448437777334', ['44', '843', '777', '7334'] # Non-geographic (NTS) it_splits '448457777334', ['44', '845', '777', '7334'] # Non-geographic (NTS) it_splits '448707777334', ['44', '870', '777', '7334'] # Non-geographic (NTS) it_splits '448727777334', ['44', '872', '777', '7334'] # Non-geographic (NTS) it_splits '449052463456', ['44', '905', '246', '3456'] # Non-geographic (PRS) it_splits '449122463456', ['44', '912', '246', '3456'] # Non-geographic (PRS) it_splits '449832463456', ['44', '983', '246', '3456'] # Non-geographic (SES) end describe 'US' do it_splits '15551115511', ['1', '555', '111', '5511'] end describe 'Venezuela' do it_splits '582121234567', ['58', '212', '1234567'] end describe 'Vietnam' do it_splits '8498123456', ['84', '98', '123456'] # Viettel Mobile it_splits '8499612345', ['84', '99', '612345'] # GTel it_splits '842421234567', ['84', '24', '2123', '4567'] # Hanoi it_splits '842841234567', ['84', '28', '4123', '4567'] # Ho Chi Minh City it_splits '84341234567', ['84', '34', '1234567'] # Viettel it_splits '84841234567', ['84', '84', '1234567'] # Vinaphone end describe 'Zambia' do it_splits '260211123456', ['260', '211', '123456'] # Fixed it_splits '260955123456', ['260', '955', '123456'] # Mobile it_splits '260967123456', ['260', '967', '123456'] # Mobile it_splits '260978123456', ['260', '978', '123456'] # Mobile it_splits '260800123456', ['260', '800', '123', '456'] # Toll free end describe 'New Zealand' do it_splits '6491234567', ['64', '9', '123', '4567'] it_splits '64800123123', ['64', '800', '123', '123'] it_splits '648001231234', ['64', '800', '123', '1234'] end describe 'Bhutan (Kingdom of)' do it_splits '9759723642', %w(975 9 723 642) end describe 'Brunei Darussalam' do it_splits '6737932744', %w(673 7 932 744) end describe 'Burkina Faso' do it_splits '22667839323', ['226', false, '6783', '9323'] end describe 'Burundi' do it_splits '25712345678', ['257', false, '1234', '5678'] end describe 'Cameroon' do it_splits '237276593812', ['237', false, '276', '59', '38', '12'] end describe 'Cape Verde' do it_splits '2385494177', ['238', false, '549', '4177'] end describe 'Central African Republic' do it_splits '23612345678', ['236', false, '1234', '5678'] end describe 'Chad' do it_splits '23512345678', ['235', false, '1234', '5678'] end describe 'Comoros' do it_splits '2693901234', ['269', false, '3901', '234'] it_splits '2693401234', ['269', false, '3401', '234'] end describe 'Congo' do it_splits '242123456789', ['242', false, '1234', '56789'] end describe 'Cook Islands' do it_splits '68251475', ['682', false, '51', '475'] end describe 'Costa Rica' do it_splits '50622345678', %w(506 2 234 5678) end describe "Côte d'Ivoire" do it_splits '22507335518', ['225', '07', '33', '55', '18'] it_splits '22537335518', ['225', '37', '33', '55', '18'] end describe 'Democratic Republic of Timor-Leste' do it_splits '6701742945', ['670', false, '174', '2945'] end describe 'Democratic Republic of the Congo' do it_splits '243121995381', %w(243 12 199 5381) end describe 'Diego Garcia' do it_splits '2461234683', ['246', false, '123', '4683'] end describe 'Djibouti' do it_splits '25349828978', ['253', false, '4982', '8978'] end describe 'Ecuador' do it_splits '593220000000', %w(593 22 000 0000) it_splits '59322000000', %w(593 2 200 0000) it_splits '593230000000', %w(593 23 000 0000) it_splits '59323000000', %w(593 2 300 0000) it_splits '59324000000', %w(593 2 400 0000) it_splits '59325000000', %w(593 2 500 0000) it_splits '593260000000', %w(593 26 000 0000) it_splits '59327000000', %w(593 2 700 0000) it_splits '593270000000', %w(593 27 000 0000) it_splits '59330000000', %w(593 3 000 0000) it_splits '59340000000', %w(593 4 000 0000) it_splits '593440000000', %w(593 44 000 0000) it_splits '593450000000', %w(593 45 000 0000) it_splits '59345000000', %w(593 4 500 0000) it_splits '59346000000', %w(593 4 600 0000) it_splits '593470000000', %w(593 47 000 0000) it_splits '59352000000', %w(593 5 200 0000) it_splits '59353000000', %w(593 5 300 0000) it_splits '59362000000', %w(593 6 200 0000) it_splits '59372000000', %w(593 7 200 0000) it_splits '59373000000', %w(593 7 300 0000) it_splits '59374000000', %w(593 7 400 0000) it_splits '59376000000', %w(593 7 600 0000) it_splits '593900000000', %w(593 9 0000 0000) end describe 'Eritrea' do it_splits '2916537192', %w(291 6 537 192) end describe 'Ethiopia' do it_splits '251721233486', %w(251 72 123 3486) end describe 'Falkland Islands (Malvinas)' do it_splits '50014963', ['500', false, '14', '963'] end describe 'Faroe Islands' do it_splits '298997986', ['298', false, '997', '986'] end describe 'Fiji (Republic of)' do it_splits '6798668123', ['679', false, '866', '8123'] end describe 'French Guiana (French Department of)' do it_splits '594594123456', %w(594 594 123 456) end describe "French Polynesia (Territoire français d'outre-mer)" do it_splits '68921988900', ['689', false, '21', '98', '89', '00'] end describe 'Gabonese Republic' do it_splits '2411834375', ['241', '1', '834', '375'] end describe 'Gambia' do it_splits '2206683355', ['220', false, '668', '3355'] end describe 'Greenland' do it_splits '299314185', ['299', '31', '4185'] it_splits '299691123', ['299', '691', '123'] end describe 'Guadeloupe (French Department of)' do it_splits '590590456789', %w(590 590 45 67 89) end describe 'Guatemala (Republic of)' do it_splits '50219123456789', ['502', '19', '123', '456', '789'] it_splits '50221234567', ['502', '2', '123', '4567'] end describe 'Guinea' do it_splits '22430311234', ['224', '3031', '12', '34'] it_splits '224662123456', ['224', '662', '12', '34', '56'] end describe 'Guinea-Bissau' do it_splits '245443837652', ['245', false, '44', '383', '7652'] end describe 'Guyana' do it_splits '5922631234', %w(592 263 1234) end describe 'Honduras (Republic of)' do it_splits '50412961637', %w(504 12 961 637) end describe 'Iraq' do it_splits '96411234567', %w(964 1 123 4567) it_splits '96421113456', %w(964 21 113 456) it_splits '9647112345678', %w(964 71 1234 5678) end describe 'Jordan (Hashemite Kingdom of)' do it_splits '96280012345', %w(962 800 123 45) it_splits '96226201234', %w(962 2 620 1234) it_splits '962712345678', %w(962 7 1234 5678) it_splits '962746612345', %w(962 7 4661 2345) it_splits '96290012345', %w(962 900 123 45) it_splits '96285123456', %w(962 85 123 456) it_splits '96270123456', %w(962 70 123 456) it_splits '96262501456', %w(962 6250 1456) it_splits '96287901456', %w(962 8790 1456) end describe 'Kiribati (Republic of)' do it_splits '68634814', ['686', false, '34', '814'] end describe "Democratic People's Republic of Korea" do it_splits '850212345', %w(850 2 123 45) it_splits '8502123456789', %w(850 2 123 456 789) it_splits '85023812356', %w(850 2 381 2356) #it_splits '85028801123456781256', %w(850 2 8801 1234 5678 1256) it_splits '8501911234567', %w(850 191 123 4567) end describe 'Kuwait (State of)' do it_splits '96523456789', ['965', false, '2345', '6789'] it_splits '9651812345', ['965', false, '181', '2345'] end describe "Lao People's Democratic Republic" do it_splits '85697831195', %w(856 97 831 195) end describe 'Latvia' do it_splits '37180123456', %w(371 801 234 56) it_splits '37163723456', %w(371 637 234 56) it_splits '37129412345', %w(371 294 123 45) end describe 'Lebanon' do it_splits '9611123456', %w(961 1 123 456) it_splits '9614123456', %w(961 4 123 456) it_splits '9613123456', %w(961 3 123 456) it_splits '96170123456', %w(961 70 123 456) it_splits '96190123456', %w(961 90 123 456) it_splits '96181123456', %w(961 81 123 456) end describe 'Lesotho' do it_splits '26623592495', ['266', false, '2359', '2495'] end describe 'Liberia' do it_splits '23121234567', ['231', false, '2123', '4567'] it_splits '2314123456', ['231', false, '4123', '456'] it_splits '231771234567', ['231', false, '77', '123', '4567'] end describe 'Libya' do it_splits '21820512345', %w(218 205 123 45) it_splits '21822123456', %w(218 22 123 456) it_splits '218211234456', %w(218 21 1234 456) it_splits '218911234456', %w(218 91 1234 456) end describe 'Madagascar' do it_splits '26120012345678', ['261', false, '20', '012', '345', '678'] it_splits '261201243456', ['261', false, *%w(20 124 3456)] it_splits '261512345678', ['261', false, *%w(512 345 678)] end describe 'Malawi' do it_splits '2651725123', ['265', false, '1725', '123'] it_splits '265213456789',[ '265', false, '213', '456', '789'] it_splits '2659123456', ['265', false, '9123', '456'] it_splits '265991123456', ['265', false, '991', '123', '456'] end describe 'Maldives (Republic of)' do it_splits '9606568279', ['960', '656', '8279'] end describe 'Mali' do it_splits '22379249349', ['223', false, '7924', '9349'] end describe 'Marshall Islands (Republic of the)' do it_splits '6924226536', ['692', false, '422', '6536'] end describe 'Martinique (French Department of)' do it_splits '596596123456', %w(596 596 12 34 56) end describe 'Mauritania' do it_splits '22212345678', ['222', false, '1234', '5678'] end describe 'Mauritius' do it_splits '23059518919', ['230', false, '5951', '8919'] end describe 'Micronesia (Federated States of)' do it_splits '6911991754', ['691', false, '199', '1754'] end describe 'Moldova' do it_splits '37380012345', %w(373 800 123 45) it_splits '37322123345', %w(373 22 123 345) it_splits '37324112345', %w(373 241 123 45) it_splits '37360512345', %w(373 605 123 45) it_splits '37380312345', %w(373 803 123 45) end describe 'Mongolia' do it_splits '9761112345', %w(976 11 123 45) it_splits '9761211234', %w(976 121 12 34) it_splits '97612112345', %w(976 121 12 345) it_splits '97670123456', %w(976 70 123 456) it_splits '97675123456', %w(976 75 123 456) it_splits '97688123456', %w(976 88 123 456) it_splits '97650123456', %w(976 50 123 456) end describe 'Mozambique' do it_splits '258600123456', %w(258 600 123 456) it_splits '25825112345', %w(258 251 123 45) it_splits '258821234456', %w(258 82 1234 456) it_splits '258712344567', %w(258 7 1234 4567) end describe 'Namibia' do it_splits '264675161324', %w(264 6751 613 24) it_splits '26467175890', %w(264 67 175 890) it_splits '26463088612345', %w(264 63 088 612 345) it_splits '264851234567', %w(264 85 1234 567) end describe 'Nauru (Republic of)' do it_splits '6741288739', ['674', false, '128', '8739'] end describe 'Nepal' do it_splits '97714345678', %w(977 1 434 5678) it_splits '97710123456', %w(977 10 123 456) it_splits '9779812345678', %w(977 98 1234 5678) end describe "New Caledonia (Territoire français d'outre-mer)" do it_splits '687747184', ['687', false, '747', '184'] end describe 'Nicaragua' do it_splits '50512345678', ['505', '12', '345', '678'] end describe 'Niger' do it_splits '22712345678', ['227', false, '1234', '5678'] end describe 'Nigeria' do it_splits '23411231234', %w(234 1 123 1234) # Lagos # mobile numbers it_splits '2347007661234', %w(234 700 766 1234) it_splits '2347017661234', %w(234 701 766 1234) it_splits '2347027661234', %w(234 702 766 1234) it_splits '2347037661234', %w(234 703 766 1234) it_splits '2347047661234', %w(234 704 766 1234) it_splits '2347057661234', %w(234 705 766 1234) it_splits '2347067661234', %w(234 706 766 1234) it_splits '2347077661234', %w(234 707 766 1234) it_splits '2347087661234', %w(234 708 766 1234) it_splits '2347097661234', %w(234 709 766 1234) it_splits '2348007661234', %w(234 800 766 1234) it_splits '2348017661234', %w(234 801 766 1234) it_splits '2348027661234', %w(234 802 766 1234) it_splits '2348037661234', %w(234 803 766 1234) it_splits '2348047661234', %w(234 804 766 1234) it_splits '2348057661234', %w(234 805 766 1234) it_splits '2348067661234', %w(234 806 766 1234) it_splits '2348077661234', %w(234 807 766 1234) it_splits '2348087661234', %w(234 808 766 1234) it_splits '2348097661234', %w(234 809 766 1234) it_splits '2349007661234', %w(234 900 766 1234) it_splits '2349017661234', %w(234 901 766 1234) it_splits '2349027661234', %w(234 902 766 1234) it_splits '2349037661234', %w(234 903 766 1234) it_splits '2349047661234', %w(234 904 766 1234) it_splits '2349057661234', %w(234 905 766 1234) it_splits '2349067661234', %w(234 906 766 1234) it_splits '2349077661234', %w(234 907 766 1234) it_splits '2349087661234', %w(234 908 766 1234) it_splits '2349097661234', %w(234 909 766 1234) it_splits '2348107661234', %w(234 810 766 1234) it_splits '2348117661234', %w(234 811 766 1234) it_splits '2348127661234', %w(234 812 766 1234) it_splits '2348137661234', %w(234 813 766 1234) it_splits '2348147661234', %w(234 814 766 1234) it_splits '2348157661234', %w(234 815 766 1234) it_splits '2348167661234', %w(234 816 766 1234) it_splits '2348177661234', %w(234 817 766 1234) it_splits '2348187661234', %w(234 818 766 1234) it_splits '2348197661234', %w(234 819 766 1234) end describe 'Niue' do it_splits '6833651', ['683', false, '3651'] end describe 'Palau (Republic of)' do it_splits '6804873653', ['680', false, '487', '3653'] end describe 'Panama (Republic of)' do it_splits '5078001234', %w(507 800 1234) it_splits '50761234567', %w(507 6 123 4567) it_splits '5072123456', %w(507 2 123 456) end describe 'Papua New Guinea' do it_splits '6753123567', %w(675 3 123 567) it_splits '6751801234', %w(675 180 1234) it_splits '67580123456', %w(675 80 123 456) it_splits '67591123456', %w(675 91 123 456) it_splits '6751612345', %w(675 16 123 45) it_splits '67518412345678', %w(675 184 1234 5678) it_splits '67517012', %w(675 170 12) it_splits '6751891', %w(675 189 1) it_splits '6752701234', %w(675 270 1234) it_splits '6752751234', %w(675 275 1234) it_splits '67527912', %w(675 279 12) it_splits '67511512345678', %w(675 115 1234 5678) it_splits '67574123456', %w(675 74 123 456) it_splits '67573123456', %w(675 731 23 456) it_splits '67577301234', %w(675 7730 1 234) end describe 'Reunion / Mayotte (new)' do it_splits '262594399265', ['262', '594', '39', '92', '65'] end describe 'Saint Helena' do it_splits '2903614', ['290', false, '3614'] end describe 'Saint Pierre and Miquelon (Collectivité territoriale de la République française)' do it_splits '508418826', ['508', false, '418', '826'] end describe 'Samoa (Independent State of)' do it_splits '685800123', ['685', false, '800', '123'] it_splits '68561123', ['685', false, '61', '123'] it_splits '6857212345', ['685', false, '721', '2345'] it_splits '685830123', ['685', false, '830', '123'] it_splits '685601234', ['685', false, '601', '234'] it_splits '6858412345', ['685', false, '841', '2345'] end describe 'San Marino' do it_splits '378800123', ['378', false, '800', '123'] it_splits '3788001234567', ['378', false, '800', '123', '4567'] it_splits '378012345', ['378', false, '012', '345'] it_splits '3780123456789', ['378', false, '012', '345', '6789'] it_splits '378512345', ['378', false, '512', '345'] it_splits '3785123456789', ['378', false, '512', '345', '6789'] end describe 'Saudi Arabia (Kingdom of)' do it_splits '9660208528423', %w(966 020 852 8423) # Fixed it_splits '966506306201', %w(966 50 630 6201) # NDC Mobile it_splits '966112345678', %w(966 11 234 5678) # NDC Region it_splits '9668001234567', %w(966 800 123 4567) # Toll Free it_splits '966920012345', %w(966 9200 12345) # Univeral Access end describe 'Senegal' do it_splits '221123456789', ['221', false, '1234', '56789'] end describe 'Serbia' do it_splits '38180012345', %w(381 800 123 45) it_splits '3811012345', %w(381 10 123 45) it_splits '38110123456', %w(381 10 123 456) it_splits '38111123456', %w(381 11 123 456) it_splits '381111234567', %w(381 11 123 4567) it_splits '381721234567', %w(381 72 123 4567) it_splits '38160123', %w(381 60 123) it_splits '381601234567', %w(381 60 123 4567) it_splits '38142123456', %w(381 42 123 456) it_splits '38191234567', %w(381 9 123 4567) it_splits '38160123', %w(381 60 123) it_splits '381601234567890', %w(381 60 123 456 7890) it_splits '38170123456', %w(381 70 123 456) it_splits '38163123456', %w(381 63 123 456) end describe 'Sierra Leone' do it_splits '23264629769', %w(232 64 629 769) end describe 'Solomon Islands' do it_splits '67754692', ['677', false, '54', '692'] it_splits '6777546921', ['677', false, '7546', '921'] end describe 'Somalia' do it_splits '252103412345', %w(252 1034 123 45) it_splits '2521313123', %w(252 1313 123) it_splits '2521601234', %w(252 160 12 34) it_splits '25250012345', %w(252 500 123 45) it_splits '252612345678', %w(252 61 234 5678) # Hormuud it_splits '252622345678', %w(252 62 234 5678) # Somtel Mogadishu it_splits '252634000613', %w(252 63 400 0613) # Telesom it_splits '252642345678', %w(252 64 234 5678) # Hormuud it_splits '252652345678', %w(252 65 234 5678) # Somtel it_splits '252662345678', %w(252 66 234 5678) # Somtel Puntland it_splits '252672345678', %w(252 67 234 5678) # Nationlink Mogadishu it_splits '252682345678', %w(252 68 234 5678) # Nationlink Mogadishu it_splits '252692345678', %w(252 69 234 5678) # Nationlink it_splits '252902345678', %w(252 90 234 5678) # Golis end describe 'Suriname (Republic of)' do it_splits '597958434', ['597', false, '958', '434'] it_splits '597212345', ['597', false, '212', '345'] it_splits '5976123456', ['597', false, '612', '3456'] end describe 'Swaziland' do it_splits '26822071234', ['268', false, '2207', '1234'] it_splits '2685501234', ['268', false, '550', '1234'] end describe 'Syrian Arab Republic' do it_splits '963111234567', %w(963 11 123 4567) it_splits '963311234567', %w(963 31 123 4567) it_splits '96315731234', %w(963 15 731 234) it_splits '963912345678', %w(963 9 1234 5678) end describe 'Taiwan' do it_splits '886212345678', %w(886 2 1234 5678) it_splits '88631234567', %w(886 3 123 4567) it_splits '88651234567', %w(886 5 123 4567) it_splits '88661234567', %w(886 6 123 4567) it_splits '88671234567', %w(886 7 123 4567) it_splits '88633123456', %w(886 3 312 3456) it_splits '88637123456', %w(886 37 12 3456) it_splits '88682712345', %w(886 82 71 2345) it_splits '88689712345', %w(886 89 71 2345) it_splits '88682672345', %w(886 826 7 2345) it_splits '88683672345', %w(886 836 7 2345) it_splits '88641212345', %w(886 4 121 2345) it_splits '886412123456', %w(886 4 1212 3456) it_splits '886491234567', %w(886 49 123 4567) it_splits '886901234567', %w(886 901 234 567) end describe 'Togolese Republic' do it_splits '22812345678', ['228', false, '1234', '5678'] end describe 'Tajikistan' do it_splits '992313012345', %w(992 3130 123 45) it_splits '992331700123', %w(992 331700 123) it_splits '992372123345', %w(992 372 123 345) it_splits '992505123456', %w(992 505 123 456) it_splits '992973123456', %w(992 973 123 456) it_splits '992474456123', %w(992 474 456 123) end describe 'Tokelau' do it_splits '6901371', %w(690 1 371) end describe 'Tonga (Kingdom of)' do it_splits '67620123', ['676', false, '20', '123'] it_splits '67684123', ['676', false, '84', '123'] it_splits '6767712345', ['676', false, '77', '123', '45'] it_splits '6768912345', ['676', false, '89', '123', '45'] end describe 'Tuvalu' do it_splits '68893741', ['688', false, '93741'] end describe 'Turkmenistan' do it_splits '99312456789', %w(993 12 456 789) it_splits '99313145678', %w(993 131 456 78) it_splits '99313924567', %w(993 1392 4567) it_splits '99361234567', %w(993 6 123 4567) end describe 'Ukraine' do it_splits '380800123456', %w(380 800 123 456) it_splits '380312123456', %w(380 312 123 456) it_splits '380320123456', %w(380 32 0123 456) it_splits '380325912345', %w(380 3259 123 45) it_splits '380326061234', %w(380 32606 1234) it_splits '380391234567', %w(380 39 123 45 67) it_splits '380501234567', %w(380 50 123 45 67) it_splits '380631234567', %w(380 63 123 45 67) it_splits '380661234567', %w(380 66 123 45 67) it_splits '380671234567', %w(380 67 123 45 67) it_splits '380681234567', %w(380 68 123 45 67) it_splits '380911234567', %w(380 91 123 45 67) it_splits '380921234567', %w(380 92 123 45 67) it_splits '380931234567', %w(380 93 123 45 67) it_splits '380731234567', %w(380 73 123 45 67) it_splits '380941234567', %w(380 94 123 45 67) it_splits '380951234567', %w(380 95 123 45 67) it_splits '380961234567', %w(380 96 123 45 67) it_splits '380971234567', %w(380 97 123 45 67) it_splits '380981234567', %w(380 98 123 45 67) it_splits '380991234567', %w(380 99 123 45 67) end describe 'United Arab Emirates' do it_splits '97180012', %w(971 800 12) it_splits '971800123456789', %w(971 800 12 345 6789) it_splits '97180012345678', %w(971 800 12 345 678) it_splits '9718001234567', %w(971 800 12 345 67) it_splits '97121234567', %w(971 2 123 4567) it_splits '971506412345', %w(971 50 641 2345) it_splits '971600641234', %w(971 600 641 234) it_splits '971500641234', %w(971 500 641 234) it_splits '971200641234', %w(971 200 641 234) it_splits '971549999999', %w(971 54 999 9999) it_splits '971589999999', %w(971 58 999 9999) end describe 'Uruguay (Eastern Republic of)' do it_splits '59880012345', %w(598 800 123 45) it_splits '59820123456', %w(598 2 012 3456) it_splits '59821123456', %w(598 21 123 456) it_splits '59890912345', %w(598 909 123 45) it_splits '59893123456', %w(598 93 123 456) it_splits '59890812345', %w(598 908 123 45) it_splits '59880512345', %w(598 805 123 45) end describe 'Uzbekistan (Republic of)' do it_splits '998433527869', %w(998 43 352 7869) end describe 'Vanuatu (Republic of)' do it_splits '67889683', ['678', false, '89', '683'] end describe 'Yemen' do it_splits '9671234567', %w(967 1 234 567) it_splits '96712345678', %w(967 1 234 5678) it_splits '9677234567', %w(967 7 234 567) it_splits '967771234567', %w(967 77 123 4567) it_splits '967581234', %w(967 58 1234) end describe 'Zimbabwe' do it_splits '2632582123456', %w(263 2582 123 456) it_splits '2632582123', %w(263 2582 123) it_splits '263147123456', %w(263 147 123 456) it_splits '263147123', %w(263 147 123) it_splits '263270123456', %w(263 270 123 456) it_splits '26327012345', %w(263 270 123 45) it_splits '2638612354567', %w(263 86 1235 4567) # mobile numbers (see http://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000E90002PDFE.pdf, Table 4, Page 25) %w(71 73 77 78).each do |prefix| number = "263#{prefix}2345678" it_splits number, ['263', prefix, '234', '5678'] end end end end
class Bmake < Formula desc "Portable version of NetBSD make(1)" homepage "http://www.crufty.net/help/sjg/bmake.html" url "http://www.crufty.net/ftp/pub/sjg/bmake-20160818.tar.gz" sha256 "d64b23e3e4013b6d4ea590b05251874ffa9d841299b4e5344a6edf45ea7e1141" bottle do sha256 "38e0b7712c5ae20b9a2639f21aa46c96e7893e3a44ce8956d1c64f5efb16ed66" => :sierra sha256 "6964daaba5e8b288e9b39ee9439821bac54f3babbc619fe9db5c6ae7d81284e8" => :el_capitan sha256 "74d7a6b8f7fb23383762be1440171f50336283eebe1f48d7163ae5b81ae4489f" => :yosemite end def install # The first, an oversight upstream; the second, don't pre-roff cat pages. inreplace "bmake.1", ".Dt MAKE", ".Dt BMAKE" inreplace "mk/man.mk", "MANTARGET?", "MANTARGET" # -DWITHOUT_PROG_LINK means "don't symlink as bmake-VERSION." args = ["--prefix=#{prefix}", "-DWITHOUT_PROG_LINK", "--install"] system "sh", "boot-strap", *args man1.install "bmake.1" end test do (testpath/"Makefile").write <<-EOS.undent all: hello hello: \t@echo 'Test successful.' clean: \trm -rf Makefile EOS system bin/"bmake" system bin/"bmake", "clean" end end bmake 20170311 Closes #11589. Signed-off-by: Tomasz Pajor <ea73344294b1c6e2cb529d7fc98a4971de7607ac@polishgeeks.com> class Bmake < Formula desc "Portable version of NetBSD make(1)" homepage "http://www.crufty.net/help/sjg/bmake.html" url "http://www.crufty.net/ftp/pub/sjg/bmake-20170311.tar.gz" sha256 "881bb42230650a6f756ac7a2054ca984f31e1002fe3362456a77631c162ba33a" bottle do sha256 "38e0b7712c5ae20b9a2639f21aa46c96e7893e3a44ce8956d1c64f5efb16ed66" => :sierra sha256 "6964daaba5e8b288e9b39ee9439821bac54f3babbc619fe9db5c6ae7d81284e8" => :el_capitan sha256 "74d7a6b8f7fb23383762be1440171f50336283eebe1f48d7163ae5b81ae4489f" => :yosemite end def install # Don't pre-roff cat pages. inreplace "mk/man.mk", "MANTARGET?", "MANTARGET" # -DWITHOUT_PROG_LINK means "don't symlink as bmake-VERSION." args = ["--prefix=#{prefix}", "-DWITHOUT_PROG_LINK", "--install"] system "sh", "boot-strap", *args man1.install "bmake.1" end test do (testpath/"Makefile").write <<-EOS.undent all: hello hello: \t@echo 'Test successful.' clean: \trm -rf Makefile EOS system bin/"bmake" system bin/"bmake", "clean" end end
require 'spec_helper' RSpec.describe TalkApiClient do let(:user) { create(:admin_user)} let(:application) { create(:application, owner: user) } describe '::load_configuration' do before(:each) do allow(described_class).to receive(:configuration).and_return({host: "http://test.example.com", user: user.id.to_s, application: application.id.to_s}) end context 'configuration in ENV variables' do before(:each) do ENV['TALK_API_HOST'] = 'http://example.com' ENV['TALK_API_USER'] = '1' ENV['TALK_API_APPLICATION'] = '1' described_class.load_configuration end after(:each) do ENV.delete('TALK_API_HOST') ENV.delete('TALK_API_USER') ENV.delete('TALK_API_APPLICATION') end it 'should set host to TALK_API_HOST var' do expect(described_class.host).to eq('http://example.com') end it 'should set user_id to TALK_API_USER var' do expect(described_class.user_id).to eq(1) end it 'should set application_id to TALK_API_APPLICATION var' do expect(described_class.application_id).to eq(1) end end context 'configuration in file' do before(:each) do described_class.load_configuration end it 'should set host to configuration host' do expect(described_class.host).to eq('http://test.example.com') end it 'should set user_id to configuration user' do expect(described_class.user_id).to eq(user.id) end it 'should set application_id to configuration application' do expect(described_class.application_id).to eq(application.id) end end end describe "::configuration" do before(:each) do described_class.instance_variable_set(:@configuration, nil) end it 'should try to load the file at config/talk_api.yml' do expect(File).to receive(:read).with(Rails.root.join 'config/talk_api.yml') described_class.configuration end it 'should retun the configuration for the current rails environment' do expect(YAML).to receive(:load).and_return({"test" => {host: "example.coffee"}, "development" => {host: "example.sucks"}}) expect(described_class.configuration).to eq({host: "example.coffee"}) end it 'should memoize the results' do described_class.configuration expect(File).to_not receive(:read) described_class.configuration end end context "instance methods" do let(:stubs) do Faraday::Adapter::Test::Stubs.new do |stub| stub.get('/') do |env| [200, {'Content-Type' => 'application/vnd.api+json'}, {roles: { href: '/roles', type: 'roles'}}.to_json] end end end before(:each) do allow(described_class).to receive(:configuration).and_return({host: "http://test.example.com", user: user.id.to_s, application: application.id.to_s}) described_class.load_configuration end describe "#create_token" do subject { described_class.new([:test, stubs]).token.attributes } it { is_expected.to include("resource_owner_id" => user.id) } it { is_expected.to include("application_id" => user.id) } it { is_expected.to include("expires_in" => 1.day) } end describe "#initial_reqest" do subject { described_class.new([:test, stubs]) } it 'should add resources to the resources hash' do expect(subject.instance_variable_get(:@resources)).to include('roles') end it 'should create a resource class for the hash' do expect(subject.instance_variable_get(:@resources)['roles']).to be_a(TalkApiClient::JSONAPIResource) end end describe "#request" do subject { described_class.new([:test, stubs]) } it 'should make a request with the connection' do expect(subject.connection).to receive(:send).with('get', '/') subject.request('get', '/') end end describe "#method_missing" do subject { described_class.new([:test, stubs]) } it 'should proxy the resources hash' do expect(subject.roles).to be_a(TalkApiClient::JSONAPIResource) end it 'should raise an error if no resource is known' do expect{ subject.boards }.to raise_error end end describe "TalkApiClient::JSONAPIResource" do let(:conn_instance) { described_class.new([:test, stubs])} describe "#create" do it 'should send a POST request with a JSON body' do expect(conn_instance).to receive(:request).with('POST', '/roles') do |*args, &block| struct = Struct.new(:body).new block.call(struct) expect(struct.body).to eq({role: "admin"}.to_json) end conn_instance.roles.create(role: "admin") end end end end end Fix incorrect Talk Api test spec require 'spec_helper' RSpec.describe TalkApiClient do let(:user) { create(:admin_user)} let(:application) { create(:application, owner: user) } describe '::load_configuration' do before(:each) do allow(described_class).to receive(:configuration).and_return({host: "http://test.example.com", user: user.id.to_s, application: application.id.to_s}) end context 'configuration in ENV variables' do before(:each) do ENV['TALK_API_HOST'] = 'http://example.com' ENV['TALK_API_USER'] = '1' ENV['TALK_API_APPLICATION'] = '1' described_class.load_configuration end after(:each) do ENV.delete('TALK_API_HOST') ENV.delete('TALK_API_USER') ENV.delete('TALK_API_APPLICATION') end it 'should set host to TALK_API_HOST var' do expect(described_class.host).to eq('http://example.com') end it 'should set user_id to TALK_API_USER var' do expect(described_class.user_id).to eq(1) end it 'should set application_id to TALK_API_APPLICATION var' do expect(described_class.application_id).to eq(1) end end context 'configuration in file' do before(:each) do described_class.load_configuration end it 'should set host to configuration host' do expect(described_class.host).to eq('http://test.example.com') end it 'should set user_id to configuration user' do expect(described_class.user_id).to eq(user.id) end it 'should set application_id to configuration application' do expect(described_class.application_id).to eq(application.id) end end end describe "::configuration" do before(:each) do described_class.instance_variable_set(:@configuration, nil) end it 'should try to load the file at config/talk_api.yml' do expect(File).to receive(:read).with(Rails.root.join 'config/talk_api.yml') described_class.configuration end it 'should retun the configuration for the current rails environment' do expect(YAML).to receive(:load).and_return({"test" => {host: "example.coffee"}, "development" => {host: "example.sucks"}}) expect(described_class.configuration).to eq({host: "example.coffee"}) end it 'should memoize the results' do described_class.configuration expect(File).to_not receive(:read) described_class.configuration end end context "instance methods" do let(:stubs) do Faraday::Adapter::Test::Stubs.new do |stub| stub.get('/') do |env| [200, {'Content-Type' => 'application/vnd.api+json'}, {roles: { href: '/roles', type: 'roles'}}.to_json] end end end before(:each) do allow(described_class).to receive(:configuration).and_return({host: "http://test.example.com", user: user.id.to_s, application: application.id.to_s}) described_class.load_configuration end describe "#create_token" do subject { described_class.new([:test, stubs]).token.attributes } it { is_expected.to include("resource_owner_id" => user.id) } it { is_expected.to include("application_id" => application.id) } it { is_expected.to include("expires_in" => 1.day) } end describe "#initial_reqest" do subject { described_class.new([:test, stubs]) } it 'should add resources to the resources hash' do expect(subject.instance_variable_get(:@resources)).to include('roles') end it 'should create a resource class for the hash' do expect(subject.instance_variable_get(:@resources)['roles']).to be_a(TalkApiClient::JSONAPIResource) end end describe "#request" do subject { described_class.new([:test, stubs]) } it 'should make a request with the connection' do expect(subject.connection).to receive(:send).with('get', '/') subject.request('get', '/') end end describe "#method_missing" do subject { described_class.new([:test, stubs]) } it 'should proxy the resources hash' do expect(subject.roles).to be_a(TalkApiClient::JSONAPIResource) end it 'should raise an error if no resource is known' do expect{ subject.boards }.to raise_error end end describe "TalkApiClient::JSONAPIResource" do let(:conn_instance) { described_class.new([:test, stubs])} describe "#create" do it 'should send a POST request with a JSON body' do expect(conn_instance).to receive(:request).with('POST', '/roles') do |*args, &block| struct = Struct.new(:body).new block.call(struct) expect(struct.body).to eq({role: "admin"}.to_json) end conn_instance.roles.create(role: "admin") end end end end end
class Boost < Formula desc "Collection of portable C++ source libraries" homepage "https://www.boost.org/" url "https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2" sha256 "2684c972994ee57fc5632e03bf044746f6eb45d4920c343937a465fd67a5adba" head "https://github.com/boostorg/boost.git" bottle do cellar :any sha256 "3d44a7402cb17d919a555f4d34deda8f0ea14e681892c761be4c719c48b339a5" => :high_sierra sha256 "de2a0c3faa675427e641cf3dd7af2278e7e1db3f6f4c508d61627866c4abef0e" => :sierra sha256 "1d38618d30d6872cf52f8f12fbc545f435f8994dbf8ad9cdff706dfc0c0f564a" => :el_capitan end option "with-icu4c", "Build regexp engine with icu support" option "without-single", "Disable building single-threading variant" option "without-static", "Disable building static library variant" deprecated_option "with-icu" => "with-icu4c" depends_on "icu4c" => :optional unless OS.mac? depends_on "bzip2" depends_on "zlib" end needs :cxx11 def install # Reduce memory usage below 4 GB for Circle CI. ENV["MAKEFLAGS"] = "-j5" if ENV["CIRCLECI"] # Force boost to compile with the desired compiler open("user-config.jam", "a") do |file| if OS.mac? file.write "using darwin : : #{ENV.cxx} ;\n" else file.write "using gcc : : #{ENV.cxx} ;\n" end file.write "using mpi ;\n" if build.with? "mpi" end # libdir should be set by --prefix but isn't bootstrap_args = ["--prefix=#{prefix}", "--libdir=#{lib}"] if build.with? "icu4c" icu4c_prefix = Formula["icu4c"].opt_prefix bootstrap_args << "--with-icu=#{icu4c_prefix}" else bootstrap_args << "--without-icu" end # Handle libraries that will not be built. without_libraries = ["python", "mpi"] # Boost.Log cannot be built using Apple GCC at the moment. Disabled # on such systems. without_libraries << "log" if ENV.compiler == :gcc bootstrap_args << "--without-libraries=#{without_libraries.join(",")}" # layout should be synchronized with boost-python and boost-mpi args = ["--prefix=#{prefix}", "--libdir=#{lib}", "-d2", "-j#{ENV.make_jobs}", "--layout=tagged", "--user-config=user-config.jam", "-sNO_LZMA=1", "install"] if build.with? "single" args << "threading=multi,single" else args << "threading=multi" end if build.with? "static" args << "link=shared,static" else args << "link=shared" end # Trunk starts using "clang++ -x c" to select C compiler which breaks C++11 # handling using ENV.cxx11. Using "cxxflags" and "linkflags" still works. args << "cxxflags=-std=c++11" if ENV.compiler == :clang args << "cxxflags=-stdlib=libc++" << "linkflags=-stdlib=libc++" end # Fix error: bzlib.h: No such file or directory # and /usr/bin/ld: cannot find -lbz2 args += ["include=#{HOMEBREW_PREFIX}/include", "linkflags=-L#{HOMEBREW_PREFIX}/lib"] unless OS.mac? system "./bootstrap.sh", *bootstrap_args system "./b2", "headers" system "./b2", *args end def caveats s = "" # ENV.compiler doesn't exist in caveats. Check library availability # instead. if Dir["#{lib}/libboost_log*"].empty? s += <<~EOS Building of Boost.Log is disabled because it requires newer GCC or Clang. EOS end s end test do (testpath/"test.cpp").write <<~EOS #include <boost/algorithm/string.hpp> #include <string> #include <vector> #include <assert.h> using namespace boost::algorithm; using namespace std; int main() { string str("a,b"); vector<string> strVec; split(strVec, str, is_any_of(",")); assert(strVec.size()==2); assert(strVec[0]=="a"); assert(strVec[1]=="b"); return 0; } EOS system ENV.cxx, "test.cpp", "-std=c++1y", "-L#{lib}", "-lboost_system", "-o", "test" system "./test" end end boost: update 1.67.0 bottle for Linuxbrew. class Boost < Formula desc "Collection of portable C++ source libraries" homepage "https://www.boost.org/" url "https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2" sha256 "2684c972994ee57fc5632e03bf044746f6eb45d4920c343937a465fd67a5adba" head "https://github.com/boostorg/boost.git" bottle do cellar :any sha256 "7bf5ad6a1dd369a95f088fab8a6ffc853d28aa309a0cee397b18895d0bd4575d" => :x86_64_linux end option "with-icu4c", "Build regexp engine with icu support" option "without-single", "Disable building single-threading variant" option "without-static", "Disable building static library variant" deprecated_option "with-icu" => "with-icu4c" depends_on "icu4c" => :optional unless OS.mac? depends_on "bzip2" depends_on "zlib" end needs :cxx11 def install # Reduce memory usage below 4 GB for Circle CI. ENV["MAKEFLAGS"] = "-j5" if ENV["CIRCLECI"] # Force boost to compile with the desired compiler open("user-config.jam", "a") do |file| if OS.mac? file.write "using darwin : : #{ENV.cxx} ;\n" else file.write "using gcc : : #{ENV.cxx} ;\n" end file.write "using mpi ;\n" if build.with? "mpi" end # libdir should be set by --prefix but isn't bootstrap_args = ["--prefix=#{prefix}", "--libdir=#{lib}"] if build.with? "icu4c" icu4c_prefix = Formula["icu4c"].opt_prefix bootstrap_args << "--with-icu=#{icu4c_prefix}" else bootstrap_args << "--without-icu" end # Handle libraries that will not be built. without_libraries = ["python", "mpi"] # Boost.Log cannot be built using Apple GCC at the moment. Disabled # on such systems. without_libraries << "log" if ENV.compiler == :gcc bootstrap_args << "--without-libraries=#{without_libraries.join(",")}" # layout should be synchronized with boost-python and boost-mpi args = ["--prefix=#{prefix}", "--libdir=#{lib}", "-d2", "-j#{ENV.make_jobs}", "--layout=tagged", "--user-config=user-config.jam", "-sNO_LZMA=1", "install"] if build.with? "single" args << "threading=multi,single" else args << "threading=multi" end if build.with? "static" args << "link=shared,static" else args << "link=shared" end # Trunk starts using "clang++ -x c" to select C compiler which breaks C++11 # handling using ENV.cxx11. Using "cxxflags" and "linkflags" still works. args << "cxxflags=-std=c++11" if ENV.compiler == :clang args << "cxxflags=-stdlib=libc++" << "linkflags=-stdlib=libc++" end # Fix error: bzlib.h: No such file or directory # and /usr/bin/ld: cannot find -lbz2 args += ["include=#{HOMEBREW_PREFIX}/include", "linkflags=-L#{HOMEBREW_PREFIX}/lib"] unless OS.mac? system "./bootstrap.sh", *bootstrap_args system "./b2", "headers" system "./b2", *args end def caveats s = "" # ENV.compiler doesn't exist in caveats. Check library availability # instead. if Dir["#{lib}/libboost_log*"].empty? s += <<~EOS Building of Boost.Log is disabled because it requires newer GCC or Clang. EOS end s end test do (testpath/"test.cpp").write <<~EOS #include <boost/algorithm/string.hpp> #include <string> #include <vector> #include <assert.h> using namespace boost::algorithm; using namespace std; int main() { string str("a,b"); vector<string> strVec; split(strVec, str, is_any_of(",")); assert(strVec.size()==2); assert(strVec[0]=="a"); assert(strVec[1]=="b"); return 0; } EOS system ENV.cxx, "test.cpp", "-std=c++1y", "-L#{lib}", "-lboost_system", "-o", "test" system "./test" end end
# Copyright (c) 2010-2011, Diaspora Inc. This file is # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. require 'spec_helper' describe Maintenance, :type => :mailer do describe 'create warning' do before do @removal_timestamp = Time.now + 3.days @user = FactoryGirl.create(:user_with_aspect, :username => "local", :remove_after => @removal_timestamp) end it "#should deliver successfully" do expect { Maintenance.account_removal_warning(@user).deliver }.to_not raise_error end it "#should be added to the delivery queue" do expect { Maintenance.account_removal_warning(@user).deliver }.to change(ActionMailer::Base.deliveries, :size).by(1) end it "#should include correct recipient" do Maintenance.account_removal_warning(@user).deliver expect(ActionMailer::Base.deliveries.last.to[0]).to include(@user.email) end it "#should include after inactivity days from settings" do Maintenance.account_removal_warning(@user).deliver expect(ActionMailer::Base.deliveries.last.body.parts[0].body.raw_source).to include("more than "+AppConfig.settings.maintenance.remove_old_users.after_days.to_s+" days") end it "#should include timestamp for account removal" do Maintenance.account_removal_warning(@user).deliver expect(ActionMailer::Base.deliveries.last.body.parts[0].body.raw_source).to include("logging into the account before "+@removal_timestamp.utc.to_s) end end end update maintenance mailer spec for new mail text # Copyright (c) 2010-2011, Diaspora Inc. This file is # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. require 'spec_helper' describe Maintenance, :type => :mailer do describe 'create warning' do before do @removal_timestamp = Time.now + 3.days @user = FactoryGirl.create(:user_with_aspect, :username => "local", :remove_after => @removal_timestamp) end it "#should deliver successfully" do expect { Maintenance.account_removal_warning(@user).deliver }.to_not raise_error end it "#should be added to the delivery queue" do expect { Maintenance.account_removal_warning(@user).deliver }.to change(ActionMailer::Base.deliveries, :size).by(1) end it "#should include correct recipient" do Maintenance.account_removal_warning(@user).deliver expect(ActionMailer::Base.deliveries.last.to[0]).to include(@user.email) end it "#should include after inactivity days from settings" do Maintenance.account_removal_warning(@user).deliver expect(ActionMailer::Base.deliveries.last.body.parts[0].body.raw_source).to include("for #{AppConfig.settings.maintenance.remove_old_users.after_days} days") end it "#should include timestamp for account removal" do Maintenance.account_removal_warning(@user).deliver expect(ActionMailer::Base.deliveries.last.body.parts[0].body.raw_source).to include("sign in to your account before #{@removal_timestamp.utc}") end end end
class Botan < Formula homepage "http://botan.randombit.net/" url "http://botan.randombit.net/releases/Botan-1.10.9.tgz" sha1 "e1c8e97b214b23931f7dc8aba44306fbeca9055c" bottle do sha1 "3f9096cdf4156db3af972765fe9b8bb58a7b7261" => :yosemite sha1 "d2f2f165eccbd6db984b83149a1f1df1b66dadbb" => :mavericks sha1 "26196739a9584d6b3a129e32d3a2358484d6d8ed" => :mountain_lion end option "with-debug", "Enable debug build of Botan" deprecated_option "enable-debug" => "with-debug" depends_on "pkg-config" => :build depends_on "openssl" # upstream ticket: https://bugs.randombit.net/show_bug.cgi?id=267 patch :DATA def install args = %W[ --prefix=#{prefix} --docdir=share/doc --cpu=#{MacOS.preferred_arch} --cc=#{ENV.compiler} --os=darwin --with-openssl --with-zlib --with-bzip2 ] args << "--enable-debug" if build.with? "debug" system "./configure.py", *args # A hack to force them use our CFLAGS. MACH_OPT is empty in the Makefile # but used for each call to cc/ld. system "make", "install", "MACH_OPT=#{ENV.cflags}" end test do assert_match /lcrypto/, shell_output("#{bin}/botan-config-1.10 --libs") end end __END__ --- a/src/build-data/makefile/unix_shr.in +++ b/src/build-data/makefile/unix_shr.in @@ -57,8 +57,8 @@ LIBNAME = %{lib_prefix}libbotan STATIC_LIB = $(LIBNAME)-$(SERIES).a -SONAME = $(LIBNAME)-$(SERIES).%{so_suffix}.%{so_abi_rev} -SHARED_LIB = $(SONAME).%{version_patch} +SONAME = $(LIBNAME)-$(SERIES).%{so_abi_rev}.%{so_suffix} +SHARED_LIB = $(LIBNAME)-$(SERIES).%{so_abi_rev}.%{version_patch}.%{so_suffix} SYMLINK = $(LIBNAME)-$(SERIES).%{so_suffix} botan: update 1.10.9 bottle. class Botan < Formula homepage "http://botan.randombit.net/" url "http://botan.randombit.net/releases/Botan-1.10.9.tgz" sha1 "e1c8e97b214b23931f7dc8aba44306fbeca9055c" bottle do revision 1 sha256 "21928e32477150b767937ecfbf8be519c279474eb7273c38475ee39501084977" => :yosemite sha256 "a89a03f87751e838d0e7265fff8f92f19782048b2b17bd0bcadbcef186f4f29f" => :mavericks sha256 "c8899f3e0b379e27e37fd7e3e83bbec52803cce45800c7bf88c509f09a7e520b" => :mountain_lion end option "with-debug", "Enable debug build of Botan" deprecated_option "enable-debug" => "with-debug" depends_on "pkg-config" => :build depends_on "openssl" # upstream ticket: https://bugs.randombit.net/show_bug.cgi?id=267 patch :DATA def install args = %W[ --prefix=#{prefix} --docdir=share/doc --cpu=#{MacOS.preferred_arch} --cc=#{ENV.compiler} --os=darwin --with-openssl --with-zlib --with-bzip2 ] args << "--enable-debug" if build.with? "debug" system "./configure.py", *args # A hack to force them use our CFLAGS. MACH_OPT is empty in the Makefile # but used for each call to cc/ld. system "make", "install", "MACH_OPT=#{ENV.cflags}" end test do assert_match /lcrypto/, shell_output("#{bin}/botan-config-1.10 --libs") end end __END__ --- a/src/build-data/makefile/unix_shr.in +++ b/src/build-data/makefile/unix_shr.in @@ -57,8 +57,8 @@ LIBNAME = %{lib_prefix}libbotan STATIC_LIB = $(LIBNAME)-$(SERIES).a -SONAME = $(LIBNAME)-$(SERIES).%{so_suffix}.%{so_abi_rev} -SHARED_LIB = $(SONAME).%{version_patch} +SONAME = $(LIBNAME)-$(SERIES).%{so_abi_rev}.%{so_suffix} +SHARED_LIB = $(LIBNAME)-$(SERIES).%{so_abi_rev}.%{version_patch}.%{so_suffix} SYMLINK = $(LIBNAME)-$(SERIES).%{so_suffix}
require 'spec_helper' describe UserMailer do describe 'checkin_receipt' describe 'checkout_receipt' describe 'missed_reservation_deleted_notification' describe 'overdue_checkin_notification' describe 'overdue_checked_in_fine' describe 'reservation_confirmation' describe 'upcoming_checkin_notification' end user mailer tests" require 'spec_helper' shared_examples_for "valid user email" do it "sends to the reserver" do expect(@mail.to.size).to eq(1) expect(@mail.to.first).to eq(reserver.email) end it "sends an email" do ActionMailer::Base.deliveries.count.should eq(1) end it "is from the admin" do expect(@mail.from.size).to eq(1) expect(@mail.from.first).to eq(AppConfig.first.admin_email) end end describe UserMailer do before(:all) { @app_config = FactoryGirl.create(:app_config) } before(:each) do ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries = [] end let!(:reserver) { FactoryGirl.create(:user) } describe 'checkin_receipt' do before do @res = FactoryGirl.build(:checked_in_reservation, reserver: reserver) @res.save(validate: false) @mail = UserMailer.checkin_receipt(@res).deliver end it_behaves_like "valid user email" end describe 'checkout_receipt' do before do @res = FactoryGirl.build(:checked_out_reservation, reserver: reserver) @res.save(validate: false) @mail = UserMailer.checkout_receipt(@res).deliver end it_behaves_like "valid user email" end describe 'missed_reservation_deleted_notification' do before do @res = FactoryGirl.build(:missed_reservation, reserver: reserver) @res.save(validate: false) @mail = UserMailer.missed_reservation_deleted_notification(@res).deliver end it_behaves_like "valid user email" end describe 'overdue_checkin_notification' do before do @res = FactoryGirl.build(:checked_in_reservation, reserver: reserver) @res.save(validate: false) @mail = UserMailer.overdue_checkin_notification(@res).deliver end it_behaves_like "valid user email" end describe 'overdue_checked_in_fine' do before do @res = FactoryGirl.build(:checked_in_reservation, reserver: reserver) @res.save(validate: false) @mail = UserMailer.overdue_checked_in_fine(@res).deliver end it_behaves_like "valid user email" end describe 'reservation_confirmation' do before do @res = [] << FactoryGirl.create(:valid_reservation, reserver: reserver) @mail = UserMailer.reservation_confirmation(@res).deliver end it_behaves_like "valid user email" end describe 'upcoming_checkin_notification' do before do @res = FactoryGirl.create(:valid_reservation, reserver: reserver) @mail = UserMailer.upcoming_checkin_notification(@res).deliver end it_behaves_like "valid user email" end end
class Brook < Formula desc "Cross-platform strong encryption and not detectable proxy. Zero-Configuration" homepage "https://txthinking.github.io/brook/" url "https://github.com/txthinking/brook/archive/refs/tags/v20220401.tar.gz" sha256 "cd3c467d23f4677c51e6764e0a3203cf39ac6c1081203bfd9f5c79680317be22" license "GPL-3.0-only" bottle do sha256 cellar: :any_skip_relocation, arm64_monterey: "4742c24be5fa0765b3aa16179793fbfc2bb18bfcfed788434fca4a8815e1d5bb" sha256 cellar: :any_skip_relocation, arm64_big_sur: "76789baeb8d527f328223cd15d0dfa5557388d3df01c47df9a28b901dbf634f8" sha256 cellar: :any_skip_relocation, monterey: "c7d8221ceefc98f9f5be210ca26c345b5cfc24cc0e902b0cc9f16fa887dd2f12" sha256 cellar: :any_skip_relocation, big_sur: "e14d0602ea5dd95ca0bec06fbd9ac365422fc38e5930f969e207d743e42b399e" sha256 cellar: :any_skip_relocation, catalina: "84b9bc1480a0e1cc4f1c0bfc1f9eed5882ba0e13ae2f26ba806470db84e29b16" sha256 cellar: :any_skip_relocation, x86_64_linux: "8e1f8677d3ab9d9e973503d50eab5ce4600ac9353da7ba34223e4f077f4f74a8" end depends_on "go" => :build def install system "go", "build", *std_go_args(ldflags: "-s -w"), "./cli/brook" end test do output = shell_output "#{bin}/brook link --server 1.2.3.4:56789 --password hello" assert_match "brook://server?address=&insecure=&name=&password=hello&server=1.2.3.4%3A56789&username=", output end end brook 20220404 Closes #96206. Signed-off-by: Michael Cho <ad37dc0e034c3938811c0096de6272abd124db31@users.noreply.github.com> Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com> class Brook < Formula desc "Cross-platform strong encryption and not detectable proxy. Zero-Configuration" homepage "https://txthinking.github.io/brook/" url "https://github.com/txthinking/brook/archive/refs/tags/v20220404.tar.gz" sha256 "a119adf673df8f61fcaec841e471392cfdd9d307fe52ec9d6b3d9393846a7630" license "GPL-3.0-only" bottle do sha256 cellar: :any_skip_relocation, arm64_monterey: "4742c24be5fa0765b3aa16179793fbfc2bb18bfcfed788434fca4a8815e1d5bb" sha256 cellar: :any_skip_relocation, arm64_big_sur: "76789baeb8d527f328223cd15d0dfa5557388d3df01c47df9a28b901dbf634f8" sha256 cellar: :any_skip_relocation, monterey: "c7d8221ceefc98f9f5be210ca26c345b5cfc24cc0e902b0cc9f16fa887dd2f12" sha256 cellar: :any_skip_relocation, big_sur: "e14d0602ea5dd95ca0bec06fbd9ac365422fc38e5930f969e207d743e42b399e" sha256 cellar: :any_skip_relocation, catalina: "84b9bc1480a0e1cc4f1c0bfc1f9eed5882ba0e13ae2f26ba806470db84e29b16" sha256 cellar: :any_skip_relocation, x86_64_linux: "8e1f8677d3ab9d9e973503d50eab5ce4600ac9353da7ba34223e4f077f4f74a8" end depends_on "go" => :build def install system "go", "build", *std_go_args(ldflags: "-s -w"), "./cli/brook" end test do output = shell_output "#{bin}/brook link --server 1.2.3.4:56789 --password hello" assert_match "brook://server?address=&insecure=&name=&password=hello&server=1.2.3.4%3A56789&username=", output end end
require_relative '../../lib/melodiest/generator' describe Melodiest::Generator do let(:generator) { Melodiest::Generator.new @app, destination: @dest } let(:generator_with_db) { Melodiest::Generator.new @app, destination: @dest_with_db, with_database: true } let(:target_dir) { "#{@dest}/#{@app}" } let(:target_dir_with_db) { "#{@dest_with_db}/#{@app}" } before :all do @dest = "/tmp/melodiest" @dest_with_db = "#{@dest}_with_db" @app = "my_app" end before :all do FileUtils.rm_r @dest if Dir.exists?(@dest) FileUtils.rm_r @dest_with_db if Dir.exists?(@dest_with_db) end after :all do FileUtils.rm_r @dest FileUtils.rm_r @dest_with_db end it "sets app_name" do expect(generator.app_name).to eq @app end it "sets app_class_name" do expect(generator.app_class_name).to eq "MyApp" end it "has default destination path app_name" do FileUtils.rm_r @app if Dir.exists?(@app) expect(Melodiest::Generator.new(@app).destination).to eq File.expand_path(@app) FileUtils.rm_r @app end it "sets new destination path even if it's not exist yet" do expect("/tmp/melodiest/my_app").to eq target_dir end describe "#generate_gemfile" do context "without database" do let(:gemfile) { "#{target_dir}/Gemfile" } it "should generate Gemfile without sequel" do generator.generate_gemfile file_content = File.read(gemfile) expected_file_content = File.read(File.expand_path("../../fixtures/without_db/gemfile.txt", __FILE__)) expect(File.exists?(gemfile)).to be_truthy expect(file_content).to eq(expected_file_content) end end context "with database" do let(:gemfile) { "#{target_dir_with_db}/Gemfile" } it "should generate Gemfile with sequel" do generator_with_db.generate_gemfile file_content = File.read(gemfile) expected_file_content = File.read(File.expand_path("../../fixtures/with_db/gemfile.txt", __FILE__)) expect(File.exists?(gemfile)).to be_truthy expect(file_content).to eq(expected_file_content) end end end describe "#generate_bundle_config" do let(:bundle_config) { "#{target_dir}/config.ru" } it "should generate config.ru with correct content" do generator.generate_bundle_config file_content = File.read(bundle_config) expected_file_content = File.read(File.expand_path("../../fixtures/config_ru.txt", __FILE__)) expect(File.exists?(bundle_config)).to be_truthy expect(file_content).to eq(expected_file_content) end end describe "#generate_app" do def expected_default_files(target_dir, expected_value) config_dir = "#{target_dir}/config" assets_dir = "#{target_dir}/assets" public_dir = "#{target_dir}/public" boot = "#{config_dir}/boot.rb" application = "#{config_dir}/application.rb" app_dir = "#{target_dir}/app" routes_dir = "#{target_dir}/app/routes" views_dir = "#{target_dir}/app/views" layout = "#{target_dir}/app/views/layout.erb" home_index = "#{target_dir}/app/views/home/index.erb" expect(File.exists?(config_dir)).to eq(expected_value) expect(File.exists?("#{config_dir}/boot.rb")).to eq(expected_value) expect(File.exists?("#{config_dir}/application.rb")).to eq(expected_value) expect(File.exists?(assets_dir)).to eq(expected_value) expect(File.exists?(public_dir)).to eq(expected_value) expect(Dir.exists?(app_dir)).to eq(expected_value) expect(Dir.exists?(routes_dir)).to eq(expected_value) expect(Dir.exists?(views_dir)).to eq(expected_value) expect(File.exists?(layout)).to eq(expected_value) expect(File.exists?(home_index)).to eq(expected_value) end def expected_generated_files_with_db(target_dir, expected_value) sample_migration = "#{target_dir}/db/migrations/000_example.rb" expect(Dir.exists?("#{target_dir}/app/models")).to eq(expected_value) expect(File.exists?("#{target_dir}/config/database.yml.example")).to eq(expected_value) expect(File.exists?(sample_migration)).to eq(expected_value) end before { FileUtils.rm_r @dest if Dir.exists?(@dest) } before { FileUtils.rm_r @dest_with_db if Dir.exists?(@dest_with_db) } it "generates home route" do generator.generate_app app_file = "#{target_dir}/app/routes/home.rb" erb_file = "#{target_dir}/app/routes/home.erb" file_content = File.read(app_file) expected_file_content = File.read(File.expand_path("../../fixtures/app_routes_home.txt", __FILE__)) expect(File.exists?(app_file)).to be_truthy expect(File.exists?(erb_file)).to be_falsey expect(file_content).to eq expected_file_content end context "when generating without database" do describe "copy_templates" do it "copies from melodiest templates" do expected_default_files(target_dir, false) expected_generated_files_with_db(target_dir, false) generator.generate_app expected_default_files(target_dir, true) expected_generated_files_with_db(target_dir, false) end end describe "app file" do let(:secret) { "supersecretcookiefromgenerator" } before { allow(SecureRandom).to receive(:hex).with(32).and_return(secret) } it "generates <app_name>.rb, public dir, and app dir" do generator.generate_app app_file = "#{target_dir}/my_app.rb" file_content = File.read(app_file) expected_file_content = File.read(File.expand_path("../../fixtures/without_db/app.txt", __FILE__)) expect(File.exists?(app_file)).to be_truthy expect(file_content).to eq expected_file_content end end end context "when generating with database" do describe "copy templates" do it "copies from melodiest templates" do expected_default_files(target_dir_with_db, false) expected_generated_files_with_db(target_dir_with_db, false) generator_with_db.generate_app expected_default_files(target_dir_with_db, true) expected_generated_files_with_db(target_dir_with_db, true) end end describe "app file" do let(:secret) { "supersecretcookiefromgenerator" } before { allow(SecureRandom).to receive(:hex).with(32).and_return(secret) } it "has sequel database connector" do generator_with_db.generate_app app_file = "#{target_dir_with_db}/my_app.rb" file_content = File.read(app_file) expected_file_content = File.read(File.expand_path("../../fixtures/with_db/app.txt", __FILE__)) expect(file_content).to eq expected_file_content end end end end describe "#generate_rakefile" do it "generate basic Rakefile tasks" do expected_rakefile_content = expected_rakefile_content = File.read(File.expand_path("../../fixtures/without_db/rakefile.txt", __FILE__)) generator.generate_rakefile rakefile = "#{target_dir}/Rakefile" rakefile_content = File.read(rakefile) expect(rakefile_content).to eq expected_rakefile_content end context "with database" do it "generates db related tasks" do expected_rakefile_content = File.read(File.expand_path("../../fixtures/with_db/rakefile.txt", __FILE__)) generator_with_db.generate_rakefile rakefile = "#{target_dir_with_db}/Rakefile" rakefile_content = File.read(rakefile) expect(rakefile_content).to eq expected_rakefile_content end end end end refactor generate_gemfile spec require_relative '../../lib/melodiest/generator' describe Melodiest::Generator do let(:generator) { Melodiest::Generator.new @app, destination: @dest } let(:generator_with_db) { Melodiest::Generator.new @app, destination: @dest_with_db, with_database: true } let(:target_dir) { "#{@dest}/#{@app}" } let(:target_dir_with_db) { "#{@dest_with_db}/#{@app}" } before :all do @dest = "/tmp/melodiest" @dest_with_db = "#{@dest}_with_db" @app = "my_app" end before :all do FileUtils.rm_r @dest if Dir.exists?(@dest) FileUtils.rm_r @dest_with_db if Dir.exists?(@dest_with_db) end after :all do FileUtils.rm_r @dest FileUtils.rm_r @dest_with_db end it "sets app_name" do expect(generator.app_name).to eq @app end it "sets app_class_name" do expect(generator.app_class_name).to eq "MyApp" end it "has default destination path app_name" do FileUtils.rm_r @app if Dir.exists?(@app) expect(Melodiest::Generator.new(@app).destination).to eq File.expand_path(@app) FileUtils.rm_r @app end it "sets new destination path even if it's not exist yet" do expect("/tmp/melodiest/my_app").to eq target_dir end describe "#generate_gemfile" do def expected_gemfile(generator, target_dir, expected_gemfile) gemfile = "#{target_dir}/Gemfile" generator.generate_gemfile file_content = File.read(gemfile) expect(File.exists?(gemfile)).to be_truthy expect(file_content).to eq(expected_gemfile) end context "without database" do it "should generate Gemfile without sequel" do expected_file_content = File.read(File.expand_path("../../fixtures/without_db/gemfile.txt", __FILE__)) expected_gemfile(generator, target_dir, expected_file_content) end end context "with database" do let(:gemfile) { "#{target_dir_with_db}/Gemfile" } it "should generate Gemfile with sequel" do expected_file_content = File.read(File.expand_path("../../fixtures/with_db/gemfile.txt", __FILE__)) expected_gemfile(generator_with_db, target_dir_with_db, expected_file_content) end end end describe "#generate_bundle_config" do let(:bundle_config) { "#{target_dir}/config.ru" } it "should generate config.ru with correct content" do generator.generate_bundle_config file_content = File.read(bundle_config) expected_file_content = File.read(File.expand_path("../../fixtures/config_ru.txt", __FILE__)) expect(File.exists?(bundle_config)).to be_truthy expect(file_content).to eq(expected_file_content) end end describe "#generate_app" do def expected_default_files(target_dir, expected_value) config_dir = "#{target_dir}/config" assets_dir = "#{target_dir}/assets" public_dir = "#{target_dir}/public" boot = "#{config_dir}/boot.rb" application = "#{config_dir}/application.rb" app_dir = "#{target_dir}/app" routes_dir = "#{target_dir}/app/routes" views_dir = "#{target_dir}/app/views" layout = "#{target_dir}/app/views/layout.erb" home_index = "#{target_dir}/app/views/home/index.erb" expect(File.exists?(config_dir)).to eq(expected_value) expect(File.exists?("#{config_dir}/boot.rb")).to eq(expected_value) expect(File.exists?("#{config_dir}/application.rb")).to eq(expected_value) expect(File.exists?(assets_dir)).to eq(expected_value) expect(File.exists?(public_dir)).to eq(expected_value) expect(Dir.exists?(app_dir)).to eq(expected_value) expect(Dir.exists?(routes_dir)).to eq(expected_value) expect(Dir.exists?(views_dir)).to eq(expected_value) expect(File.exists?(layout)).to eq(expected_value) expect(File.exists?(home_index)).to eq(expected_value) end def expected_generated_files_with_db(target_dir, expected_value) sample_migration = "#{target_dir}/db/migrations/000_example.rb" expect(Dir.exists?("#{target_dir}/app/models")).to eq(expected_value) expect(File.exists?("#{target_dir}/config/database.yml.example")).to eq(expected_value) expect(File.exists?(sample_migration)).to eq(expected_value) end before { FileUtils.rm_r @dest if Dir.exists?(@dest) } before { FileUtils.rm_r @dest_with_db if Dir.exists?(@dest_with_db) } it "generates home route" do generator.generate_app app_file = "#{target_dir}/app/routes/home.rb" erb_file = "#{target_dir}/app/routes/home.erb" file_content = File.read(app_file) expected_file_content = File.read(File.expand_path("../../fixtures/app_routes_home.txt", __FILE__)) expect(File.exists?(app_file)).to be_truthy expect(File.exists?(erb_file)).to be_falsey expect(file_content).to eq expected_file_content end context "when generating without database" do describe "copy_templates" do it "copies from melodiest templates" do expected_default_files(target_dir, false) expected_generated_files_with_db(target_dir, false) generator.generate_app expected_default_files(target_dir, true) expected_generated_files_with_db(target_dir, false) end end describe "app file" do let(:secret) { "supersecretcookiefromgenerator" } before { allow(SecureRandom).to receive(:hex).with(32).and_return(secret) } it "generates <app_name>.rb, public dir, and app dir" do generator.generate_app app_file = "#{target_dir}/my_app.rb" file_content = File.read(app_file) expected_file_content = File.read(File.expand_path("../../fixtures/without_db/app.txt", __FILE__)) expect(File.exists?(app_file)).to be_truthy expect(file_content).to eq expected_file_content end end end context "when generating with database" do describe "copy templates" do it "copies from melodiest templates" do expected_default_files(target_dir_with_db, false) expected_generated_files_with_db(target_dir_with_db, false) generator_with_db.generate_app expected_default_files(target_dir_with_db, true) expected_generated_files_with_db(target_dir_with_db, true) end end describe "app file" do let(:secret) { "supersecretcookiefromgenerator" } before { allow(SecureRandom).to receive(:hex).with(32).and_return(secret) } it "has sequel database connector" do generator_with_db.generate_app app_file = "#{target_dir_with_db}/my_app.rb" file_content = File.read(app_file) expected_file_content = File.read(File.expand_path("../../fixtures/with_db/app.txt", __FILE__)) expect(file_content).to eq expected_file_content end end end end describe "#generate_rakefile" do it "generate basic Rakefile tasks" do expected_rakefile_content = expected_rakefile_content = File.read(File.expand_path("../../fixtures/without_db/rakefile.txt", __FILE__)) generator.generate_rakefile rakefile = "#{target_dir}/Rakefile" rakefile_content = File.read(rakefile) expect(rakefile_content).to eq expected_rakefile_content end context "with database" do it "generates db related tasks" do expected_rakefile_content = File.read(File.expand_path("../../fixtures/with_db/rakefile.txt", __FILE__)) generator_with_db.generate_rakefile rakefile = "#{target_dir_with_db}/Rakefile" rakefile_content = File.read(rakefile) expect(rakefile_content).to eq expected_rakefile_content end end end end
class Broot < Formula desc "New way to see and navigate directory trees" homepage "https://dystroy.org/broot" url "https://github.com/Canop/broot/archive/v0.13.0.tar.gz" sha256 "677854cc1b3a177f2281979008cebc1880b0149ebd7be5dc5c58d162ed1e5522" head "https://github.com/Canop/broot.git" bottle do cellar :any_skip_relocation sha256 "43eeaf906a5648cc1ee554e019bb07784feb6372bcc9aa939c366be4c38a9c7c" => :catalina sha256 "6c92d76311ea4eceab85eab11596171f756cf276546bd4c37463dc786a7189eb" => :mojave sha256 "86cd281c8e26c5f74fbce9c519c38cf2f87042f47be3f9fe23b069fa3c04433d" => :high_sierra end depends_on "rust" => :build def install system "cargo", "install", "--locked", "--root", prefix, "--path", "." end test do assert_match version.to_s, shell_output("#{bin}/broot --version") assert_match "BFS", shell_output("#{bin}/broot --help 2>&1") (testpath/"test.exp").write <<~EOS spawn #{bin}/broot --cmd :pt --no-style --out #{testpath}/output.txt send "n\r" expect { timeout { exit 1 } eof } EOS assert_match "New Configuration file written in", shell_output("expect -f test.exp 2>&1") end end broot 0.13.1 Closes #49936. Signed-off-by: Alexander Bayandin <673dbf9b1367181cd47bae83bf10b2ffe51be6ac@gmail.com> class Broot < Formula desc "New way to see and navigate directory trees" homepage "https://dystroy.org/broot" url "https://github.com/Canop/broot/archive/v0.13.1.tar.gz" sha256 "594130c1e985379ce60885aab1b961d2326d0e5b34816d1c3590cf5837493742" head "https://github.com/Canop/broot.git" bottle do cellar :any_skip_relocation sha256 "43eeaf906a5648cc1ee554e019bb07784feb6372bcc9aa939c366be4c38a9c7c" => :catalina sha256 "6c92d76311ea4eceab85eab11596171f756cf276546bd4c37463dc786a7189eb" => :mojave sha256 "86cd281c8e26c5f74fbce9c519c38cf2f87042f47be3f9fe23b069fa3c04433d" => :high_sierra end depends_on "rust" => :build def install system "cargo", "install", "--locked", "--root", prefix, "--path", "." end test do assert_match version.to_s, shell_output("#{bin}/broot --version") assert_match "BFS", shell_output("#{bin}/broot --help 2>&1") (testpath/"test.exp").write <<~EOS spawn #{bin}/broot --cmd :pt --no-style --out #{testpath}/output.txt send "n\r" expect { timeout { exit 1 } eof } EOS assert_match "New Configuration file written in", shell_output("expect -f test.exp 2>&1") end end
require 'rails_helper' RSpec.describe BowlingGame, type: :model do subject { BowlingGame.new } describe "public class methods" do context "responds to its methods" do it { expect(subject).to respond_to(:score) } it { expect(subject).to respond_to(:attempt) } end describe "#score" do it { expect(subject.score).to be 0 } it 'should be 0 after 20 attempts with 0 pins down' do 20.times { subject.attempt(0) } expect(subject.score).to be 0 end it 'should be 20 after 20 attempts with 1 pins down' do 20.times { subject.attempt(1) } expect(subject.score).to be 20 end it 'should be 30 after 1 strike and 18 attempts with 1 pins down' do subject.attempt(10) 18.times { subject.attempt(1) } expect(subject.score).to be 30 end it 'should be 300 after 10 attempts with 10 pins down' do 12.times { subject.attempt(10) } expect(subject.score).to be 300 end end end end rename tests descriptions require 'rails_helper' RSpec.describe BowlingGame, type: :model do subject { BowlingGame.new } describe "public class methods" do context "responds to its methods" do it { expect(subject).to respond_to(:score) } it { expect(subject).to respond_to(:attempt) } end describe "#score" do it { expect(subject.score).to be 0 } it '0 after 20 attempts with 0 pins down' do 20.times { subject.attempt(0) } expect(subject.score).to be 0 end it '20 after 20 attempts with 1 pins down' do 20.times { subject.attempt(1) } expect(subject.score).to be 20 end it '30 after 1 strike and 18 attempts with 1 pins down' do subject.attempt(10) 18.times { subject.attempt(1) } expect(subject.score).to be 30 end it '300 after 10 attempts with 10 pins down' do 12.times { subject.attempt(10) } expect(subject.score).to be 300 end end end end
class Bwctl < Formula desc "Command-line tool and daemon for network measuring tools" homepage "https://software.internet2.edu/bwctl/" url "https://software.internet2.edu/sources/bwctl/bwctl-1.5.4.tar.gz" sha256 "e6dca6ca30c8ef4d68e6b34b011a9ff7eff3aba4a84efc19d96e3675182e40ef" license "Apache-2.0" bottle do cellar :any_skip_relocation rebuild 1 sha256 "125c3592d5a34d3913dde26356ee894136716f6b224ab1d8bc14ab487fbd2633" => :catalina sha256 "b4e91dbfca063d51a0280dffde519e9d4e5d66d0e0a301936dbbe86239e295a3" => :mojave sha256 "2d326aaaa5c9031fd668569cbd68627d84884389b4883282d82259af152b12c3" => :high_sierra sha256 "8667bc495aaeaca247c9a643f35baec59af1143de4d3cbf69904c35257899940" => :x86_64_linux end # https://software.internet2.edu/bwctl/ # The use of BWCTL became deprecated with the release of pScheduler in perfSONAR 4.0 in April, 2017. deprecate! :date => "2017-04-01" depends_on "i2util" => :build def install # configure mis-sets CFLAGS for I2util # https://lists.internet2.edu/sympa/arc/perfsonar-user/2015-04/msg00016.html # https://github.com/Homebrew/homebrew/pull/38212 inreplace "configure", 'CFLAGS="-I$I2util_dir/include $CFLAGS"', 'CFLAGS="-I$with_I2util/include $CFLAGS"' system "./configure", "--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}", "--mandir=#{man}", "--with-I2util=#{Formula["i2util"].opt_prefix}" system "make", "install" end test do system "#{bin}/bwctl", "-V" end end bwctl: fix RuboCop style. See https://github.com/Homebrew/brew/pull/7867. class Bwctl < Formula desc "Command-line tool and daemon for network measuring tools" homepage "https://software.internet2.edu/bwctl/" url "https://software.internet2.edu/sources/bwctl/bwctl-1.5.4.tar.gz" sha256 "e6dca6ca30c8ef4d68e6b34b011a9ff7eff3aba4a84efc19d96e3675182e40ef" license "Apache-2.0" bottle do cellar :any_skip_relocation rebuild 1 sha256 "125c3592d5a34d3913dde26356ee894136716f6b224ab1d8bc14ab487fbd2633" => :catalina sha256 "b4e91dbfca063d51a0280dffde519e9d4e5d66d0e0a301936dbbe86239e295a3" => :mojave sha256 "2d326aaaa5c9031fd668569cbd68627d84884389b4883282d82259af152b12c3" => :high_sierra sha256 "8667bc495aaeaca247c9a643f35baec59af1143de4d3cbf69904c35257899940" => :x86_64_linux end # https://software.internet2.edu/bwctl/ # The use of BWCTL became deprecated with the release of pScheduler in perfSONAR 4.0 in April, 2017. deprecate! date: "2017-04-01" depends_on "i2util" => :build def install # configure mis-sets CFLAGS for I2util # https://lists.internet2.edu/sympa/arc/perfsonar-user/2015-04/msg00016.html # https://github.com/Homebrew/homebrew/pull/38212 inreplace "configure", 'CFLAGS="-I$I2util_dir/include $CFLAGS"', 'CFLAGS="-I$with_I2util/include $CFLAGS"' system "./configure", "--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}", "--mandir=#{man}", "--with-I2util=#{Formula["i2util"].opt_prefix}" system "make", "install" end test do system "#{bin}/bwctl", "-V" end end
require 'rails_helper' describe Budget::Phase do let(:budget) { create(:budget) } let(:first_phase) { budget.phases.drafting } let(:second_phase) { budget.phases.informing } let(:third_phase) { budget.phases.accepting } let(:fourth_phase) { budget.phases.reviewing } let(:fifth_phase) { budget.phases.selecting } let(:final_phase) { budget.phases.finished} before do first_phase.update_attributes(starts_at: Date.current - 3.days, ends_at: Date.current - 1.day) second_phase.update_attributes(starts_at: Date.current - 1.days, ends_at: Date.current + 1.day) third_phase.update_attributes(starts_at: Date.current + 1.days, ends_at: Date.current + 3.day) fourth_phase.update_attributes(starts_at: Date.current + 3.days, ends_at: Date.current + 5.day) fifth_phase.update_attributes(starts_at: Date.current + 5.days, ends_at: Date.current + 7.day) end describe "validates" do it "is not valid without a budget" do expect(build(:budget_phase, budget: nil)).not_to be_valid end describe "kind validations" do it "is not valid without a kind" do expect(build(:budget_phase, kind: nil)).not_to be_valid end it "is not valid with a kind not in valid budget phases" do expect(build(:budget_phase, kind: 'invalid_phase_kind')).not_to be_valid end it "is not valid with the same kind as another budget's phase" do expect(build(:budget_phase, budget: budget)).not_to be_valid end end describe "#dates_range_valid?" do it "is valid when start & end dates are different & consecutive" do first_phase.update_attributes(starts_at: Date.today, ends_at: Date.tomorrow) expect(first_phase).to be_valid end it "is not valid when dates are equal" do first_phase.update_attributes(starts_at: Date.today, ends_at: Date.today) expect(first_phase).not_to be_valid end it "is not valid when start date is later than end date" do first_phase.update_attributes(starts_at: Date.tomorrow, ends_at: Date.today) expect(first_phase).not_to be_valid end end describe "#prev_phase_dates_valid?" do let(:error) do "Start date must be later than the start date of the previous enabled phase"\ " (Draft (Not visible to the public))" end it "is invalid when start date is same as previous enabled phase start date" do second_phase.assign_attributes(starts_at: second_phase.prev_enabled_phase.starts_at) expect(second_phase).not_to be_valid expect(second_phase.errors.messages[:starts_at]).to include(error) end it "is invalid when start date is earlier than previous enabled phase start date" do second_phase.assign_attributes(starts_at: second_phase.prev_enabled_phase.starts_at - 1.day) expect(second_phase).not_to be_valid expect(second_phase.errors.messages[:starts_at]).to include(error) end it "is valid when start date is in between previous enabled phase start & end dates" do second_phase.assign_attributes(starts_at: second_phase.prev_enabled_phase.starts_at + 1.day) expect(second_phase).to be_valid end it "is valid when start date is later than previous enabled phase end date" do second_phase.assign_attributes(starts_at: second_phase.prev_enabled_phase.ends_at + 1.day) expect(second_phase).to be_valid end end describe "#next_phase_dates_valid?" do let(:error) do "End date must be earlier than the end date of the next enabled phase (Accepting projects)" end it "is invalid when end date is same as next enabled phase end date" do second_phase.assign_attributes(ends_at: second_phase.next_enabled_phase.ends_at) expect(second_phase).not_to be_valid expect(second_phase.errors.messages[:ends_at]).to include(error) end it "is invalid when end date is later than next enabled phase end date" do second_phase.assign_attributes(ends_at: second_phase.next_enabled_phase.ends_at + 1.day) expect(second_phase).not_to be_valid expect(second_phase.errors.messages[:ends_at]).to include(error) end it "is valid when end date is in between next enabled phase start & end dates" do second_phase.assign_attributes(ends_at: second_phase.next_enabled_phase.ends_at - 1.day) expect(second_phase).to be_valid end it "is valid when end date is earlier than next enabled phase start date" do second_phase.assign_attributes(ends_at: second_phase.next_enabled_phase.starts_at - 1.day) expect(second_phase).to be_valid end end end describe "#adjust_date_ranges" do let(:prev_enabled_phase) { second_phase.prev_enabled_phase } let(:next_enabled_phase) { second_phase.next_enabled_phase } describe "when enabled" do it "adjusts previous enabled phase end date to its own start date" do expect(prev_enabled_phase.ends_at).to eq(second_phase.starts_at) end it "adjusts next enabled phase start date to its own end date" do expect(next_enabled_phase.starts_at).to eq(second_phase.ends_at) end end describe "when being enabled" do before do second_phase.update_attributes(enabled: false, starts_at: Date.current, ends_at: Date.current + 2.days) end it "adjusts previous enabled phase end date to its own start date" do expect{ second_phase.update_attributes(enabled: true) }.to change{ prev_enabled_phase.ends_at.to_date }.to(Date.current) end it "adjusts next enabled phase start date to its own end date" do expect{ second_phase.update_attributes(enabled: true) }.to change{ next_enabled_phase.starts_at.to_date }.to(Date.current + 2.days) end end describe "when disabled" do before do second_phase.update_attributes(enabled: false) end it "doesn't change previous enabled phase end date" do expect { second_phase.update_attributes(starts_at: Date.current, ends_at: Date.current + 2.days) }.not_to (change{ prev_enabled_phase.ends_at }) end it "doesn't change next enabled phase start date" do expect{ second_phase.update_attributes(starts_at: Date.current, ends_at: Date.current + 2.days) }.not_to (change{ next_enabled_phase.starts_at }) end end describe "when being disabled" do it "doesn't adjust previous enabled phase end date to its own start date" do expect { second_phase.update_attributes(enabled: false, starts_at: Date.current, ends_at: Date.current + 2.days) }.not_to (change{ prev_enabled_phase.ends_at }) end it "adjusts next enabled phase start date to its own start date" do expect { second_phase.update_attributes(enabled: false, starts_at: Date.current, ends_at: Date.current + 2.days) }.to change{ next_enabled_phase.starts_at.to_date }.to(Date.current) end end end describe "next & prev enabled phases" do before do second_phase.update_attributes(enabled: false) end describe "#next_enabled_phase" do it "returns the right next enabled phase" do expect(first_phase.reload.next_enabled_phase).to eq(third_phase) expect(third_phase.reload.next_enabled_phase).to eq(fourth_phase) expect(final_phase.reload.next_enabled_phase).to eq(nil) end end describe "#prev_enabled_phase" do it "returns the right previous enabled phase" do expect(first_phase.reload.prev_enabled_phase).to eq(nil) expect(third_phase.reload.prev_enabled_phase).to eq(first_phase) expect(fourth_phase.reload.prev_enabled_phase).to eq(third_phase) end end end describe "#sanitize_description" do it "removes html entities from the description" do expect{ first_phase.update_attributes(description: "<a>a</p> <javascript>javascript</javascript>") }.to change{ first_phase.description }.to('a javascript') end end end Fix test now the <a> tag is permited, also the list of allowed tags is in the configuration of ckeditor4 require 'rails_helper' describe Budget::Phase do let(:budget) { create(:budget) } let(:first_phase) { budget.phases.drafting } let(:second_phase) { budget.phases.informing } let(:third_phase) { budget.phases.accepting } let(:fourth_phase) { budget.phases.reviewing } let(:fifth_phase) { budget.phases.selecting } let(:final_phase) { budget.phases.finished} before do first_phase.update_attributes(starts_at: Date.current - 3.days, ends_at: Date.current - 1.day) second_phase.update_attributes(starts_at: Date.current - 1.days, ends_at: Date.current + 1.day) third_phase.update_attributes(starts_at: Date.current + 1.days, ends_at: Date.current + 3.day) fourth_phase.update_attributes(starts_at: Date.current + 3.days, ends_at: Date.current + 5.day) fifth_phase.update_attributes(starts_at: Date.current + 5.days, ends_at: Date.current + 7.day) end describe "validates" do it "is not valid without a budget" do expect(build(:budget_phase, budget: nil)).not_to be_valid end describe "kind validations" do it "is not valid without a kind" do expect(build(:budget_phase, kind: nil)).not_to be_valid end it "is not valid with a kind not in valid budget phases" do expect(build(:budget_phase, kind: 'invalid_phase_kind')).not_to be_valid end it "is not valid with the same kind as another budget's phase" do expect(build(:budget_phase, budget: budget)).not_to be_valid end end describe "#dates_range_valid?" do it "is valid when start & end dates are different & consecutive" do first_phase.update_attributes(starts_at: Date.today, ends_at: Date.tomorrow) expect(first_phase).to be_valid end it "is not valid when dates are equal" do first_phase.update_attributes(starts_at: Date.today, ends_at: Date.today) expect(first_phase).not_to be_valid end it "is not valid when start date is later than end date" do first_phase.update_attributes(starts_at: Date.tomorrow, ends_at: Date.today) expect(first_phase).not_to be_valid end end describe "#prev_phase_dates_valid?" do let(:error) do "Start date must be later than the start date of the previous enabled phase"\ " (Draft (Not visible to the public))" end it "is invalid when start date is same as previous enabled phase start date" do second_phase.assign_attributes(starts_at: second_phase.prev_enabled_phase.starts_at) expect(second_phase).not_to be_valid expect(second_phase.errors.messages[:starts_at]).to include(error) end it "is invalid when start date is earlier than previous enabled phase start date" do second_phase.assign_attributes(starts_at: second_phase.prev_enabled_phase.starts_at - 1.day) expect(second_phase).not_to be_valid expect(second_phase.errors.messages[:starts_at]).to include(error) end it "is valid when start date is in between previous enabled phase start & end dates" do second_phase.assign_attributes(starts_at: second_phase.prev_enabled_phase.starts_at + 1.day) expect(second_phase).to be_valid end it "is valid when start date is later than previous enabled phase end date" do second_phase.assign_attributes(starts_at: second_phase.prev_enabled_phase.ends_at + 1.day) expect(second_phase).to be_valid end end describe "#next_phase_dates_valid?" do let(:error) do "End date must be earlier than the end date of the next enabled phase (Accepting projects)" end it "is invalid when end date is same as next enabled phase end date" do second_phase.assign_attributes(ends_at: second_phase.next_enabled_phase.ends_at) expect(second_phase).not_to be_valid expect(second_phase.errors.messages[:ends_at]).to include(error) end it "is invalid when end date is later than next enabled phase end date" do second_phase.assign_attributes(ends_at: second_phase.next_enabled_phase.ends_at + 1.day) expect(second_phase).not_to be_valid expect(second_phase.errors.messages[:ends_at]).to include(error) end it "is valid when end date is in between next enabled phase start & end dates" do second_phase.assign_attributes(ends_at: second_phase.next_enabled_phase.ends_at - 1.day) expect(second_phase).to be_valid end it "is valid when end date is earlier than next enabled phase start date" do second_phase.assign_attributes(ends_at: second_phase.next_enabled_phase.starts_at - 1.day) expect(second_phase).to be_valid end end end describe "#adjust_date_ranges" do let(:prev_enabled_phase) { second_phase.prev_enabled_phase } let(:next_enabled_phase) { second_phase.next_enabled_phase } describe "when enabled" do it "adjusts previous enabled phase end date to its own start date" do expect(prev_enabled_phase.ends_at).to eq(second_phase.starts_at) end it "adjusts next enabled phase start date to its own end date" do expect(next_enabled_phase.starts_at).to eq(second_phase.ends_at) end end describe "when being enabled" do before do second_phase.update_attributes(enabled: false, starts_at: Date.current, ends_at: Date.current + 2.days) end it "adjusts previous enabled phase end date to its own start date" do expect{ second_phase.update_attributes(enabled: true) }.to change{ prev_enabled_phase.ends_at.to_date }.to(Date.current) end it "adjusts next enabled phase start date to its own end date" do expect{ second_phase.update_attributes(enabled: true) }.to change{ next_enabled_phase.starts_at.to_date }.to(Date.current + 2.days) end end describe "when disabled" do before do second_phase.update_attributes(enabled: false) end it "doesn't change previous enabled phase end date" do expect { second_phase.update_attributes(starts_at: Date.current, ends_at: Date.current + 2.days) }.not_to (change{ prev_enabled_phase.ends_at }) end it "doesn't change next enabled phase start date" do expect{ second_phase.update_attributes(starts_at: Date.current, ends_at: Date.current + 2.days) }.not_to (change{ next_enabled_phase.starts_at }) end end describe "when being disabled" do it "doesn't adjust previous enabled phase end date to its own start date" do expect { second_phase.update_attributes(enabled: false, starts_at: Date.current, ends_at: Date.current + 2.days) }.not_to (change{ prev_enabled_phase.ends_at }) end it "adjusts next enabled phase start date to its own start date" do expect { second_phase.update_attributes(enabled: false, starts_at: Date.current, ends_at: Date.current + 2.days) }.to change{ next_enabled_phase.starts_at.to_date }.to(Date.current) end end end describe "next & prev enabled phases" do before do second_phase.update_attributes(enabled: false) end describe "#next_enabled_phase" do it "returns the right next enabled phase" do expect(first_phase.reload.next_enabled_phase).to eq(third_phase) expect(third_phase.reload.next_enabled_phase).to eq(fourth_phase) expect(final_phase.reload.next_enabled_phase).to eq(nil) end end describe "#prev_enabled_phase" do it "returns the right previous enabled phase" do expect(first_phase.reload.prev_enabled_phase).to eq(nil) expect(third_phase.reload.prev_enabled_phase).to eq(first_phase) expect(fourth_phase.reload.prev_enabled_phase).to eq(third_phase) end end end end
class Byacc < Formula desc "(Arguably) the best yacc variant" homepage "http://invisible-island.net/byacc/byacc.html" url "ftp://invisible-island.net/byacc/byacc-20170430.tgz" sha256 "44cb43306c0f1e7b8539025fb02120261488d872969c8aa658bd50b0a5467299" bottle do cellar :any_skip_relocation sha256 "62b3f87a17d1fa2309444b295b3f1b92e2c2afaa8566effbdf2f3dd7f06a3052" => :sierra sha256 "9fde660e4a2eac410064b77801c364cc3c7dbb9a0fabe1c5aa929aeb1aec6808" => :el_capitan sha256 "59e8adc373dd31b8087d6a82fa2c6fcb7c50f21d23b2c65d6f91f9d72b754211" => :yosemite end def install system "./configure", "--disable-debug", "--disable-dependency-tracking", "--program-prefix=b", "--prefix=#{prefix}", "--man=#{man}" system "make", "install" end test do system bin/"byacc", "-V" end end byacc: update 20170430 bottle. class Byacc < Formula desc "(Arguably) the best yacc variant" homepage "http://invisible-island.net/byacc/byacc.html" url "ftp://invisible-island.net/byacc/byacc-20170430.tgz" sha256 "44cb43306c0f1e7b8539025fb02120261488d872969c8aa658bd50b0a5467299" bottle do cellar :any_skip_relocation sha256 "0fe9ae7c9e17d4c86b482c1687154a0505d3789aaef27ecb7447020a97fed735" => :sierra sha256 "db200946b47757fa0dacf8a4c5869b02b44a77277406f9a4d9ac9927b3ddbc03" => :el_capitan sha256 "b9d1cf3f27f5b0e32d41a5838057779953f5642ebf0bcf7c15a03193a3e14568" => :yosemite end def install system "./configure", "--disable-debug", "--disable-dependency-tracking", "--program-prefix=b", "--prefix=#{prefix}", "--man=#{man}" system "make", "install" end test do system bin/"byacc", "-V" end end
require 'rails_helper' RSpec.describe Contribution, type: :model do let(:user){ create(:user) } let(:failed_project){ create(:project, state: 'online') } let(:unfinished_project){ create(:project, state: 'online') } let(:successful_project){ create(:project, state: 'online') } let(:unfinished_project_contribution){ create(:contribution, state: 'confirmed', user: user, project: unfinished_project) } let(:sucessful_project_contribution){ create(:contribution, state: 'confirmed', user: user, project: successful_project) } let(:not_confirmed_contribution){ create(:contribution, user: user, project: unfinished_project) } let(:valid_refund){ create(:contribution, state: 'confirmed', user: user, project: failed_project) } let(:contribution) { create(:contribution) } describe "Associations" do it { is_expected.to have_many(:payment_notifications) } it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:reward) } it { is_expected.to belong_to(:country) } it { is_expected.to belong_to(:recurring_contribution) } end describe "Validations" do it{ is_expected.to validate_presence_of(:project) } it{ is_expected.to validate_presence_of(:user) } xit{ is_expected.to validate_presence_of(:value) } it{ is_expected.to allow_value(10).for(:value) } it{ is_expected.to allow_value(20).for(:value) } end describe "Custom validations" do let(:user) { create(:user) } describe "validates_numericality_of :value" do context "when user has credits" do let(:contribution) { build(:contribution, user: user) } before do allow(user).to receive(:credits).and_return(5) contribution.value = 5 contribution.save end it { expect(contribution.valid?).to be_truthy } it { expect(contribution.errors).to be_empty } end context "when user not have credits" do let(:contribution) { build(:contribution, user: user) } before do allow(user).to receive(:credits).and_return(0) contribution.value = 5 contribution.save end xit { expect(contribution.valid?).to be_falsey } xit { expect(contribution.errors).not_to be_empty } end end end describe ".avaiable_to_automatic_refund" do before do create(:contribution, state: 'confirmed', payment_choice: 'CartaoDeCredito', payment_method: nil) create(:contribution, state: 'confirmed', payment_choice: 'BoletoBancario', payment_method: 'Pagarme') create(:contribution, state: 'confirmed', payment_choice: nil, payment_method: 'PayPal') 14.times { create(:contribution, state: 'confirmed', payment_choice: 'BoletoBancario', payment_method: 'MoIP') } end subject { Contribution.avaiable_to_automatic_refund } it { is_expected.to have(3).itens } end describe ".confirmed_today" do before do 3.times { create(:contribution, state: 'confirmed', confirmed_at: 2.days.ago) } 4.times { create(:contribution, state: 'confirmed', confirmed_at: 6.days.ago) } #TODO: need to investigate this timestamp issue when # use DateTime.now or Time.now 7.times { create(:contribution, state: 'confirmed', confirmed_at: Time.now) } end subject { Contribution.confirmed_today } it { is_expected.to have(7).items } end describe ".between_values" do let(:start_at) { 10 } let(:ends_at) { 20 } subject { Contribution.between_values(start_at, ends_at) } before do create(:contribution, value: 10) create(:contribution, value: 15) create(:contribution, value: 20) create(:contribution, value: 21) end xit { is_expected.to have(3).itens } end describe ".can_cancel" do subject { Contribution.can_cancel} context "when contribution is in time to wait the confirmation" do before do create(:contribution, state: 'waiting_confirmation', created_at: 3.weekdays_ago) end it { is_expected.to have(0).item } end context "when contribution is by bank transfer and is passed the confirmation time" do before do create(:contribution, state: 'waiting_confirmation', payment_choice: 'DebitoBancario', created_at: 2.weekdays_ago) create(:contribution, state: 'waiting_confirmation', payment_choice: 'DebitoBancario', created_at: 0.weekdays_ago) end it { is_expected.to have(1).item } end context "when we have contributions that is passed the confirmation time" do before do create(:contribution, state: 'waiting_confirmation', created_at: 3.weekdays_ago) create(:contribution, state: 'waiting_confirmation', created_at: 6.weekdays_ago) end it { is_expected.to have(1).itens } end end describe '#slip_payment?' do subject { contribution.slip_payment? } context "when contribution is made with Boleto" do before do contribution.update_attributes payment_choice: 'BoletoBancario' end it { is_expected.to eq(true)} end context "when contribution is not made with Boleto" do before do contribution.update_attributes payment_choice: 'CartaoDeCredito' end it { is_expected.to eq(false)} end end describe '#recommended_projects' do subject{ contribution.recommended_projects } context "when we have another projects in the same category" do before do @recommended = create(:project, category: contribution.project.category) # add a project successful that should not apear as recommended create(:project, category: contribution.project.category, state: 'successful') end it{ is_expected.to eq [@recommended] } end context "when another user has contributed the same project" do before do @another_contribution = create(:contribution, project: contribution.project) @recommended = create(:contribution, user: @another_contribution.user).project # add a project successful that should not apear as recommended create(:contribution, user: @another_contribution.user, project: successful_project) successful_project.update_attributes state: 'successful' end it{ is_expected.to eq [@recommended] } end end describe ".can_refund" do subject{ Contribution.can_refund.load } before do create(:contribution, state: 'confirmed', credits: true, project: failed_project) valid_refund sucessful_project_contribution unfinished_project not_confirmed_contribution successful_project.update_attributes state: 'successful' failed_project.update_attributes state: 'failed' end it{ is_expected.to eq([valid_refund]) } end describe "#can_refund?" do subject{ contribution.can_refund? } before do valid_refund sucessful_project_contribution successful_project.update_attributes state: 'successful' failed_project.update_attributes state: 'failed' end context "when project is successful" do let(:contribution){ sucessful_project_contribution } it{ is_expected.to eq(false) } end context "when project is not finished" do let(:contribution){ unfinished_project_contribution } it{ is_expected.to eq(false) } end context "when contribution is not confirmed" do let(:contribution){ not_confirmed_contribution } it{ is_expected.to eq(false) } end context "when it's a valid refund" do let(:contribution){ valid_refund } xit{ is_expected.to eq(true) } end end describe "#credits" do subject{ user.credits.to_f } context "when contributions are confirmed and not done with credits but project is successful" do before do create(:contribution, state: 'confirmed', user: user, project: successful_project) successful_project.update_attributes state: 'successful' end it{ is_expected.to eq(0) } end context "when contributions are confirmed and not done with credits" do before do create(:contribution, state: 'confirmed', user: user, project: failed_project) failed_project.update_attributes state: 'failed' user.reload end it{ is_expected.to eq(10) } end context "when contributions are done with credits" do before do create(:contribution, credits: true, state: 'confirmed', user: user, project: failed_project) failed_project.update_attributes state: 'failed' end it{ is_expected.to eq(0) } end context "when contributions are not confirmed" do before do create(:contribution, user: user, project: failed_project, state: 'pending') failed_project.update_attributes state: 'failed' end it{ is_expected.to eq(0) } end end describe '.only_recurring' do subject { Contribution.only_recurring } context 'when we dont have any recurring contribution' do it { is_expected.to have(0).item } end context 'when we have recurring contributions' do before do recurring_contribution = create(:recurring_contribution, contributions: [contribution]) contribution.update_attributes(recurring_contribution: recurring_contribution) end it { is_expected.to have(1).item } end end describe '.only_cancelled_recurring' do subject { Contribution.only_recurring } context 'when we dont have any cancelled recurring contribution' do it { is_expected.to have(0).item } end context 'when we have cancelled recurring contributions' do before do recurring_contribution = create(:recurring_contribution, contributions: [contribution], cancelled_at: Time.now) contribution.update_attributes(recurring_contribution: recurring_contribution) end it { is_expected.to have(1).item } end end describe '#with_cause' do let(:category) { create(:category) } let(:project) { create(:project) } before do create(:contribution, project: project, payer_email: 'test1@test.com') create(:contribution, project: project, payer_email: 'test2@test.com') create(:contribution, project: project, payer_email: 'test3@test.com') create(:contribution, payer_email: 'test4@test.com') end context 'when category does not have a project' do it 'does not find a contributions having the category as a cause' do contributions = Contribution.with_cause(category.id) expect(contributions).to have(0).items end end context 'when category have registered projects' do before do @contributions = Contribution.with_cause(project.category_id) @payer_emails = @contributions.map(&:payer_email) end it 'does find contributions having the category as a cause' do expect(@payer_emails).to match_array(['test1@test.com', 'test2@test.com', 'test3@test.com']) end it 'ommits contributions without the category as a cause' do expect(@payer_emails).not_to include('test4@test.com') end end end end Create specs for project_name_contains scope require 'rails_helper' RSpec.describe Contribution, type: :model do let(:user){ create(:user) } let(:failed_project){ create(:project, state: 'online') } let(:unfinished_project){ create(:project, state: 'online') } let(:successful_project){ create(:project, state: 'online') } let(:unfinished_project_contribution){ create(:contribution, state: 'confirmed', user: user, project: unfinished_project) } let(:sucessful_project_contribution){ create(:contribution, state: 'confirmed', user: user, project: successful_project) } let(:not_confirmed_contribution){ create(:contribution, user: user, project: unfinished_project) } let(:valid_refund){ create(:contribution, state: 'confirmed', user: user, project: failed_project) } let(:contribution) { create(:contribution) } describe "Associations" do it { is_expected.to have_many(:payment_notifications) } it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:reward) } it { is_expected.to belong_to(:country) } it { is_expected.to belong_to(:recurring_contribution) } end describe "Validations" do it{ is_expected.to validate_presence_of(:project) } it{ is_expected.to validate_presence_of(:user) } xit{ is_expected.to validate_presence_of(:value) } it{ is_expected.to allow_value(10).for(:value) } it{ is_expected.to allow_value(20).for(:value) } end describe "Custom validations" do let(:user) { create(:user) } describe "validates_numericality_of :value" do context "when user has credits" do let(:contribution) { build(:contribution, user: user) } before do allow(user).to receive(:credits).and_return(5) contribution.value = 5 contribution.save end it { expect(contribution.valid?).to be_truthy } it { expect(contribution.errors).to be_empty } end context "when user not have credits" do let(:contribution) { build(:contribution, user: user) } before do allow(user).to receive(:credits).and_return(0) contribution.value = 5 contribution.save end xit { expect(contribution.valid?).to be_falsey } xit { expect(contribution.errors).not_to be_empty } end end end describe ".avaiable_to_automatic_refund" do before do create(:contribution, state: 'confirmed', payment_choice: 'CartaoDeCredito', payment_method: nil) create(:contribution, state: 'confirmed', payment_choice: 'BoletoBancario', payment_method: 'Pagarme') create(:contribution, state: 'confirmed', payment_choice: nil, payment_method: 'PayPal') 14.times { create(:contribution, state: 'confirmed', payment_choice: 'BoletoBancario', payment_method: 'MoIP') } end subject { Contribution.avaiable_to_automatic_refund } it { is_expected.to have(3).itens } end describe ".confirmed_today" do before do 3.times { create(:contribution, state: 'confirmed', confirmed_at: 2.days.ago) } 4.times { create(:contribution, state: 'confirmed', confirmed_at: 6.days.ago) } #TODO: need to investigate this timestamp issue when # use DateTime.now or Time.now 7.times { create(:contribution, state: 'confirmed', confirmed_at: Time.now) } end subject { Contribution.confirmed_today } it { is_expected.to have(7).items } end describe ".between_values" do let(:start_at) { 10 } let(:ends_at) { 20 } subject { Contribution.between_values(start_at, ends_at) } before do create(:contribution, value: 10) create(:contribution, value: 15) create(:contribution, value: 20) create(:contribution, value: 21) end xit { is_expected.to have(3).itens } end describe ".can_cancel" do subject { Contribution.can_cancel} context "when contribution is in time to wait the confirmation" do before do create(:contribution, state: 'waiting_confirmation', created_at: 3.weekdays_ago) end it { is_expected.to have(0).item } end context "when contribution is by bank transfer and is passed the confirmation time" do before do create(:contribution, state: 'waiting_confirmation', payment_choice: 'DebitoBancario', created_at: 2.weekdays_ago) create(:contribution, state: 'waiting_confirmation', payment_choice: 'DebitoBancario', created_at: 0.weekdays_ago) end it { is_expected.to have(1).item } end context "when we have contributions that is passed the confirmation time" do before do create(:contribution, state: 'waiting_confirmation', created_at: 3.weekdays_ago) create(:contribution, state: 'waiting_confirmation', created_at: 6.weekdays_ago) end it { is_expected.to have(1).itens } end end describe '#slip_payment?' do subject { contribution.slip_payment? } context "when contribution is made with Boleto" do before do contribution.update_attributes payment_choice: 'BoletoBancario' end it { is_expected.to eq(true)} end context "when contribution is not made with Boleto" do before do contribution.update_attributes payment_choice: 'CartaoDeCredito' end it { is_expected.to eq(false)} end end describe '#recommended_projects' do subject{ contribution.recommended_projects } context "when we have another projects in the same category" do before do @recommended = create(:project, category: contribution.project.category) # add a project successful that should not apear as recommended create(:project, category: contribution.project.category, state: 'successful') end it{ is_expected.to eq [@recommended] } end context "when another user has contributed the same project" do before do @another_contribution = create(:contribution, project: contribution.project) @recommended = create(:contribution, user: @another_contribution.user).project # add a project successful that should not apear as recommended create(:contribution, user: @another_contribution.user, project: successful_project) successful_project.update_attributes state: 'successful' end it{ is_expected.to eq [@recommended] } end end describe ".can_refund" do subject{ Contribution.can_refund.load } before do create(:contribution, state: 'confirmed', credits: true, project: failed_project) valid_refund sucessful_project_contribution unfinished_project not_confirmed_contribution successful_project.update_attributes state: 'successful' failed_project.update_attributes state: 'failed' end it{ is_expected.to eq([valid_refund]) } end describe "#can_refund?" do subject{ contribution.can_refund? } before do valid_refund sucessful_project_contribution successful_project.update_attributes state: 'successful' failed_project.update_attributes state: 'failed' end context "when project is successful" do let(:contribution){ sucessful_project_contribution } it{ is_expected.to eq(false) } end context "when project is not finished" do let(:contribution){ unfinished_project_contribution } it{ is_expected.to eq(false) } end context "when contribution is not confirmed" do let(:contribution){ not_confirmed_contribution } it{ is_expected.to eq(false) } end context "when it's a valid refund" do let(:contribution){ valid_refund } xit{ is_expected.to eq(true) } end end describe "#credits" do subject{ user.credits.to_f } context "when contributions are confirmed and not done with credits but project is successful" do before do create(:contribution, state: 'confirmed', user: user, project: successful_project) successful_project.update_attributes state: 'successful' end it{ is_expected.to eq(0) } end context "when contributions are confirmed and not done with credits" do before do create(:contribution, state: 'confirmed', user: user, project: failed_project) failed_project.update_attributes state: 'failed' user.reload end it{ is_expected.to eq(10) } end context "when contributions are done with credits" do before do create(:contribution, credits: true, state: 'confirmed', user: user, project: failed_project) failed_project.update_attributes state: 'failed' end it{ is_expected.to eq(0) } end context "when contributions are not confirmed" do before do create(:contribution, user: user, project: failed_project, state: 'pending') failed_project.update_attributes state: 'failed' end it{ is_expected.to eq(0) } end end describe '.only_recurring' do subject { Contribution.only_recurring } context 'when we dont have any recurring contribution' do it { is_expected.to have(0).item } end context 'when we have recurring contributions' do before do recurring_contribution = create(:recurring_contribution, contributions: [contribution]) contribution.update_attributes(recurring_contribution: recurring_contribution) end it { is_expected.to have(1).item } end end describe '.only_cancelled_recurring' do subject { Contribution.only_recurring } context 'when we dont have any cancelled recurring contribution' do it { is_expected.to have(0).item } end context 'when we have cancelled recurring contributions' do before do recurring_contribution = create(:recurring_contribution, contributions: [contribution], cancelled_at: Time.now) contribution.update_attributes(recurring_contribution: recurring_contribution) end it { is_expected.to have(1).item } end end describe '#with_cause' do let(:category) { create(:category) } let(:project) { create(:project) } before do create(:contribution, project: project, payer_email: 'test1@test.com') create(:contribution, project: project, payer_email: 'test2@test.com') create(:contribution, project: project, payer_email: 'test3@test.com') create(:contribution, payer_email: 'test4@test.com') end context 'when category does not have a project' do it 'does not find a contributions having the category as a cause' do contributions = Contribution.with_cause(category.id) expect(contributions).to have(0).items end end context 'when category have registered projects' do before do @contributions = Contribution.with_cause(project.category_id) @payer_emails = @contributions.map(&:payer_email) end it 'does find contributions having the category as a cause' do expect(@payer_emails).to match_array(['test1@test.com', 'test2@test.com', 'test3@test.com']) end it 'ommits contributions without the category as a cause' do expect(@payer_emails).not_to include('test4@test.com') end end end describe '#project_name_contains' do let(:great_name_project){ create(:project, name: 'Great project') } let(:great_headline_project){ create(:project, headline: 'Great project') } let(:great_permalink_project){ create(:project, permalink: 'great') } let(:great_project_contributions){ Contribution.project_name_contains('great') } before(:each) do create(:contribution, project: great_name_project, project_value: 50) create(:contribution, project: great_headline_project, project_value: 40) create(:contribution, project: great_permalink_project, project_value: 30) end context 'when there are contributions made to project that matches the term searched' do it 'returns the contributions made to project found' do expect(great_project_contributions.map(&:project_value)).to contain_exactly(40.0, 30.0, 50.0) end it "returns the contributions in the right order of Project.search_on_name's against param rules" do all_great_project_contributions = great_project_contributions.map { |c| c.project_value.to_f } expect(all_great_project_contributions).to eq([50.0, 40.0, 30.0]) end end context 'when contributions to a project that name matches the term searched do not exist' do it 'does not return contributions' do cool_project_contributions = Contribution.project_name_contains('cool') expect(cool_project_contributions).to be_empty end end end end
class Byobu < Formula desc "Text-based window manager and terminal multiplexer" homepage "http://byobu.co" url "https://launchpad.net/byobu/trunk/5.94/+download/byobu_5.94.orig.tar.gz" sha256 "4917013f590110d25b18293a51af02bd1ebcd1c665474f62e2566fb9b8f62916" bottle do cellar :any_skip_relocation revision 1 sha256 "210e6c1e3e682f64decac62c00f07729f700b22e3aaa4fea115d3276136b4cee" => :el_capitan sha256 "5b9cd209e5607b1a24f000172bbe750906f5ec25c1f653f123332c0d7f314704" => :yosemite sha256 "e554b1b2db2ae5008bff7fadf2ca98e6269c4b68374da80d103379d6b22b68a5" => :mavericks end conflicts_with "ctail", :because => "both install `ctail` binaries" depends_on "coreutils" depends_on "gnu-sed" # fails with BSD sed depends_on "tmux" depends_on "newt" => "with-python" def install system "./configure", "--prefix=#{prefix}" system "make", "install" end def caveats; <<-EOS.undent Add the following to your shell configuration file: export BYOBU_PREFIX=$(brew --prefix) EOS end test do system bin/"byobu-status" end end byobu 5.101 byobu: bump to 5.101, add head with build deps Closes Homebrew/homebrew#48343. Signed-off-by: Dominyk Tiller <53e438f55903875d07efdd98a8aaf887e7208dd3@gmail.com> class Byobu < Formula desc "Text-based window manager and terminal multiplexer" homepage "http://byobu.co" url "https://launchpad.net/byobu/trunk/5.101/+download/byobu_5.101.orig.tar.gz" sha256 "15972e7a6fc877fbc4e281f75ea23c04393d99764c8f6fe129dc91d614f5c8ce" head do url "https://github.com/dustinkirkland/byobu.git" depends_on "automake" => :build depends_on "autoconf" => :build end bottle do cellar :any_skip_relocation revision 1 sha256 "210e6c1e3e682f64decac62c00f07729f700b22e3aaa4fea115d3276136b4cee" => :el_capitan sha256 "5b9cd209e5607b1a24f000172bbe750906f5ec25c1f653f123332c0d7f314704" => :yosemite sha256 "e554b1b2db2ae5008bff7fadf2ca98e6269c4b68374da80d103379d6b22b68a5" => :mavericks end conflicts_with "ctail", :because => "both install `ctail` binaries" depends_on "coreutils" depends_on "gnu-sed" # fails with BSD sed depends_on "tmux" depends_on "newt" => "with-python" def install if build.head? cp "./debian/changelog", "./ChangeLog" system "autoreconf", "-fvi" end system "./configure", "--prefix=#{prefix}" system "make", "install" end def caveats; <<-EOS.undent Add the following to your shell configuration file: export BYOBU_PREFIX=$(brew --prefix) EOS end test do system bin/"byobu-status" end end
Some simple tests for the deep cloning functionality. require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe DeepCloning do before(:each) do @world = BiologicaWorld.create!(:name => "world", :description => "world description", :species_path => "org/concord/biologica/worlds/dragon.xml") @org = BiologicaOrganism.create!(:name => "organism", :description => "organism description", :sex => 0, :fatal_characteristics => true, :biologica_world => @world) @static_org = BiologicaStaticOrganism.create(:name => "static org", :description => "static org description", :biologica_organism => @org) @static_org2 = BiologicaStaticOrganism.create(:name => "static org2", :description => "static org2 description", :biologica_organism => @org) @page = Page.create!(:name => "Page", :description => "Page description") @page2 = Page.create!(:name => "Page2", :description => "Page2 description") @section = Section.create!(:name => "Section", :description => "Section description") @section.pages << @page @section.pages << @page2 @static_org.pages << @page @static_org2.pages << @page2 end def compare_equal(obj1, obj2, attrs = []) compare(obj1, obj2, true, attrs) end def compare_not_equal(obj1, obj2, attrs = []) compare(obj1, obj2, false, attrs) end def compare(obj1, obj2, equal, attrs) if attrs.size == 0 # FIXME Compare all the attributes else attrs.each do |att| if equal obj1.send(att).should == obj2.send(att) else obj1.send(att).should_not == obj2.send(att) end end end end it "should recursively clone page elements" do klone = @page.deep_clone :include => {:page_elements => :embeddable} klone.save! compare_equal(klone, @page, [:name, :description]) klone.page_elements.size.should == 1 klone.page_elements[0].embeddable.class.should == BiologicaStaticOrganism compare_equal(klone.page_elements[0].embeddable, @static_org, [:name, :description]) klone.page_elements[0].embeddable.biologica_organism.should_not == nil klone.page_elements[0].embeddable.biologica_organism.class.should == BiologicaOrganism compare_equal(klone.page_elements[0].embeddable.biologica_organism, @org, [:name, :description, :sex]) klone.page_elements[0].embeddable.biologica_organism.biologica_world.should_not == nil klone.page_elements[0].embeddable.biologica_organism.biologica_world.class.should == BiologicaWorld compare_equal(klone.page_elements[0].embeddable.biologica_organism.biologica_world, @world, [:name, :description, :species_path]) end it "should not clone uuid or timestamps" do klone = @page.deep_clone :never_clone => [:uuid, :created_at, :updated_at], :include => {:page_elements => :embeddable} klone.save! compare_not_equal(klone, @page, [:uuid, :created_at, :updated_at]) compare_not_equal(klone.page_elements[0].embeddable, @static_org, [:uuid, :created_at, :updated_at]) compare_not_equal(klone.page_elements[0].embeddable.biologica_organism, @org, [:uuid, :created_at, :updated_at]) compare_not_equal(klone.page_elements[0].embeddable.biologica_organism.biologica_world, @world, [:uuid, :created_at, :updated_at]) end it "should not make multiple organisms or worlds" do klone = @section.deep_clone :no_duplicates => true, :never_clone => [:uuid, :created_at, :updated_at], :include => {:pages => {:page_elements => :embeddable}} klone.pages.size.should == 2 klone.pages[0].page_elements[0].embeddable.biologica_organism.should == klone.pages[1].page_elements[0].embeddable.biologica_organism klone.pages[0].page_elements[0].embeddable.biologica_organism.biologica_world.should == klone.pages[1].page_elements[0].embeddable.biologica_organism.biologica_world end it "should make multiple organisms or worlds" do klone = @section.deep_clone :no_duplicates => false, :never_clone => [:uuid, :created_at, :updated_at], :include => {:pages => {:page_elements => :embeddable}} klone.pages.size.should == 2 klone.pages[0].page_elements[0].embeddable.biologica_organism.should_not == klone.pages[1].page_elements[0].embeddable.biologica_organism klone.pages[0].page_elements[0].embeddable.biologica_organism.biologica_world.should_not == klone.pages[1].page_elements[0].embeddable.biologica_organism.biologica_world end end
bzip2 1.0.6: New formula require "formula" class Bzip2 < Formula homepage "http://www.bzip.org/downloads.html" url "http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz" sha1 "3f89f861209ce81a6bab1fd1998c0ef311712002" def install system "make", "install", "PREFIX=#{prefix}" if OS.linux? # Install the shared library. system "make", "-f", "Makefile-libbz2_so", "clean" system "make", "-f", "Makefile-libbz2_so" lib.install "libbz2.so.1.0.6", "libbz2.so.1.0" lib.install_symlink "libbz2.so.1.0.6" => "libbz2.so.1" lib.install_symlink "libbz2.so.1.0.6" => "libbz2.so" end end test do system "#{bin}/bzip2 --version" end end
class Cacli < Formula desc "Train machine learning models from Cloud Annotations" homepage "https://cloud.annotations.ai" url "https://github.com/cloud-annotations/training/archive/v1.2.30.tar.gz" sha256 "f10758c46deefc90d08967f6e0f7d232947d5c795b9c533a2ffa898363391e81" bottle do cellar :any_skip_relocation sha256 "9b2d628a0cc4ba4e426cbd5afea64c3ec1af0877aeee605e3536ec57817e7924" => :catalina sha256 "ff5f177e8708eeb3567feedf4ff48e5c233b1cc9283153dc6437e6f651da502b" => :mojave sha256 "90127c81c2ae488e493ae7aae91d2a783e790fdb4809d9c620a093289f425cb0" => :high_sierra end depends_on "go" => :build def install cd "cacli" do project = "github.com/cloud-annotations/training/cacli" system "go", "build", "-ldflags", "-s -w -X #{project}/version.Version=#{version}", "-o", bin/"cacli" end end test do # Attempt to list training runs without credentials and confirm that it # fails as expected. output = shell_output("#{bin}/cacli list 2>&1", 1).strip cleaned = output.gsub(/\e\[([;\d]+)?m/, "") # Remove colors from output. assert_match "FAILED\nNot logged in. Use 'cacli login' to log in.", cleaned end end cacli 1.3.1 Closes #53167. Signed-off-by: Bo Anderson <1d6e1cf70ec6f9ab28d3ea4b27a49a77654d370e@boanderson.me> class Cacli < Formula desc "Train machine learning models from Cloud Annotations" homepage "https://cloud.annotations.ai" url "https://github.com/cloud-annotations/training/archive/v1.3.1.tar.gz" sha256 "fae8c52e5d2824846641f5bd25697d48e9701d35127a2032d230fd3415b1006b" bottle do cellar :any_skip_relocation sha256 "9b2d628a0cc4ba4e426cbd5afea64c3ec1af0877aeee605e3536ec57817e7924" => :catalina sha256 "ff5f177e8708eeb3567feedf4ff48e5c233b1cc9283153dc6437e6f651da502b" => :mojave sha256 "90127c81c2ae488e493ae7aae91d2a783e790fdb4809d9c620a093289f425cb0" => :high_sierra end depends_on "go" => :build def install cd "cacli" do project = "github.com/cloud-annotations/training/cacli" system "go", "build", "-ldflags", "-s -w -X #{project}/version.Version=#{version}", "-o", bin/"cacli" end end test do # Attempt to list training runs without credentials and confirm that it # fails as expected. output = shell_output("#{bin}/cacli list 2>&1", 1).strip cleaned = output.gsub(/\e\[([;\d]+)?m/, "") # Remove colors from output. assert_match "FAILED\nNot logged in. Use 'cacli login' to log in.", cleaned end end
require 'spec_helper' module ItemRequestSpecHelper def setup_item_request_helper_environment @requester_user = Factory(:user) @requester = Factory(:person, :user => @requester_user) reputation = Factory(:reputation_rating, :person_id => @requester.id) @gifter_user = Factory(:user, :uid => '111') @gifter = Factory(:person, :user => @gifter_user) reputation = Factory(:reputation_rating, :person_id => @gifter.id) @item = Factory(:item, :owner => @gifter) @item_request = Factory(:item_request, :requester => @requester, :gifter => @gifter, :item => @item, :status => ItemRequest::STATUS_REQUESTED) end def delete_item_request_helper_environment @item_request.delete @gifter.delete @gifter_user.delete @requester.delete @requster_user.delete end def valid_item_request_attributes { :requester_id => 1, :requester_type => "Person", :gifter_id => 2, :gifter_type => "Person", :item_id => @item.id, :description => "ItemRequestDescription", :status => ItemRequest::STATUS_REQUESTED } end end describe ItemRequest do it { should belong_to(:requester) } it { should belong_to(:gifter) } it { should belong_to(:item) } # it { should validate_presence_of(:description) } it { should validate_presence_of(:requester_id) } it { should validate_presence_of(:requester_type) } it { should validate_presence_of(:item_id) } it { should validate_presence_of(:status) } it "should validate inclusion of status in predefined values" do ItemRequest::STATUSES.keys.each do |status| should allow_value(status).for(:status) end end it { should_not allow_value("bad status").for(:status) } end describe ItemRequest, ".status_name" do it "should return correct status name" do item_request = ItemRequest.new(:status => ItemRequest::STATUS_REQUESTED) item_request.status_name.should eql(ItemRequest::STATUSES[ItemRequest::STATUS_REQUESTED]) end end describe ItemRequest, ".requester?" do let(:mock_person) { mock_model(Person) } before(:each) do @item_request = ItemRequest.new(:requester => mock_person) end it "should return true if given object is requester" do @item_request.requester?(mock_person).should be_true end it "should return false if given object is not requester" do some_other_person = mock_model(Person) @item_request.requester?(some_other_person).should be_false end end describe ItemRequest, ".gifter?" do let(:mock_person) { mock_model(Person) } before(:each) do @item_request = ItemRequest.new(:gifter => mock_person) end it "should return true if given object is gifter" do @item_request.gifter?(mock_person).should be_true end it "should return false if given object is not gifter" do some_other_person = mock_model(Person) @item_request.gifter?(some_other_person).should be_false end end describe ItemRequest, ".accept!" do include ItemRequestSpecHelper before(:each) do setup_item_request_helper_environment end it "should update status to accepted" do expect { @item_request.accept! }.to change { @item_request.status }.from(ItemRequest::STATUS_REQUESTED).to(ItemRequest::STATUS_ACCEPTED) end it "should save the request object" do expect { @item_request.accept! }.to change { @item_request.changed? }.to(false) end it "should raise exception if request object is cannot be saved" do @item_request = ItemRequest.new # invalid object attrs expect { @item_request.accept! }.to raise_error end after(:all) do delete_item_request_helper_environment end end describe ItemRequest, ".reject!" do include ItemRequestSpecHelper before(:each) do setup_item_request_helper_environment end it "should update status to rejected" do expect { @item_request.reject! }.to change { @item_request.status }.from(ItemRequest::STATUS_REQUESTED).to(ItemRequest::STATUS_REJECTED) end it "should save the request object" do expect { @item_request.reject! }.to change { @item_request.changed? }.to(false) end it "should raise exception if request object is cannot be saved" do @item_request = ItemRequest.new # invalid object attrs expect { @item_request.reject! }.to raise_error end end describe ItemRequest, ".cancel!" do include ItemRequestSpecHelper before(:each) do setup_item_request_helper_environment end it "should update status to canceled" do expect { @item_request.cancel!(@requester) }.to change { @item_request.status }.from(ItemRequest::STATUS_REQUESTED).to(ItemRequest::STATUS_CANCELED) end it "should save the request object" do expect { @item_request.cancel!(@requester) }.to change { @item_request.changed? }.to(false) end it "should raise exception if request object is cannot be saved" do @item_request = ItemRequest.new # invalid object attrs expect { @item_request.cancel!(@requester) }.to raise_error end end describe ItemRequest, ".collected!" do include ItemRequestSpecHelper before(:each) do setup_item_request_helper_environment end it "should update status to collected" do expect { @item_request.collected! }.to change { @item_request.status }.to(ItemRequest::STATUS_COLLECTED) end it "should save the request object" do expect { @item_request.collected! }.to change { @item_request.changed? }.to(false) end it "should raise exception if request object is cannot be saved" do @item_request = ItemRequest.new # invalid object attrs expect { @item_request.collected! }.to raise_error end end describe ItemRequest, ".complete!" do include ItemRequestSpecHelper before(:each) do setup_item_request_helper_environment end it "should update status to completed" do expect { @item_request.complete!(@requester) }.to change { @item_request.status }.to(ItemRequest::STATUS_COMPLETED) end it "should save the request object" do expect { @item_request.complete!(@requester) }.to change { @item_request.changed? }.to(false) end it "should raise exception if request object is cannot be saved" do @item_request = ItemRequest.new # invalid object attrs expect { @item_request.complete!(@requester) }.to raise_error end end Item request model spec updated require 'spec_helper' module ItemRequestSpecHelper def setup_item_request_helper_environment @requester_user = Factory(:user) @requester = Factory(:person, :user => @requester_user) reputation = Factory(:reputation_rating, :person_id => @requester.id) @gifter_user = Factory(:user, :uid => '111') @gifter = Factory(:person, :user => @gifter_user) reputation = Factory(:reputation_rating, :person_id => @gifter.id) @item = Factory(:item, :owner => @gifter) @item_request = Factory(:item_request, :requester => @requester, :gifter => @gifter, :item => @item, :status => ItemRequest::STATUS_REQUESTED) end def delete_item_request_helper_environment @item_request.delete @gifter.delete @gifter_user.delete @requester.delete @requster_user.delete end def valid_item_request_attributes { :requester_id => 1, :requester_type => "Person", :gifter_id => 2, :gifter_type => "Person", :item_id => @item.id, :description => "ItemRequestDescription", :status => ItemRequest::STATUS_REQUESTED } end end describe ItemRequest do it { should belong_to(:requester) } it { should belong_to(:gifter) } it { should belong_to(:item) } # it { should validate_presence_of(:description) } it { should validate_presence_of(:requester_id) } it { should validate_presence_of(:requester_type) } it { should validate_presence_of(:item_id) } it { should validate_presence_of(:status) } it "should validate inclusion of status in predefined values" do ItemRequest::STATUSES.keys.each do |status| should allow_value(status).for(:status) end end it { should_not allow_value("bad status").for(:status) } end describe ItemRequest, ".status_name" do it "should return correct status name" do item_request = ItemRequest.new(:status => ItemRequest::STATUS_REQUESTED) item_request.status_name.should eql(ItemRequest::STATUSES[ItemRequest::STATUS_REQUESTED]) end end describe ItemRequest, ".requester?" do let(:mock_person) { mock_model(Person) } before(:each) do @item_request = ItemRequest.new(:requester => mock_person) end it "should return true if given object is requester" do @item_request.requester?(mock_person).should be_true end it "should return false if given object is not requester" do some_other_person = mock_model(Person) @item_request.requester?(some_other_person).should be_false end end describe ItemRequest, ".gifter?" do let(:mock_person) { mock_model(Person) } before(:each) do @item_request = ItemRequest.new(:gifter => mock_person) end it "should return true if given object is gifter" do @item_request.gifter?(mock_person).should be_true end it "should return false if given object is not gifter" do some_other_person = mock_model(Person) @item_request.gifter?(some_other_person).should be_false end end describe ItemRequest, ".accept!" do include ItemRequestSpecHelper before(:each) do setup_item_request_helper_environment end it "should update status to accepted" do expect { @item_request.accept! }.to change { @item_request.status }.from(ItemRequest::STATUS_REQUESTED).to(ItemRequest::STATUS_ACCEPTED) end it "should save the request object" do expect { @item_request.accept! }.to change { @item_request.status }.to(ItemRequest::STATUS_ACCEPTED) end it "should raise exception if request object is cannot be saved" do @item_request = ItemRequest.new # invalid object attrs expect { @item_request.accept! }.to raise_error end after(:all) do delete_item_request_helper_environment end end describe ItemRequest, ".reject!" do include ItemRequestSpecHelper before(:each) do setup_item_request_helper_environment end it "should update status to rejected" do expect { @item_request.reject! }.to change { @item_request.status }.from(ItemRequest::STATUS_REQUESTED).to(ItemRequest::STATUS_REJECTED) end it "should save the request object" do expect { @item_request.reject! }.to change { @item_request.status }.to(ItemRequest::STATUS_REJECTED) end it "should raise exception if request object is cannot be saved" do @item_request = ItemRequest.new # invalid object attrs expect { @item_request.reject! }.to raise_error end end describe ItemRequest, ".cancel!" do include ItemRequestSpecHelper before(:each) do setup_item_request_helper_environment end it "should update status to canceled" do expect { @item_request.cancel!(@requester) }.to change { @item_request.status }.from(ItemRequest::STATUS_REQUESTED).to(ItemRequest::STATUS_CANCELED) end it "should save the request object" do expect { @item_request.cancel!(@requester) }.to change { @item_request.status }.to(ItemRequest::STATUS_CANCELED) end it "should raise exception if request object is cannot be saved" do @item_request = ItemRequest.new # invalid object attrs expect { @item_request.cancel!(@requester) }.to raise_error end end describe ItemRequest, ".collected!" do include ItemRequestSpecHelper before(:each) do setup_item_request_helper_environment end it "should update status to collected" do expect { @item_request.collected! }.to change { @item_request.status }.to(ItemRequest::STATUS_COLLECTED) end it "should save the request object" do expect { @item_request.collected! }.to change { @item_request.status }.to(ItemRequest::STATUS_COLLECTED) end it "should raise exception if request object is cannot be saved" do @item_request = ItemRequest.new # invalid object attrs expect { @item_request.collected! }.to raise_error end end describe ItemRequest, ".complete!" do include ItemRequestSpecHelper before(:each) do setup_item_request_helper_environment end it "should update status to completed" do expect { @item_request.complete!(@requester) }.to change { @item_request.status }.to(ItemRequest::STATUS_COMPLETED) end it "should save the request object" do expect { @item_request.complete!(@requester) }.to change { @item_request.status }.to(ItemRequest::STATUS_COMPLETED) end it "should raise exception if request object is cannot be saved" do @item_request = ItemRequest.new # invalid object attrs expect { @item_request.complete!(@requester) }.to raise_error end end
class Cairo < Formula desc "Vector graphics library with cross-device output support" homepage "https://cairographics.org/" url "https://cairographics.org/releases/cairo-1.14.6.tar.xz" mirror "https://www.mirrorservice.org/sites/ftp.netbsd.org/pub/pkgsrc/distfiles/cairo-1.14.6.tar.xz" sha256 "613cb38447b76a93ff7235e17acd55a78b52ea84a9df128c3f2257f8eaa7b252" revision 1 bottle do sha256 "dd4dc801ee427ca2d2305403cacf747a51b58d80a2cd2ebf20a9623229830278" => :el_capitan sha256 "3ac3b4af558425ff4c3a9799bfb24ab70e41210d63323195db4a5e6feb790497" => :yosemite sha256 "15ec1a777186dc6af988c9d1de94449ce730ec64a1588d63f3a1b95222d75a8d" => :mavericks end devel do url "https://cairographics.org/snapshots/cairo-1.15.2.tar.xz" sha256 "268cc265a7f807403582f440643064bf52896556766890c8df7bad02d230f6c9" end keg_only :provided_pre_mountain_lion option :universal depends_on "pkg-config" => :build depends_on :x11 => OS.mac? ? :optional : :recommended if MacOS.version > :leopard || !OS.mac? depends_on "freetype" depends_on "fontconfig" depends_on "libpng" depends_on "pixman" depends_on "glib" def install ENV.universal_binary if build.universal? args = %W[ --disable-dependency-tracking --prefix=#{prefix} --enable-gobject=yes --enable-svg=yes --enable-tee=yes ] args += %W[ --enable-quartz-image ] if OS.mac? if build.with? "x11" args << "--enable-xcb=yes" << "--enable-xlib=yes" << "--enable-xlib-xrender=yes" else args << "--enable-xcb=no" << "--enable-xlib=no" << "--enable-xlib-xrender=no" end system "./configure", *args system "make", "install" end test do (testpath/"test.c").write <<-EOS.undent #include <cairo.h> int main(int argc, char *argv[]) { cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 600, 400); cairo_t *context = cairo_create(surface); return 0; } EOS fontconfig = Formula["fontconfig"] freetype = Formula["freetype"] gettext = Formula["gettext"] glib = Formula["glib"] libpng = Formula["libpng"] pixman = Formula["pixman"] flags = (ENV.cflags || "").split + (ENV.cppflags || "").split + (ENV.ldflags || "").split flags += %W[ -I#{fontconfig.opt_include} -I#{freetype.opt_include}/freetype2 -I#{gettext.opt_include} -I#{glib.opt_include}/glib-2.0 -I#{glib.opt_lib}/glib-2.0/include -I#{include}/cairo -I#{libpng.opt_include}/libpng16 -I#{pixman.opt_include}/pixman-1 -L#{lib} -lcairo ] system ENV.cc, "test.c", "-o", "test", *flags system "./test" end end cairo: update 1.14.6_1 bottle for Linuxbrew. Closes Linuxbrew/homebrew-core#45. Signed-off-by: Shaun Jackman <b580dab3251a9622aba3803114310c23fdb42900@gmail.com> class Cairo < Formula desc "Vector graphics library with cross-device output support" homepage "https://cairographics.org/" url "https://cairographics.org/releases/cairo-1.14.6.tar.xz" mirror "https://www.mirrorservice.org/sites/ftp.netbsd.org/pub/pkgsrc/distfiles/cairo-1.14.6.tar.xz" sha256 "613cb38447b76a93ff7235e17acd55a78b52ea84a9df128c3f2257f8eaa7b252" revision 1 bottle do sha256 "dd4dc801ee427ca2d2305403cacf747a51b58d80a2cd2ebf20a9623229830278" => :el_capitan sha256 "3ac3b4af558425ff4c3a9799bfb24ab70e41210d63323195db4a5e6feb790497" => :yosemite sha256 "15ec1a777186dc6af988c9d1de94449ce730ec64a1588d63f3a1b95222d75a8d" => :mavericks sha256 "4aef70e64c8f91cbc009f311b6d01b2f6b19ce7ab6b7240102a42e9b93e661e6" => :x86_64_linux end devel do url "https://cairographics.org/snapshots/cairo-1.15.2.tar.xz" sha256 "268cc265a7f807403582f440643064bf52896556766890c8df7bad02d230f6c9" end keg_only :provided_pre_mountain_lion option :universal depends_on "pkg-config" => :build depends_on :x11 => OS.mac? ? :optional : :recommended if MacOS.version > :leopard || !OS.mac? depends_on "freetype" depends_on "fontconfig" depends_on "libpng" depends_on "pixman" depends_on "glib" def install ENV.universal_binary if build.universal? args = %W[ --disable-dependency-tracking --prefix=#{prefix} --enable-gobject=yes --enable-svg=yes --enable-tee=yes ] args += %W[ --enable-quartz-image ] if OS.mac? if build.with? "x11" args << "--enable-xcb=yes" << "--enable-xlib=yes" << "--enable-xlib-xrender=yes" else args << "--enable-xcb=no" << "--enable-xlib=no" << "--enable-xlib-xrender=no" end system "./configure", *args system "make", "install" end test do (testpath/"test.c").write <<-EOS.undent #include <cairo.h> int main(int argc, char *argv[]) { cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 600, 400); cairo_t *context = cairo_create(surface); return 0; } EOS fontconfig = Formula["fontconfig"] freetype = Formula["freetype"] gettext = Formula["gettext"] glib = Formula["glib"] libpng = Formula["libpng"] pixman = Formula["pixman"] flags = (ENV.cflags || "").split + (ENV.cppflags || "").split + (ENV.ldflags || "").split flags += %W[ -I#{fontconfig.opt_include} -I#{freetype.opt_include}/freetype2 -I#{gettext.opt_include} -I#{glib.opt_include}/glib-2.0 -I#{glib.opt_lib}/glib-2.0/include -I#{include}/cairo -I#{libpng.opt_include}/libpng16 -I#{pixman.opt_include}/pixman-1 -L#{lib} -lcairo ] system ENV.cc, "test.c", "-o", "test", *flags system "./test" end end
if JsonVersion.table_exists? require 'rails_helper' describe JsonVersion, :type => :model do it "should include the `VersionConcern` module to get base functionality" do expect(JsonVersion).to include(PaperTrail::VersionConcern) end describe "Methods" do describe "Class" do describe '#where_object' do it { expect(JsonVersion).to respond_to(:where_object) } context "invalid arguments" do it "should raise an error" do expect { JsonVersion.where_object(:foo) }.to raise_error(ArgumentError) expect { JsonVersion.where_object([]) }.to raise_error(ArgumentError) end end context "valid arguments", :versioning => true do let(:fruit_names) { %w(apple orange lemon banana lime coconut strawberry blueberry) } let(:fruit) { Fruit.new } let(:name) { 'pomegranate' } let(:color) { Faker::Color.name } before do fruit.update_attributes!(:name => name) fruit.update_attributes!(:name => fruit_names.sample, :color => color) fruit.update_attributes!(:name => fruit_names.sample, :color => Faker::Color.name) end it "should be able to locate versions according to their `object` contents" do expect(JsonVersion.where_object(:name => name)).to eq([fruit.versions[1]]) expect(JsonVersion.where_object(:color => color)).to eq([fruit.versions[2]]) end end end describe '#where_object_changes' do it { expect(JsonVersion).to respond_to(:where_object_changes) } context "invalid arguments" do it "should raise an error" do expect { JsonVersion.where_object_changes(:foo) }.to raise_error(ArgumentError) expect { JsonVersion.where_object_changes([]) }.to raise_error(ArgumentError) end end context "valid arguments", :versioning => true do let(:fruit_names) { %w(apple orange lemon banana lime strawberry blueberry) } let(:tropical_fruit_names) { %w(coconut pineapple kiwi mango melon) } let(:fruit) { Fruit.new } let(:name) { 'pomegranate' } let(:color) { Faker::Color.name } before do fruit.update_attributes!(:name => name) fruit.update_attributes!(:name => tropical_fruit_names.sample, :color => color) fruit.update_attributes!(:name => fruit_names.sample, :color => Faker::Color.name) end it "should be able to locate versions according to their `object_changes` contents" do expect(fruit.versions.where_object_changes(:name => name)).to eq(fruit.versions[0..1]) expect(fruit.versions.where_object_changes(:color => color)).to eq(fruit.versions[1..2]) end it "should be able to handle queries for multiple attributes" do expect(fruit.versions.where_object_changes(:color => color, :name => name)).to eq([fruit.versions[1]]) end end end end end end end Fix NameError: uninitialized constant JsonVersion require 'rails_helper' # The `json_versions` table tests postgres' `json` data type. So, that # table is only created when testing against postgres and ActiveRecord >= 4. if JsonVersion.table_exists? describe JsonVersion, :type => :model do it "should include the `VersionConcern` module to get base functionality" do expect(JsonVersion).to include(PaperTrail::VersionConcern) end describe "Methods" do describe "Class" do describe '#where_object' do it { expect(JsonVersion).to respond_to(:where_object) } context "invalid arguments" do it "should raise an error" do expect { JsonVersion.where_object(:foo) }.to raise_error(ArgumentError) expect { JsonVersion.where_object([]) }.to raise_error(ArgumentError) end end context "valid arguments", :versioning => true do let(:fruit_names) { %w(apple orange lemon banana lime coconut strawberry blueberry) } let(:fruit) { Fruit.new } let(:name) { 'pomegranate' } let(:color) { Faker::Color.name } before do fruit.update_attributes!(:name => name) fruit.update_attributes!(:name => fruit_names.sample, :color => color) fruit.update_attributes!(:name => fruit_names.sample, :color => Faker::Color.name) end it "should be able to locate versions according to their `object` contents" do expect(JsonVersion.where_object(:name => name)).to eq([fruit.versions[1]]) expect(JsonVersion.where_object(:color => color)).to eq([fruit.versions[2]]) end end end describe '#where_object_changes' do it { expect(JsonVersion).to respond_to(:where_object_changes) } context "invalid arguments" do it "should raise an error" do expect { JsonVersion.where_object_changes(:foo) }.to raise_error(ArgumentError) expect { JsonVersion.where_object_changes([]) }.to raise_error(ArgumentError) end end context "valid arguments", :versioning => true do let(:fruit_names) { %w(apple orange lemon banana lime strawberry blueberry) } let(:tropical_fruit_names) { %w(coconut pineapple kiwi mango melon) } let(:fruit) { Fruit.new } let(:name) { 'pomegranate' } let(:color) { Faker::Color.name } before do fruit.update_attributes!(:name => name) fruit.update_attributes!(:name => tropical_fruit_names.sample, :color => color) fruit.update_attributes!(:name => fruit_names.sample, :color => Faker::Color.name) end it "should be able to locate versions according to their `object_changes` contents" do expect(fruit.versions.where_object_changes(:name => name)).to eq(fruit.versions[0..1]) expect(fruit.versions.where_object_changes(:color => color)).to eq(fruit.versions[1..2]) end it "should be able to handle queries for multiple attributes" do expect(fruit.versions.where_object_changes(:color => color, :name => name)).to eq([fruit.versions[1]]) end end end end end end end
class Carla < Formula desc "Audio plugin host supporting LADSPA, LV2, VST2/3, SF2 and more" homepage "https://kxstudio.linuxaudio.org/Applications:Carla" url "https://github.com/falkTX/Carla/archive/v2.0.0.tar.gz" sha256 "d0c8d8417f8cce9abe807f6359231f187d60db7121ec1dccce3b596a22ef6c41" head "https://github.com/falkTX/Carla.git" bottle do cellar :any sha256 "7c7bfc02681d230a88fb382f099808e446f871a587af5970c7739a58fd6be77a" => :mojave sha256 "d17f98134588c6bba57c1731fb0018e136016ada2d4f00d8555b20b0701c1ee4" => :high_sierra sha256 "74a55831b1cdcafcfa758475aee7d75c60e156b09bff81abe5c0656a3687c9de" => :sierra end depends_on "pkg-config" => :build depends_on "fluid-synth" depends_on "liblo" depends_on "libmagic" depends_on "pyqt" depends_on "python" def install system "make" system "make", "install", "PREFIX=#{prefix}" end test do system bin/"carla", "--version" system lib/"carla/carla-discovery-native", "internal", ":all" end end carla: update 2.0.0 bottle. class Carla < Formula desc "Audio plugin host supporting LADSPA, LV2, VST2/3, SF2 and more" homepage "https://kxstudio.linuxaudio.org/Applications:Carla" url "https://github.com/falkTX/Carla/archive/v2.0.0.tar.gz" sha256 "d0c8d8417f8cce9abe807f6359231f187d60db7121ec1dccce3b596a22ef6c41" head "https://github.com/falkTX/Carla.git" bottle do cellar :any sha256 "a39e18a5d4607940f90a6a32efc29fa82ec626995fe93354a85f248c63e65c2a" => :mojave sha256 "24e9a7ac065d312ad4911dd663befc3abadc020a239f013345cfd6b3bfac2c4e" => :high_sierra sha256 "2ce1ae9b9971999d046e84523807da278fbd67dedfcc5282b7e0965880980cd5" => :sierra end depends_on "pkg-config" => :build depends_on "fluid-synth" depends_on "liblo" depends_on "libmagic" depends_on "pyqt" depends_on "python" def install system "make" system "make", "install", "PREFIX=#{prefix}" end test do system bin/"carla", "--version" system lib/"carla/carla-discovery-native", "internal", ":all" end end
require 'spec_helper' describe Relation do describe 'belongs_to project' do before do @project = FactoryGirl.create(:project, :user => FactoryGirl.create(:user)) @doc = FactoryGirl.create(:doc) @denotation = FactoryGirl.create(:denotation, :project => @project, :doc => @doc) @modification = FactoryGirl.create(:modification, :obj => @denotation, :project => @project) end it 'modification should belongs to project' do @modification.project.should eql(@project) end end describe 'belongs_to obj' do before do @project = FactoryGirl.create(:project, :user => FactoryGirl.create(:user)) @doc = FactoryGirl.create(:doc, :sourcedb => 'sourcedb', :sourceid => 1, :serial => 1, :section => 'section', :body => 'doc body') @denotation = FactoryGirl.create(:denotation, :project => @project, :doc => @doc) @instance = FactoryGirl.create(:instance, :hid => 'instance hid', :project => @project, :obj => @denotation) @modification = FactoryGirl.create(:modification, :obj => @instance, :project => @project) end it 'modification should belongs to obj' do @modification.obj.should eql(@instance) end end describe 'get_hash' do before do @project = FactoryGirl.create(:project, :user => FactoryGirl.create(:user)) @doc = FactoryGirl.create(:doc, :sourcedb => 'sourcedb', :sourceid => 1, :serial => 1, :section => 'section', :body => 'doc body') @denotation = FactoryGirl.create(:denotation, :project => @project, :doc => @doc) @instance = FactoryGirl.create(:instance, :hid => 'instance hid', :project => @project, :obj => @denotation) @subcatrel = FactoryGirl.create(:subcatrel, :obj => @denotation, :project => @project) @insmod = FactoryGirl.create(:modification, :hid => 'modification hid', :pred => 'pred', :obj => @instance, :project => @project ) @get_hash = @insmod.get_hash end it 'should set hid as id' do @get_hash[:id].should eql(@insmod[:hid]) end it 'should set pred as type' do @get_hash[:pred].should eql(@insmod[:pred]) end it 'should set end as denotation:end' do @get_hash[:obj].should eql(@instance[:hid]) end end end Fixed modification_spec require 'spec_helper' describe Relation do describe 'belongs_to project' do before do @project = FactoryGirl.create(:project, :user => FactoryGirl.create(:user)) @doc = FactoryGirl.create(:doc) @denotation = FactoryGirl.create(:denotation, :project => @project, :doc => @doc) @modification = FactoryGirl.create(:modification, :obj => @denotation, :project => @project) end it 'modification should belongs to project' do @modification.project.should eql(@project) end end describe 'belongs_to obj' do before do @project = FactoryGirl.create(:project, :user => FactoryGirl.create(:user)) @doc = FactoryGirl.create(:doc, :sourcedb => 'sourcedb', :sourceid => '1', :serial => 1, :section => 'section', :body => 'doc body') @denotation = FactoryGirl.create(:denotation, :project => @project, :doc => @doc) @instance = FactoryGirl.create(:instance, :hid => 'instance hid', :project => @project, :obj => @denotation) @modification = FactoryGirl.create(:modification, :obj => @instance, :project => @project) end it 'modification should belongs to obj' do @modification.obj.should eql(@instance) end end describe 'get_hash' do before do @project = FactoryGirl.create(:project, :user => FactoryGirl.create(:user)) @doc = FactoryGirl.create(:doc, :sourcedb => 'sourcedb', :sourceid => '1', :serial => 1, :section => 'section', :body => 'doc body') @denotation = FactoryGirl.create(:denotation, :project => @project, :doc => @doc) @instance = FactoryGirl.create(:instance, :hid => 'instance hid', :project => @project, :obj => @denotation) @subcatrel = FactoryGirl.create(:subcatrel, :obj => @denotation, :subj => @denotation, :project => @project) @insmod = FactoryGirl.create(:modification, :hid => 'modification hid', :pred => 'pred', :obj => @instance, :project => @project ) @get_hash = @insmod.get_hash end it 'should set hid as id' do @get_hash[:id].should eql(@insmod[:hid]) end it 'should set pred as type' do @get_hash[:pred].should eql(@insmod[:pred]) end it 'should set end as denotation:end' do @get_hash[:obj].should eql(@instance[:hid]) end end end
class Cconv < Formula desc "Iconv based simplified-traditional Chinese conversion tool" homepage "https://github.com/xiaoyjy/cconv" url "https://github.com/xiaoyjy/cconv/archive/v0.6.3.tar.gz" sha256 "82f46a94829f5a8157d6f686e302ff5710108931973e133d6e19593061b81d84" license "MIT" bottle do sha256 cellar: :any, arm64_big_sur: "58c753e4b4b6887b81202d33c63ac6ef153d7166c6542661ab3dcbb322f173bf" sha256 cellar: :any, big_sur: "f39720a1d032edbcdbf6ccfd6a5f8c9dc46faaf95e479904cfde25ec5c7622d6" sha256 cellar: :any, catalina: "06b6bafaadcaa16329ba0cdeee7d11a13e94f126a4011b54253e31a1ea82108e" sha256 cellar: :any, mojave: "ffaf8b5cab0618e52cfedff14a5084cfe54e0b1b6480433e2ffb4beee8e47ec9" sha256 cellar: :any, high_sierra: "c4d197f979340a89d5a87e05eae6a39db38863f89b6ddda42f924472d87a5b0d" sha256 cellar: :any, sierra: "2e885b9571a8814f2b23b088f3f0d45f47b1fe762f040c3e66b1a81f84673646" sha256 cellar: :any, el_capitan: "bda78602260276dd3e5187a5a9d6bbcfb95ff40aa513840569e490d5dc96aab2" sha256 cellar: :any, yosemite: "a77d6efc52430482ff2c64db8ba20444b50faf79491c95f8f6bd9f3f29050c53" end depends_on "autoconf" => :build depends_on "automake" => :build depends_on "libtool" => :build def install on_macos do ENV.append "LDFLAGS", "-liconv" end system "autoreconf", "-fvi" system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}" system "make", "install" rm_f include/"unicode.h" end test do encodings = "GB2312, GBK, GB-HANS, GB-HANT, GB18030, BIG5, UTF8, UTF8-CN, UTF8-TW, UTF8-HK" assert_match encodings, shell_output("#{bin}/cconv -l") end end cconv: update 0.6.3 bottle. class Cconv < Formula desc "Iconv based simplified-traditional Chinese conversion tool" homepage "https://github.com/xiaoyjy/cconv" url "https://github.com/xiaoyjy/cconv/archive/v0.6.3.tar.gz" sha256 "82f46a94829f5a8157d6f686e302ff5710108931973e133d6e19593061b81d84" license "MIT" bottle do sha256 cellar: :any, arm64_big_sur: "58c753e4b4b6887b81202d33c63ac6ef153d7166c6542661ab3dcbb322f173bf" sha256 cellar: :any, big_sur: "f39720a1d032edbcdbf6ccfd6a5f8c9dc46faaf95e479904cfde25ec5c7622d6" sha256 cellar: :any, catalina: "06b6bafaadcaa16329ba0cdeee7d11a13e94f126a4011b54253e31a1ea82108e" sha256 cellar: :any, mojave: "ffaf8b5cab0618e52cfedff14a5084cfe54e0b1b6480433e2ffb4beee8e47ec9" sha256 cellar: :any, high_sierra: "c4d197f979340a89d5a87e05eae6a39db38863f89b6ddda42f924472d87a5b0d" sha256 cellar: :any, sierra: "2e885b9571a8814f2b23b088f3f0d45f47b1fe762f040c3e66b1a81f84673646" sha256 cellar: :any, el_capitan: "bda78602260276dd3e5187a5a9d6bbcfb95ff40aa513840569e490d5dc96aab2" sha256 cellar: :any, yosemite: "a77d6efc52430482ff2c64db8ba20444b50faf79491c95f8f6bd9f3f29050c53" sha256 cellar: :any_skip_relocation, x86_64_linux: "d7176512194c3bed0f8db76bf768136559dd09bfaaa3562908acaa748ccbd288" end depends_on "autoconf" => :build depends_on "automake" => :build depends_on "libtool" => :build def install on_macos do ENV.append "LDFLAGS", "-liconv" end system "autoreconf", "-fvi" system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}" system "make", "install" rm_f include/"unicode.h" end test do encodings = "GB2312, GBK, GB-HANS, GB-HANT, GB18030, BIG5, UTF8, UTF8-CN, UTF8-TW, UTF8-HK" assert_match encodings, shell_output("#{bin}/cconv -l") end end
require 'spec_helper' describe Neighborhood do pending "add some examples to (or delete) #{__FILE__}" end Add deletion flag to neighborhood spec require 'spec_helper' describe Neighborhood do pending "flagged for deletion #{__FILE__}" end
require "language/node" class Cdk8s < Formula desc "Define k8s native apps and abstractions using object-oriented programming" homepage "https://cdk8s.io/" url "https://registry.npmjs.org/cdk8s-cli/-/cdk8s-cli-1.0.28.tgz" sha256 "9346ff31b873b74c2637430eb0fdf4721e69cae05fdcec1c236d47a3771ae5de" license "Apache-2.0" bottle do sha256 cellar: :any_skip_relocation, all: "a0c786e404480e6278822fbf95feab685f8c42a1529233799542a1f39517a63a" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do assert_match "Cannot initialize a project in a non-empty directory", shell_output("#{bin}/cdk8s init python-app 2>&1", 1) end end cdk8s: update 1.0.28 bottle. require "language/node" class Cdk8s < Formula desc "Define k8s native apps and abstractions using object-oriented programming" homepage "https://cdk8s.io/" url "https://registry.npmjs.org/cdk8s-cli/-/cdk8s-cli-1.0.28.tgz" sha256 "9346ff31b873b74c2637430eb0fdf4721e69cae05fdcec1c236d47a3771ae5de" license "Apache-2.0" bottle do sha256 cellar: :any_skip_relocation, all: "7b482a2e0e42282267590d2ed115da99528bfc76dbf63594dba533e24b8006bf" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do assert_match "Cannot initialize a project in a non-empty directory", shell_output("#{bin}/cdk8s init python-app 2>&1", 1) end end
require "rails_helper" require "controller_spec_helper" require "stringio" RSpec.describe OrderImport, :time_travel do CSV_HEADERS = [ "Netid / Email", "Chart String", "Product Name", "Quantity", "Order Date", "Fulfillment Date", "Note", ].freeze def nucore_format_date(date) date.strftime("%m/%d/%Y") end let(:now) { fiscal_year_beginning + 5.days } subject(:order_import) do OrderImport.create!( created_by: director.id, upload_file: stored_file, facility: facility, ) end let(:account) do create(:nufs_account, description: "dummy account", account_number: "111-2222222-33333333-01", account_users_attributes: account_users_attributes, ) end let(:account_users_attributes) do account_users_attributes_hash(user: guest) + account_users_attributes_hash( user: guest2, created_by: guest, user_role: AccountUser::ACCOUNT_PURCHASER, ) end let(:default_order_date) { 4.days.ago.to_date } let(:default_fulfilled_date) { 3.days.ago.to_date } let(:director) { @director } let(:error_file_row_count) do Paperclip .io_adapters .for(order_import.error_file.file) .read .split("\n") .count end let(:facility) { create(:facility) } let(:facility_account) do facility.facility_accounts.create!(attributes_for(:facility_account)) end let(:fiscal_year_beginning) { SettingsHelper.fiscal_year_beginning } let(:guest) { @guest } let(:guest2) { create(:user, username: "guest2") } let(:import_file_row_count) { import_file.read.split("\n").count } let(:item) do facility.items.create!(attributes_for(:item, facility_account_id: facility_account.id, name: "Example Item", )) end let(:service) do facility.services.create!(attributes_for(:service, facility_account_id: facility_account.id, name: "Example Service", )) end let(:stored_file) do StoredFile.create!( file: StringIO.new("c,s,v"), file_type: "import_upload", name: "clean_import.csv", created_by: director.id, ) end before(:all) { create_users } before :each do grant_role(director, facility) price_group = FactoryBot.create(:price_group, facility: facility) create(:account_price_group_member, account: account, price_group: price_group) item.item_price_policies.create!(attributes_for(:item_price_policy, price_group_id: price_group.id, start_date: fiscal_year_beginning, )) service.service_price_policies.create!(attributes_for(:service_price_policy, price_group_id: price_group.id, start_date: fiscal_year_beginning, )) end shared_examples_for "it does not send notifications" do it "does not send notifications" do expect(PurchaseNotifier).to receive(:order_receipt).never order_import.process_upload! end end context "validations" do it { is_expected.to belong_to :creator } it { is_expected.to belong_to(:upload_file).required } it { is_expected.to belong_to :error_file } it { is_expected.to validate_presence_of :upload_file } it { is_expected.to validate_presence_of :created_by } end def generate_import_file(*args) args = [{}] if args.length == 0 # default to at least one valid row whole_csv = CSV.generate headers: true do |csv| csv << CSV_HEADERS args.each do |opts| row = CSV::Row.new(CSV_HEADERS, [ opts[:username] || "guest", opts[:account_number] || "111-2222222-33333333-01", opts[:product_name] || "Example Item", opts[:quantity] || 1, opts[:order_date] || nucore_format_date(default_order_date), opts[:fullfillment_date] || nucore_format_date(default_fulfilled_date), opts[:note] || "Test Note", ]) csv << row end end StringIO.new whole_csv end context "when in save-clean-orders mode" do let(:import_file) do generate_import_file( # First order: { order_date: nucore_format_date(default_order_date) }, { order_date: nucore_format_date(default_order_date) }, # Second order (a different order_date): order_date: nucore_format_date(default_order_date + 1.day), product_name: "Invalid Item", ) end before :each do order_import.fail_on_error = false order_import.send_receipts = true order_import.upload_file.file = import_file order_import.upload_file.save! order_import.save! end it "sends notifications" do expect(PurchaseNotifier) .to receive(:order_receipt) .once .and_return(double(deliver_later: nil)) order_import.process_upload! end end context "when in save-nothing-on-error mode" do before :each do order_import.fail_on_error = true order_import.send_receipts = send_receipts order_import.upload_file.file = import_file order_import.upload_file.save! order_import.save! end context "with notifications enabled" do let(:send_receipts) { true } context "with errors" do let(:import_file) do generate_import_file({}, product_name: "Invalid Item") end it_behaves_like "it does not send notifications" end context "with no errors" do let(:import_file) { generate_import_file } it "sends notifications" do expect(PurchaseNotifier) .to receive(:order_receipt) .once .and_return(double(deliver_later: nil)) order_import.process_upload! end end end context "with notifications disabled" do let(:import_file) { generate_import_file } let(:send_receipts) { false } it_behaves_like "it does not send notifications" end end context "importing two orders" do context "when one order_detail has an error" do let(:import_file) do generate_import_file( # First order: { product_name: "Invalid Item" }, {}, # Second order (a different user): username: guest2.username, ) end before :each do Order.destroy_all order_import.upload_file.file = import_file order_import.upload_file.save! order_import.send_receipts = true order_import.save! import_file.rewind # because #save! reads the file end context "when in save-nothing-on-error mode" do before :each do order_import.fail_on_error = true order_import.save! end it "creates no orders" do expect { order_import.process_upload! }.not_to change(Order, :count) end it_behaves_like "it does not send notifications" it "includes all rows in its error report" do order_import.process_upload! expect(error_file_row_count).to eq(import_file_row_count) end end context "when in save-clean-orders mode" do before :each do order_import.fail_on_error = false order_import.save! end it "creates an order" do expect { order_import.process_upload! }.to change(Order, :count).by(1) end it "sends a notification for second order" do expect(PurchaseNotifier) .to receive(:order_receipt) .once .and_return(double(deliver_later: nil)) order_import.process_upload! end it "has the first two rows in its error report" do order_import.process_upload! # minus one because one order (and order_detail) will succeed expect(error_file_row_count).to eq(import_file_row_count - 1) end end end end context "when importing multiple orders" do context "and the second order's order_detail has an error" do let(:import_file) do generate_import_file({}, product_name: "Invalid Item") end before :each do Order.destroy_all order_import.upload_file.file = import_file order_import.upload_file.save! import_file.rewind order_import.fail_on_error = fail_on_error order_import.send_receipts = true order_import.save! end shared_examples_for "an import failure" do it "creates no orders" do expect { order_import.process_upload! }.not_to change(Order, :count) end it_behaves_like "it does not send notifications" it "includes all rows in its error report (as there's only one order)" do order_import.process_upload! expect(error_file_row_count).to eq(import_file_row_count) end end context "when in save-clean-orders mode" do let(:fail_on_error) { false } it_behaves_like "an import failure" end context "when in save-nothing-on-error mode" do let(:fail_on_error) { true } it_behaves_like "an import failure" end end end describe "#process_upload!" do subject(:import) { create(:order_import) } context "an exception is raised in import" do before do allow_any_instance_of(OrderRowImporter).to receive(:import).and_raise("Something unknown happened") import.upload_file.file = generate_import_file import.upload_file.save! import.process_upload! end it "produces an error report" do expect(import.error_file_content).to include("Failed to import row") end it "sets error flags" do expect(import).to be_error_mode expect(import.result).to be_failed end it "sends an exception notification" do expect(ActiveSupport::Notifications).to receive(:instrument).with("background_error", anything) import.process_upload! end end context "an exception is raised when opening the CSV" do before do allow(CSV).to receive(:parse).and_raise(ArgumentError, "invalid byte sequence in UTF-8") import.upload_file.file = generate_import_file import.upload_file.save! import.process_upload! end it "produces an error report" do expect(import.error_file_content).to include("Unable to open CSV File") end it "sets error flags" do expect(import).to be_error_mode expect(import.result).to be_failed end end end end Make order import spec use the nufs_account format (#1614) TECH TASK: Make OrderImport spec more flexible to allow different account number formats. require "rails_helper" require "controller_spec_helper" require "stringio" RSpec.describe OrderImport, :time_travel do CSV_HEADERS = [ "Netid / Email", "Chart String", "Product Name", "Quantity", "Order Date", "Fulfillment Date", "Note", ].freeze def nucore_format_date(date) date.strftime("%m/%d/%Y") end let(:now) { fiscal_year_beginning + 5.days } subject(:order_import) do OrderImport.create!( created_by: director.id, upload_file: stored_file, facility: facility, ) end let(:account) do create(:nufs_account, description: "dummy account", account_users_attributes: account_users_attributes, ) end let(:account_users_attributes) do account_users_attributes_hash(user: guest) + account_users_attributes_hash( user: guest2, created_by: guest, user_role: AccountUser::ACCOUNT_PURCHASER, ) end let(:default_order_date) { 4.days.ago.to_date } let(:default_fulfilled_date) { 3.days.ago.to_date } let(:director) { @director } let(:error_file_row_count) do Paperclip .io_adapters .for(order_import.error_file.file) .read .split("\n") .count end let(:facility) { create(:facility) } let(:facility_account) do facility.facility_accounts.create!(attributes_for(:facility_account)) end let(:fiscal_year_beginning) { SettingsHelper.fiscal_year_beginning } let(:guest) { @guest } let(:guest2) { create(:user, username: "guest2") } let(:import_file_row_count) { import_file.read.split("\n").count } let(:item) do facility.items.create!(attributes_for(:item, facility_account_id: facility_account.id, name: "Example Item", )) end let(:service) do facility.services.create!(attributes_for(:service, facility_account_id: facility_account.id, name: "Example Service", )) end let(:stored_file) do StoredFile.create!( file: StringIO.new("c,s,v"), file_type: "import_upload", name: "clean_import.csv", created_by: director.id, ) end before(:all) { create_users } before :each do grant_role(director, facility) price_group = FactoryBot.create(:price_group, facility: facility) create(:account_price_group_member, account: account, price_group: price_group) item.item_price_policies.create!(attributes_for(:item_price_policy, price_group_id: price_group.id, start_date: fiscal_year_beginning, )) service.service_price_policies.create!(attributes_for(:service_price_policy, price_group_id: price_group.id, start_date: fiscal_year_beginning, )) end shared_examples_for "it does not send notifications" do it "does not send notifications" do expect(PurchaseNotifier).to receive(:order_receipt).never order_import.process_upload! end end context "validations" do it { is_expected.to belong_to :creator } it { is_expected.to belong_to(:upload_file).required } it { is_expected.to belong_to :error_file } it { is_expected.to validate_presence_of :upload_file } it { is_expected.to validate_presence_of :created_by } end def generate_import_file(*args) args = [{}] if args.length == 0 # default to at least one valid row whole_csv = CSV.generate headers: true do |csv| csv << CSV_HEADERS args.each do |opts| row = CSV::Row.new(CSV_HEADERS, [ opts[:username] || "guest", opts[:account_number] || account.account_number, opts[:product_name] || "Example Item", opts[:quantity] || 1, opts[:order_date] || nucore_format_date(default_order_date), opts[:fullfillment_date] || nucore_format_date(default_fulfilled_date), opts[:note] || "Test Note", ]) csv << row end end StringIO.new whole_csv end context "when in save-clean-orders mode" do let(:import_file) do generate_import_file( # First order: { order_date: nucore_format_date(default_order_date) }, { order_date: nucore_format_date(default_order_date) }, # Second order (a different order_date): order_date: nucore_format_date(default_order_date + 1.day), product_name: "Invalid Item", ) end before :each do order_import.fail_on_error = false order_import.send_receipts = true order_import.upload_file.file = import_file order_import.upload_file.save! order_import.save! end it "sends notifications" do expect(PurchaseNotifier) .to receive(:order_receipt) .once .and_return(double(deliver_later: nil)) order_import.process_upload! end end context "when in save-nothing-on-error mode" do before :each do order_import.fail_on_error = true order_import.send_receipts = send_receipts order_import.upload_file.file = import_file order_import.upload_file.save! order_import.save! end context "with notifications enabled" do let(:send_receipts) { true } context "with errors" do let(:import_file) do generate_import_file({}, product_name: "Invalid Item") end it_behaves_like "it does not send notifications" end context "with no errors" do let(:import_file) { generate_import_file } it "sends notifications" do expect(PurchaseNotifier) .to receive(:order_receipt) .once .and_return(double(deliver_later: nil)) order_import.process_upload! end end end context "with notifications disabled" do let(:import_file) { generate_import_file } let(:send_receipts) { false } it_behaves_like "it does not send notifications" end end context "importing two orders" do context "when one order_detail has an error" do let(:import_file) do generate_import_file( # First order: { product_name: "Invalid Item" }, {}, # Second order (a different user): username: guest2.username, ) end before :each do Order.destroy_all order_import.upload_file.file = import_file order_import.upload_file.save! order_import.send_receipts = true order_import.save! import_file.rewind # because #save! reads the file end context "when in save-nothing-on-error mode" do before :each do order_import.fail_on_error = true order_import.save! end it "creates no orders" do expect { order_import.process_upload! }.not_to change(Order, :count) end it_behaves_like "it does not send notifications" it "includes all rows in its error report" do order_import.process_upload! expect(error_file_row_count).to eq(import_file_row_count) end end context "when in save-clean-orders mode" do before :each do order_import.fail_on_error = false order_import.save! end it "creates an order" do expect { order_import.process_upload! }.to change(Order, :count).by(1) end it "sends a notification for second order" do expect(PurchaseNotifier) .to receive(:order_receipt) .once .and_return(double(deliver_later: nil)) order_import.process_upload! end it "has the first two rows in its error report" do order_import.process_upload! # minus one because one order (and order_detail) will succeed expect(error_file_row_count).to eq(import_file_row_count - 1) end end end end context "when importing multiple orders" do context "and the second order's order_detail has an error" do let(:import_file) do generate_import_file({}, product_name: "Invalid Item") end before :each do Order.destroy_all order_import.upload_file.file = import_file order_import.upload_file.save! import_file.rewind order_import.fail_on_error = fail_on_error order_import.send_receipts = true order_import.save! end shared_examples_for "an import failure" do it "creates no orders" do expect { order_import.process_upload! }.not_to change(Order, :count) end it_behaves_like "it does not send notifications" it "includes all rows in its error report (as there's only one order)" do order_import.process_upload! expect(error_file_row_count).to eq(import_file_row_count) end end context "when in save-clean-orders mode" do let(:fail_on_error) { false } it_behaves_like "an import failure" end context "when in save-nothing-on-error mode" do let(:fail_on_error) { true } it_behaves_like "an import failure" end end end describe "#process_upload!" do subject(:import) { create(:order_import) } context "an exception is raised in import" do before do allow_any_instance_of(OrderRowImporter).to receive(:import).and_raise("Something unknown happened") import.upload_file.file = generate_import_file import.upload_file.save! import.process_upload! end it "produces an error report" do expect(import.error_file_content).to include("Failed to import row") end it "sets error flags" do expect(import).to be_error_mode expect(import.result).to be_failed end it "sends an exception notification" do expect(ActiveSupport::Notifications).to receive(:instrument).with("background_error", anything) import.process_upload! end end context "an exception is raised when opening the CSV" do before do allow(CSV).to receive(:parse).and_raise(ArgumentError, "invalid byte sequence in UTF-8") import.upload_file.file = generate_import_file import.upload_file.save! import.process_upload! end it "produces an error report" do expect(import.error_file_content).to include("Unable to open CSV File") end it "sets error flags" do expect(import).to be_error_mode expect(import.result).to be_failed end end end end
require "language/node" class Cdk8s < Formula desc "Define k8s native apps and abstractions using object-oriented programming" homepage "https://cdk8s.io/" url "https://registry.npmjs.org/cdk8s-cli/-/cdk8s-cli-2.1.47.tgz" sha256 "55e72637e461c48246efb43d398b7e1f31314e1cd2787261c9e7783aa675dfbc" license "Apache-2.0" bottle do sha256 cellar: :any_skip_relocation, all: "0ae51e3448a61fd1df7318f1070f0ee65db3a890601b9e5cd147095ed80fe50a" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do assert_match "Cannot initialize a project in a non-empty directory", shell_output("#{bin}/cdk8s init python-app 2>&1", 1) end end cdk8s 2.1.48 Closes #115887. Signed-off-by: Patrick Linnane <cbb7353e6d953ef360baf960c122346276c6e320@linnane.io> Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com> require "language/node" class Cdk8s < Formula desc "Define k8s native apps and abstractions using object-oriented programming" homepage "https://cdk8s.io/" url "https://registry.npmjs.org/cdk8s-cli/-/cdk8s-cli-2.1.48.tgz" sha256 "1e1e4dbc9a561f11ccf6fc1ad0d61cff287f990523f5a2ad2149156df8da5658" license "Apache-2.0" bottle do sha256 cellar: :any_skip_relocation, all: "0ae51e3448a61fd1df7318f1070f0ee65db3a890601b9e5cd147095ed80fe50a" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do assert_match "Cannot initialize a project in a non-empty directory", shell_output("#{bin}/cdk8s init python-app 2>&1", 1) end end
forgot spec for Organisation (ex Constitution) require File.join( File.dirname(__FILE__), '..', "spec_helper" ) describe Organisation do describe "text fields" do before(:each) do Clause.set_text('organisation_name', 'The Cheese Collective') Clause.set_text('objectives', 'eat all the cheese') Clause.set_text('domain', 'fromage.com') end it "should get the name of the organisation" do Organisation.name.should == ("The Cheese Collective") end it "should get the objectives of the organisation" do Organisation.objectives.should == ("eat all the cheese") end it "should get the domain" do Organisation.domain.should == ("fromage.com") end it "should change the name of the organisation" do lambda { Clause.set_text(:organisation_name, "The Yoghurt Yurt") }.should change(Clause, :count).by(1) Organisation.name.should == "The Yoghurt Yurt" end it "should change the objectives of the organisation" do lambda { Clause.set_text(:objectives, "make all the yoghurt") }.should change(Clause, :count).by(1) Organisation.objectives.should == "make all the yoghurt" end it "should change the domain of the organisation" do lambda { Clause.set_text(:domain, "yaourt.org") }.should change(Clause, :count).by(1) Organisation.domain.should == "yaourt.org" end end end
require "language/node" class Cdk8s < Formula desc "Define k8s native apps and abstractions using object-oriented programming" homepage "https://cdk8s.io/" url "https://registry.npmjs.org/cdk8s-cli/-/cdk8s-cli-2.0.47.tgz" sha256 "0ff0da56a7ff16213bdc3a833b92e1ca49c393d11d22421e755338810d8f1185" license "Apache-2.0" bottle do sha256 cellar: :any_skip_relocation, all: "1611f0c95219d46245921b7ef66bc3d717ecf3cf2871621d77e615520b42f03c" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do assert_match "Cannot initialize a project in a non-empty directory", shell_output("#{bin}/cdk8s init python-app 2>&1", 1) end end cdk8s 2.0.48 Closes #105587. Signed-off-by: Sean Molenaar <2b250e3fea88cfef248b497ad5fc17f7dc435154@users.noreply.github.com> Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com> require "language/node" class Cdk8s < Formula desc "Define k8s native apps and abstractions using object-oriented programming" homepage "https://cdk8s.io/" url "https://registry.npmjs.org/cdk8s-cli/-/cdk8s-cli-2.0.48.tgz" sha256 "686c9bb760f724e65112b493d078e4acd0eeb15eb2107f8986c984940e02225c" license "Apache-2.0" bottle do sha256 cellar: :any_skip_relocation, all: "1611f0c95219d46245921b7ef66bc3d717ecf3cf2871621d77e615520b42f03c" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do assert_match "Cannot initialize a project in a non-empty directory", shell_output("#{bin}/cdk8s init python-app 2>&1", 1) end end
require "language/node" class Cdk8s < Formula desc "Define k8s native apps and abstractions using object-oriented programming" homepage "https://cdk8s.io/" url "https://registry.npmjs.org/cdk8s-cli/-/cdk8s-cli-2.0.89.tgz" sha256 "119b6ef63b3cb23f8d4506777aa3766b3fbd7506798f2e9eb5228237fee89f2e" license "Apache-2.0" bottle do sha256 cellar: :any_skip_relocation, all: "ca2d11a746510178948fc07c1f92b0ce42e37ddd993220ca88a886aba6ea0875" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do assert_match "Cannot initialize a project in a non-empty directory", shell_output("#{bin}/cdk8s init python-app 2>&1", 1) end end cdk8s: update 2.0.89 bottle. require "language/node" class Cdk8s < Formula desc "Define k8s native apps and abstractions using object-oriented programming" homepage "https://cdk8s.io/" url "https://registry.npmjs.org/cdk8s-cli/-/cdk8s-cli-2.0.89.tgz" sha256 "119b6ef63b3cb23f8d4506777aa3766b3fbd7506798f2e9eb5228237fee89f2e" license "Apache-2.0" bottle do sha256 cellar: :any_skip_relocation, all: "8b74b25e61572f7413ac353c65078d01cc792ebcafa4997ad63bb843356ee746" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do assert_match "Cannot initialize a project in a non-empty directory", shell_output("#{bin}/cdk8s init python-app 2>&1", 1) end end
require 'spec_helper' describe OAuth2::AccessToken do let(:client) do cli = OAuth2::Client.new('abc', 'def', :site => 'https://api.example.com') cli.connection.build do |b| b.adapter :test do |stub| stub.get('/client?oauth_token=monkey') {|env| [200, {}, 'get']} stub.post('/client') {|env| [200, {}, 'oauth_token=' << env[:body]['oauth_token']]} stub.put('/client') {|env| [200, {}, 'oauth_token=' << env[:body]['oauth_token']]} stub.delete('/client') {|env| [200, {}, 'oauth_token=' << env[:body]['oauth_token']]} end end cli end let(:token) {'monkey'} subject {OAuth2::AccessToken.new(client, token)} describe '#initialize' do it 'should assign client and token' do subject.client.should == client subject.token.should == token end it 'should assign extra params' do target = OAuth2::AccessToken.new(client, token, nil, nil, {'foo' => 'bar'}) target.params.should include('foo') target.params['foo'].should == 'bar' end it "makes GET requests with access token" do subject.send(:get, 'client').should == 'get' end %w(post put delete).each do |http_method| it "makes #{http_method.upcase} requests with access token" do subject.send(http_method.to_sym, 'client').should == 'oauth_token=monkey' end end end describe '#expires?' do it 'should be false if there is no expires_at' do OAuth2::AccessToken.new(client, token).should_not be_expires end it 'should be true if there is an expires_at' do OAuth2::AccessToken.new(client, token, 'abaca', 600).should be_expires end end describe '#expires_at' do before do @now = Time.now Time.stub!(:now).and_return(@now) end subject{OAuth2::AccessToken.new(client, token, 'abaca', 600)} it 'should be a time representation of #expires_in' do subject.expires_at.should == (@now + 600) end end describe '#expired?' do it 'should be false if there is no expires_at' do OAuth2::AccessToken.new(client, token).should_not be_expired end it 'should be false if expires_at is in the future' do OAuth2::AccessToken.new(client, token, 'abaca', 10800).should_not be_expired end it 'should be true if expires_at is in the past' do access = OAuth2::AccessToken.new(client, token, 'abaca', 600) @now = Time.now + 10800 Time.stub!(:now).and_return(@now) access.should be_expired end end end fixed tests to reflect correct :delete behaviour require 'spec_helper' describe OAuth2::AccessToken do let(:client) do cli = OAuth2::Client.new('abc', 'def', :site => 'https://api.example.com') cli.connection.build do |b| b.adapter :test do |stub| stub.get('/client?oauth_token=monkey') {|env| [200, {}, 'get']} stub.post('/client') {|env| [200, {}, 'oauth_token=' << env[:body]['oauth_token']]} stub.put('/client') {|env| [200, {}, 'oauth_token=' << env[:body]['oauth_token']]} stub.delete('/client?oauth_token=monkey') {|env| [200, {}, 'delete']} end end cli end let(:token) {'monkey'} subject {OAuth2::AccessToken.new(client, token)} describe '#initialize' do it 'should assign client and token' do subject.client.should == client subject.token.should == token end it 'should assign extra params' do target = OAuth2::AccessToken.new(client, token, nil, nil, {'foo' => 'bar'}) target.params.should include('foo') target.params['foo'].should == 'bar' end %w(get delete).each do |http_method| it "makes #{http_method.upcase} requests with access token" do subject.send(http_method.to_sym, 'client').should == http_method end end %w(post put).each do |http_method| it "makes #{http_method.upcase} requests with access token" do subject.send(http_method.to_sym, 'client').should == 'oauth_token=monkey' end end end describe '#expires?' do it 'should be false if there is no expires_at' do OAuth2::AccessToken.new(client, token).should_not be_expires end it 'should be true if there is an expires_at' do OAuth2::AccessToken.new(client, token, 'abaca', 600).should be_expires end end describe '#expires_at' do before do @now = Time.now Time.stub!(:now).and_return(@now) end subject{OAuth2::AccessToken.new(client, token, 'abaca', 600)} it 'should be a time representation of #expires_in' do subject.expires_at.should == (@now + 600) end end describe '#expired?' do it 'should be false if there is no expires_at' do OAuth2::AccessToken.new(client, token).should_not be_expired end it 'should be false if expires_at is in the future' do OAuth2::AccessToken.new(client, token, 'abaca', 10800).should_not be_expired end it 'should be true if expires_at is in the past' do access = OAuth2::AccessToken.new(client, token, 'abaca', 600) @now = Time.now + 10800 Time.stub!(:now).and_return(@now) access.should be_expired end end end
require "language/node" class Cdk8s < Formula desc "Define k8s native apps and abstractions using object-oriented programming" homepage "https://cdk8s.io/" url "https://registry.npmjs.org/cdk8s-cli/-/cdk8s-cli-2.0.69.tgz" sha256 "76ff959365081ab96b32a307886d6d4e9c6ac5401582df66fd1006e8a3b087f0" license "Apache-2.0" bottle do sha256 cellar: :any_skip_relocation, all: "27d89b748ccc221e6a6ca58e2eedb47c1c204896d01e599c6981f0cacd79e434" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do assert_match "Cannot initialize a project in a non-empty directory", shell_output("#{bin}/cdk8s init python-app 2>&1", 1) end end cdk8s: update 2.0.69 bottle. require "language/node" class Cdk8s < Formula desc "Define k8s native apps and abstractions using object-oriented programming" homepage "https://cdk8s.io/" url "https://registry.npmjs.org/cdk8s-cli/-/cdk8s-cli-2.0.69.tgz" sha256 "76ff959365081ab96b32a307886d6d4e9c6ac5401582df66fd1006e8a3b087f0" license "Apache-2.0" bottle do sha256 cellar: :any_skip_relocation, all: "c62c4f07417ce230992c27dc41a5ada55eeb89e744bc4b49a885807bae5fa2d9" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do assert_match "Cannot initialize a project in a non-empty directory", shell_output("#{bin}/cdk8s init python-app 2>&1", 1) end end
require 'spec_helper' describe "real world edgecases", :realworld => true do # there is no rbx-relative-require gem that will install on 1.9 it "ignores extra gems with bad platforms", :ruby => "1.8" do install_gemfile <<-G source :rubygems gem "linecache", "0.46" G expect(err).to eq("") end # https://github.com/bundler/bundler/issues/1202 it "bundle cache works with rubygems 1.3.7 and pre gems", :ruby => "1.8" do install_gemfile <<-G source :rubygems gem "rack", "1.3.0.beta2" gem "will_paginate", "3.0.pre2" G bundle :cache expect(out).not_to include("Removing outdated .gem files from vendor/cache") end # https://github.com/bundler/bundler/issues/1486 # this is a hash collision that only manifests on 1.8.7 it "finds the correct child versions", :ruby => "1.8" do install_gemfile <<-G source :rubygems gem 'i18n', '~> 0.6.0' gem 'activesupport', '~> 3.0' gem 'activerecord', '~> 3.0' gem 'builder', '~> 2.1.2' G expect(out).to include("activemodel 3.0.5") end it "resolves dependencies correctly", :ruby => "1.9" do install_gemfile <<-G source "https://rubygems.org" gem 'rails', '~> 3.0' gem 'capybara', '~> 2.2.0' G expect(out).to include("rails 3.2.21") expect(out).to include("capybara 2.2.1") end it "installs the latest version of gxapi_rails", :ruby => "1.9" do install_gemfile <<-G source "https://rubygems.org" gem "sass-rails" gem "rails", "~> 3" gem "gxapi_rails" G expect(out).to include("gxapi_rails 0.0.6") end it "installs the latest version of i18n" do install_gemfile <<-G source "https://rubygems.org" gem "i18n", "~> 0.6.0" gem "activesupport", "~> 3.0" gem "activerecord", "~> 3.0" gem "builder", "~> 2.1.2" G expect(out).to include("i18n 0.6.11") expect(out).to include("activesupport 3.0.5") end # https://github.com/bundler/bundler/issues/1500 it "does not fail install because of gem plugins" do realworld_system_gems("open_gem --version 1.4.2", "rake --version 0.9.2") gemfile <<-G source :rubygems gem 'rack', '1.0.1' G bundle "install --path vendor/bundle", :expect_err => true expect(err).not_to include("Could not find rake") expect(err).to be_empty end it "checks out git repos when the lockfile is corrupted" do gemfile <<-G source :rubygems gem 'activerecord', :github => 'carlhuda/rails-bundler-test', :branch => 'master' gem 'activesupport', :github => 'carlhuda/rails-bundler-test', :branch => 'master' gem 'actionpack', :github => 'carlhuda/rails-bundler-test', :branch => 'master' G lockfile <<-L GIT remote: git://github.com/carlhuda/rails-bundler-test.git revision: 369e28a87419565f1940815219ea9200474589d4 branch: master specs: actionpack (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) activemodel (3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) activerecord (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) arel (~> 3.0.2) tzinfo (~> 0.3.29) activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) GIT remote: git://github.com/carlhuda/rails-bundler-test.git revision: 369e28a87419565f1940815219ea9200474589d4 branch: master specs: actionpack (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) activemodel (3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) activerecord (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) arel (~> 3.0.2) tzinfo (~> 0.3.29) activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) GIT remote: git://github.com/carlhuda/rails-bundler-test.git revision: 369e28a87419565f1940815219ea9200474589d4 branch: master specs: actionpack (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) activemodel (3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) activerecord (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) arel (~> 3.0.2) tzinfo (~> 0.3.29) activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) GEM remote: https://rubygems.org/ specs: arel (3.0.2) builder (3.0.0) erubis (2.7.0) hike (1.2.1) i18n (0.6.0) journey (1.0.3) multi_json (1.1.0) rack (1.4.1) rack-cache (1.2) rack (>= 0.4) rack-test (0.6.1) rack (>= 1.0) sprockets (2.1.2) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) tilt (1.3.3) tzinfo (0.3.32) PLATFORMS ruby DEPENDENCIES actionpack! activerecord! activesupport! L bundle :install, :exitstatus => true expect(exitstatus).to eq(0) end end Don't change i18n version of Ruby 1.8 spec require 'spec_helper' describe "real world edgecases", :realworld => true do # there is no rbx-relative-require gem that will install on 1.9 it "ignores extra gems with bad platforms", :ruby => "1.8" do install_gemfile <<-G source :rubygems gem "linecache", "0.46" G expect(err).to eq("") end # https://github.com/bundler/bundler/issues/1202 it "bundle cache works with rubygems 1.3.7 and pre gems", :ruby => "1.8" do install_gemfile <<-G source :rubygems gem "rack", "1.3.0.beta2" gem "will_paginate", "3.0.pre2" G bundle :cache expect(out).not_to include("Removing outdated .gem files from vendor/cache") end # https://github.com/bundler/bundler/issues/1486 # this is a hash collision that only manifests on 1.8.7 it "finds the correct child versions", :ruby => "1.8" do install_gemfile <<-G source :rubygems gem 'i18n', '~> 0.4' gem 'activesupport', '~> 3.0' gem 'activerecord', '~> 3.0' gem 'builder', '~> 2.1.2' G expect(out).to include("activemodel 3.0.5") end it "resolves dependencies correctly", :ruby => "1.9" do install_gemfile <<-G source "https://rubygems.org" gem 'rails', '~> 3.0' gem 'capybara', '~> 2.2.0' G expect(out).to include("rails 3.2.21") expect(out).to include("capybara 2.2.1") end it "installs the latest version of gxapi_rails", :ruby => "1.9" do install_gemfile <<-G source "https://rubygems.org" gem "sass-rails" gem "rails", "~> 3" gem "gxapi_rails" G expect(out).to include("gxapi_rails 0.0.6") end it "installs the latest version of i18n" do install_gemfile <<-G source "https://rubygems.org" gem "i18n", "~> 0.6.0" gem "activesupport", "~> 3.0" gem "activerecord", "~> 3.0" gem "builder", "~> 2.1.2" G expect(out).to include("i18n 0.6.11") expect(out).to include("activesupport 3.0.5") end # https://github.com/bundler/bundler/issues/1500 it "does not fail install because of gem plugins" do realworld_system_gems("open_gem --version 1.4.2", "rake --version 0.9.2") gemfile <<-G source :rubygems gem 'rack', '1.0.1' G bundle "install --path vendor/bundle", :expect_err => true expect(err).not_to include("Could not find rake") expect(err).to be_empty end it "checks out git repos when the lockfile is corrupted" do gemfile <<-G source :rubygems gem 'activerecord', :github => 'carlhuda/rails-bundler-test', :branch => 'master' gem 'activesupport', :github => 'carlhuda/rails-bundler-test', :branch => 'master' gem 'actionpack', :github => 'carlhuda/rails-bundler-test', :branch => 'master' G lockfile <<-L GIT remote: git://github.com/carlhuda/rails-bundler-test.git revision: 369e28a87419565f1940815219ea9200474589d4 branch: master specs: actionpack (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) activemodel (3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) activerecord (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) arel (~> 3.0.2) tzinfo (~> 0.3.29) activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) GIT remote: git://github.com/carlhuda/rails-bundler-test.git revision: 369e28a87419565f1940815219ea9200474589d4 branch: master specs: actionpack (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) activemodel (3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) activerecord (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) arel (~> 3.0.2) tzinfo (~> 0.3.29) activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) GIT remote: git://github.com/carlhuda/rails-bundler-test.git revision: 369e28a87419565f1940815219ea9200474589d4 branch: master specs: actionpack (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) activemodel (3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) activerecord (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) arel (~> 3.0.2) tzinfo (~> 0.3.29) activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) GEM remote: https://rubygems.org/ specs: arel (3.0.2) builder (3.0.0) erubis (2.7.0) hike (1.2.1) i18n (0.6.0) journey (1.0.3) multi_json (1.1.0) rack (1.4.1) rack-cache (1.2) rack (>= 0.4) rack-test (0.6.1) rack (>= 1.0) sprockets (2.1.2) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) tilt (1.3.3) tzinfo (0.3.32) PLATFORMS ruby DEPENDENCIES actionpack! activerecord! activesupport! L bundle :install, :exitstatus => true expect(exitstatus).to eq(0) end end
require "formula" require "language/haskell" class Cgrep < Formula include Language::Haskell::Cabal homepage "https://github.com/awgn/cgrep" url "https://github.com/awgn/cgrep/archive/v6.4.2.tar.gz" sha1 "209bc29721bcfdc5652839c54c89ceb2d5a86bf9" head "https://github.com/awgn/cgrep.git", :branch => "master" bottle do cellar :any sha1 "7c8b5399e4cbed0cf3e51565d7b009c70576c8e8" => :mavericks sha1 "cf0ebb3fb08a172a91645184458c3cf6bebfc981" => :mountain_lion sha1 "33a5fbe772ae2ffa7a5d3374a7304960053ee05d" => :lion end depends_on "ghc" => :build depends_on "cabal-install" => :build def install install_cabal_package end test do test_string = "String in" path = testpath/"test.rb" path.write <<-EOS.undent # puts #{test_string} comment. puts "#{test_string} literal." EOS comment = `cgrep --comment "#{test_string}" #{path}` assert_equal 1, comment.lines.count literal = `cgrep --literal "#{test_string}" #{path}` assert_equal 1, literal.lines.count code = `cgrep --code puts #{path}` assert_equal 1, code.lines.count end end cgrep 6.4.4 require "formula" require "language/haskell" class Cgrep < Formula include Language::Haskell::Cabal homepage "https://github.com/awgn/cgrep" url "https://github.com/awgn/cgrep/archive/v6.4.4.tar.gz" sha1 "d36eef5d93e660df971a9f74d4ffff6ed6fab710" head "https://github.com/awgn/cgrep.git", :branch => "master" bottle do cellar :any sha1 "7c8b5399e4cbed0cf3e51565d7b009c70576c8e8" => :mavericks sha1 "cf0ebb3fb08a172a91645184458c3cf6bebfc981" => :mountain_lion sha1 "33a5fbe772ae2ffa7a5d3374a7304960053ee05d" => :lion end depends_on "ghc" => :build depends_on "cabal-install" => :build def install install_cabal_package end test do test_string = "String in" path = testpath/"test.rb" path.write <<-EOS.undent # puts #{test_string} comment. puts "#{test_string} literal." EOS comment = `cgrep --comment "#{test_string}" #{path}` assert_equal 1, comment.lines.count literal = `cgrep --literal "#{test_string}" #{path}` assert_equal 1, literal.lines.count code = `cgrep --code puts #{path}` assert_equal 1, code.lines.count end end
require 'spec_helper' describe "real world edgecases", :realworld => true do # there is no rbx-relative-require gem that will install on 1.9 it "ignores extra gems with bad platforms", :ruby => "1.8" do install_gemfile <<-G source :rubygems gem "linecache", "0.46" G err.should eq("") end # https://github.com/carlhuda/bundler/issues/1202 it "bundle cache works with rubygems 1.3.7 and pre gems" do install_gemfile <<-G source :rubygems gem "rack", "1.3.0.beta2" gem "will_paginate", "3.0.pre2" G bundle :cache out.should_not include("Removing outdated .gem files from vendor/cache") end # https://github.com/carlhuda/bundler/issues/1486 # this is a hash collision that only manifests on 1.8.7 it "finds the correct child versions" do install_gemfile <<-G source :rubygems gem 'i18n', '~> 0.4' gem 'activesupport', '~> 3.0' gem 'activerecord', '~> 3.0' gem 'builder', '~> 2.1.2' G out.should include("activemodel (3.0.5)") end # https://github.com/carlhuda/bundler/issues/1500 it "does not fail install because of gem plugins" do realworld_system_gems("open_gem --version 1.4.2", "rake --version 0.9.2") gemfile <<-G source :rubygems gem 'rack', '1.0.0' G bundle "install --path vendor/bundle", :expect_err => true err.should_not include("Could not find rake") err.should be_empty end it "checks out git repos when the lockfile is corrupted" do gemfile <<-G source :rubygems gem 'activerecord', :github => 'carlhuda/rails-bundler-test', :branch => 'master' gem 'activesupport', :github => 'carlhuda/rails-bundler-test', :branch => 'master' gem 'actionpack', :github => 'carlhuda/rails-bundler-test', :branch => 'master' G lockfile <<-L GIT remote: git://github.com/carlhuda/rails-bundler-test.git revision: 369e28a87419565f1940815219ea9200474589d4 branch: master specs: actionpack (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) activemodel (3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) activerecord (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) arel (~> 3.0.2) tzinfo (~> 0.3.29) activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) GIT remote: git://github.com/carlhuda/rails-bundler-test.git revision: 369e28a87419565f1940815219ea9200474589d4 branch: master specs: actionpack (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) activemodel (3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) activerecord (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) arel (~> 3.0.2) tzinfo (~> 0.3.29) activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) GIT remote: git://github.com/carlhuda/rails-bundler-test.git revision: 369e28a87419565f1940815219ea9200474589d4 branch: master specs: actionpack (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) activemodel (3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) activerecord (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) arel (~> 3.0.2) tzinfo (~> 0.3.29) activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) GEM remote: http://rubygems.org/ specs: arel (3.0.2) builder (3.0.0) erubis (2.7.0) hike (1.2.1) i18n (0.6.0) journey (1.0.3) multi_json (1.1.0) rack (1.4.1) rack-cache (1.2) rack (>= 0.4) rack-test (0.6.1) rack (>= 1.0) sprockets (2.1.2) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) tilt (1.3.3) tzinfo (0.3.32) PLATFORMS ruby DEPENDENCIES actionpack! activerecord! activesupport! L bundle :install, :exitstatus => true exitstatus.should == 0 end end Fix failing test case Explanation: "rack" 1.0.0 can not be installed because of a circular dependency ("rack" depends on "thin", and "thin" depends on "rack"). For "rack" 1.0.1 (and later), "thin" is only development dependency, hence we now use 1.0.1 for our test. require 'spec_helper' describe "real world edgecases", :realworld => true do # there is no rbx-relative-require gem that will install on 1.9 it "ignores extra gems with bad platforms", :ruby => "1.8" do install_gemfile <<-G source :rubygems gem "linecache", "0.46" G err.should eq("") end # https://github.com/carlhuda/bundler/issues/1202 it "bundle cache works with rubygems 1.3.7 and pre gems" do install_gemfile <<-G source :rubygems gem "rack", "1.3.0.beta2" gem "will_paginate", "3.0.pre2" G bundle :cache out.should_not include("Removing outdated .gem files from vendor/cache") end # https://github.com/carlhuda/bundler/issues/1486 # this is a hash collision that only manifests on 1.8.7 it "finds the correct child versions" do install_gemfile <<-G source :rubygems gem 'i18n', '~> 0.4' gem 'activesupport', '~> 3.0' gem 'activerecord', '~> 3.0' gem 'builder', '~> 2.1.2' G out.should include("activemodel (3.0.5)") end # https://github.com/carlhuda/bundler/issues/1500 it "does not fail install because of gem plugins" do realworld_system_gems("open_gem --version 1.4.2", "rake --version 0.9.2") gemfile <<-G source :rubygems gem 'rack', '1.0.1' G bundle "install --path vendor/bundle", :expect_err => true err.should_not include("Could not find rake") err.should be_empty end it "checks out git repos when the lockfile is corrupted" do gemfile <<-G source :rubygems gem 'activerecord', :github => 'carlhuda/rails-bundler-test', :branch => 'master' gem 'activesupport', :github => 'carlhuda/rails-bundler-test', :branch => 'master' gem 'actionpack', :github => 'carlhuda/rails-bundler-test', :branch => 'master' G lockfile <<-L GIT remote: git://github.com/carlhuda/rails-bundler-test.git revision: 369e28a87419565f1940815219ea9200474589d4 branch: master specs: actionpack (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) activemodel (3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) activerecord (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) arel (~> 3.0.2) tzinfo (~> 0.3.29) activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) GIT remote: git://github.com/carlhuda/rails-bundler-test.git revision: 369e28a87419565f1940815219ea9200474589d4 branch: master specs: actionpack (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) activemodel (3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) activerecord (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) arel (~> 3.0.2) tzinfo (~> 0.3.29) activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) GIT remote: git://github.com/carlhuda/rails-bundler-test.git revision: 369e28a87419565f1940815219ea9200474589d4 branch: master specs: actionpack (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) activemodel (3.2.2) activesupport (= 3.2.2) builder (~> 3.0.0) activerecord (3.2.2) activemodel (= 3.2.2) activesupport (= 3.2.2) arel (~> 3.0.2) tzinfo (~> 0.3.29) activesupport (3.2.2) i18n (~> 0.6) multi_json (~> 1.0) GEM remote: http://rubygems.org/ specs: arel (3.0.2) builder (3.0.0) erubis (2.7.0) hike (1.2.1) i18n (0.6.0) journey (1.0.3) multi_json (1.1.0) rack (1.4.1) rack-cache (1.2) rack (>= 0.4) rack-test (0.6.1) rack (>= 1.0) sprockets (2.1.2) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) tilt (1.3.3) tzinfo (0.3.32) PLATFORMS ruby DEPENDENCIES actionpack! activerecord! activesupport! L bundle :install, :exitstatus => true exitstatus.should == 0 end end
class Chafa < Formula desc "Versatile and fast Unicode/ASCII/ANSI graphics renderer" homepage "https://hpjansson.org/chafa/" url "https://hpjansson.org/chafa/releases/chafa-1.8.0.tar.xz" sha256 "21ff652d836ba207098c40c459652b2f1de6c8a64fbffc62e7c6319ced32286b" license "LGPL-3.0-or-later" livecheck do url "https://hpjansson.org/chafa/releases/?C=M&O=D" regex(/href=.*?chafa[._-]v?(\d+(?:\.\d+)+)\.t/i) end bottle do sha256 cellar: :any, arm64_big_sur: "ec3e9511b3a0ce9c08156e0129bc1b6b457bb872633ffad80e3dc75500ebd665" sha256 cellar: :any, big_sur: "978b79d0ad33901c14156632e34a1b8eba5a0256c92662dde6b9ec2cff0600f8" sha256 cellar: :any, catalina: "8603c4aea080189a148ca7097146edfd5c79fd0ddcc52ffca94eb5d8709ecff5" sha256 cellar: :any, mojave: "3b2b88dae2564f4f2d83f10f55d16866e50a1e8294a409562633d48d618252f3" sha256 cellar: :any_skip_relocation, x86_64_linux: "e58acfb3ef38da06719618923b87c4f9a5fb971390b134bf566dfe8f2634f325" end depends_on "pkg-config" => :build depends_on "glib" depends_on "imagemagick" def install system "./configure", "--disable-debug", "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=#{prefix}" system "make", "install" end test do output = shell_output("#{bin}/chafa #{test_fixtures("test.png")}") assert_equal 4, output.lines.count end end chafa: rebuild chafa 1.8.0 Closes #84884. Signed-off-by: rui <907c7afd57be493757f13ccd1dd45dddf02db069@chenrui.dev> Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com> class Chafa < Formula desc "Versatile and fast Unicode/ASCII/ANSI graphics renderer" homepage "https://hpjansson.org/chafa/" url "https://hpjansson.org/chafa/releases/chafa-1.8.0.tar.xz" sha256 "21ff652d836ba207098c40c459652b2f1de6c8a64fbffc62e7c6319ced32286b" license "LGPL-3.0-or-later" livecheck do url "https://hpjansson.org/chafa/releases/?C=M&O=D" regex(/href=.*?chafa[._-]v?(\d+(?:\.\d+)+)\.t/i) end bottle do sha256 cellar: :any, arm64_big_sur: "ec3e9511b3a0ce9c08156e0129bc1b6b457bb872633ffad80e3dc75500ebd665" sha256 cellar: :any, big_sur: "978b79d0ad33901c14156632e34a1b8eba5a0256c92662dde6b9ec2cff0600f8" sha256 cellar: :any, catalina: "8603c4aea080189a148ca7097146edfd5c79fd0ddcc52ffca94eb5d8709ecff5" sha256 cellar: :any, mojave: "3b2b88dae2564f4f2d83f10f55d16866e50a1e8294a409562633d48d618252f3" sha256 cellar: :any_skip_relocation, x86_64_linux: "e58acfb3ef38da06719618923b87c4f9a5fb971390b134bf566dfe8f2634f325" end depends_on "pkg-config" => :build depends_on "glib" depends_on "imagemagick" def install system "./configure", "--disable-debug", "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=#{prefix}" system "make", "install" man1.install "docs/chafa.1" end test do output = shell_output("#{bin}/chafa #{test_fixtures("test.png")}") assert_equal 4, output.lines.count end end
require File.expand_path("../../Homebrew/emacs_formula", __FILE__) class AsciiArtToUnicode < EmacsFormula desc "Convert ASCII line art to Unicode line art" homepage "http://www.gnuvola.org/software/aa2u/" url "http://elpa.gnu.org/packages/ascii-art-to-unicode-1.9.el" sha256 "bba9e158f755a3d74705a08ded026b20ded7e0a1bab38ec2688de880fa74cf51" head "http://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/packages/ascii-art-to-unicode/ascii-art-to-unicode.el" depends_on :emacs def install mv "ascii-art-to-unicode-#{version}.el", "ascii-art-to-unicode.el" if build.stable? byte_compile "ascii-art-to-unicode.el" (share/"emacs/site-lisp/ascii-art-to-unicode").install Dir["*.el"], Dir["*.elc"] end def caveats; <<-EOS.undent Add the following to your init file: (require 'ascii-art-to-unicode) EOS end test do (testpath/"test.el").write <<-EOS.undent (add-to-list 'load-path "#{HOMEBREW_PREFIX}/share/emacs/site-lisp") (load "ascii-art-to-unicode") (print (minibuffer-prompt-width)) EOS assert_equal "0", shell_output("emacs -batch -l #{testpath}/test.el").strip end end ascii-art-to-unicode: fix test require File.expand_path("../../Homebrew/emacs_formula", __FILE__) class AsciiArtToUnicode < EmacsFormula desc "Convert ASCII line art to Unicode line art" homepage "http://www.gnuvola.org/software/aa2u/" url "http://elpa.gnu.org/packages/ascii-art-to-unicode-1.9.el" sha256 "bba9e158f755a3d74705a08ded026b20ded7e0a1bab38ec2688de880fa74cf51" head "http://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/packages/ascii-art-to-unicode/ascii-art-to-unicode.el" depends_on :emacs def install mv "ascii-art-to-unicode-#{version}.el", "ascii-art-to-unicode.el" if build.stable? byte_compile "ascii-art-to-unicode.el" (share/"emacs/site-lisp/ascii-art-to-unicode").install Dir["*.el"], Dir["*.elc"] end def caveats; <<-EOS.undent Add the following to your init file: (require 'ascii-art-to-unicode) EOS end test do (testpath/"test.el").write <<-EOS.undent (add-to-list 'load-path "#{share}/emacs/site-lisp/ascii-art-to-unicode") (load "ascii-art-to-unicode") (print (minibuffer-prompt-width)) EOS assert_equal "0", shell_output("emacs -Q --batch -l #{testpath}/test.el").strip end end
require "spec_helper" describe "User dashboards" do context "show" do context "groups" do context "not in a group" do include_context "signed in as a site user" it "should have guidance about the lack of groups" do visit dashboard_path page.should have_content(I18n.t(".dashboards.show.no_user_groups")) end end context "in a group" do include_context "signed in as a group member" context "that has no threads" do it "should have guidance about the lack of threads" do visit dashboard_path page.should have_content(I18n.t(".dashboards.show.no_group_threads")) end end context "that has some threads" do it "should list the latest threads from the groups I belong to" do current_user.groups.each do |group| 3.times do # Use factory_with_trait syntax here as for some bug causes multiple # creates with separate trait to fail FactoryGirl.create(:message_thread_with_messages, group: group) end end visit dashboard_path current_user.groups.each do |group| group.threads.each do |thread| page.should have_content(thread.title) end end end end end end context "threads" do include_context "signed in as a site user" it "should list threads I'm subscribed to" context "with no threads" do it "should give guidance" do visit dashboard_path page.should have_content(I18n.t(".dashboards.show.recent_threads")) end end context "with threads" do it "should list threads I'm involved with" do messages = FactoryGirl.create_list(:message, 3, created_by: current_user) current_user.involved_threads.count.should > 0 visit dashboard_path messages.map {|m| m.thread }.each do |thread| page.should have_content(thread.title) end end end end context "issues" do include_context "signed in as a site user" let(:issue) { FactoryGirl.create(:issue) } context "no locations" do it "should give some guidance" do visit dashboard_path page.should have_content(I18n.t(".dashboards.show.add_some_locations")) end end context "unhelpful location" do before do # Give the current user a location that doesn't match the issue ul = current_user.locations.build(category: FactoryGirl.create(:location_category), location: "POINT(-90 -90)") ul.save visit dashboard_path end it "should give some more guidance" do page.should have_content(I18n.t(".dashboards.show.add_another_location")) end end context "matching location" do before do # Give the current user a location that matches the issue ul = current_user.locations.build(category: FactoryGirl.create(:location_category), location: issue.location) ul.save visit dashboard_path end it "should show issues in my area" do page.should have_content(issue.title) end end end end end Ensure the deadlines tab appears on the overview pages. require "spec_helper" describe "User dashboards" do context "show" do context "groups" do context "not in a group" do include_context "signed in as a site user" it "should have guidance about the lack of groups" do visit dashboard_path page.should have_content(I18n.t(".dashboards.show.no_user_groups")) end end context "in a group" do include_context "signed in as a group member" context "that has no threads" do it "should have guidance about the lack of threads" do visit dashboard_path page.should have_content(I18n.t(".dashboards.show.no_group_threads")) end end context "that has some threads" do it "should list the latest threads from the groups I belong to" do current_user.groups.each do |group| 3.times do # Use factory_with_trait syntax here as for some bug causes multiple # creates with separate trait to fail FactoryGirl.create(:message_thread_with_messages, group: group) end end visit dashboard_path current_user.groups.each do |group| group.threads.each do |thread| page.should have_content(thread.title) end end end end end end context "threads" do include_context "signed in as a site user" it "should list threads I'm subscribed to" context "with no threads" do it "should give guidance" do visit dashboard_path page.should have_content(I18n.t(".dashboards.show.recent_threads")) end end context "with threads" do it "should list threads I'm involved with" do messages = FactoryGirl.create_list(:message, 3, created_by: current_user) current_user.involved_threads.count.should > 0 visit dashboard_path messages.map {|m| m.thread }.each do |thread| page.should have_content(thread.title) end end end end context "issues" do include_context "signed in as a site user" let(:issue) { FactoryGirl.create(:issue) } context "no locations" do it "should give some guidance" do visit dashboard_path page.should have_content(I18n.t(".dashboards.show.add_some_locations")) end end context "unhelpful location" do before do # Give the current user a location that doesn't match the issue ul = current_user.locations.build(category: FactoryGirl.create(:location_category), location: "POINT(-90 -90)") ul.save visit dashboard_path end it "should give some more guidance" do page.should have_content(I18n.t(".dashboards.show.add_another_location")) end end context "matching location" do before do # Give the current user a location that matches the issue ul = current_user.locations.build(category: FactoryGirl.create(:location_category), location: issue.location) ul.save visit dashboard_path end it "should show issues in my area" do page.should have_content(issue.title) end end end context "deadlines" do include_context "signed in as a site user" context "no deadlines" do it "should give a warning" do visit dashboard_path page.should have_content(I18n.t(".dashboards.show.no_upcoming_deadline_threads")) end end context "with a deadline" do let!(:message) { FactoryGirl.create(:message, created_by: current_user) } let!(:deadline) { FactoryGirl.create(:deadline_message, message: FactoryGirl.create(:message, thread: message.thread)) } it "should show the deadline" do visit dashboard_path page.should have_content(deadline.title) page.should have_content(I18n.l(deadline.deadline.to_date, format: :long)) end end end end end
class Chars < Formula desc "Command-line tool to display information about unicode characters" homepage "https://github.com/antifuchs/chars/" url "https://github.com/antifuchs/chars/archive/v0.6.0.tar.gz" sha256 "34537fd7b8b5fdc79a35284236443b07c54dded81d558c5bb774a2a354b498c7" license "MIT" head "https://github.com/antifuchs/chars.git", branch: "master" bottle do sha256 cellar: :any_skip_relocation, arm64_ventura: "ee69a8455622d2561dd6ead1727c8f4006070f3679b4e94b5927f7c42aa1097c" sha256 cellar: :any_skip_relocation, arm64_monterey: "65d4047f46ba1526f22d731c7b74de64ca33d59acda6791ff25f9680ad92d261" sha256 cellar: :any_skip_relocation, arm64_big_sur: "2c1f8f9c18e61de6516ffacd7a8d0012dc5a79440d91ba27e3c444c90346375e" sha256 cellar: :any_skip_relocation, monterey: "d500b53477aa281423107e2671e7375da0b653b387a2f7397e6c5692c34dbb0c" sha256 cellar: :any_skip_relocation, big_sur: "bfddb7bd963efcdf967cbeb1ed7086816431d9f494f198e201dd6888d7844f34" sha256 cellar: :any_skip_relocation, catalina: "b67bf752923b6943a07bc90cbd7b3a3a64e02968fe752579266561844e979763" sha256 cellar: :any_skip_relocation, x86_64_linux: "4d2f9a30b1ddfee10bac0c2b65d8c99be8755a2b6166b88111a244eafa27a768" end depends_on "rust" => :build def install cd "chars" do system "cargo", "install", *std_cargo_args end end test do output = shell_output "#{bin}/chars 1C" assert_match "Control character", output assert_match "FS", output assert_match "File Separator", output end end chars: update 0.6.0 bottle. class Chars < Formula desc "Command-line tool to display information about unicode characters" homepage "https://github.com/antifuchs/chars/" url "https://github.com/antifuchs/chars/archive/v0.6.0.tar.gz" sha256 "34537fd7b8b5fdc79a35284236443b07c54dded81d558c5bb774a2a354b498c7" license "MIT" head "https://github.com/antifuchs/chars.git", branch: "master" bottle do rebuild 1 sha256 cellar: :any_skip_relocation, arm64_ventura: "e86820c61f169941a6a3dae1cfcb6c1482cf8d3c085ce6efbf667bdbe1cfe894" sha256 cellar: :any_skip_relocation, arm64_monterey: "213905dc7e59d0347209f84242f9fbdc7dd1adea7f890c9668472b3b5389ec74" sha256 cellar: :any_skip_relocation, arm64_big_sur: "46c98e22e7a51a614c1dc0d91843e864571c06a89b9776097f2d69dbc863d041" sha256 cellar: :any_skip_relocation, monterey: "f6a1f04b6483546d3290e6205425b9848f12f6649245138a81855ea64f45ecb5" sha256 cellar: :any_skip_relocation, big_sur: "8f269cd28454df1e15bb292be55d98c2416c82bef436bd0328b74db74abc4058" sha256 cellar: :any_skip_relocation, x86_64_linux: "f2612efe435bbd11443b34bc4a3dffecbc9036884ce64e9c6fd5ad32e65c767e" end depends_on "rust" => :build def install cd "chars" do system "cargo", "install", *std_cargo_args end end test do output = shell_output "#{bin}/chars 1C" assert_match "Control character", output assert_match "FS", output assert_match "File Separator", output end end
class AwsElasticbeanstalk < Formula include Language::Python::Virtualenv desc "Client for Amazon Elastic Beanstalk web service" homepage "https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3.html" url "https://files.pythonhosted.org/packages/e9/82/ef6f42b1a01772e7e9b0ecb1225bc55bd06a4f240e04991eb841d559f276/awsebcli-3.12.0.tar.gz" sha256 "6db6aae69f5ec61048d2ac81fe2f1355cb1361a52ad23b6898f5f6b788565952" bottle do cellar :any_skip_relocation sha256 "d207f4eeab0a523875daa5a9836ede61f346e9ed46b3b7d9a38c21f70e7a352c" => :high_sierra sha256 "ddb90d10aa4616b390a7b4f3ab8d2b8e09ca4e447f4d8cd2ef0843e34acb633d" => :sierra sha256 "1c6b7218472b429695d8390642fa2e53f2fec98e254190d030f919449d7b546f" => :el_capitan end depends_on :python if MacOS.version <= :snow_leopard resource "blessed" do url "https://files.pythonhosted.org/packages/c2/04/be691f2ad9d70252476bb0d74a1e46390364d751b021b747b7dc1c8dfb0c/blessed-1.14.2.tar.gz" sha256 "2342125fd4f27f00d2677798bd06be2e6a1178e77c0298080abe4f720070693b" end resource "botocore" do url "https://files.pythonhosted.org/packages/6e/25/9dceea9455b318af8befd7d1659411599da864ebfc811e99f3b2b088d514/botocore-1.7.34.tar.gz" sha256 "7e048dcdb2bc5f2f35141542c872c602a08db921bafd42f21823c49756dc4e90" end resource "cement" do url "https://files.pythonhosted.org/packages/70/60/608f0b8975f4ee7deaaaa7052210d095e0b96e7cd3becdeede9bd13674a1/cement-2.8.2.tar.gz" sha256 "8765ed052c061d74e4d0189addc33d268de544ca219b259d797741f725e422d2" end resource "colorama" do url "https://files.pythonhosted.org/packages/f0/d0/21c6449df0ca9da74859edc40208b3a57df9aca7323118c913e58d442030/colorama-0.3.7.tar.gz" sha256 "e043c8d32527607223652021ff648fbb394d5e19cba9f1a698670b338c9d782b" end resource "docker-py" do url "https://files.pythonhosted.org/packages/2c/f8/719f2b240e2b546a8ee779ac74e54754ccf2f17baad728e89188d70e0b5f/docker-py-1.7.2.tar.gz" sha256 "95b1d14c4ae49dfbb724332cda9c63fb67628b8bdee79c321f2d405cf7a8d04c" end resource "dockerpty" do url "https://files.pythonhosted.org/packages/8d/ee/e9ecce4c32204a6738e0a5d5883d3413794d7498fe8b06f44becc028d3ba/dockerpty-0.4.1.tar.gz" sha256 "69a9d69d573a0daa31bcd1c0774eeed5c15c295fe719c61aca550ed1393156ce" end resource "docopt" do url "https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz" sha256 "49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491" end resource "docutils" do url "https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-0.14.tar.gz" sha256 "51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274" end resource "jmespath" do url "https://files.pythonhosted.org/packages/e5/21/795b7549397735e911b032f255cff5fb0de58f96da794274660bca4f58ef/jmespath-0.9.3.tar.gz" sha256 "6a81d4c9aa62caf061cb517b4d9ad1dd300374cd4706997aff9cd6aedd61fc64" end resource "pathspec" do url "https://files.pythonhosted.org/packages/67/f6/ad4d6964da803ffe0ec9d513b0be6924be0f502636c17781308561f08034/pathspec-0.5.0.tar.gz" sha256 "aa3a071054d4740b963c91a3127a5e0e1358351718bae2a3f731ec24fb0bdd1f" end resource "python-dateutil" do url "https://files.pythonhosted.org/packages/54/bb/f1db86504f7a49e1d9b9301531181b00a1c7325dc85a29160ee3eaa73a54/python-dateutil-2.6.1.tar.gz" sha256 "891c38b2a02f5bb1be3e4793866c8df49c7d19baabf9c1bad62547e0b4866aca" end resource "PyYAML" do url "https://files.pythonhosted.org/packages/4a/85/db5a2df477072b2902b0eb892feb37d88ac635d36245a72a6a69b23b383a/PyYAML-3.12.tar.gz" sha256 "592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab" end resource "requests" do url "https://files.pythonhosted.org/packages/f9/6d/07c44fb1ebe04d069459a189e7dab9e4abfe9432adcd4477367c25332748/requests-2.9.1.tar.gz" sha256 "c577815dd00f1394203fc44eb979724b098f88264a9ef898ee45b8e5e9cf587f" end resource "semantic_version" do url "https://files.pythonhosted.org/packages/8e/0e/33052dd97ab9d07dae8ddffcfb2740efe58c46d72efbc060cf6da250439f/semantic_version-2.5.0.tar.gz" sha256 "3baad35dcb074a49419539cea6a33b484706b6c2dd03f05b67763eba4c1bb65c" end resource "six" do url "https://files.pythonhosted.org/packages/16/d8/bc6316cf98419719bd59c91742194c111b6f2e85abac88e496adefaf7afe/six-1.11.0.tar.gz" sha256 "70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9" end resource "tabulate" do url "https://files.pythonhosted.org/packages/db/40/6ffc855c365769c454591ac30a25e9ea0b3e8c952a1259141f5b9878bd3d/tabulate-0.7.5.tar.gz" sha256 "9071aacbd97a9a915096c1aaf0dc684ac2672904cd876db5904085d6dac9810e" end resource "termcolor" do url "https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz" sha256 "1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b" end resource "wcwidth" do url "https://files.pythonhosted.org/packages/55/11/e4a2bb08bb450fdbd42cc709dd40de4ed2c472cf0ccb9e64af22279c5495/wcwidth-0.1.7.tar.gz" sha256 "3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e" end resource "websocket-client" do url "https://files.pythonhosted.org/packages/06/19/f00725a8aee30163a7f257092e356388443034877c101757c1466e591bf8/websocket_client-0.44.0.tar.gz" sha256 "15f585566e2ea7459136a632b9785aa081093064391878a448c382415e948d72" end resource "backports.ssl_match_hostname" do url "https://files.pythonhosted.org/packages/76/21/2dc61178a2038a5cb35d14b61467c6ac632791ed05131dda72c20e7b9e23/backports.ssl_match_hostname-3.5.0.1.tar.gz" sha256 "502ad98707319f4a51fa2ca1c677bd659008d27ded9f6380c79e8932e38dcdf2" end def install virtualenv_install_with_resources bash_completion.install libexec/"bin/eb_completion.bash" end test do system "#{bin}/eb", "--version" end end aws-elasticbeanstalk: update 3.12.0 bottle for Linuxbrew. class AwsElasticbeanstalk < Formula include Language::Python::Virtualenv desc "Client for Amazon Elastic Beanstalk web service" homepage "https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3.html" url "https://files.pythonhosted.org/packages/e9/82/ef6f42b1a01772e7e9b0ecb1225bc55bd06a4f240e04991eb841d559f276/awsebcli-3.12.0.tar.gz" sha256 "6db6aae69f5ec61048d2ac81fe2f1355cb1361a52ad23b6898f5f6b788565952" bottle do cellar :any_skip_relocation sha256 "d207f4eeab0a523875daa5a9836ede61f346e9ed46b3b7d9a38c21f70e7a352c" => :high_sierra sha256 "ddb90d10aa4616b390a7b4f3ab8d2b8e09ca4e447f4d8cd2ef0843e34acb633d" => :sierra sha256 "1c6b7218472b429695d8390642fa2e53f2fec98e254190d030f919449d7b546f" => :el_capitan sha256 "7b137c8adcaf98f1ddd8e2d2314602f031d49592c16c1dda1a66720624b27e77" => :x86_64_linux end depends_on :python if MacOS.version <= :snow_leopard resource "blessed" do url "https://files.pythonhosted.org/packages/c2/04/be691f2ad9d70252476bb0d74a1e46390364d751b021b747b7dc1c8dfb0c/blessed-1.14.2.tar.gz" sha256 "2342125fd4f27f00d2677798bd06be2e6a1178e77c0298080abe4f720070693b" end resource "botocore" do url "https://files.pythonhosted.org/packages/6e/25/9dceea9455b318af8befd7d1659411599da864ebfc811e99f3b2b088d514/botocore-1.7.34.tar.gz" sha256 "7e048dcdb2bc5f2f35141542c872c602a08db921bafd42f21823c49756dc4e90" end resource "cement" do url "https://files.pythonhosted.org/packages/70/60/608f0b8975f4ee7deaaaa7052210d095e0b96e7cd3becdeede9bd13674a1/cement-2.8.2.tar.gz" sha256 "8765ed052c061d74e4d0189addc33d268de544ca219b259d797741f725e422d2" end resource "colorama" do url "https://files.pythonhosted.org/packages/f0/d0/21c6449df0ca9da74859edc40208b3a57df9aca7323118c913e58d442030/colorama-0.3.7.tar.gz" sha256 "e043c8d32527607223652021ff648fbb394d5e19cba9f1a698670b338c9d782b" end resource "docker-py" do url "https://files.pythonhosted.org/packages/2c/f8/719f2b240e2b546a8ee779ac74e54754ccf2f17baad728e89188d70e0b5f/docker-py-1.7.2.tar.gz" sha256 "95b1d14c4ae49dfbb724332cda9c63fb67628b8bdee79c321f2d405cf7a8d04c" end resource "dockerpty" do url "https://files.pythonhosted.org/packages/8d/ee/e9ecce4c32204a6738e0a5d5883d3413794d7498fe8b06f44becc028d3ba/dockerpty-0.4.1.tar.gz" sha256 "69a9d69d573a0daa31bcd1c0774eeed5c15c295fe719c61aca550ed1393156ce" end resource "docopt" do url "https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz" sha256 "49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491" end resource "docutils" do url "https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-0.14.tar.gz" sha256 "51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274" end resource "jmespath" do url "https://files.pythonhosted.org/packages/e5/21/795b7549397735e911b032f255cff5fb0de58f96da794274660bca4f58ef/jmespath-0.9.3.tar.gz" sha256 "6a81d4c9aa62caf061cb517b4d9ad1dd300374cd4706997aff9cd6aedd61fc64" end resource "pathspec" do url "https://files.pythonhosted.org/packages/67/f6/ad4d6964da803ffe0ec9d513b0be6924be0f502636c17781308561f08034/pathspec-0.5.0.tar.gz" sha256 "aa3a071054d4740b963c91a3127a5e0e1358351718bae2a3f731ec24fb0bdd1f" end resource "python-dateutil" do url "https://files.pythonhosted.org/packages/54/bb/f1db86504f7a49e1d9b9301531181b00a1c7325dc85a29160ee3eaa73a54/python-dateutil-2.6.1.tar.gz" sha256 "891c38b2a02f5bb1be3e4793866c8df49c7d19baabf9c1bad62547e0b4866aca" end resource "PyYAML" do url "https://files.pythonhosted.org/packages/4a/85/db5a2df477072b2902b0eb892feb37d88ac635d36245a72a6a69b23b383a/PyYAML-3.12.tar.gz" sha256 "592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab" end resource "requests" do url "https://files.pythonhosted.org/packages/f9/6d/07c44fb1ebe04d069459a189e7dab9e4abfe9432adcd4477367c25332748/requests-2.9.1.tar.gz" sha256 "c577815dd00f1394203fc44eb979724b098f88264a9ef898ee45b8e5e9cf587f" end resource "semantic_version" do url "https://files.pythonhosted.org/packages/8e/0e/33052dd97ab9d07dae8ddffcfb2740efe58c46d72efbc060cf6da250439f/semantic_version-2.5.0.tar.gz" sha256 "3baad35dcb074a49419539cea6a33b484706b6c2dd03f05b67763eba4c1bb65c" end resource "six" do url "https://files.pythonhosted.org/packages/16/d8/bc6316cf98419719bd59c91742194c111b6f2e85abac88e496adefaf7afe/six-1.11.0.tar.gz" sha256 "70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9" end resource "tabulate" do url "https://files.pythonhosted.org/packages/db/40/6ffc855c365769c454591ac30a25e9ea0b3e8c952a1259141f5b9878bd3d/tabulate-0.7.5.tar.gz" sha256 "9071aacbd97a9a915096c1aaf0dc684ac2672904cd876db5904085d6dac9810e" end resource "termcolor" do url "https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz" sha256 "1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b" end resource "wcwidth" do url "https://files.pythonhosted.org/packages/55/11/e4a2bb08bb450fdbd42cc709dd40de4ed2c472cf0ccb9e64af22279c5495/wcwidth-0.1.7.tar.gz" sha256 "3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e" end resource "websocket-client" do url "https://files.pythonhosted.org/packages/06/19/f00725a8aee30163a7f257092e356388443034877c101757c1466e591bf8/websocket_client-0.44.0.tar.gz" sha256 "15f585566e2ea7459136a632b9785aa081093064391878a448c382415e948d72" end resource "backports.ssl_match_hostname" do url "https://files.pythonhosted.org/packages/76/21/2dc61178a2038a5cb35d14b61467c6ac632791ed05131dda72c20e7b9e23/backports.ssl_match_hostname-3.5.0.1.tar.gz" sha256 "502ad98707319f4a51fa2ca1c677bd659008d27ded9f6380c79e8932e38dcdf2" end def install virtualenv_install_with_resources bash_completion.install libexec/"bin/eb_completion.bash" end test do system "#{bin}/eb", "--version" end end
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') describe "resource(:milestones)" do describe "GET" do before(:each) do login @response = request(resource(Project.first, :milestones)) end it "responds successfully" do @response.should be_successful end it "contains a list of milestones" do @response.should have_xpath("//ul") end end describe "GET" do before(:each) do login need_a_milestone @response = request(resource(Project.first, :milestones)) end it "has a list of milestones" do @response.should have_xpath("//ul/li") end end describe "a successful POST" do before(:each) do login_admin @response = request(resource(Project.first, :milestones), :method => "POST", :params => { :milestone => { :name => 'New Milestone' }}) end it "redirects to resource(:milestones)" do @response.should redirect_to(resource(Project.first, Milestone.first(:name => 'New Milestone')), :message => {:notice => "milestone was successfully created"}) end end end describe "resource(@milestone)" do describe "a successful DELETE" do before(:each) do login_admin @response = request(resource(Project.first, Project.first.milestones.first), :method => "DELETE") end it "should redirect to the index action" do @response.should redirect_to(resource(Project.first, :milestones)) end end end describe "resource(:milestones, :new)" do before(:each) do login_admin @response = request(resource(Project.first, :milestones, :new)) end it "responds successfully" do @response.should be_successful end end describe "resource(@milestone, :edit)" do before(:each) do login_admin @response = request(resource(Project.first, Project.first.milestones.first, :edit)) end it "responds successfully" do @response.should be_successful end end describe "resource(@milestone)" do describe "GET" do before(:each) do need_a_milestone @response = request(resource(Project.first, Project.first.milestones.first)) end it "responds successfully" do @response.should be_successful end end describe "PUT" do before(:each) do login_admin @project = Project.first @milestone = @project.milestones.first @response = request(resource(@project, @milestone), :method => "PUT", :params => { :milestone => {:id => @milestone.id, :name => 'HELLO'} }) end it "redirect to the article show action" do @response.should redirect_to(resource(@project, @milestone)) end it "change name of milestone" do @milestone.reload.name.should == 'HELLO' end end end fix all request/milestone spec require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') describe "resource(:milestones)" do describe "GET" do before(:each) do login @response = request(resource(Project.first, :milestones)) end it "responds successfully" do @response.should be_successful end it "contains a list of milestones" do @response.should have_xpath("//ul") end end describe "GET" do before(:each) do login need_a_milestone @response = request(resource(Project.first, :milestones)) end it "has a list of milestones" do @response.should have_xpath("//ul/li") end end describe "a successful POST" do before(:each) do Milestone.destroy_all login_admin @response = request(resource(Project.first, :milestones), :method => "POST", :params => { :milestone => { :name => 'New Milestone' }}) end it "redirects to resource(:milestones)" do @response.should redirect_to(resource(Project.first, Milestone.first(:conditions => {:name => 'New Milestone'})), :message => {:notice => "milestone was successfully created"}) end end end describe "resource(@milestone)" do describe "a successful DELETE" do before(:each) do login_admin @response = request(resource(Project.first, Project.first.milestones.first), :method => "DELETE") end it "should redirect to the index action" do @response.should redirect_to(resource(Project.first, :milestones)) end end end describe "resource(:milestones, :new)" do before(:each) do login_admin @response = request(resource(Project.first, :milestones, :new)) end it "responds successfully" do @response.should be_successful end end describe "resource(@milestone, :edit)" do before(:each) do login_admin @response = request(resource(Project.first, Project.first.milestones.first, :edit)) end it "responds successfully" do @response.should be_successful end end describe "resource(@milestone)" do describe "GET" do before(:each) do need_a_milestone @response = request(resource(Project.first, Project.first.milestones.first)) end it "responds successfully" do @response.should be_successful end end describe "PUT" do before(:each) do login_admin @project = Project.first @milestone = @project.milestones.first @response = request(resource(@project, @milestone), :method => "PUT", :params => { :milestone => {:id => @milestone.id, :name => 'HELLO'} }) end it "redirect to the article show action" do @response.should redirect_to(resource(@project, @milestone)) end it "change name of milestone" do Milestone.find(@milestone.id).name.should == 'HELLO' end end end
class Cheat < Formula desc "Create and view interactive cheat sheets for *nix commands" homepage "https://github.com/chrisallenlane/cheat" url "https://github.com/chrisallenlane/cheat/archive/2.1.25.tar.gz" sha256 "3627da400caebe5a813aec4f76f4d0999d4ed80d4eff0023f6e1a2a2de016e2f" head "https://github.com/chrisallenlane/cheat.git" bottle do cellar :any_skip_relocation sha256 "c3e7039546197e8747966f52338033d203db340fc3816d2c81588cb87316f622" => :el_capitan sha256 "9dfbfa311c6a57b9071170229c0af543422e68cb6a974e4d630d52b166a4e4eb" => :yosemite sha256 "bf4fbbbff20150fb796dffd28b8038be00fcfe76161dee5b067f64a2fbbf1065" => :mavericks end depends_on :python if MacOS.version <= :snow_leopard resource "docopt" do url "https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz" sha256 "49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491" end resource "Pygments" do url "https://files.pythonhosted.org/packages/b8/67/ab177979be1c81bc99c8d0592ef22d547e70bb4c6815c383286ed5dec504/Pygments-2.1.3.tar.gz" sha256 "88e4c8a91b2af5962bfa5ea2447ec6dd357018e86e94c7d14bd8cacbc5b55d81" end def install ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages" resources.each do |r| r.stage do system "python", *Language::Python.setup_install_args(libexec/"vendor") end end ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python2.7/site-packages" system "python", *Language::Python.setup_install_args(libexec) bash_completion.install "cheat/autocompletion/cheat.bash" zsh_completion.install "cheat/autocompletion/cheat.zsh" => "_cheat" bin.install Dir[libexec/"bin/*"] bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"]) end test do system bin/"cheat", "tar" end end cheat: update 2.1.25 bottle. class Cheat < Formula desc "Create and view interactive cheat sheets for *nix commands" homepage "https://github.com/chrisallenlane/cheat" url "https://github.com/chrisallenlane/cheat/archive/2.1.25.tar.gz" sha256 "3627da400caebe5a813aec4f76f4d0999d4ed80d4eff0023f6e1a2a2de016e2f" head "https://github.com/chrisallenlane/cheat.git" bottle do cellar :any_skip_relocation sha256 "9837962b7701531cb48670dedd9e8468deb1439f63ad5c1e6b6e31bd4522075d" => :el_capitan sha256 "f796ed1abd758afd365f4eab473169d051a0e97a58662f57b1459f729138c0dc" => :yosemite sha256 "5539d5048c4d371ead16e7783d591220ca33728cdcead2e661aeb55022b6eee0" => :mavericks end depends_on :python if MacOS.version <= :snow_leopard resource "docopt" do url "https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz" sha256 "49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491" end resource "Pygments" do url "https://files.pythonhosted.org/packages/b8/67/ab177979be1c81bc99c8d0592ef22d547e70bb4c6815c383286ed5dec504/Pygments-2.1.3.tar.gz" sha256 "88e4c8a91b2af5962bfa5ea2447ec6dd357018e86e94c7d14bd8cacbc5b55d81" end def install ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages" resources.each do |r| r.stage do system "python", *Language::Python.setup_install_args(libexec/"vendor") end end ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python2.7/site-packages" system "python", *Language::Python.setup_install_args(libexec) bash_completion.install "cheat/autocompletion/cheat.bash" zsh_completion.install "cheat/autocompletion/cheat.zsh" => "_cheat" bin.install Dir[libexec/"bin/*"] bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"]) end test do system bin/"cheat", "tar" end end
require "language/node" class BashLanguageServer < Formula desc "Language Server for Bash" homepage "https://github.com/bash-lsp/bash-language-server" url "https://registry.npmjs.org/bash-language-server/-/bash-language-server-3.1.0.tgz" sha256 "36646b3788e238b6e4d2d5c6b8adef86ee30d4fb1cd8d6cb7f68e674dc5f216d" license "MIT" bottle do sha256 cellar: :any_skip_relocation, arm64_ventura: "42b66a767a56d5cd8a71a4763572b88a23b430b0838e17a8d1341bd71369361a" sha256 cellar: :any_skip_relocation, arm64_monterey: "c9e5313f877b77afad07f9418b5a4bc0828e911173d6bd4b0726dc02885fed4a" sha256 cellar: :any_skip_relocation, arm64_big_sur: "c9e5313f877b77afad07f9418b5a4bc0828e911173d6bd4b0726dc02885fed4a" sha256 cellar: :any_skip_relocation, monterey: "ea2aa92dcfe287797e4eb693dfbfaede9ab13c28b177fa4c7f500b92d8e261f6" sha256 cellar: :any_skip_relocation, big_sur: "ea2aa92dcfe287797e4eb693dfbfaede9ab13c28b177fa4c7f500b92d8e261f6" sha256 cellar: :any_skip_relocation, catalina: "ea2aa92dcfe287797e4eb693dfbfaede9ab13c28b177fa4c7f500b92d8e261f6" sha256 cellar: :any_skip_relocation, x86_64_linux: "c9e5313f877b77afad07f9418b5a4bc0828e911173d6bd4b0726dc02885fed4a" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do json = <<~JSON { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "rootUri": null, "capabilities": {} } } JSON input = "Content-Length: #{json.size}\r\n\r\n#{json}" output = pipe_output("#{bin}/bash-language-server start", input, 0) assert_match(/^Content-Length: \d+/i, output) end end bash-language-server 3.1.1 Closes #116115. Signed-off-by: Rui Chen <907c7afd57be493757f13ccd1dd45dddf02db069@chenrui.dev> Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com> require "language/node" class BashLanguageServer < Formula desc "Language Server for Bash" homepage "https://github.com/bash-lsp/bash-language-server" url "https://registry.npmjs.org/bash-language-server/-/bash-language-server-3.1.1.tgz" sha256 "0251fef70b3367746ceb3576a5d9b883b094fe80f24af447e68fc24e33a63014" license "MIT" bottle do sha256 cellar: :any_skip_relocation, arm64_ventura: "42b66a767a56d5cd8a71a4763572b88a23b430b0838e17a8d1341bd71369361a" sha256 cellar: :any_skip_relocation, arm64_monterey: "c9e5313f877b77afad07f9418b5a4bc0828e911173d6bd4b0726dc02885fed4a" sha256 cellar: :any_skip_relocation, arm64_big_sur: "c9e5313f877b77afad07f9418b5a4bc0828e911173d6bd4b0726dc02885fed4a" sha256 cellar: :any_skip_relocation, monterey: "ea2aa92dcfe287797e4eb693dfbfaede9ab13c28b177fa4c7f500b92d8e261f6" sha256 cellar: :any_skip_relocation, big_sur: "ea2aa92dcfe287797e4eb693dfbfaede9ab13c28b177fa4c7f500b92d8e261f6" sha256 cellar: :any_skip_relocation, catalina: "ea2aa92dcfe287797e4eb693dfbfaede9ab13c28b177fa4c7f500b92d8e261f6" sha256 cellar: :any_skip_relocation, x86_64_linux: "c9e5313f877b77afad07f9418b5a4bc0828e911173d6bd4b0726dc02885fed4a" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do json = <<~JSON { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "rootUri": null, "capabilities": {} } } JSON input = "Content-Length: #{json.size}\r\n\r\n#{json}" output = pipe_output("#{bin}/bash-language-server start", input, 0) assert_match(/^Content-Length: \d+/i, output) end end
# encoding: utf-8 require_relative '../spec_helper' include Warden::Test::Helpers include Carto::Factories::Visualizations def login(user) login_as(user, scope: user.username) host! "#{user.username}.localhost.lan" end def follow_redirects(limit = 10) while response.redirect? && (limit -= 1) > 0 follow_redirect! end end describe "UserState" do before(:all) do @feature_flag = FactoryGirl.create(:feature_flag, name: 'no_free_tier', restricted: false) @locked_user = FactoryGirl.create(:locked_user) @map, @table, @table_visualization, @visualization = create_full_builder_vis(@locked_user) @visualization.create_mapcap! @non_locked_user = FactoryGirl.create(:valid_user) @dashboard_endpoints = ['/dashboard', '/dashboard/tables', '/dashboard/datasets', '/dashboard/visualizations', '/dashboard/maps'].freeze @public_user_endpoints = ['/me'].freeze @user_endpoints = ['/account', '/profile'].freeze @tables_endpoints = ["/tables/#{@table.id}", "/tables/#{@table.id}/public", "/tables/#{@table.id}/embed_map"].freeze @viz_endpoints = ["/viz/#{@visualization.id}/public", "/viz/#{@visualization.id}/embed_map", "/viz/#{@visualization.id}/public_map", "/builder/#{@visualization.id}", "/builder/#{@visualization.id}/embed"].freeze @public_api_endpoints = ["/api/v1/viz", "/api/v1/viz/#{@visualization.id}", "/api/v2/viz/#{@visualization.id}/viz", "/api/v3/me", "/api/v3/viz/#{@visualization.id}/viz"].freeze @private_api_endpoints = ["/api/v1/tables/#{@table.id}", "/api/v1/tables/#{@table.id}/columns", "/api/v1/imports", "/api/v1/users/#{@locked_user.id}/layers", "/api/v1/synchronizations", "/api/v1/geocodings", "/api/v1/users/#{@locked_user.id}"] @headers = {} @api_headers = { 'CONTENT_TYPE' => 'application/json', :format => "json" } end after(:all) do @locked_user.destroy @non_locked_user.destroy end describe '#locked user' do it 'owner accessing their resources' do login(@locked_user) @dashboard_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 302 follow_redirect! request.path.should == '/lockout' response.status.should == 200 end @user_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 302 follow_redirect! request.path.should == '/lockout' response.status.should == 200 end @public_user_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 302 follow_redirect! request.path.should == '/lockout' response.status.should == 200 end @tables_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 302 follow_redirect! request.path.should == '/lockout' response.status.should == 200 end @viz_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 302 follow_redirect! request.path.should == '/lockout' response.status.should == 200 end @private_api_endpoints.each do |endpoint| get "#{endpoint}?api_key=#{@locked_user.api_key}", {}, @api_headers request.path == endpoint response.status.should == 404 end @public_api_endpoints.each do |endpoint| get endpoint, {}, @api_headers request.path == endpoint response.status.should == 404 end end it 'locked user can delete their own account' do to_be_deleted_user = FactoryGirl.create(:locked_user) to_be_deleted_user.password = 'pwd123' to_be_deleted_user.password_confirmation = 'pwd123' to_be_deleted_user.save login(to_be_deleted_user) delete account_delete_user_url, deletion_password_confirmation: 'pwd123' expect(User.find(id: to_be_deleted_user.id)).to be_nil end it 'user accessing a locked user resources' do login(@non_locked_user) host! "#{@locked_user.username}.localhost.lan" @user_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @public_user_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @tables_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @viz_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @public_api_endpoints.each do |endpoint| get endpoint, {}, @api_headers request.path == endpoint response.status.should == 404 end end it 'non-logged user accessing a locked user resources' do host! "#{@locked_user.username}.localhost.lan" @public_user_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @tables_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @viz_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @public_api_endpoints.each do |endpoint| get endpoint, {}, @api_headers request.path == endpoint response.status.should == 404 end end end describe '#non locked user' do before(:all) do @locked_user.state = 'active' @locked_user.save end after(:all) do @locked_user.state = 'locked' @locked_user.save end it 'owner accessing their resources' do Admin::UsersController.any_instance.stubs(:render) login(@locked_user) host! "#{@locked_user.username}.localhost.lan" @dashboard_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects request.path.should_not == '/lockout' response.status.should == 200 end @user_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects request.path.should_not == '/lockout' response.status.should == 200 end @public_user_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects request.path.should_not == '/lockout' response.status.should == 200 end @tables_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects request.path.should_not == '/lockout' response.status.should == 200 end @viz_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects request.path.should_not == '/lockout' response.status.should == 200 end @private_api_endpoints.each do |endpoint| get "#{endpoint}?api_key=#{@locked_user.api_key}", {}, @api_headers request.path == endpoint response.status.should == 200 end @public_api_endpoints.each do |endpoint| get endpoint, {}, @api_headers request.path == endpoint response.status.should == 200 end end it 'non locked user accessing a locked user resources' do login(@non_locked_user) @user_endpoints.each do |endpoint| host! "#{@locked_user.username}.localhost.lan" get endpoint, {}, @headers follow_redirects response.status.should == 200 end @public_user_endpoints.each do |endpoint| host! "#{@locked_user.username}.localhost.lan" get endpoint, {}, @headers follow_redirects response.status.should == 200 end @tables_endpoints.each do |endpoint| host! "#{@locked_user.username}.localhost.lan" get endpoint, {}, @headers follow_redirects response.status.should == 200 end @viz_endpoints.each do |endpoint| host! "#{@locked_user.username}.localhost.lan" get endpoint, {}, @headers follow_redirects response.status.should == 200 end @public_api_endpoints.each do |endpoint| get endpoint, {}, @api_headers request.path == endpoint response.status.should == 200 end end it 'non-logged user accessing a locked user resources' do host! "#{@locked_user.username}.localhost.lan" @public_user_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects response.status.should == 200 end @tables_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects response.status.should == 200 end @viz_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects response.status.should == 200 end @public_api_endpoints.each do |endpoint| get endpoint, {}, @api_headers request.path == endpoint response.status.should == 200 end end end end Fix failing specs # encoding: utf-8 require_relative '../spec_helper' include Warden::Test::Helpers include Carto::Factories::Visualizations def login(user) login_as(user, scope: user.username) host! "#{user.username}.localhost.lan" end def follow_redirects(limit = 10) while response.redirect? && (limit -= 1) > 0 follow_redirect! end end describe "UserState" do before(:all) do @feature_flag = FactoryGirl.create(:feature_flag, name: 'no_free_tier', restricted: false) @locked_user = FactoryGirl.create(:locked_user) @map, @table, @table_visualization, @visualization = create_full_builder_vis(@locked_user) @visualization.create_mapcap! @non_locked_user = FactoryGirl.create(:valid_user) @dashboard_endpoints = ['/dashboard', '/dashboard/tables', '/dashboard/datasets', '/dashboard/visualizations', '/dashboard/maps'].freeze @public_user_endpoints = ['/me'].freeze @user_endpoints = ['/account', '/profile'].freeze @tables_endpoints = ["/tables/#{@table.id}", "/tables/#{@table.id}/public", "/tables/#{@table.id}/embed_map"].freeze @viz_endpoints = ["/viz/#{@visualization.id}/public", "/viz/#{@visualization.id}/embed_map", "/viz/#{@visualization.id}/public_map", "/builder/#{@visualization.id}", "/builder/#{@visualization.id}/embed"].freeze @public_api_endpoints = ["/api/v1/viz", "/api/v1/viz/#{@visualization.id}", "/api/v2/viz/#{@visualization.id}/viz", "/api/v3/me", "/api/v3/viz/#{@visualization.id}/viz"].freeze @private_api_endpoints = ["/api/v1/tables/#{@table.id}", "/api/v1/tables/#{@table.id}/columns", "/api/v1/imports", "/api/v1/users/#{@locked_user.id}/layers", "/api/v1/synchronizations", "/api/v1/geocodings", "/api/v1/users/#{@locked_user.id}"] @headers = {} @api_headers = { 'CONTENT_TYPE' => 'application/json', :format => "json" } end after(:all) do @locked_user.destroy @non_locked_user.destroy end describe '#locked user' do it 'owner accessing their resources' do login(@locked_user) @dashboard_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 302 follow_redirect! request.path.should == '/lockout' response.status.should == 200 end @user_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 302 follow_redirect! request.path.should == '/lockout' response.status.should == 200 end @public_user_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 302 follow_redirect! request.path.should == '/lockout' response.status.should == 200 end @tables_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 302 follow_redirect! request.path.should == '/lockout' response.status.should == 200 end @viz_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 302 follow_redirect! request.path.should == '/lockout' response.status.should == 200 end @private_api_endpoints.each do |endpoint| get "#{endpoint}?api_key=#{@locked_user.api_key}", {}, @api_headers request.path == endpoint response.status.should == 404 end @public_api_endpoints.each do |endpoint| get endpoint, {}, @api_headers request.path == endpoint response.status.should == 200 end end it 'locked user can delete their own account' do to_be_deleted_user = FactoryGirl.create(:locked_user) to_be_deleted_user.password = 'pwd123' to_be_deleted_user.password_confirmation = 'pwd123' to_be_deleted_user.save login(to_be_deleted_user) delete account_delete_user_url, deletion_password_confirmation: 'pwd123' expect(User.find(id: to_be_deleted_user.id)).to be_nil end it 'user accessing a locked user resources' do login(@non_locked_user) host! "#{@locked_user.username}.localhost.lan" @user_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @public_user_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @tables_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @viz_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @public_api_endpoints.each do |endpoint| get endpoint, {}, @api_headers request.path == endpoint response.status.should == 200 end end it 'non-logged user accessing a locked user resources' do host! "#{@locked_user.username}.localhost.lan" @public_user_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @tables_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @viz_endpoints.each do |endpoint| get endpoint, {}, @headers response.status.should == 404 end @public_api_endpoints.each do |endpoint| get endpoint, {}, @api_headers request.path == endpoint response.status.should == 200 end end end describe '#non locked user' do before(:all) do @locked_user.state = 'active' @locked_user.save end after(:all) do @locked_user.state = 'locked' @locked_user.save end it 'owner accessing their resources' do Admin::UsersController.any_instance.stubs(:render) login(@locked_user) host! "#{@locked_user.username}.localhost.lan" @dashboard_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects request.path.should_not == '/lockout' response.status.should == 200 end @user_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects request.path.should_not == '/lockout' response.status.should == 200 end @public_user_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects request.path.should_not == '/lockout' response.status.should == 200 end @tables_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects request.path.should_not == '/lockout' response.status.should == 200 end @viz_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects request.path.should_not == '/lockout' response.status.should == 200 end @private_api_endpoints.each do |endpoint| get "#{endpoint}?api_key=#{@locked_user.api_key}", {}, @api_headers request.path == endpoint response.status.should == 200 end @public_api_endpoints.each do |endpoint| get endpoint, {}, @api_headers request.path == endpoint response.status.should == 200 end end it 'non locked user accessing a locked user resources' do login(@non_locked_user) @user_endpoints.each do |endpoint| host! "#{@locked_user.username}.localhost.lan" get endpoint, {}, @headers follow_redirects response.status.should == 200 end @public_user_endpoints.each do |endpoint| host! "#{@locked_user.username}.localhost.lan" get endpoint, {}, @headers follow_redirects response.status.should == 200 end @tables_endpoints.each do |endpoint| host! "#{@locked_user.username}.localhost.lan" get endpoint, {}, @headers follow_redirects response.status.should == 200 end @viz_endpoints.each do |endpoint| host! "#{@locked_user.username}.localhost.lan" get endpoint, {}, @headers follow_redirects response.status.should == 200 end @public_api_endpoints.each do |endpoint| get endpoint, {}, @api_headers request.path == endpoint response.status.should == 200 end end it 'non-logged user accessing a locked user resources' do host! "#{@locked_user.username}.localhost.lan" @public_user_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects response.status.should == 200 end @tables_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects response.status.should == 200 end @viz_endpoints.each do |endpoint| get endpoint, {}, @headers follow_redirects response.status.should == 200 end @public_api_endpoints.each do |endpoint| get endpoint, {}, @api_headers request.path == endpoint response.status.should == 200 end end end end
class Cheat < Formula desc "Create and view interactive cheat sheets for *nix commands" homepage "https://github.com/cheat/cheat" url "https://github.com/cheat/cheat.git", :tag => "3.2.1", :revision => "e2920bd922654c71a1c9be35a5c5d7ebbc875792" bottle do cellar :any_skip_relocation sha256 "487e2315487800539702b067e01462fd1201144fdaeb5ea9233280f377abab37" => :catalina sha256 "c711b3a1b833f5195b91e46592ab2e729f31315ea11aac55cbc52a50f4d34b77" => :mojave sha256 "415508d19027f9da22c99c5d927a2fe73fefe5e25ba471a22ad6b5010dd72627" => :high_sierra end depends_on "go" => :build def install system "go", "build", "-mod", "vendor", "-o", bin/"cheat", "./cmd/cheat" end test do assert_match version.to_s, shell_output("#{bin}/cheat --version") output = shell_output("#{bin}/cheat --init 2>&1") assert_match "editor: vim", output assert_match "could not locate config file", shell_output("#{bin}/cheat tar 2>&1", 1) end end cheat: update 3.2.1 bottle. class Cheat < Formula desc "Create and view interactive cheat sheets for *nix commands" homepage "https://github.com/cheat/cheat" url "https://github.com/cheat/cheat.git", :tag => "3.2.1", :revision => "e2920bd922654c71a1c9be35a5c5d7ebbc875792" bottle do cellar :any_skip_relocation sha256 "321397ea3add121780d15c32a8072169c703cd3af7848e5fd3e65395d173df51" => :catalina sha256 "522ba4dca28c4bf7323ec7f79004cc28cd1564cd2f4c8e874776343c9f90c508" => :mojave sha256 "f9ca85aecc85a09842d4b96260167cbf565830981d1f8f7eeb47e74890a46a50" => :high_sierra end depends_on "go" => :build def install system "go", "build", "-mod", "vendor", "-o", bin/"cheat", "./cmd/cheat" end test do assert_match version.to_s, shell_output("#{bin}/cheat --version") output = shell_output("#{bin}/cheat --init 2>&1") assert_match "editor: vim", output assert_match "could not locate config file", shell_output("#{bin}/cheat tar 2>&1", 1) end end
require "language/node" class BashLanguageServer < Formula desc "Language Server for Bash" homepage "https://github.com/bash-lsp/bash-language-server" url "https://registry.npmjs.org/bash-language-server/-/bash-language-server-3.0.4.tgz" sha256 "88a676b6ad4dc6409a813588fd975a97f881b8f4c2bb4fcb3d4880302606dc2d" license "MIT" bottle do sha256 cellar: :any_skip_relocation, arm64_monterey: "66d942af49ea0b5cb649fea031f9068bce2d05e29ed27f2a6ba7c8df90a6b1f3" sha256 cellar: :any_skip_relocation, arm64_big_sur: "66d942af49ea0b5cb649fea031f9068bce2d05e29ed27f2a6ba7c8df90a6b1f3" sha256 cellar: :any_skip_relocation, monterey: "c503581875b31ce39a99f023ab56ee8cce3cb15e4c9b198d7e51845de8adf689" sha256 cellar: :any_skip_relocation, big_sur: "c503581875b31ce39a99f023ab56ee8cce3cb15e4c9b198d7e51845de8adf689" sha256 cellar: :any_skip_relocation, catalina: "c503581875b31ce39a99f023ab56ee8cce3cb15e4c9b198d7e51845de8adf689" sha256 cellar: :any_skip_relocation, x86_64_linux: "66d942af49ea0b5cb649fea031f9068bce2d05e29ed27f2a6ba7c8df90a6b1f3" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do json = <<~JSON { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "rootUri": null, "capabilities": {} } } JSON input = "Content-Length: #{json.size}\r\n\r\n#{json}" output = pipe_output("#{bin}/bash-language-server start", input, 0) assert_match(/^Content-Length: \d+/i, output) end end bash-language-server: update 3.0.4 bottle. require "language/node" class BashLanguageServer < Formula desc "Language Server for Bash" homepage "https://github.com/bash-lsp/bash-language-server" url "https://registry.npmjs.org/bash-language-server/-/bash-language-server-3.0.4.tgz" sha256 "88a676b6ad4dc6409a813588fd975a97f881b8f4c2bb4fcb3d4880302606dc2d" license "MIT" bottle do sha256 cellar: :any_skip_relocation, arm64_monterey: "b4eab9f073fee502d3fb8ff095604b6bd1c9f2b33f6a84d7020ef0fc1beb5f1a" sha256 cellar: :any_skip_relocation, arm64_big_sur: "b4eab9f073fee502d3fb8ff095604b6bd1c9f2b33f6a84d7020ef0fc1beb5f1a" sha256 cellar: :any_skip_relocation, monterey: "58e20942d6fcd90bf7d78deba2b7c4d6f3473a2f8074318082eb76253cf369c5" sha256 cellar: :any_skip_relocation, big_sur: "58e20942d6fcd90bf7d78deba2b7c4d6f3473a2f8074318082eb76253cf369c5" sha256 cellar: :any_skip_relocation, catalina: "58e20942d6fcd90bf7d78deba2b7c4d6f3473a2f8074318082eb76253cf369c5" sha256 cellar: :any_skip_relocation, x86_64_linux: "b4eab9f073fee502d3fb8ff095604b6bd1c9f2b33f6a84d7020ef0fc1beb5f1a" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do json = <<~JSON { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "rootUri": null, "capabilities": {} } } JSON input = "Content-Length: #{json.size}\r\n\r\n#{json}" output = pipe_output("#{bin}/bash-language-server start", input, 0) assert_match(/^Content-Length: \d+/i, output) end end
require 'spec_helper' describe MountainBerryFields::Test::RubySyntaxChecker do it 'implements the SyntaxChecker interface' do MountainBerryFields::Interface::SyntaxChecker.should substitute_for described_class end describe '#valid?' do it 'returns false for invalid syntax' do described_class.new("{").should_not be_valid end it 'returns true for valid syntax' do described_class.new("{}").should be_valid end end describe '#invalid_message' do it 'returns whatever Ruby gave it on the command line, followed by the original file' do described_class.new("{").invalid_message.should == "-:1: syntax error, unexpected $end, expecting '}'\n"\ "\n" \ "original file:\n" \ "{" end end end Update specs since Ruby 2.0 changed error messages require 'spec_helper' describe MountainBerryFields::Test::RubySyntaxChecker do it 'implements the SyntaxChecker interface' do MountainBerryFields::Interface::SyntaxChecker.should substitute_for described_class end describe '#valid?' do it 'returns false for invalid syntax' do described_class.new("{").should_not be_valid end it 'returns true for valid syntax' do described_class.new("{}").should be_valid end end describe '#invalid_message' do it 'returns whatever Ruby gave it on the command line, followed by the original file' do described_class.new("{").invalid_message.should include 'syntax error' end end end
cheat 2.0.9 (new formula) require "formula" class Cheat < Formula homepage "https://github.com/chrisallenlane/cheat" url "https://github.com/chrisallenlane/cheat/archive/2.0.9.tar.gz" sha1 "cf4a76badd8d0e58c9299037703ba4abbd2217df" head "https://github.com/chrisallenlane/cheat.git" depends_on :python if MacOS.version <= :snow_leopard resource "docopt" do url "https://pypi.python.org/packages/source/d/docopt/docopt-0.6.1.tar.gz" sha1 "3d0ad1cf495d2c801327042e02d67b4ee4b85cd4" end resource "Pygments" do url "https://pypi.python.org/packages/source/P/Pygments/Pygments-1.6.tar.gz" sha1 "53d831b83b1e4d4f16fec604057e70519f9f02fb" end def install ENV["PYTHONPATH"] = lib+"python2.7/site-packages" ENV.prepend_create_path "PYTHONPATH", libexec+"lib/python2.7/site-packages" install_args = [ "setup.py", "install", "--prefix=#{libexec}" ] %w[docopt Pygments].each do |r| resource(r).stage { system "python", *install_args } end system "python", "setup.py", "install", "--prefix=#{prefix}" bash_completion.install "cheat/autocompletion/cheat.bash" zsh_completion.install "cheat/autocompletion/cheat.zsh" => "_cheat" bin.env_script_all_files(libexec+"bin", :PYTHONPATH => ENV["PYTHONPATH"]) end test do system "#{bin}/cheat", "tar" end end
class FcitxRemoteForOsx < Formula desc "Handle input method in command-line" homepage "https://github.com/CodeFalling/fcitx-remote-for-osx" url "https://github.com/CodeFalling/fcitx-remote-for-osx/archive/0.3.0.tar.gz" sha256 "b4490a6a0db3c28ce3ddbe89dd038f5ab404744539adc5520eab1a1a39819de6" license "GPL-3.0" bottle do cellar :any_skip_relocation rebuild 1 sha256 "7e6f127565c5e0b1c842cf88ee440ac1e86d99a902c1f892008e146cfe86497a" => :catalina sha256 "63e285ce25dfefd7220ed07bb0c85f0b2f6e74997b0eb94117619cfdc04a5002" => :mojave sha256 "6c88cbd0c4ca46c2b0d809adc3e93c4be3178c014b55d377f95b7e0740cfab99" => :high_sierra sha256 "16efcc3f2a5ac6fd63bfea3d85286fac823cc7b21520d85f46d0b3c066668671" => :sierra end def install system "./build.py", "build", "general" bin.install "fcitx-remote-general" bin.install_symlink "fcitx-remote-general" => "fcitx-remote" end test do system "#{bin}/fcitx-remote", "-n" end end fcitx-remote-for-osx: fix urls class FcitxRemoteForOsx < Formula desc "Handle input method in command-line" homepage "https://github.com/xcodebuild/fcitx-remote-for-osx" url "https://github.com/xcodebuild/fcitx-remote-for-osx/archive/0.3.0.tar.gz" sha256 "b4490a6a0db3c28ce3ddbe89dd038f5ab404744539adc5520eab1a1a39819de6" license "GPL-3.0" bottle do cellar :any_skip_relocation rebuild 1 sha256 "7e6f127565c5e0b1c842cf88ee440ac1e86d99a902c1f892008e146cfe86497a" => :catalina sha256 "63e285ce25dfefd7220ed07bb0c85f0b2f6e74997b0eb94117619cfdc04a5002" => :mojave sha256 "6c88cbd0c4ca46c2b0d809adc3e93c4be3178c014b55d377f95b7e0740cfab99" => :high_sierra sha256 "16efcc3f2a5ac6fd63bfea3d85286fac823cc7b21520d85f46d0b3c066668671" => :sierra end def install system "./build.py", "build", "general" bin.install "fcitx-remote-general" bin.install_symlink "fcitx-remote-general" => "fcitx-remote" end test do system "#{bin}/fcitx-remote", "-n" end end
require 'spec_helper' module Scriptura describe ScriptureReference do describe '#within_same_book?' do it 'returns a true when the start verse is Gen 1:1 and end verse is Gen 50:26' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 50, 26)) expect(@scripture_reference.within_same_book?).to eq(true) end it 'returns a true when the start verse is Gen 3:1 and end verse is Gen 3:5' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 3, 1), ScriptureVerse.new(1, 3, 5)) expect(@scripture_reference.within_same_book?).to eq(true) end it 'returns a true when the start verse is Gen 1:1 and end verse is Exo 1:1' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(2, 1, 1)) expect(@scripture_reference.within_same_book?).to eq(false) end end describe '#within_same_chapter?' do it 'returns a true when the start verse is Gen 1:1 and end verse is Gen 1:12' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 1, 12)) expect(@scripture_reference.within_same_book?).to eq(true) end it 'returns a true when the start verse is Gen 3:1 and end verse is Gen 3:5' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 3, 1), ScriptureVerse.new(1, 3, 5)) expect(@scripture_reference.within_same_book?).to eq(true) end it 'returns a true when the start verse is Gen 1:1 and end verse is Exo 1:1' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(2, 1, 1)) expect(@scripture_reference.within_same_book?).to eq(false) end end describe '#spans_entire_book?' do it 'returns a true when the start verse is Gen 1:1 and end verse is Gen 50:26' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 50, 26)) expect(@scripture_reference.spans_entire_book?).to eq(true) end it 'returns a false when the start verse is Gen 1:2 and end verse is Gen 50:26' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 2), ScriptureVerse.new(1, 50, 26)) expect(@scripture_reference.spans_entire_book?).to eq(false) end it 'returns a false when the start verse is Gen 1:1 and end verse is Gen 50:25' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 50, 25)) expect(@scripture_reference.spans_entire_book?).to eq(false) end end describe '#spans_entire_chapter?' do it 'returns a true when the start verse is Gen 50:1 and end verse is Gen 50:26' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 50, 1), ScriptureVerse.new(1, 50, 26)) expect(@scripture_reference.spans_entire_chapter?).to eq(true) end it 'returns a false when the start verse is Gen 50:2 and end verse is Gen 50:26' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 50, 2), ScriptureVerse.new(1, 50, 26)) expect(@scripture_reference.spans_entire_chapter?).to eq(false) end it 'returns a false when the start verse is Gen 50:1 and end verse is Gen 50:25' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 50, 1), ScriptureVerse.new(1, 50, 25)) expect(@scripture_reference.spans_entire_chapter?).to eq(false) end it 'returns a false when the start verse is Gen 49:1 and end verse is Gen 50:25' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 49, 1), ScriptureVerse.new(1, 50, 25)) expect(@scripture_reference.spans_entire_chapter?).to eq(false) end it 'returns a false when the start verse is Gen 1:1 and end verse is Exo 1:22' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(2, 1, 22)) expect(@scripture_reference.spans_entire_chapter?).to eq(false) end end describe '#spans_single_verse?' do it 'returns a true when the start verse is Gen 1:1 and end verse is Gen 1:1' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 1, 1)) expect(@scripture_reference.spans_single_verse?).to eq(true) end it 'returns a false when the start verse is Gen 1:1 and end verse is Gen 1:2' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 1, 2)) expect(@scripture_reference.spans_single_verse?).to eq(false) end it 'returns a false when the start verse is Gen 1:1 and end verse is Gen 2:1' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 2, 1)) expect(@scripture_reference.spans_single_verse?).to eq(false) end it 'returns a false when the start verse is Gen 1:1 and end verse is Exo 1:2' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(2, 1, 2)) expect(@scripture_reference.spans_single_verse?).to eq(false) end end describe '#to_s' do it "returns 'Genesis' when it spans the entire book of Genesis" do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 50, 26)) expect(@scripture_reference.to_s).to eq('Genesis') end it "returns 'Gen 1' when it spans the entire chapter of Genesis 1" do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 1, 31)) expect(@scripture_reference.to_s).to eq('Genesis 1') end it "returns 'Genesis 1:1' when it only covers one verse" do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 1, 1)) expect(@scripture_reference.to_s).to eq('Genesis 1:1') end it "returns 'Genesis 1:1-2'" do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 1, 2)) expect(@scripture_reference.to_s).to eq('Genesis 1:1-2') end it "returns 'Genesis 1:1 - 3:2'" do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 3, 2)) expect(@scripture_reference.to_s).to eq('Genesis 1:1 - 3:2') end it "returns 'Genesis 1:1 - Exodus 3:2'" do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(2, 3, 2)) expect(@scripture_reference.to_s).to eq('Genesis 1:1 - Exodus 3:2') end end end end Tighten up some specs require 'spec_helper' module Scriptura describe ScriptureReference do describe '#within_same_book?' do it 'returns a true when the start verse is Gen 1:1 and end verse is Gen 50:26' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 50, 26)) expect(@scripture_reference.within_same_book?).to eq(true) end it 'returns a true when the start verse is Gen 3:1 and end verse is Gen 3:5' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 3, 1), ScriptureVerse.new(1, 3, 5)) expect(@scripture_reference.within_same_book?).to eq(true) end it 'returns a true when the start verse is Gen 1:1 and end verse is Exo 1:1' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(2, 1, 1)) expect(@scripture_reference.within_same_book?).to eq(false) end end describe '#within_same_chapter?' do it 'returns a true when the start verse is Gen 1:1 and end verse is Gen 1:12' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 1, 12)) expect(@scripture_reference.within_same_book?).to eq(true) end it 'returns a true when the start verse is Gen 3:1 and end verse is Gen 3:5' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 3, 1), ScriptureVerse.new(1, 3, 5)) expect(@scripture_reference.within_same_book?).to eq(true) end it 'returns a true when the start verse is Gen 1:1 and end verse is Exo 1:1' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(2, 1, 1)) expect(@scripture_reference.within_same_book?).to eq(false) end end describe '#spans_entire_book?' do it 'returns a true when the start verse is Gen 1:1 and end verse is Gen 50:26' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 50, 26)) expect(@scripture_reference.spans_entire_book?).to eq(true) end it 'returns false when the verse spans two books' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(2, 40, 38)) expect(@scripture_reference.spans_entire_book?).to eq(false) end it 'returns a false when the start verse is Gen 1:2 and end verse is Gen 50:26' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 2), ScriptureVerse.new(1, 50, 26)) expect(@scripture_reference.spans_entire_book?).to eq(false) end it 'returns a false when the start verse is Gen 1:1 and end verse is Gen 50:25' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 50, 25)) expect(@scripture_reference.spans_entire_book?).to eq(false) end end describe '#spans_entire_chapter?' do it 'returns a true when the start verse is Gen 50:1 and end verse is Gen 50:26' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 50, 1), ScriptureVerse.new(1, 50, 26)) expect(@scripture_reference.spans_entire_chapter?).to eq(true) end it 'returns false when the verse spans two chapters' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 2, 25)) expect(@scripture_reference.spans_entire_book?).to eq(false) end it 'returns a false when the start verse is Gen 50:2 and end verse is Gen 50:26' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 50, 2), ScriptureVerse.new(1, 50, 26)) expect(@scripture_reference.spans_entire_chapter?).to eq(false) end it 'returns a false when the start verse is Gen 50:1 and end verse is Gen 50:25' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 50, 1), ScriptureVerse.new(1, 50, 25)) expect(@scripture_reference.spans_entire_chapter?).to eq(false) end it 'returns a false when the start verse is Gen 49:1 and end verse is Gen 50:25' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 49, 1), ScriptureVerse.new(1, 50, 25)) expect(@scripture_reference.spans_entire_chapter?).to eq(false) end it 'returns a false when the start verse is Gen 1:1 and end verse is Exo 1:22' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(2, 1, 22)) expect(@scripture_reference.spans_entire_chapter?).to eq(false) end end describe '#spans_single_verse?' do it 'returns a true when the start verse is Gen 1:1 and end verse is Gen 1:1' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 1, 1)) expect(@scripture_reference.spans_single_verse?).to eq(true) end it 'returns a false when the start verse is Gen 1:1 and end verse is Gen 1:2' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 1, 2)) expect(@scripture_reference.spans_single_verse?).to eq(false) end it 'returns a false when the start verse is Gen 1:1 and end verse is Gen 2:1' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 2, 1)) expect(@scripture_reference.spans_single_verse?).to eq(false) end it 'returns a false when the start verse is Gen 1:1 and end verse is Exo 1:2' do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(2, 1, 2)) expect(@scripture_reference.spans_single_verse?).to eq(false) end end describe '#to_s' do it "returns 'Genesis' when it spans the entire book of Genesis" do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 50, 26)) expect(@scripture_reference.to_s).to eq('Genesis') end it "returns 'Gen 1' when it spans the entire chapter of Genesis 1" do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 1, 31)) expect(@scripture_reference.to_s).to eq('Genesis 1') end it "returns 'Genesis 1:1' when it only covers one verse" do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 1, 1)) expect(@scripture_reference.to_s).to eq('Genesis 1:1') end it "returns 'Genesis 1:1-2'" do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 1, 2)) expect(@scripture_reference.to_s).to eq('Genesis 1:1-2') end it "returns 'Genesis 1:1 - 3:2'" do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(1, 3, 2)) expect(@scripture_reference.to_s).to eq('Genesis 1:1 - 3:2') end it "returns 'Genesis 1:1 - Exodus 3:2'" do @scripture_reference = ScriptureReference.new(ScriptureVerse.new(1, 1, 1), ScriptureVerse.new(2, 3, 2)) expect(@scripture_reference.to_s).to eq('Genesis 1:1 - Exodus 3:2') end end end end
class Citus < Formula desc "PostgreSQL-based distributed RDBMS" homepage "https://www.citusdata.com" url "https://github.com/citusdata/citus/archive/v10.1.1.tar.gz" sha256 "2494184d6ac7a6b66bb2380daf4abc616c931d33737179dbaca64c9760542187" license "AGPL-3.0-only" head "https://github.com/citusdata/citus.git" bottle do sha256 cellar: :any, arm64_big_sur: "0e98ca621a36ea07b194558997512b701af14533b247962395bdcf3f09c7e675" sha256 cellar: :any, big_sur: "8bf36aead06ce6aebfffd6e8ec40269bf3b5eb5b40168abe7cf1f159f1a26ed2" sha256 cellar: :any, catalina: "5e0ab05900f8144950195e16362a8e7892038ca3c2082403b64bca5c1bf9e135" sha256 cellar: :any, mojave: "243bca46ceacb61d3738f1b17815cd64adc4035c23d060b130bb82876001eed6" end depends_on "lz4" depends_on "postgresql" depends_on "readline" depends_on "zstd" def install ENV["PG_CONFIG"] = Formula["postgresql"].opt_bin/"pg_config" system "./configure" # workaround for https://github.com/Homebrew/homebrew/issues/49948 system "make", "libpq=-L#{Formula["postgresql"].opt_lib} -lpq" # Use stage directory to prevent installing to pg_config-defined dirs, # which would not be within this package's Cellar. mkdir "stage" system "make", "install", "DESTDIR=#{buildpath}/stage" bin.install Dir["stage/**/bin/*"] lib.install Dir["stage/**/lib/*"] include.install Dir["stage/**/include/*"] (share/"postgresql/extension").install Dir["stage/**/share/postgresql/extension/*"] end end citus: update 10.1.1 bottle. class Citus < Formula desc "PostgreSQL-based distributed RDBMS" homepage "https://www.citusdata.com" url "https://github.com/citusdata/citus/archive/v10.1.1.tar.gz" sha256 "2494184d6ac7a6b66bb2380daf4abc616c931d33737179dbaca64c9760542187" license "AGPL-3.0-only" head "https://github.com/citusdata/citus.git" bottle do sha256 cellar: :any, arm64_big_sur: "55ca70957f451ac2e369b83d09f2e381a3d474a7963d0f4fa062f2b184d1563a" sha256 cellar: :any, big_sur: "ddb0ea0a2af6fa10982bec99201ad024338fa49d7151924ae4b303a18c01de1b" sha256 cellar: :any, catalina: "c2db86947e92a6bea0025aa43ffc22cba47fc5920beb4461efd38604e8d4e00f" sha256 cellar: :any, mojave: "4fe4630cbd313aea0a3f1c4c5dd7ce1d6c0a01fc4afb37a5453a2e9a35c174a0" end depends_on "lz4" depends_on "postgresql" depends_on "readline" depends_on "zstd" def install ENV["PG_CONFIG"] = Formula["postgresql"].opt_bin/"pg_config" system "./configure" # workaround for https://github.com/Homebrew/homebrew/issues/49948 system "make", "libpq=-L#{Formula["postgresql"].opt_lib} -lpq" # Use stage directory to prevent installing to pg_config-defined dirs, # which would not be within this package's Cellar. mkdir "stage" system "make", "install", "DESTDIR=#{buildpath}/stage" bin.install Dir["stage/**/bin/*"] lib.install Dir["stage/**/lib/*"] include.install Dir["stage/**/include/*"] (share/"postgresql/extension").install Dir["stage/**/share/postgresql/extension/*"] end end
require "language/node" class GenerateJsonSchema < Formula desc "Generate a JSON Schema from Sample JSON" homepage "https://github.com/Nijikokun/generate-schema" url "https://registry.npmjs.org/generate-schema/-/generate-schema-2.6.0.tgz" sha256 "1ddbf91aab2d649108308d1de7af782d9270a086919edb706f48d0216d51374a" license "MIT" head "https://github.com/Nijikokun/generate-schema.git" bottle do sha256 cellar: :any_skip_relocation, arm64_big_sur: "d19c2a0542dea7690c93f7a8e97a25c8979c7e489dca485dcfc35f6073d47beb" sha256 cellar: :any_skip_relocation, big_sur: "aee39ac19fd8f45785021bd737daf8f8ab15e7265b5e196485259d5a2c2cfede" sha256 cellar: :any_skip_relocation, catalina: "4d5a50f712bb6714564574d20cbd771e62ad1da6dcd58d9b7225822af0821d73" sha256 cellar: :any_skip_relocation, mojave: "e049d098796be43aa340eca884fa71ec90f4fbeda02031142f66752df005de97" sha256 cellar: :any_skip_relocation, high_sierra: "3461301c038b8bb6e15b8e183661976e95ea7b7e0659d57f0f21ea2c0eb4e67c" sha256 cellar: :any_skip_relocation, sierra: "a6ff075810774d44030a59a12032d302c64834d03c7aabeb32efb8dc86d276de" sha256 cellar: :any_skip_relocation, el_capitan: "5a5b34d8e233d9b75648c39f8edada5077c8f6c6466bd3358f3f661062ccbe83" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do (testpath/"test.json").write <<~EOS { "id": 2, "name": "An ice sculpture", "price": 12.50, "tags": ["cold", "ice"], "dimensions": { "length": 7.0, "width": 12.0, "height": 9.5 }, "warehouseLocation": { "latitude": -78.75, "longitude": 20.4 } } EOS assert_match "schema.org", shell_output("#{bin}/generate-schema test.json", 1) end end generate-json-schema: update 2.6.0 bottle. require "language/node" class GenerateJsonSchema < Formula desc "Generate a JSON Schema from Sample JSON" homepage "https://github.com/Nijikokun/generate-schema" url "https://registry.npmjs.org/generate-schema/-/generate-schema-2.6.0.tgz" sha256 "1ddbf91aab2d649108308d1de7af782d9270a086919edb706f48d0216d51374a" license "MIT" head "https://github.com/Nijikokun/generate-schema.git" bottle do sha256 cellar: :any_skip_relocation, arm64_big_sur: "d19c2a0542dea7690c93f7a8e97a25c8979c7e489dca485dcfc35f6073d47beb" sha256 cellar: :any_skip_relocation, big_sur: "aee39ac19fd8f45785021bd737daf8f8ab15e7265b5e196485259d5a2c2cfede" sha256 cellar: :any_skip_relocation, catalina: "4d5a50f712bb6714564574d20cbd771e62ad1da6dcd58d9b7225822af0821d73" sha256 cellar: :any_skip_relocation, mojave: "e049d098796be43aa340eca884fa71ec90f4fbeda02031142f66752df005de97" sha256 cellar: :any_skip_relocation, high_sierra: "3461301c038b8bb6e15b8e183661976e95ea7b7e0659d57f0f21ea2c0eb4e67c" sha256 cellar: :any_skip_relocation, sierra: "a6ff075810774d44030a59a12032d302c64834d03c7aabeb32efb8dc86d276de" sha256 cellar: :any_skip_relocation, el_capitan: "5a5b34d8e233d9b75648c39f8edada5077c8f6c6466bd3358f3f661062ccbe83" sha256 cellar: :any_skip_relocation, x86_64_linux: "12487b77022ffd791d6fbd7a50362a08f5209ba50ad1cc67c3558d63db1e9264" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do (testpath/"test.json").write <<~EOS { "id": 2, "name": "An ice sculpture", "price": 12.50, "tags": ["cold", "ice"], "dimensions": { "length": 7.0, "width": 12.0, "height": 9.5 }, "warehouseLocation": { "latitude": -78.75, "longitude": 20.4 } } EOS assert_match "schema.org", shell_output("#{bin}/generate-schema test.json", 1) end end
RSpec.shared_examples "acts_as_multilist" do |list_type| SpreeMarketing::CONFIG ||= { Rails.env => {} } context "#self.load_list" do let!(:list) { create(list_type.to_s.demodulize.underscore.to_sym, name: list_type.to_s.demodulize.underscore + "_" + entity_name) } it { expect(list_type.send :load_list, entity_key).to eq list } end context "#self.generator" do class GibbonServiceTest end let(:gibbon_service) { GibbonServiceTest.new } before do allow(GibbonService).to receive(:new).and_return(gibbon_service) allow(gibbon_service).to receive(:delete_lists).and_return(true) end context "if list already exists" do let(:emails) { ['test@example.com'] } let(:contacts_data) { [{ id: '12345678', email_address: emails.first, unique_email_id: 'test' }.with_indifferent_access] } let(:list) { create(list_type.to_s.demodulize.underscore.to_sym, name: list_type.to_s.demodulize.underscore + "_" + entity_name) } before do allow(list_type).to receive(:find_by).and_return(list) allow(gibbon_service).to receive(:update_list).and_return(contacts_data) end it { expect { list_type.send :generator }.to change { list_type.all.count }.by 0 } it { expect { list_type.send :generator }.to change { list_type.last.contacts.count }.by 1 } end context "if list doesn't exists" do let(:list_name) { 'test' } let(:list_data) { { id: '12345678', name: list_name }.with_indifferent_access } let(:emails) { ['test@example.com'] } let(:contacts_data) { [{ id: '12345678', email_address: emails.first, unique_email_id: 'test' }.with_indifferent_access] } before do allow(list_type).to receive(:find_by).and_return(nil) allow(gibbon_service).to receive(:generate_list).and_return(list_data) allow(gibbon_service).to receive(:subscribe_members).and_return(contacts_data) end it { expect { list_type.send :generator }.to change { list_type.all.count }.by 1 } end end end optimize factories and variables which were repeated RSpec.shared_examples "acts_as_multilist" do |list_type| SpreeMarketing::CONFIG ||= { Rails.env => {} } context "#self.load_list" do let!(:list) { create(list_type.to_s.demodulize.underscore.to_sym, name: list_type.to_s.demodulize.underscore + "_" + entity_name) } it { expect(list_type.send :load_list, entity_key).to eq list } end context "#self.generator" do class GibbonServiceTest end let(:gibbon_service) { GibbonServiceTest.new } let(:emails) { ['test@example.com'] } let(:contacts_data) { [{ id: '12345678', email_address: emails.first, unique_email_id: 'test' }.with_indifferent_access] } before do allow(GibbonService).to receive(:new).and_return(gibbon_service) allow(gibbon_service).to receive(:delete_lists).and_return(true) end context "if list already exists" do let(:list) { create(list_type.to_s.demodulize.underscore.to_sym, name: list_type.to_s.demodulize.underscore + "_" + entity_name) } before do allow(list_type).to receive(:find_by).and_return(list) allow(gibbon_service).to receive(:update_list).and_return(contacts_data) end it { expect { list_type.send :generator }.to change { list_type.all.count }.by 0 } it { expect { list_type.send :generator }.to change { list_type.last.contacts.count }.by 1 } end context "if list doesn't exists" do let(:list_name) { 'test' } let(:list_data) { { id: '12345678', name: list_name }.with_indifferent_access } before do allow(list_type).to receive(:find_by).and_return(nil) allow(gibbon_service).to receive(:generate_list).and_return(list_data) allow(gibbon_service).to receive(:subscribe_members).and_return(contacts_data) end it { expect { list_type.send :generator }.to change { list_type.all.count }.by 1 } end end end
class Clash < Formula desc "Rule-based tunnel in Go" homepage "https://github.com/Dreamacro/clash" url "https://github.com/Dreamacro/clash/archive/v1.6.5.tar.gz" sha256 "3b0af8e8c42f077f8cf4fe62c8f0da7b9170c85930680135834bac2f0e46cbce" license "GPL-3.0-only" bottle do sha256 cellar: :any_skip_relocation, arm64_big_sur: "8aef958297b8b5830956a7ddc5963612e9e2c740352edd38c25df56a5580cb0b" sha256 cellar: :any_skip_relocation, big_sur: "929218c5e3d4f4298354d4f472d2d23d74c1fa646c4314ef9dd59806c7a19d85" sha256 cellar: :any_skip_relocation, catalina: "48a4822d2b73eb0c26b40c556206768e0f622b19e419f496802118fabd6b98d3" sha256 cellar: :any_skip_relocation, mojave: "6f48c8bbb360d16ac86763d0114c2f03bece2bcd0295c2e8ce8344b806f873ba" end depends_on "go" => :build depends_on "shadowsocks-libev" => :test def install system "go", "build", *std_go_args end service do run opt_bin/"clash" keep_alive true error_log_path var/"log/clash.log" log_path var/"log/clash.log" end test do ss_port = free_port (testpath/"shadowsocks-libev.json").write <<~EOS { "server":"127.0.0.1", "server_port":#{ss_port}, "password":"test", "timeout":600, "method":"chacha20-ietf-poly1305" } EOS server = fork { exec "ss-server", "-c", testpath/"shadowsocks-libev.json" } clash_port = free_port (testpath/"config.yaml").write <<~EOS mixed-port: #{clash_port} mode: global proxies: - name: "server" type: ss server: 127.0.0.1 port: #{ss_port} password: "test" cipher: chacha20-ietf-poly1305 EOS system "#{bin}/clash", "-t", "-d", testpath # test config && download Country.mmdb client = fork { exec "#{bin}/clash", "-d", testpath } sleep 3 begin system "curl", "--socks5", "127.0.0.1:#{clash_port}", "github.com" ensure Process.kill 9, server Process.wait server Process.kill 9, client Process.wait client end end end clash: update 1.6.5 bottle. class Clash < Formula desc "Rule-based tunnel in Go" homepage "https://github.com/Dreamacro/clash" url "https://github.com/Dreamacro/clash/archive/v1.6.5.tar.gz" sha256 "3b0af8e8c42f077f8cf4fe62c8f0da7b9170c85930680135834bac2f0e46cbce" license "GPL-3.0-only" bottle do sha256 cellar: :any_skip_relocation, arm64_big_sur: "5804c6175628e8360fc20e187d1283fd9915448968b5bb29d3f2910614df22d9" sha256 cellar: :any_skip_relocation, big_sur: "f07f34ebd6750c2df7120cda275b02a12315d27e8a6ac2cdd5af81fe507a410a" sha256 cellar: :any_skip_relocation, catalina: "3bbce471b72391bce052279f861d1b8ea642b34e84c44ee8f6c9482b7ccf7add" sha256 cellar: :any_skip_relocation, mojave: "0f1e0e2c3eab1bad6cf974e113a5c0114d6a38d1189211fb28cb64ca45652e6f" end depends_on "go" => :build depends_on "shadowsocks-libev" => :test def install system "go", "build", *std_go_args end service do run opt_bin/"clash" keep_alive true error_log_path var/"log/clash.log" log_path var/"log/clash.log" end test do ss_port = free_port (testpath/"shadowsocks-libev.json").write <<~EOS { "server":"127.0.0.1", "server_port":#{ss_port}, "password":"test", "timeout":600, "method":"chacha20-ietf-poly1305" } EOS server = fork { exec "ss-server", "-c", testpath/"shadowsocks-libev.json" } clash_port = free_port (testpath/"config.yaml").write <<~EOS mixed-port: #{clash_port} mode: global proxies: - name: "server" type: ss server: 127.0.0.1 port: #{ss_port} password: "test" cipher: chacha20-ietf-poly1305 EOS system "#{bin}/clash", "-t", "-d", testpath # test config && download Country.mmdb client = fork { exec "#{bin}/clash", "-d", testpath } sleep 3 begin system "curl", "--socks5", "127.0.0.1:#{clash_port}", "github.com" ensure Process.kill 9, server Process.wait server Process.kill 9, client Process.wait client end end end
class GstEditingServices < Formula desc "GStreamer Editing Services" homepage "https://gstreamer.freedesktop.org/modules/gst-editing-services.html" url "https://gstreamer.freedesktop.org/src/gst-editing-services/gstreamer-editing-services-1.14.1.tar.xz" sha256 "7e7c0962f39388cdf81b5e0d9f768eb15e30f58b346fd79f1ea778979eae113e" bottle do sha256 "4e2e03a93ce8016174b938050675bde833a48ed73008d8464c8b50de9bd790ad" => :high_sierra sha256 "121dfe755996c0aeb88a4c239be99ea1c831e8ab655886418721b4f47588401c" => :sierra sha256 "aab3f5d4909908af856a96eafd11087ae775d06b416e6deaf4777d6f738a72d5" => :el_capitan end depends_on "pkg-config" => :build depends_on "gstreamer" depends_on "gst-plugins-base" def install system "./configure", "--prefix=#{prefix}", "--disable-gtk-doc", "--disable-docbook" system "make" system "make", "install" end test do system "#{bin}/ges-launch-1.0", "--ges-version" end end gst-editing-services: update 1.14.1 bottle. class GstEditingServices < Formula desc "GStreamer Editing Services" homepage "https://gstreamer.freedesktop.org/modules/gst-editing-services.html" url "https://gstreamer.freedesktop.org/src/gst-editing-services/gstreamer-editing-services-1.14.1.tar.xz" sha256 "7e7c0962f39388cdf81b5e0d9f768eb15e30f58b346fd79f1ea778979eae113e" bottle do cellar :any sha256 "dddd6a905cf531080a04e7f8af75c8dfa9406387aa29a086dee47765460be518" => :high_sierra sha256 "52be6d8262363557d5148a2b780521bede1da5a3c08e7a3b1d8c88534af65486" => :sierra sha256 "071cfb5213cf5b6ed166e79b59c9dfe12ec1c9270e152c79f9cd6755e196b29e" => :el_capitan end depends_on "pkg-config" => :build depends_on "gstreamer" depends_on "gst-plugins-base" def install system "./configure", "--prefix=#{prefix}", "--disable-gtk-doc", "--disable-docbook" system "make" system "make", "install" end test do system "#{bin}/ges-launch-1.0", "--ges-version" end end
# encoding: utf-8 require 'helper' describe SimpleOAuth::Header do describe ".default_options" do let(:default_options){ SimpleOAuth::Header.default_options } it "is different every time" do expect(SimpleOAuth::Header.default_options).not_to eq default_options end it "is used for new headers" do SimpleOAuth::Header.stub(:default_options => default_options) header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}) expect(header.options).to eq default_options end it "includes a signature method and an OAuth version" do expect(default_options[:signature_method]).not_to be_nil expect(default_options[:version]).not_to be_nil end end describe ".escape" do it "escapes (most) non-word characters" do [' ', '!', '@', '#', '$', '%', '^', '&'].each do |character| escaped = SimpleOAuth::Header.escape(character) expect(escaped).not_to eq character expect(escaped).to eq uri_parser.escape(character, /.*/) end end it "does not escape - . or ~" do ['-', '.', '~'].each do |character| escaped = SimpleOAuth::Header.escape(character) expect(escaped).to eq character end end def self.test_special_characters it "escapes non-ASCII characters" do expect(SimpleOAuth::Header.escape('é')).to eq '%C3%A9' end it "escapes multibyte characters" do expect(SimpleOAuth::Header.escape('あ')).to eq '%E3%81%82' end end if RUBY_VERSION >= '1.9' test_special_characters else %w(n N e E s S u U).each do |kcode| describe %(when $KCODE = "#{kcode}") do original_kcode = $KCODE begin $KCODE = kcode test_special_characters ensure $KCODE = original_kcode end end end end end describe ".unescape" do pending end describe ".parse" do let(:header){ SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}) } let(:parsed_options){ SimpleOAuth::Header.parse(header) } it "returns a hash" do expect(parsed_options).to be_a(Hash) end it "includes the options used to build the header" do expect(parsed_options.reject{|k,_| k == :signature }).to eq header.options end it "includes a signature" do expect(header.options).not_to have_key(:signature) expect(parsed_options).to have_key(:signature) expect(parsed_options[:signature]).not_to be_nil end it "handles optional 'linear white space'" do parsed_header_with_spaces = SimpleOAuth::Header.parse 'OAuth oauth_consumer_key="abcd", oauth_nonce="oLKtec51GQy", oauth_signature="efgh%26mnop", oauth_signature_method="PLAINTEXT", oauth_timestamp="1286977095", oauth_token="ijkl", oauth_version="1.0"' expect(parsed_header_with_spaces).to be_a_kind_of(Hash) expect(parsed_header_with_spaces.keys.size).to eq 7 parsed_header_with_tabs = SimpleOAuth::Header.parse 'OAuth oauth_consumer_key="abcd", oauth_nonce="oLKtec51GQy", oauth_signature="efgh%26mnop", oauth_signature_method="PLAINTEXT", oauth_timestamp="1286977095", oauth_token="ijkl", oauth_version="1.0"' expect(parsed_header_with_tabs).to be_a_kind_of(Hash) expect(parsed_header_with_tabs.keys.size).to eq 7 parsed_header_with_spaces_and_tabs = SimpleOAuth::Header.parse 'OAuth oauth_consumer_key="abcd", oauth_nonce="oLKtec51GQy", oauth_signature="efgh%26mnop", oauth_signature_method="PLAINTEXT", oauth_timestamp="1286977095", oauth_token="ijkl", oauth_version="1.0"' expect(parsed_header_with_spaces_and_tabs).to be_a_kind_of(Hash) expect(parsed_header_with_spaces_and_tabs.keys.size).to eq 7 parsed_header_without_spaces = SimpleOAuth::Header.parse 'OAuth oauth_consumer_key="abcd",oauth_nonce="oLKtec51GQy",oauth_signature="efgh%26mnop",oauth_signature_method="PLAINTEXT",oauth_timestamp="1286977095",oauth_token="ijkl",oauth_version="1.0"' expect(parsed_header_without_spaces).to be_a_kind_of(Hash) expect(parsed_header_without_spaces.keys.size).to eq 7 end end describe "#initialize" do let(:header){ SimpleOAuth::Header.new(:get, 'HTTPS://api.TWITTER.com:443/1/statuses/friendships.json?foo=bar#anchor', {}) } it "stringifies and uppercases the request method" do expect(header.method).to eq 'GET' end it "downcases the scheme and authority" do expect(header.url).to match %r(^https://api\.twitter\.com/) end it "ignores the query and fragment" do expect(header.url).to match %r(/1/statuses/friendships\.json$) end end describe "#valid?" do context "using the HMAC-SHA1 signature method" do it "requires consumer and token secrets" do secrets = {:consumer_secret => 'CONSUMER_SECRET', :token_secret => 'TOKEN_SECRET'} header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, secrets) parsed_header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, header) expect(parsed_header).not_to be_valid expect(parsed_header).to be_valid(secrets) end end context "using the RSA-SHA1 signature method" do it "requires an identical private key" do secrets = {:consumer_secret => rsa_private_key} header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, secrets.merge(:signature_method => 'RSA-SHA1')) parsed_header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, header) expect{ parsed_header.valid? }.to raise_error(TypeError) expect(parsed_header).to be_valid(secrets) end end context "using the RSA-SHA1 signature method" do it "requires consumer and token secrets" do secrets = {:consumer_secret => 'CONSUMER_SECRET', :token_secret => 'TOKEN_SECRET'} header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, secrets.merge(:signature_method => 'PLAINTEXT')) parsed_header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, header) expect(parsed_header).not_to be_valid expect(parsed_header).to be_valid(secrets) end end end describe "#normalized_attributes" do let(:header){ SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}) } let(:normalized_attributes){ header.send(:normalized_attributes) } it "returns a sorted-key, quoted-value and comma-separated list" do header.stub(:signed_attributes => {:d => 1, :c => 2, :b => 3, :a => 4}) expect(normalized_attributes).to eq 'a="4", b="3", c="2", d="1"' end it "URI encodes its values" do header.stub(:signed_attributes => {1 => '!', 2 => '@', 3 => '#', 4 => '$'}) expect(normalized_attributes).to eq '1="%21", 2="%40", 3="%23", 4="%24"' end end describe "#signed_attributes" do it "includes the OAuth signature" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}) expect(header.send(:signed_attributes)).to have_key(:oauth_signature) end end describe "#attributes" do let(:header) do options = {} SimpleOAuth::Header::ATTRIBUTE_KEYS.each{|k| options[k] = k.to_s.upcase } options[:other] = 'OTHER' SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}, options) end let(:attributes){ header.send(:attributes) } it "prepends keys with 'oauth_'" do expect(attributes.keys).to be_all{|k| k.to_s =~ /^oauth_/ } end it "excludes keys not included in the list of valid attributes" do expect(attributes.keys).to be_all{|k| k.is_a?(Symbol) } expect(attributes).not_to have_key(:oauth_other) end it "preserves values for valid keys" do expect(attributes.size).to eq SimpleOAuth::Header::ATTRIBUTE_KEYS.size expect(attributes).to be_all{|k,v| k.to_s == "oauth_#{v.downcase}" } end end describe "#signature" do context "calls the appropriate signature method" do specify "when using HMAC-SHA1" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, :signature_method => 'HMAC-SHA1') expect(header).to receive(:hmac_sha1_signature).once.and_return('HMAC_SHA1_SIGNATURE') expect(header.send(:signature)).to eq 'HMAC_SHA1_SIGNATURE' end specify "when using RSA-SHA1" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, :signature_method => 'RSA-SHA1') expect(header).to receive(:rsa_sha1_signature).once.and_return('RSA_SHA1_SIGNATURE') expect(header.send(:signature)).to eq 'RSA_SHA1_SIGNATURE' end specify "when using PLAINTEXT" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, :signature_method => 'PLAINTEXT') expect(header).to receive(:plaintext_signature).once.and_return('PLAINTEXT_SIGNATURE') expect(header.send(:signature)).to eq 'PLAINTEXT_SIGNATURE' end end end describe "#hmac_sha1_signature" do it "reproduces a successful Twitter GET" do options = { :consumer_key => '8karQBlMg6gFOwcf8kcoYw', :consumer_secret => '3d0vcHyUiiqADpWxolW8nlDIpSWMlyK7YNgc5Qna2M', :nonce => '547fed103e122eecf84c080843eedfe6', :signature_method => 'HMAC-SHA1', :timestamp => '1286830180', :token => '201425800-Sv4sTcgoffmHGkTCue0JnURT8vrm4DiFAkeFNDkh', :token_secret => 'T5qa1tF57tfDzKmpM89DHsNuhgOY4NT6DlNLsTFcuQ' } header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, options) expect(header.to_s).to eq 'OAuth oauth_consumer_key="8karQBlMg6gFOwcf8kcoYw", oauth_nonce="547fed103e122eecf84c080843eedfe6", oauth_signature="i9CT6ahDRAlfGX3hKYf78QzXsaw%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1286830180", oauth_token="201425800-Sv4sTcgoffmHGkTCue0JnURT8vrm4DiFAkeFNDkh", oauth_version="1.0"' end it "reproduces a successful Twitter POST" do options = { :consumer_key => '8karQBlMg6gFOwcf8kcoYw', :consumer_secret => '3d0vcHyUiiqADpWxolW8nlDIpSWMlyK7YNgc5Qna2M', :nonce => 'b40a3e0f18590ecdcc0e273f7d7c82f8', :signature_method => 'HMAC-SHA1', :timestamp => '1286830181', :token => '201425800-Sv4sTcgoffmHGkTCue0JnURT8vrm4DiFAkeFNDkh', :token_secret => 'T5qa1tF57tfDzKmpM89DHsNuhgOY4NT6DlNLsTFcuQ' } header = SimpleOAuth::Header.new(:post, 'https://api.twitter.com/1/statuses/update.json', {:status => 'hi, again'}, options) expect(header.to_s).to eq 'OAuth oauth_consumer_key="8karQBlMg6gFOwcf8kcoYw", oauth_nonce="b40a3e0f18590ecdcc0e273f7d7c82f8", oauth_signature="mPqSFKejrWWk3ZT9bTQjhO5b2xI%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1286830181", oauth_token="201425800-Sv4sTcgoffmHGkTCue0JnURT8vrm4DiFAkeFNDkh", oauth_version="1.0"' end end describe "#secret" do let(:header){ SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}) } let(:secret){ header.send(:secret) } it "combines the consumer and token secrets with an ampersand" do header.stub(:options => {:consumer_secret => 'CONSUMER_SECRET', :token_secret => 'TOKEN_SECRET'}) expect(secret).to eq 'CONSUMER_SECRET&TOKEN_SECRET' end it "URI encodes each secret value before combination" do header.stub(:options => {:consumer_secret => 'CONSUM#R_SECRET', :token_secret => 'TOKEN_S#CRET'}) expect(secret).to eq 'CONSUM%23R_SECRET&TOKEN_S%23CRET' end end describe "#signature_base" do let(:header){ SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}) } let(:signature_base){ header.send(:signature_base) } it "combines the request method, URL and normalized parameters using ampersands" do header.stub(:method => 'METHOD', :url => 'URL', :normalized_params => 'NORMALIZED_PARAMS') expect(signature_base).to eq 'METHOD&URL&NORMALIZED_PARAMS' end it "URI encodes each value before combination" do header.stub(:method => 'ME#HOD', :url => 'U#L', :normalized_params => 'NORMAL#ZED_PARAMS') expect(signature_base).to eq 'ME%23HOD&U%23L&NORMAL%23ZED_PARAMS' end end describe "#normalized_params" do let(:header) do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}) header.stub(:signature_params => [['A', '4'], ['B', '3'], ['B', '2'], ['C', '1'], ['D[]', '0 ']]) header end let(:signature_params){ header.send(:signature_params) } let(:normalized_params){ header.send(:normalized_params) } it "joins key/value pairs with equal signs and ampersands" do expect(normalized_params).to be_a(String) parts = normalized_params.split('&') expect(parts.size).to eq signature_params.size pairs = parts.map{|p| p.split('=') } expect(pairs).to be_all{|p| p.size == 2 } end end describe "#signature_params" do let(:header){ SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}) } let(:signature_params){ header.send(:signature_params) } it "combines OAuth header attributes, body parameters and URL parameters into an flattened array of key/value pairs" do header.stub( :attributes => {:attribute => 'ATTRIBUTE'}, :params => {'param' => 'PARAM'}, :url_params => [['url_param', '1'], ['url_param', '2']] ) expect(signature_params).to eq [ [:attribute, 'ATTRIBUTE'], ['param', 'PARAM'], ['url_param', '1'], ['url_param', '2'] ] end end describe "#url_params" do it "returns an empty array when the URL has no query parameters" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}) expect(header.send(:url_params)).to eq [] end it "returns an array of key/value pairs for each query parameter" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json?test=TEST', {}) expect(header.send(:url_params)).to eq [['test', 'TEST']] end it "sorts values for repeated keys" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json?test=3&test=1&test=2', {}) expect(header.send(:url_params)).to eq [['test', '1'], ['test', '2'], ['test', '3']] end end describe "#rsa_sha1_signature" do it "reproduces a successful OAuth example GET" do options = { :consumer_key => 'dpf43f3p2l4k3l03', :consumer_secret => rsa_private_key, :nonce => '13917289812797014437', :signature_method => 'RSA-SHA1', :timestamp => '1196666512' } header = SimpleOAuth::Header.new(:get, 'http://photos.example.net/photos', {:file => 'vacaction.jpg', :size => 'original'}, options) expect(header.to_s).to eq 'OAuth oauth_consumer_key="dpf43f3p2l4k3l03", oauth_nonce="13917289812797014437", oauth_signature="jvTp%2FwX1TYtByB1m%2BPbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2%2F9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW%2F%2Fe%2BRinhejgCuzoH26dyF8iY2ZZ%2F5D1ilgeijhV%2FvBka5twt399mXwaYdCwFYE%3D", oauth_signature_method="RSA-SHA1", oauth_timestamp="1196666512", oauth_version="1.0"' end end describe "#private_key" do pending end describe "#plaintext_signature" do it "reproduces a successful OAuth example GET" do options = { :consumer_key => 'abcd', :consumer_secret => 'efgh', :nonce => 'oLKtec51GQy', :signature_method => 'PLAINTEXT', :timestamp => '1286977095', :token => 'ijkl', :token_secret => 'mnop' } header = SimpleOAuth::Header.new(:get, 'http://host.net/resource?name=value', {:name => 'value'}, options) expect(header.to_s).to eq 'OAuth oauth_consumer_key="abcd", oauth_nonce="oLKtec51GQy", oauth_signature="efgh%26mnop", oauth_signature_method="PLAINTEXT", oauth_timestamp="1286977095", oauth_token="ijkl", oauth_version="1.0"' end end end Replace stub with allow...to receive # encoding: utf-8 require 'helper' describe SimpleOAuth::Header do describe ".default_options" do let(:default_options){ SimpleOAuth::Header.default_options } it "is different every time" do expect(SimpleOAuth::Header.default_options).not_to eq default_options end it "is used for new headers" do allow(SimpleOAuth::Header).to receive(:default_options).and_return(default_options) header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}) expect(header.options).to eq default_options end it "includes a signature method and an OAuth version" do expect(default_options[:signature_method]).not_to be_nil expect(default_options[:version]).not_to be_nil end end describe ".escape" do it "escapes (most) non-word characters" do [' ', '!', '@', '#', '$', '%', '^', '&'].each do |character| escaped = SimpleOAuth::Header.escape(character) expect(escaped).not_to eq character expect(escaped).to eq uri_parser.escape(character, /.*/) end end it "does not escape - . or ~" do ['-', '.', '~'].each do |character| escaped = SimpleOAuth::Header.escape(character) expect(escaped).to eq character end end def self.test_special_characters it "escapes non-ASCII characters" do expect(SimpleOAuth::Header.escape('é')).to eq '%C3%A9' end it "escapes multibyte characters" do expect(SimpleOAuth::Header.escape('あ')).to eq '%E3%81%82' end end if RUBY_VERSION >= '1.9' test_special_characters else %w(n N e E s S u U).each do |kcode| describe %(when $KCODE = "#{kcode}") do original_kcode = $KCODE begin $KCODE = kcode test_special_characters ensure $KCODE = original_kcode end end end end end describe ".unescape" do pending end describe ".parse" do let(:header){ SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}) } let(:parsed_options){ SimpleOAuth::Header.parse(header) } it "returns a hash" do expect(parsed_options).to be_a(Hash) end it "includes the options used to build the header" do expect(parsed_options.reject{|k,_| k == :signature }).to eq header.options end it "includes a signature" do expect(header.options).not_to have_key(:signature) expect(parsed_options).to have_key(:signature) expect(parsed_options[:signature]).not_to be_nil end it "handles optional 'linear white space'" do parsed_header_with_spaces = SimpleOAuth::Header.parse 'OAuth oauth_consumer_key="abcd", oauth_nonce="oLKtec51GQy", oauth_signature="efgh%26mnop", oauth_signature_method="PLAINTEXT", oauth_timestamp="1286977095", oauth_token="ijkl", oauth_version="1.0"' expect(parsed_header_with_spaces).to be_a_kind_of(Hash) expect(parsed_header_with_spaces.keys.size).to eq 7 parsed_header_with_tabs = SimpleOAuth::Header.parse 'OAuth oauth_consumer_key="abcd", oauth_nonce="oLKtec51GQy", oauth_signature="efgh%26mnop", oauth_signature_method="PLAINTEXT", oauth_timestamp="1286977095", oauth_token="ijkl", oauth_version="1.0"' expect(parsed_header_with_tabs).to be_a_kind_of(Hash) expect(parsed_header_with_tabs.keys.size).to eq 7 parsed_header_with_spaces_and_tabs = SimpleOAuth::Header.parse 'OAuth oauth_consumer_key="abcd", oauth_nonce="oLKtec51GQy", oauth_signature="efgh%26mnop", oauth_signature_method="PLAINTEXT", oauth_timestamp="1286977095", oauth_token="ijkl", oauth_version="1.0"' expect(parsed_header_with_spaces_and_tabs).to be_a_kind_of(Hash) expect(parsed_header_with_spaces_and_tabs.keys.size).to eq 7 parsed_header_without_spaces = SimpleOAuth::Header.parse 'OAuth oauth_consumer_key="abcd",oauth_nonce="oLKtec51GQy",oauth_signature="efgh%26mnop",oauth_signature_method="PLAINTEXT",oauth_timestamp="1286977095",oauth_token="ijkl",oauth_version="1.0"' expect(parsed_header_without_spaces).to be_a_kind_of(Hash) expect(parsed_header_without_spaces.keys.size).to eq 7 end end describe "#initialize" do let(:header){ SimpleOAuth::Header.new(:get, 'HTTPS://api.TWITTER.com:443/1/statuses/friendships.json?foo=bar#anchor', {}) } it "stringifies and uppercases the request method" do expect(header.method).to eq 'GET' end it "downcases the scheme and authority" do expect(header.url).to match %r(^https://api\.twitter\.com/) end it "ignores the query and fragment" do expect(header.url).to match %r(/1/statuses/friendships\.json$) end end describe "#valid?" do context "using the HMAC-SHA1 signature method" do it "requires consumer and token secrets" do secrets = {:consumer_secret => 'CONSUMER_SECRET', :token_secret => 'TOKEN_SECRET'} header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, secrets) parsed_header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, header) expect(parsed_header).not_to be_valid expect(parsed_header).to be_valid(secrets) end end context "using the RSA-SHA1 signature method" do it "requires an identical private key" do secrets = {:consumer_secret => rsa_private_key} header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, secrets.merge(:signature_method => 'RSA-SHA1')) parsed_header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, header) expect{ parsed_header.valid? }.to raise_error(TypeError) expect(parsed_header).to be_valid(secrets) end end context "using the RSA-SHA1 signature method" do it "requires consumer and token secrets" do secrets = {:consumer_secret => 'CONSUMER_SECRET', :token_secret => 'TOKEN_SECRET'} header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, secrets.merge(:signature_method => 'PLAINTEXT')) parsed_header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, header) expect(parsed_header).not_to be_valid expect(parsed_header).to be_valid(secrets) end end end describe "#normalized_attributes" do let(:header){ SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}) } let(:normalized_attributes){ header.send(:normalized_attributes) } it "returns a sorted-key, quoted-value and comma-separated list" do allow(header).to receive(:signed_attributes).and_return({:d => 1, :c => 2, :b => 3, :a => 4}) expect(normalized_attributes).to eq 'a="4", b="3", c="2", d="1"' end it "URI encodes its values" do allow(header).to receive(:signed_attributes).and_return({1 => '!', 2 => '@', 3 => '#', 4 => '$'}) expect(normalized_attributes).to eq '1="%21", 2="%40", 3="%23", 4="%24"' end end describe "#signed_attributes" do it "includes the OAuth signature" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}) expect(header.send(:signed_attributes)).to have_key(:oauth_signature) end end describe "#attributes" do let(:header) do options = {} SimpleOAuth::Header::ATTRIBUTE_KEYS.each{|k| options[k] = k.to_s.upcase } options[:other] = 'OTHER' SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}, options) end let(:attributes){ header.send(:attributes) } it "prepends keys with 'oauth_'" do expect(attributes.keys).to be_all{|k| k.to_s =~ /^oauth_/ } end it "excludes keys not included in the list of valid attributes" do expect(attributes.keys).to be_all{|k| k.is_a?(Symbol) } expect(attributes).not_to have_key(:oauth_other) end it "preserves values for valid keys" do expect(attributes.size).to eq SimpleOAuth::Header::ATTRIBUTE_KEYS.size expect(attributes).to be_all{|k,v| k.to_s == "oauth_#{v.downcase}" } end end describe "#signature" do context "calls the appropriate signature method" do specify "when using HMAC-SHA1" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, :signature_method => 'HMAC-SHA1') expect(header).to receive(:hmac_sha1_signature).once.and_return('HMAC_SHA1_SIGNATURE') expect(header.send(:signature)).to eq 'HMAC_SHA1_SIGNATURE' end specify "when using RSA-SHA1" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, :signature_method => 'RSA-SHA1') expect(header).to receive(:rsa_sha1_signature).once.and_return('RSA_SHA1_SIGNATURE') expect(header.send(:signature)).to eq 'RSA_SHA1_SIGNATURE' end specify "when using PLAINTEXT" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, :signature_method => 'PLAINTEXT') expect(header).to receive(:plaintext_signature).once.and_return('PLAINTEXT_SIGNATURE') expect(header.send(:signature)).to eq 'PLAINTEXT_SIGNATURE' end end end describe "#hmac_sha1_signature" do it "reproduces a successful Twitter GET" do options = { :consumer_key => '8karQBlMg6gFOwcf8kcoYw', :consumer_secret => '3d0vcHyUiiqADpWxolW8nlDIpSWMlyK7YNgc5Qna2M', :nonce => '547fed103e122eecf84c080843eedfe6', :signature_method => 'HMAC-SHA1', :timestamp => '1286830180', :token => '201425800-Sv4sTcgoffmHGkTCue0JnURT8vrm4DiFAkeFNDkh', :token_secret => 'T5qa1tF57tfDzKmpM89DHsNuhgOY4NT6DlNLsTFcuQ' } header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friends.json', {}, options) expect(header.to_s).to eq 'OAuth oauth_consumer_key="8karQBlMg6gFOwcf8kcoYw", oauth_nonce="547fed103e122eecf84c080843eedfe6", oauth_signature="i9CT6ahDRAlfGX3hKYf78QzXsaw%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1286830180", oauth_token="201425800-Sv4sTcgoffmHGkTCue0JnURT8vrm4DiFAkeFNDkh", oauth_version="1.0"' end it "reproduces a successful Twitter POST" do options = { :consumer_key => '8karQBlMg6gFOwcf8kcoYw', :consumer_secret => '3d0vcHyUiiqADpWxolW8nlDIpSWMlyK7YNgc5Qna2M', :nonce => 'b40a3e0f18590ecdcc0e273f7d7c82f8', :signature_method => 'HMAC-SHA1', :timestamp => '1286830181', :token => '201425800-Sv4sTcgoffmHGkTCue0JnURT8vrm4DiFAkeFNDkh', :token_secret => 'T5qa1tF57tfDzKmpM89DHsNuhgOY4NT6DlNLsTFcuQ' } header = SimpleOAuth::Header.new(:post, 'https://api.twitter.com/1/statuses/update.json', {:status => 'hi, again'}, options) expect(header.to_s).to eq 'OAuth oauth_consumer_key="8karQBlMg6gFOwcf8kcoYw", oauth_nonce="b40a3e0f18590ecdcc0e273f7d7c82f8", oauth_signature="mPqSFKejrWWk3ZT9bTQjhO5b2xI%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1286830181", oauth_token="201425800-Sv4sTcgoffmHGkTCue0JnURT8vrm4DiFAkeFNDkh", oauth_version="1.0"' end end describe "#secret" do let(:header){ SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}) } let(:secret){ header.send(:secret) } it "combines the consumer and token secrets with an ampersand" do allow(header).to receive(:options).and_return({:consumer_secret => 'CONSUMER_SECRET', :token_secret => 'TOKEN_SECRET'}) expect(secret).to eq 'CONSUMER_SECRET&TOKEN_SECRET' end it "URI encodes each secret value before combination" do allow(header).to receive(:options).and_return({:consumer_secret => 'CONSUM#R_SECRET', :token_secret => 'TOKEN_S#CRET'}) expect(secret).to eq 'CONSUM%23R_SECRET&TOKEN_S%23CRET' end end describe "#signature_base" do let(:header){ SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}) } let(:signature_base){ header.send(:signature_base) } it "combines the request method, URL and normalized parameters using ampersands" do allow(header).to receive(:method).and_return('METHOD') allow(header).to receive(:url).and_return('URL') allow(header).to receive(:normalized_params).and_return('NORMALIZED_PARAMS') expect(signature_base).to eq 'METHOD&URL&NORMALIZED_PARAMS' end it "URI encodes each value before combination" do allow(header).to receive(:method).and_return('ME#HOD') allow(header).to receive(:url).and_return('U#L') allow(header).to receive(:normalized_params).and_return('NORMAL#ZED_PARAMS') expect(signature_base).to eq 'ME%23HOD&U%23L&NORMAL%23ZED_PARAMS' end end describe "#normalized_params" do let(:header) do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}) allow(header).to receive(:signature_params).and_return([['A', '4'], ['B', '3'], ['B', '2'], ['C', '1'], ['D[]', '0 ']]) header end let(:signature_params){ header.send(:signature_params) } let(:normalized_params){ header.send(:normalized_params) } it "joins key/value pairs with equal signs and ampersands" do expect(normalized_params).to be_a(String) parts = normalized_params.split('&') expect(parts.size).to eq signature_params.size pairs = parts.map{|p| p.split('=') } expect(pairs).to be_all{|p| p.size == 2 } end end describe "#signature_params" do let(:header){ SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}) } let(:signature_params){ header.send(:signature_params) } it "combines OAuth header attributes, body parameters and URL parameters into an flattened array of key/value pairs" do allow(header).to receive(:attributes).and_return({:attribute => 'ATTRIBUTE'}) allow(header).to receive(:params).and_return({'param' => 'PARAM'}) allow(header).to receive(:url_params).and_return([['url_param', '1'], ['url_param', '2']]) expect(signature_params).to eq [ [:attribute, 'ATTRIBUTE'], ['param', 'PARAM'], ['url_param', '1'], ['url_param', '2'] ] end end describe "#url_params" do it "returns an empty array when the URL has no query parameters" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json', {}) expect(header.send(:url_params)).to eq [] end it "returns an array of key/value pairs for each query parameter" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json?test=TEST', {}) expect(header.send(:url_params)).to eq [['test', 'TEST']] end it "sorts values for repeated keys" do header = SimpleOAuth::Header.new(:get, 'https://api.twitter.com/1/statuses/friendships.json?test=3&test=1&test=2', {}) expect(header.send(:url_params)).to eq [['test', '1'], ['test', '2'], ['test', '3']] end end describe "#rsa_sha1_signature" do it "reproduces a successful OAuth example GET" do options = { :consumer_key => 'dpf43f3p2l4k3l03', :consumer_secret => rsa_private_key, :nonce => '13917289812797014437', :signature_method => 'RSA-SHA1', :timestamp => '1196666512' } header = SimpleOAuth::Header.new(:get, 'http://photos.example.net/photos', {:file => 'vacaction.jpg', :size => 'original'}, options) expect(header.to_s).to eq 'OAuth oauth_consumer_key="dpf43f3p2l4k3l03", oauth_nonce="13917289812797014437", oauth_signature="jvTp%2FwX1TYtByB1m%2BPbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2%2F9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW%2F%2Fe%2BRinhejgCuzoH26dyF8iY2ZZ%2F5D1ilgeijhV%2FvBka5twt399mXwaYdCwFYE%3D", oauth_signature_method="RSA-SHA1", oauth_timestamp="1196666512", oauth_version="1.0"' end end describe "#private_key" do pending end describe "#plaintext_signature" do it "reproduces a successful OAuth example GET" do options = { :consumer_key => 'abcd', :consumer_secret => 'efgh', :nonce => 'oLKtec51GQy', :signature_method => 'PLAINTEXT', :timestamp => '1286977095', :token => 'ijkl', :token_secret => 'mnop' } header = SimpleOAuth::Header.new(:get, 'http://host.net/resource?name=value', {:name => 'value'}, options) expect(header.to_s).to eq 'OAuth oauth_consumer_key="abcd", oauth_nonce="oLKtec51GQy", oauth_signature="efgh%26mnop", oauth_signature_method="PLAINTEXT", oauth_timestamp="1286977095", oauth_token="ijkl", oauth_version="1.0"' end end end
require 'formula' class Szip < Formula homepage 'http://www.hdfgroup.org/HDF5/release/obtain5.html#extlibs' url 'http://www.hdfgroup.org/ftp/lib-external/szip/2.1/src/szip-2.1.tar.gz' sha256 'a816d95d5662e8279625abdbea7d0e62157d7d1f028020b1075500bf483ed5ef' revision 1 bottle do root_url 'https://juliabottles.s3.amazonaws.com' cellar :any end option :universal def install ENV.universal_binary if build.universal? system "./configure", "--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}" system "make install" end end Bottle szip require 'formula' class Szip < Formula homepage 'http://www.hdfgroup.org/HDF5/release/obtain5.html#extlibs' url 'http://www.hdfgroup.org/ftp/lib-external/szip/2.1/src/szip-2.1.tar.gz' sha256 'a816d95d5662e8279625abdbea7d0e62157d7d1f028020b1075500bf483ed5ef' revision 1 bottle do root_url 'https://juliabottles.s3.amazonaws.com' cellar :any sha256 "ec54e3c66ac599d71b44d971b2b25a09158b01400ff546190a5b3176313dc1ed" => :mavericks sha256 "95a96ce6a89b106c207c101cf558ee48d426d785d74701117f00aae1757ad0b0" => :yosemite sha256 "b4b4099411b1d91af315c59cbe7deec08cb8b049db151ec3e78a76c6f62b81ef" => :el_capitan end option :universal def install ENV.universal_binary if build.universal? system "./configure", "--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}" system "make install" end end
require "language/haskell" class Cless < Formula include Language::Haskell::Cabal desc "Display file contents with colorized syntax highlighting" homepage "https://github.com/tanakh/cless" url "https://github.com/tanakh/cless/archive/0.3.0.0.tar.gz" sha256 "382ad9b2ce6bf216bf2da1b9cadd9a7561526bfbab418c933b646d03e56833b2" revision 1 bottle do cellar :any_skip_relocation rebuild 2 sha256 "3244447865fa989bf33235e88637e0d6c19032c7a2d099c1c0fc7645d0cd043e" => :mojave sha256 "b0f4cd35cfb88bae1816f87df9a6eac25ffc5b68bc03ed7d92c8bba493add8c1" => :high_sierra sha256 "3585e128d1f855aede1e5bb6adec957c64e6777b126cc93a4165d68ccc304038" => :sierra sha256 "660d59f6fe5f0b319091559c727a8b1b241f62244b877fc35ecdf34d69bf7713" => :el_capitan end depends_on "cabal-install" => :build depends_on "ghc" => :build def install # GHC 8 compat # Reported 25 May 2016: https://github.com/tanakh/cless/issues/3 # Also see "fix compilation with GHC 7.10", which has the base bump but not # the transformers bump: https://github.com/tanakh/cless/pull/2 (buildpath/"cabal.config").write("allow-newer: base,transformers\n") install_cabal_package end test do system "#{bin}/cless", "--help" system "#{bin}/cless", "--list-langs" system "#{bin}/cless", "--list-styles" end end cless: delete (#50828)
launch_socket_server 2.0.0 Closes #47897. Signed-off-by: Misty De Meo <85d6b3741948526aebc363d97f74b6575b2cc027@gmail.com> class LaunchSocketServer < Formula desc "Bind to privileged ports without running a server as root" homepage "https://github.com/mistydemeo/launch_socket_server" url "https://github.com/mistydemeo/launch_socket_server/archive/v2.0.0.tar.gz" sha256 "507184544d170dab63e6112198212033aaa84edf0e092c1dfe641087f092f365" head "https://github.com/mistydemeo/launch_socket_server.git" depends_on "go" => :build def install system "make", "install", "PREFIX=#{prefix}" end plist_options :startup => true def plist <<~EOS <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>#{plist_name}</string> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/> <key>ProgramArguments</key> <array> <string>#{opt_sbin}/launch_socket_server</string> <string>-</string> </array> <key>Sockets</key> <dict> <key>Socket</key> <dict> <key>SockNodeName</key> <string>0.0.0.0</string> <key>SockServiceName</key> <string>80</string> </dict> </dict> <key>EnvironmentVariables</key> <dict> <key>LAUNCH_PROGRAM_TCP_ADDRESS</key> <string>127.0.0.1:8080</string> </dict> <key>StandardErrorPath</key> <string>#{var}/log/launch_socket_server.log</string> <key>StandardOutPath</key> <string>#{var}/log/launch_socket_server.log</string> </dict> </plist> EOS end test do assert_includes shell_output("#{opt_sbin}/launch_socket_server 2>&1; true"), "usage: #{opt_sbin}/launch_socket_server" end end
require 'spec_helper' module Sphere describe Projects do before do @proj = Sphere::Projects.new end describe '#select' do it 'project_key is nil or empty' do expect { @proj.select [], {} }.to raise_error "No project key provided." expect { @proj.select [''], {} }.to raise_error "No project key provided." end it 'stores project_key' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[{"key":"some-project"}]' }) expect { @proj.select ['some-project'], {} }.to_not raise_error File.should be_file File.join '.sphere', 'project' end it 'fails if there are no projects' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[]' }) expect { @proj.select ['project-xyz'], {} }.to raise_error "Project with key 'project-xyz' does not exist." end it 'fails if given project_key does not exists' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[{},{},{}]' }) expect { @proj.select ['project-xyz'], {} }.to raise_error "Project with key 'project-xyz' does not exist." end end describe '#details' do it 'project_key is nil or empty' do expect { @proj.details [], {} }.to raise_error "No project key provided." expect { @proj.details [''], {} }.to raise_error "No project key provided." end it 'no project' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[]' }) expect { @proj.details ['some-project'], {} }.to raise_error "Project with key 'some-project' does not exist." end it 'just works' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[{"id":"1","key":"p","name":"P"}]' }) expect { @proj.details ['p'], {} }.to_not raise_error end end describe '#list' do it 'no projects' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[]' }) o, e = capture_outs { @proj.list({}) } o.should match /^There are no projects.$/ end it 'just works' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[{"key":"p"},{"key":"q"}]' }) expect { @proj.list({}) }.to_not raise_error end end describe '#create' do it 'project_key is nil or empty' do expect { @proj.create [], {}, {} }.to raise_error "No project key provided." expect { @proj.create [''], {}, {} }.to raise_error "No project key provided." end it 'no orgs' do Excon.stub( { :method => :get, :path => '/api/organizations' }, { :status => 200, :body => '[]' }) o, e = capture_outs { @proj.create ['p'], {}, {} } o.should match /^You are not a member of any organizations.$/ end it 'too many orgs' do Excon.stub( { :method => :get, :path => '/api/organizations' }, { :status => 200, :body => '[{},{}]' }) expect { @proj.create ['p'], {}, {} }.to raise_error 'There are more than one organization. Please specify which organization to create the new project for.' end it 'my org does not exists' do Excon.stub( { :method => :get, :path => '/api/organizations' }, { :status => 200, :body => '[{"name":"SomeOrg"},{"name":"NotMyOrg"}]' }) expect { @proj.create ['p'], { :org => 'myOrg' }, {} }.to raise_error "Organization 'myOrg' does not exist." end it 'just works' do Excon.stub( { :method => :get, :path => '/api/organizations' }, { :status => 200, :body => '[{"id":"org"}]' }) Excon.stub( { :method => :post, :path => '/api/projects', :body => '{"name":"p","key":"p","owner":{"typeId":"organization","id":"org"},"languages":["de","en"],"currencies":["YEN"],"plan":"Medium"}' }, { :status => 200, :body => '{"project":{"key":"p","version":1},"client":{"id":"123","secret":"geheim"}}' }) Excon.stub( { :method => :put, :path => '/api/projects/p', :body => '{"key":"p","version":1,"actions":[{"action":"setCountries","countries":["DE"]}]}' }, { :status => 200 }) Excon.stub( { :method => :post, :path => '/api/p/sample-data' }, { :status => 200 }) expect { @proj.create ['p'], { :l => 'de,en', :m => 'YEN', :c => 'DE', :'sample-data' => true }, { } }.not_to raise_error end end describe '#delete' do it 'no project key' do expect { @proj.delete [], {} }.to raise_error "No project key provided." expect { @proj.delete [''], {} }.to raise_error "No project key provided." end it 'just works' do Excon.stub( { :method => :delete, :path => '/api/projects/old-proj' }, { :status => 200 }) expect { @proj.delete ['old-proj'], { :force => true } }.to_not raise_error end end end end Adjust tests to organization handling on project creation. require 'spec_helper' module Sphere describe Projects do before do @proj = Sphere::Projects.new end describe '#select' do it 'project_key is nil or empty' do expect { @proj.select [], {} }.to raise_error "No project key provided." expect { @proj.select [''], {} }.to raise_error "No project key provided." end it 'stores project_key' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[{"key":"some-project"}]' }) expect { @proj.select ['some-project'], {} }.to_not raise_error File.should be_file File.join '.sphere', 'project' end it 'fails if there are no projects' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[]' }) expect { @proj.select ['project-xyz'], {} }.to raise_error "Project with key 'project-xyz' does not exist." end it 'fails if given project_key does not exists' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[{},{},{}]' }) expect { @proj.select ['project-xyz'], {} }.to raise_error "Project with key 'project-xyz' does not exist." end end describe '#details' do it 'project_key is nil or empty' do expect { @proj.details [], {} }.to raise_error "No project key provided." expect { @proj.details [''], {} }.to raise_error "No project key provided." end it 'no project' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[]' }) expect { @proj.details ['some-project'], {} }.to raise_error "Project with key 'some-project' does not exist." end it 'just works' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[{"id":"1","key":"p","name":"P"}]' }) expect { @proj.details ['p'], {} }.to_not raise_error end end describe '#list' do it 'no projects' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[]' }) o, e = capture_outs { @proj.list({}) } o.should match /^There are no projects.$/ end it 'just works' do Excon.stub( { :method => :get, :path => '/api/projects' }, { :status => 200, :body => '[{"key":"p"},{"key":"q"}]' }) expect { @proj.list({}) }.to_not raise_error end end describe '#create' do it 'project_key is nil or empty' do expect { @proj.create [], {}, {} }.to raise_error "No project key provided." expect { @proj.create [''], {}, {} }.to raise_error "No project key provided." end it 'no orgs' do Excon.stub( { :method => :get, :path => '/api/organizations' }, { :status => 200, :body => '[]' }) o, e = capture_outs { @proj.create ['p'], {}, {} } o.should match /^You are not a member of any organizations.$/ end it 'too many orgs' do Excon.stub( { :method => :get, :path => '/api/organizations' }, { :status => 200, :body => '[{},{}]' }) expect { @proj.create ['p'], {}, {} }.to raise_error 'Please specify which organization to create the new project for.' end it 'my org does not exists' do Excon.stub( { :method => :get, :path => '/api/organizations' }, { :status => 200, :body => '[{"name":"SomeOrg"},{"name":"NotMyOrg"}]' }) expect { @proj.create ['p'], { :o => 'myOrg' }, {} }.to raise_error "Organization 'myOrg' does not exist." end it 'just works' do Excon.stub( { :method => :get, :path => '/api/organizations' }, { :status => 200, :body => '[{"id":"org"}]' }) Excon.stub( { :method => :post, :path => '/api/projects', :body => '{"name":"p","key":"p","owner":{"typeId":"organization","id":"org"},"languages":["de","en"],"currencies":["YEN"],"plan":"Medium"}' }, { :status => 200, :body => '{"project":{"key":"p","version":1},"client":{"id":"123","secret":"geheim"}}' }) Excon.stub( { :method => :put, :path => '/api/projects/p', :body => '{"key":"p","version":1,"actions":[{"action":"setCountries","countries":["DE"]}]}' }, { :status => 200 }) Excon.stub( { :method => :post, :path => '/api/p/sample-data' }, { :status => 200 }) expect { @proj.create ['p'], { :l => 'de,en', :m => 'YEN', :c => 'DE', :'sample-data' => true }, { } }.not_to raise_error end end describe '#delete' do it 'no project key' do expect { @proj.delete [], {} }.to raise_error "No project key provided." expect { @proj.delete [''], {} }.to raise_error "No project key provided." end it 'just works' do Excon.stub( { :method => :delete, :path => '/api/projects/old-proj' }, { :status => 200 }) expect { @proj.delete ['old-proj'], { :force => true } }.to_not raise_error end end end end
class Clisp < Formula desc "GNU CLISP, a Common Lisp implementation" homepage "http://www.clisp.org/" url "http://ftpmirror.gnu.org/clisp/release/2.49/clisp-2.49.tar.bz2" mirror "https://ftp.gnu.org/gnu/clisp/release/2.49/clisp-2.49.tar.bz2" sha256 "8132ff353afaa70e6b19367a25ae3d5a43627279c25647c220641fed00f8e890" bottle do sha256 "cbd72b99874b8a53da52938f41122e741cccb1e300c2bbf3175f6cefbe48a100" => :yosemite sha256 "00d23db5b9accb0072a1b14d6adf1ddfd11112c5c36faa7e68c03f2727aa3be9" => :mavericks sha256 "4acc75971d4dd0a316586b38cfa53162887104a9e9a33a0ca26134a3696307e0" => :mountain_lion end depends_on "libsigsegv" depends_on "readline" fails_with :llvm do build 2334 cause "Configure fails on XCode 4/Snow Leopard." end patch :DATA patch :p0 do url "https://raw.githubusercontent.com/Homebrew/patches/e2cc7c1/clisp/patch-src_lispbibl_d.diff" sha256 "fd4e8a0327e04c224fb14ad6094741034d14cb45da5b56a2f3e7c930f84fd9a0" end def install ENV.deparallelize # This build isn't parallel safe. ENV.O0 # Any optimization breaks the build # Clisp requires to select word size explicitly this way, # set it in CFLAGS won't work. ENV["CC"] = "#{ENV.cc} -m#{MacOS.prefer_64_bit? ? 64 : 32}" system "./configure", "--prefix=#{prefix}", "--with-readline=yes" cd "src" do # Multiple -O options will be in the generated Makefile, # make Homebrew's the last such option so it's effective. inreplace "Makefile" do |s| s.change_make_var! "CFLAGS", "#{s.get_make_var("CFLAGS")} #{ENV["CFLAGS"]}" end # The ulimit must be set, otherwise `make` will fail and tell you to do so system "ulimit -s 16384 && make" if MacOS.version >= :lion opoo <<-EOS.undent `make check` fails so we are skipping it. However, there will likely be other issues present. Please take them upstream to the clisp project itself. EOS else # Considering the complexity of this package, a self-check is highly recommended. system "make", "check" end system "make", "install" end end test do system "#{bin}/clisp", "--version" end end __END__ diff --git a/src/stream.d b/src/stream.d index 5345ed6..cf14e29 100644 --- a/src/stream.d +++ b/src/stream.d @@ -3994,7 +3994,7 @@ global object iconv_range (object encoding, uintL start, uintL end, uintL maxint nonreturning_function(extern, error_unencodable, (object encoding, chart ch)); /* Avoid annoying warning caused by a wrongly standardized iconv() prototype. */ -#ifdef GNU_LIBICONV +#if defined(GNU_LIBICONV) && !defined(__APPLE_CC__) #undef iconv #define iconv(cd,inbuf,inbytesleft,outbuf,outbytesleft) \ libiconv(cd,(ICONV_CONST char **)(inbuf),inbytesleft,outbuf,outbytesleft) clisp: update 2.49 bottle. class Clisp < Formula desc "GNU CLISP, a Common Lisp implementation" homepage "http://www.clisp.org/" url "http://ftpmirror.gnu.org/clisp/release/2.49/clisp-2.49.tar.bz2" mirror "https://ftp.gnu.org/gnu/clisp/release/2.49/clisp-2.49.tar.bz2" sha256 "8132ff353afaa70e6b19367a25ae3d5a43627279c25647c220641fed00f8e890" bottle do sha256 "68169046c3d5465c905375645b363d549812b4d543764a0eee5a7f4aeacba6cc" => :el_capitan sha256 "cbd72b99874b8a53da52938f41122e741cccb1e300c2bbf3175f6cefbe48a100" => :yosemite sha256 "00d23db5b9accb0072a1b14d6adf1ddfd11112c5c36faa7e68c03f2727aa3be9" => :mavericks sha256 "4acc75971d4dd0a316586b38cfa53162887104a9e9a33a0ca26134a3696307e0" => :mountain_lion end depends_on "libsigsegv" depends_on "readline" fails_with :llvm do build 2334 cause "Configure fails on XCode 4/Snow Leopard." end patch :DATA patch :p0 do url "https://raw.githubusercontent.com/Homebrew/patches/e2cc7c1/clisp/patch-src_lispbibl_d.diff" sha256 "fd4e8a0327e04c224fb14ad6094741034d14cb45da5b56a2f3e7c930f84fd9a0" end def install ENV.deparallelize # This build isn't parallel safe. ENV.O0 # Any optimization breaks the build # Clisp requires to select word size explicitly this way, # set it in CFLAGS won't work. ENV["CC"] = "#{ENV.cc} -m#{MacOS.prefer_64_bit? ? 64 : 32}" system "./configure", "--prefix=#{prefix}", "--with-readline=yes" cd "src" do # Multiple -O options will be in the generated Makefile, # make Homebrew's the last such option so it's effective. inreplace "Makefile" do |s| s.change_make_var! "CFLAGS", "#{s.get_make_var("CFLAGS")} #{ENV["CFLAGS"]}" end # The ulimit must be set, otherwise `make` will fail and tell you to do so system "ulimit -s 16384 && make" if MacOS.version >= :lion opoo <<-EOS.undent `make check` fails so we are skipping it. However, there will likely be other issues present. Please take them upstream to the clisp project itself. EOS else # Considering the complexity of this package, a self-check is highly recommended. system "make", "check" end system "make", "install" end end test do system "#{bin}/clisp", "--version" end end __END__ diff --git a/src/stream.d b/src/stream.d index 5345ed6..cf14e29 100644 --- a/src/stream.d +++ b/src/stream.d @@ -3994,7 +3994,7 @@ global object iconv_range (object encoding, uintL start, uintL end, uintL maxint nonreturning_function(extern, error_unencodable, (object encoding, chart ch)); /* Avoid annoying warning caused by a wrongly standardized iconv() prototype. */ -#ifdef GNU_LIBICONV +#if defined(GNU_LIBICONV) && !defined(__APPLE_CC__) #undef iconv #define iconv(cd,inbuf,inbytesleft,outbuf,outbytesleft) \ libiconv(cd,(ICONV_CONST char **)(inbuf),inbytesleft,outbuf,outbytesleft)
class PyenvVirtualenvExt < Formula desc "Make pyenv transparently aware of a virtual environment" homepage "https://github.com/jamieconnolly/pyenv-virtualenv-ext" url "https://github.com/jamieconnolly/pyenv-virtualenv-ext/archive/0.5.0.tar.gz" sha256 "6c9f5eb261e204220bbf5f5aa9e8aeef6eccead81121d45a5061295c5308fd8a" head "https://github.com/jamieconnolly/pyenv-virtualenv-ext.git" bottle :unneeded depends_on "pyenv" depends_on "pyenv-virtualenv" def install ENV["PREFIX"] = prefix system "./install.sh" end test do assert_match "virtualenv-ext.bash", shell_output("pyenv hooks version-name") assert_match "virtualenv-ext.bash", shell_output("pyenv hooks version-origin") end end Update pyenv-virtualenv-ext to 0.5.1 class PyenvVirtualenvExt < Formula desc "Make pyenv transparently aware of a virtual environment" homepage "https://github.com/jamieconnolly/pyenv-virtualenv-ext" url "https://github.com/jamieconnolly/pyenv-virtualenv-ext/archive/0.5.1.tar.gz" sha256 "e2c3995eb035d95514bcc510fbfbf73a8f7440aa0649354c8a4a297209090c5e" head "https://github.com/jamieconnolly/pyenv-virtualenv-ext.git" bottle :unneeded depends_on "pyenv" depends_on "pyenv-virtualenv" def install ENV["PREFIX"] = prefix system "./install.sh" end test do assert_match "virtualenv-ext.bash", shell_output("pyenv hooks version-name") assert_match "virtualenv-ext.bash", shell_output("pyenv hooks version-origin") end end
require 'spec_helper' RSpec.describe BarclaysBikeCli::StationRepository do let(:datasource) { TestDatasource.new } subject { BarclaysBikeCli::StationRepository.new(datasource) } describe '#all' do context 'given feed_parser returns dataset' do it 'should return expected number of results' do results = subject.all expect(results.size).to eq(2) end end end describe '#find_by_id' do context 'given feed_parser returns dataset' do it 'should return expected number of results' do results = subject.find_by_id(1) expect(results.size).to eq(1) end it 'should return expected result' do result = subject.find_by_id(1).first expect(result.name).to eq('test-station-1') end context 'given a request for an id that does not exist' do it 'should raise error' do expect do subject.find_by_id(99) end.to raise_error end end end end describe '#find_by_name' do context 'given feed_parser returns dataset' do it 'should return expected number of results' do results = subject.find_by_name('test-station-1') expect(results.size).to eq(1) end it 'should return expected result' do result = subject.find_by_name('test-station-1').first expect(result.id).to eq(1) end context 'given a request for an id that does not exist' do it 'should not raise error' do expect do subject.find_by_name('foo') end.not_to raise_error end it 'should return empty array' do expect(subject.find_by_name('foo').size).to eq(0) end end end describe 'integration tests', vcr: { cassette_name: 'feed_xml' } do subject { BarclaysBikeCli::StationRepository.new(BarclaysBikeCli::FeedParser.new) } describe '#find_by_id' do it 'should return expected number of results' do results = subject.find_by_id(777) expect(results.size).to eq(1) end it 'should return expected result' do result = subject.find_by_id(777).first expect(result.name).to eq('Limburg Road, Clapham Common') end end describe '#find_by_name' do it 'should return expected number of results' do results = subject.find_by_name('kings') expect(results.size).to eq(3) end it 'should return expected result' do result = subject.find_by_name('kings') actual_ids = result.map(&:id) expect(actual_ids).to include('283', '439', '594') end end describe '#all' do it 'should return expected number of results' do results = subject.all expect(results.size).to eq(747) end end end end end Updates since parser returns stations with int id require 'spec_helper' RSpec.describe BarclaysBikeCli::StationRepository do let(:datasource) { TestDatasource.new } subject { BarclaysBikeCli::StationRepository.new(datasource) } describe '#all' do context 'given feed_parser returns dataset' do it 'should return expected number of results' do results = subject.all expect(results.size).to eq(2) end end end describe '#find_by_id' do context 'given feed_parser returns dataset' do it 'should return expected number of results' do results = subject.find_by_id(1) expect(results.size).to eq(1) end it 'should return expected result' do result = subject.find_by_id(1).first expect(result.name).to eq('test-station-1') end context 'given a request for an id that does not exist' do it 'should raise error' do expect do subject.find_by_id(99) end.to raise_error end end end end describe '#find_by_name' do context 'given feed_parser returns dataset' do it 'should return expected number of results' do results = subject.find_by_name('test-station-1') expect(results.size).to eq(1) end it 'should return expected result' do result = subject.find_by_name('test-station-1').first expect(result.id).to eq(1) end context 'given a request for an id that does not exist' do it 'should not raise error' do expect do subject.find_by_name('foo') end.not_to raise_error end it 'should return empty array' do expect(subject.find_by_name('foo').size).to eq(0) end end end describe 'integration tests', vcr: { cassette_name: 'feed_xml' } do subject { BarclaysBikeCli::StationRepository.new(BarclaysBikeCli::FeedParser.new) } describe '#find_by_id' do it 'should return expected number of results' do results = subject.find_by_id(777) expect(results.size).to eq(1) end it 'should return expected result' do result = subject.find_by_id(777).first expect(result.name).to eq('Limburg Road, Clapham Common') end end describe '#find_by_name' do it 'should return expected number of results' do results = subject.find_by_name('kings') expect(results.size).to eq(3) end it 'should return expected result' do results = subject.find_by_name('kings') actual_ids = results.map(&:id) expect(actual_ids).to include(283, 439, 594) end end describe '#all' do it 'should return expected number of results' do results = subject.all expect(results.size).to eq(747) end end end end end
require 'formula' class Cloog < Formula homepage 'http://www.cloog.org/' url 'http://www.bastoul.net/cloog/pages/download/count.php3?url=./cloog-0.18.1.tar.gz' mirror 'http://gcc.cybermirror.org/infrastructure/cloog-0.18.1.tar.gz' sha1 '2dc70313e8e2c6610b856d627bce9c9c3f848077' bottle do cellar :any revision 1 sha1 '38afdce382abcd3c46fb94af7eb72e87d87859d4' => :mavericks sha1 'd6984ce335cf7b8eb482cdd4f0301c6583b00073' => :mountain_lion sha1 'fd707268c3e5beafa9b98a768f7064d5b9699178' => :lion end head do url 'http://repo.or.cz/r/cloog.git' depends_on "autoconf" => :build depends_on "automake" => :build depends_on "libtool" => :build end depends_on 'pkg-config' => :build depends_on 'gmp' depends_on 'isl' def install system "./autogen.sh" if build.head? args = [ "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=#{prefix}", "--with-gmp=system", "--with-gmp-prefix=#{Formula["gmp"].opt_prefix}", "--with-isl=system", "--with-isl-prefix=#{Formula["isl"].opt_prefix}" ] args << "--with-osl=bundled" if build.head? system "./configure", *args system "make install" end test do cloog_source = <<-EOS.undent c 0 2 0 1 1 0 2 0 0 0 0 0 EOS output = pipe_output("#{bin}/cloog /dev/stdin", cloog_source) assert_match /Generated from \/dev\/stdin by CLooG/, output end end cloog: update 0.18.1 bottle. require 'formula' class Cloog < Formula homepage 'http://www.cloog.org/' url 'http://www.bastoul.net/cloog/pages/download/count.php3?url=./cloog-0.18.1.tar.gz' mirror 'http://gcc.cybermirror.org/infrastructure/cloog-0.18.1.tar.gz' sha1 '2dc70313e8e2c6610b856d627bce9c9c3f848077' bottle do cellar :any revision 2 sha1 "65900e9655ab8f444ecf7edf4118caa01ca56ddb" => :yosemite sha1 "851f64756bb082a5a354e0992976acd70cfdacbf" => :mavericks sha1 "06252f0a9c453818c319b21647ebaa9a26c3f4ac" => :mountain_lion end head do url 'http://repo.or.cz/r/cloog.git' depends_on "autoconf" => :build depends_on "automake" => :build depends_on "libtool" => :build end depends_on 'pkg-config' => :build depends_on 'gmp' depends_on 'isl' def install system "./autogen.sh" if build.head? args = [ "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=#{prefix}", "--with-gmp=system", "--with-gmp-prefix=#{Formula["gmp"].opt_prefix}", "--with-isl=system", "--with-isl-prefix=#{Formula["isl"].opt_prefix}" ] args << "--with-osl=bundled" if build.head? system "./configure", *args system "make install" end test do cloog_source = <<-EOS.undent c 0 2 0 1 1 0 2 0 0 0 0 0 EOS output = pipe_output("#{bin}/cloog /dev/stdin", cloog_source) assert_match /Generated from \/dev\/stdin by CLooG/, output end end
# frozen_string_literal: true RSpec.configure do |config| config.before do if Gitlab::Database.postgresql? && ENV['PG_STAT_WARNING_THRESHOLD'] warning_threshold = ENV['PG_STAT_WARNING_THRESHOLD'].to_i results = ActiveRecord::Base.connection.execute('SELECT * FROM pg_stat_activity') ntuples = results.ntuples warn("pg_stat_activity count: #{ntuples}") if ntuples > warning_threshold results.each do |result| warn result.inspect end end end end end Revert "Merge branch 'check_pg_stat_activity' into 'master'" This reverts merge request !25723
require "language/node" class YamlLanguageServer < Formula desc "Language Server for Yaml Files" homepage "https://github.com/redhat-developer/yaml-language-server" url "https://registry.npmjs.org/yaml-language-server/-/yaml-language-server-1.2.2.tgz" sha256 "c5413137ec0ebf79a4368fd97611f2ae6d08a0c4ee2d6efb28763982a7e05e2a" license "MIT" depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do require "open3" json = <<~JSON { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "rootUri": null, "capabilities": {} } } JSON Open3.popen3("#{bin}/yaml-language-server", "--stdio") do |stdin, stdout| stdin.write "Content-Length: #{json.size}\r\n\r\n#{json}" sleep 3 assert_match(/^Content-Length: \d+/i, stdout.readline) end end end yaml-language-server: add 1.2.2 bottle. require "language/node" class YamlLanguageServer < Formula desc "Language Server for Yaml Files" homepage "https://github.com/redhat-developer/yaml-language-server" url "https://registry.npmjs.org/yaml-language-server/-/yaml-language-server-1.2.2.tgz" sha256 "c5413137ec0ebf79a4368fd97611f2ae6d08a0c4ee2d6efb28763982a7e05e2a" license "MIT" bottle do sha256 cellar: :any_skip_relocation, arm64_monterey: "9263e1c32411bccec08e034997088e8911139704992e5eb427992f1bfdb3198c" sha256 cellar: :any_skip_relocation, arm64_big_sur: "9263e1c32411bccec08e034997088e8911139704992e5eb427992f1bfdb3198c" sha256 cellar: :any_skip_relocation, monterey: "47dccc5d1968883137593117fc16944ae29edb65ffce2ef0782a9de2526a56f4" sha256 cellar: :any_skip_relocation, big_sur: "47dccc5d1968883137593117fc16944ae29edb65ffce2ef0782a9de2526a56f4" sha256 cellar: :any_skip_relocation, catalina: "47dccc5d1968883137593117fc16944ae29edb65ffce2ef0782a9de2526a56f4" sha256 cellar: :any_skip_relocation, x86_64_linux: "9263e1c32411bccec08e034997088e8911139704992e5eb427992f1bfdb3198c" end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do require "open3" json = <<~JSON { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "rootUri": null, "capabilities": {} } } JSON Open3.popen3("#{bin}/yaml-language-server", "--stdio") do |stdin, stdout| stdin.write "Content-Length: #{json.size}\r\n\r\n#{json}" sleep 3 assert_match(/^Content-Length: \d+/i, stdout.readline) end end end
class Cmake < Formula desc "Cross-platform make" homepage "https://www.cmake.org/" url "https://github.com/Kitware/CMake/releases/download/v3.18.3/cmake-3.18.3.tar.gz" sha256 "2c89f4e30af4914fd6fb5d00f863629812ada848eee4e2d29ec7e456d7fa32e5" license "BSD-3-Clause" head "https://gitlab.kitware.com/cmake/cmake.git" livecheck do url "https://cmake.org/download/" regex(/Latest Release \(v?(\d+(?:\.\d+)+)\)/i) end bottle do cellar :any_skip_relocation sha256 "2cc57360f3dc4889657e15ad7bd72187ac6a987de6582e92188897019975eee4" => :catalina sha256 "d021c273c99401bd4ae0a20f190f43887047d6170b1cf0586a7a28638d342d8c" => :mojave sha256 "0cc394f863fc73d0a93b134423ce8618be6dd30aab34f901af8fa56ec240115f" => :high_sierra end depends_on "sphinx-doc" => :build on_linux do depends_on "openssl@1.1" end # The completions were removed because of problems with system bash # The `with-qt` GUI option was removed due to circular dependencies if # CMake is built with Qt support and Qt is built with MySQL support as MySQL uses CMake. # For the GUI application please instead use `brew cask install cmake`. def install args = %W[ --prefix=#{prefix} --no-system-libs --parallel=#{ENV.make_jobs} --datadir=/share/cmake --docdir=/share/doc/cmake --mandir=/share/man --sphinx-build=#{Formula["sphinx-doc"].opt_bin}/sphinx-build --sphinx-html --sphinx-man --system-zlib --system-bzip2 --system-curl ] system "./bootstrap", *args, "--", *std_cmake_args, "-DCMake_INSTALL_EMACS_DIR=#{elisp}" system "make" system "make", "install" end test do (testpath/"CMakeLists.txt").write("find_package(Ruby)") system bin/"cmake", "." end end cmake 3.18.4 Closes #62207. Signed-off-by: Sean Molenaar <2b250e3fea88cfef248b497ad5fc17f7dc435154@users.noreply.github.com> Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com> class Cmake < Formula desc "Cross-platform make" homepage "https://www.cmake.org/" url "https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4.tar.gz" sha256 "597c61358e6a92ecbfad42a9b5321ddd801fc7e7eca08441307c9138382d4f77" license "BSD-3-Clause" head "https://gitlab.kitware.com/cmake/cmake.git" livecheck do url "https://cmake.org/download/" regex(/Latest Release \(v?(\d+(?:\.\d+)+)\)/i) end bottle do cellar :any_skip_relocation sha256 "2cc57360f3dc4889657e15ad7bd72187ac6a987de6582e92188897019975eee4" => :catalina sha256 "d021c273c99401bd4ae0a20f190f43887047d6170b1cf0586a7a28638d342d8c" => :mojave sha256 "0cc394f863fc73d0a93b134423ce8618be6dd30aab34f901af8fa56ec240115f" => :high_sierra end depends_on "sphinx-doc" => :build on_linux do depends_on "openssl@1.1" end # The completions were removed because of problems with system bash # The `with-qt` GUI option was removed due to circular dependencies if # CMake is built with Qt support and Qt is built with MySQL support as MySQL uses CMake. # For the GUI application please instead use `brew cask install cmake`. def install args = %W[ --prefix=#{prefix} --no-system-libs --parallel=#{ENV.make_jobs} --datadir=/share/cmake --docdir=/share/doc/cmake --mandir=/share/man --sphinx-build=#{Formula["sphinx-doc"].opt_bin}/sphinx-build --sphinx-html --sphinx-man --system-zlib --system-bzip2 --system-curl ] system "./bootstrap", *args, "--", *std_cmake_args, "-DCMake_INSTALL_EMACS_DIR=#{elisp}" system "make" system "make", "install" end test do (testpath/"CMakeLists.txt").write("find_package(Ruby)") system bin/"cmake", "." end end
require "spec_helper" module Sucker describe Request do use_vcr_cassette "unit/sucker/request", :record => :new_episodes let(:worker) do Sucker.new( :locale => "us", :key => "key", :secret => "secret") end context ".new" do it "sets default parameters" do default_parameters = { "Service" => "AWSECommerceService", "Version" => Sucker::CURRENT_AMAZON_API_VERSION } worker.parameters.should include default_parameters end end context "#<<" do it "merges a hash into the parameters" do worker << { "foo" => "bar" } worker.parameters["foo"].should eql "bar" end end context "api_version" do it "has a default value" do worker.api_version.should_not be_nil end end context "#api_version=" do it "sets the Amazon API version" do worker.api_version = "foo" worker.api_version.should eql "foo" end end context "#associate_tag=" do it "sets the associate tag in the parameters" do worker.associate_tag = "foo" worker.parameters["AssociateTag"].should eql "foo" end end context "#curl" do it "returns a cURL object" do worker.curl.should be_an_instance_of Curl::Easy end it "configures the cURL object" do worker.curl.interface.should be_nil worker.curl do |curl| curl.interface = "eth1" end worker.curl.interface.should eql "eth1" end end context "#get" do it "returns a Response object" do worker.get.class.ancestors.should include Sucker::Response end end context "#key=" do it "sets the Amazon AWS access key in the parameters" do worker.key = "foo" worker.parameters["AWSAccessKeyId"].should eql "foo" end end context "private methods" do context "#build_query" do it "canonicalizes parameters" do query = worker.send(:build_query) query.should match /Service=([^&]+)&Timestamp=([^&]+)&Version=([^&]+)/ end it "sorts parameters" do worker.parameters["AAA"] = "foo" query = worker.send(:build_query) query.should match /^AAA=foo/ end it "converts a parameter whose value is an array to a string" do worker.parameters["Foo"] = ["bar", "baz"] query = worker.send(:build_query) query.should match /Foo=bar%2Cbaz/ end it "handles integer parameter values" do worker.parameters["Foo"] = 1 query = worker.send(:build_query) query.should match /Foo=1/ end it "handles floating-point parameter values" do worker.parameters["Foo"] = 1.0 query = worker.send(:build_query) query.should match /Foo=1/ end end context "#host" do it "returns a host" do worker.locale = "fr" worker.send(:host).should eql "ecs.amazonaws.fr" end end context "#build_signed_query" do it "returns a signed query string" do query = worker.send :build_signed_query query.should match /&Signature=.*/ end end context "#timestamp" do it "returns a timestamp" do worker.send(:timestamp)["Timestamp"].should match /^\d+-\d+-\d+T\d+:\d+:\d+Z$/ end end context "#uri" do it "returns the URI with which to query Amazon" do worker.send(:uri).should be_an_instance_of URI::HTTP end end end end end Updated request spec require "spec_helper" module Sucker describe Request do use_vcr_cassette "unit/sucker/request", :record => :new_episodes let(:worker) do Sucker.new( :locale => "us", :key => "key", :secret => "secret") end context ".new" do it "sets default parameters" do default_parameters = { "Service" => "AWSECommerceService", "Version" => Sucker::CURRENT_AMAZON_API_VERSION } worker.parameters.should include default_parameters end end context "#<<" do it "merges a hash into the parameters" do worker << { "foo" => "bar" } worker.parameters["foo"].should eql "bar" end end context "#version=" do it "sets the Amazon API version" do worker.version = "foo" worker.parameters["Version"].should eql "foo" end end context "#associate_tag=" do it "sets the associate tag in the parameters" do worker.associate_tag = "foo" worker.parameters["AssociateTag"].should eql "foo" end end context "#curl" do it "returns a cURL object" do worker.curl.should be_an_instance_of Curl::Easy end it "configures the cURL object" do worker.curl.interface.should be_nil worker.curl do |curl| curl.interface = "eth1" end worker.curl.interface.should eql "eth1" end end context "#get" do it "returns a Response object" do worker.get.class.ancestors.should include Sucker::Response end end context "#key=" do it "sets the Amazon AWS access key in the parameters" do worker.key = "foo" worker.parameters["AWSAccessKeyId"].should eql "foo" end end context "private methods" do context "#build_query" do it "canonicalizes parameters" do query = worker.send(:build_query) query.should match /Service=([^&]+)&Timestamp=([^&]+)&Version=([^&]+)/ end it "sorts parameters" do worker.parameters["AAA"] = "foo" query = worker.send(:build_query) query.should match /^AAA=foo/ end it "converts a parameter whose value is an array to a string" do worker.parameters["Foo"] = ["bar", "baz"] query = worker.send(:build_query) query.should match /Foo=bar%2Cbaz/ end it "handles integer parameter values" do worker.parameters["Foo"] = 1 query = worker.send(:build_query) query.should match /Foo=1/ end it "handles floating-point parameter values" do worker.parameters["Foo"] = 1.0 query = worker.send(:build_query) query.should match /Foo=1/ end end context "#host" do it "returns a host" do worker.locale = "fr" worker.send(:host).should eql "ecs.amazonaws.fr" end end context "#build_signed_query" do it "returns a signed query string" do query = worker.send :build_signed_query query.should match /&Signature=.*/ end end context "#timestamp" do it "returns a timestamp" do worker.send(:timestamp)["Timestamp"].should match /^\d+-\d+-\d+T\d+:\d+:\d+Z$/ end end context "#uri" do it "returns the URI with which to query Amazon" do worker.send(:uri).should be_an_instance_of URI::HTTP end end end end end
require 'formula' class Cmake < Formula url 'http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz' md5 '209b7d1d04b2e00986538d74ba764fcf' homepage 'http://www.cmake.org/' def patches # fixes CMake 2.8 to 2.8.4 not recognizing non-standard Developer tools issue # fixed in CMake 2.8.5 (not yet released) # upstream issue at http://public.kitware.com/Bug/view.php?id=10723 "http://cmake.org/gitweb?p=cmake.git;a=patch;h=d421a433a89064926ae6aad532850b8bed113562" end def install # A framework-installed expat will be detected and mess things up. if File.exist? "/Library/Frameworks/expat.framework" opoo "/Library/Frameworks/expat.framework detected" puts <<-EOS.undent This will be picked up by Cmake's build system and likey cause the build to fail, trying to link to a 32-bit version of expat. You may need to move this file out of the way for this brew to work. EOS end if ENV['GREP_OPTIONS'] == "--color=always" opoo "GREP_OPTIONS is set to '--color=always'" puts <<-EOS.undent Having `GREP_OPTIONS` set this way causes Cmake builds to fail. You will need to `unset GREP_OPTIONS` before brewing. EOS end system "./bootstrap", "--prefix=#{prefix}", "--system-libs", "--no-system-libarchive", "--datadir=/share/cmake", "--docdir=/share/doc/cmake", "--mandir=/share/man" system "make" system "make install" end end cmake 2.8.5 Signed-off-by: Adam Vandenberg <34c2b6407fd5a10249a15d699d40f9ed1782e98c@gmail.com> require 'formula' class Cmake < Formula url 'http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz' md5 '3c5d32cec0f4c2dc45f4c2e84f4a20c5' homepage 'http://www.cmake.org/' def install # A framework-installed expat will be detected and mess things up. if File.exist? "/Library/Frameworks/expat.framework" opoo "/Library/Frameworks/expat.framework detected" puts <<-EOS.undent This will be picked up by Cmake's build system and likey cause the build to fail, trying to link to a 32-bit version of expat. You may need to move this file out of the way for this brew to work. EOS end if ENV['GREP_OPTIONS'] == "--color=always" opoo "GREP_OPTIONS is set to '--color=always'" puts <<-EOS.undent Having `GREP_OPTIONS` set this way causes Cmake builds to fail. You will need to `unset GREP_OPTIONS` before brewing. EOS end system "./bootstrap", "--prefix=#{prefix}", "--system-libs", "--no-system-libarchive", "--datadir=/share/cmake", "--docdir=/share/doc/cmake", "--mandir=/share/man" system "make" system "make install" end end
require "spec_helper" module Sucker describe Request do use_vcr_cassette "unit/sucker/request", :record => :new_episodes let(:worker) do Sucker.new( :locale => "us", :key => "key", :secret => "secret") end describe ".new" do it "sets default parameters" do default_parameters = { "Service" => "AWSECommerceService", "Version" => Sucker::CURRENT_AMAZON_API_VERSION } worker.parameters.should include default_parameters end end describe "#<<" do it "merges a hash into the parameters" do worker << { "foo" => "bar" } worker.parameters["foo"].should eql "bar" end end describe "#version=" do it "sets the Amazon API version" do worker.version = "foo" worker.parameters["Version"].should eql "foo" end end describe "#associate_tag" do it "returns the associate tag for the current locale" do worker.instance_variable_set(:@associate_tags, { :us => 'foo-bar'}) worker.associate_tag.should eql 'foo-bar' end it "returns nil if an associate tag is not set for the current locale" do worker.associate_tag.should eql nil end end describe "#associate_tag=" do it "sets the associate tag for the current locale" do worker.associate_tag = "foo-bar" associate_tags = worker.instance_variable_get(:@associate_tags) associate_tags.keys.size.should eql 1 associate_tags[:us].should eql 'foo-bar' worker.associate_tag.should eql 'foo-bar' end end describe "#associate_tags=" do it "sets associate tags for the locales" do tags = { :us => 'foo', :uk => 'bar', :de => 'baz', :ca => 'foo', :fr => 'bar', :jp => 'baz' } worker.associate_tags = tags worker.instance_variable_get(:@associate_tags).should eql tags end end describe "#curl_opts" do it "returns options for curl" do worker.curl_opts.should be_an_instance_of Hash end context "when given a block" do it "yields options for curl" do worker.curl_opts { |c| c.interface = "eth1" } worker.curl_opts[:interface].should eql "eth1" end end end describe "#get" do it "returns a response" do worker.get.class.ancestors.should include Response end it "raises an argument error if no key is provided" do worker.key = nil expect do worker.get end.to raise_error(/AWS access key missing/) end it "raises an argument error if no locale is provided" do worker.locale = nil expect do worker.get end.to raise_error(/Locale missing/) end end describe "#get_all" do it "returns an array of responses" do responses = worker.get_all responses.should be_an_instance_of Array responses.each { |resp| resp.should be_an_instance_of Response } end context "when given a block" do it "yields responses" do count = 0 worker.get_all do |resp| resp.should be_an_instance_of Response count += 1 end count.should eql Request::HOSTS.size end end end describe "#key" do it "returns the Amazon AWS access key for the current locale" do worker.instance_variable_set(:@keys, { :us => 'foo' }) worker.key.should eql 'foo' end end describe "#key=" do it "sets a global Amazon AWS access key" do worker.key = "foo" keys = worker.instance_variable_get(:@keys) keys.size.should eql Request::HOSTS.size keys.values.uniq.should eql ["foo"] end end describe "#keys=" do it "sets distinct Amazon AWS access keys for the locales" do keys = { :us => 'foo', :uk => 'bar', :de => 'baz', :ca => 'foo', :fr => 'bar', :jp => 'baz' } worker.keys = keys worker.instance_variable_get(:@keys).should eql keys end end context "private methods" do describe "#build_query" do let(:query) { worker.send(:build_query) } it "canonicalizes parameters" do query.should match /Service=([^&]+)&Timestamp=([^&]+)&Version=([^&]+)/ end it "includes the key for the current locale" do worker.instance_variable_set(:@keys, { :us => 'foo' }) query.should include 'AWSAccessKeyId=foo' end it "includes a timestamp" do query.should include 'Timestamp=' end it "sorts parameters" do worker.parameters["AAA"] = "foo" query.should match /^AAA=foo/ end it "converts a parameter whose value is an array to a string" do worker.parameters["Foo"] = ["bar", "baz"] query.should match /Foo=bar%2Cbaz/ end it "handles integer parameter values" do worker.parameters["Foo"] = 1 query.should match /Foo=1/ end it "handles floating-point parameter values" do worker.parameters["Foo"] = 1.0 query.should match /Foo=1/ end end describe "#host" do it "returns a host" do worker.locale = "fr" worker.send(:host).should eql "ecs.amazonaws.fr" end end describe "#build_signed_query" do it "returns a signed query string" do query = worker.send :build_signed_query query.should match /&Signature=.*/ end end describe "#timestamp" do it "returns a timestamp" do worker.send(:timestamp)["Timestamp"].should match /^\d+-\d+-\d+T\d+:\d+:\d+Z$/ end end describe "#uri" do it "returns the URI with which to query Amazon" do worker.send(:uri).should be_an_instance_of URI::HTTP end end end end end Proper formatting require "spec_helper" module Sucker describe Request do use_vcr_cassette "unit/sucker/request", :record => :new_episodes let(:worker) do Sucker.new( :locale => "us", :key => "key", :secret => "secret") end describe ".new" do it "sets default parameters" do default_parameters = { "Service" => "AWSECommerceService", "Version" => Sucker::CURRENT_AMAZON_API_VERSION } worker.parameters.should include default_parameters end end describe "#<<" do it "merges a hash into the parameters" do worker << { "foo" => "bar" } worker.parameters["foo"].should eql "bar" end end describe "#version=" do it "sets the Amazon API version" do worker.version = "foo" worker.parameters["Version"].should eql "foo" end end describe "#associate_tag" do it "returns the associate tag for the current locale" do worker.instance_variable_set(:@associate_tags, { :us => 'foo-bar'}) worker.associate_tag.should eql 'foo-bar' end it "returns nil if an associate tag is not set for the current locale" do worker.associate_tag.should eql nil end end describe "#associate_tag=" do it "sets the associate tag for the current locale" do worker.associate_tag = "foo-bar" associate_tags = worker.instance_variable_get(:@associate_tags) associate_tags.keys.size.should eql 1 associate_tags[:us].should eql 'foo-bar' worker.associate_tag.should eql 'foo-bar' end end describe "#associate_tags=" do it "sets associate tags for the locales" do tags = { :us => 'foo', :uk => 'bar', :de => 'baz', :ca => 'foo', :fr => 'bar', :jp => 'baz' } worker.associate_tags = tags worker.instance_variable_get(:@associate_tags).should eql tags end end describe "#curl_opts" do it "returns options for curl" do worker.curl_opts.should be_an_instance_of Hash end context "when given a block" do it "yields options for curl" do worker.curl_opts { |c| c.interface = "eth1" } worker.curl_opts[:interface].should eql "eth1" end end end describe "#get" do it "returns a response" do worker.get.class.ancestors.should include Response end it "raises an argument error if no key is provided" do worker.key = nil expect do worker.get end.to raise_error(/AWS access key missing/) end it "raises an argument error if no locale is provided" do worker.locale = nil expect do worker.get end.to raise_error(/Locale missing/) end end describe "#get_all" do it "returns an array of responses" do responses = worker.get_all responses.should be_an_instance_of Array responses.each { |resp| resp.should be_an_instance_of Response } end context "when given a block" do it "yields responses" do count = 0 worker.get_all do |resp| resp.should be_an_instance_of Response count += 1 end count.should eql Request::HOSTS.size end end end describe "#key" do it "returns the Amazon AWS access key for the current locale" do worker.instance_variable_set(:@keys, { :us => 'foo' }) worker.key.should eql 'foo' end end describe "#key=" do it "sets a global Amazon AWS access key" do worker.key = "foo" keys = worker.instance_variable_get(:@keys) keys.size.should eql Request::HOSTS.size keys.values.uniq.should eql ["foo"] end end describe "#keys=" do it "sets distinct Amazon AWS access keys for the locales" do keys = { :us => 'foo', :uk => 'bar', :de => 'baz', :ca => 'foo', :fr => 'bar', :jp => 'baz' } worker.keys = keys worker.instance_variable_get(:@keys).should eql keys end end context "private methods" do describe "#build_query" do let(:query) { worker.send(:build_query) } it "canonicalizes parameters" do query.should match /Service=([^&]+)&Timestamp=([^&]+)&Version=([^&]+)/ end it "includes the key for the current locale" do worker.instance_variable_set(:@keys, { :us => 'foo' }) query.should include 'AWSAccessKeyId=foo' end it "includes a timestamp" do query.should include 'Timestamp=' end it "sorts parameters" do worker.parameters["AAA"] = "foo" query.should match /^AAA=foo/ end it "converts a parameter whose value is an array to a string" do worker.parameters["Foo"] = ["bar", "baz"] query.should match /Foo=bar%2Cbaz/ end it "handles integer parameter values" do worker.parameters["Foo"] = 1 query.should match /Foo=1/ end it "handles floating-point parameter values" do worker.parameters["Foo"] = 1.0 query.should match /Foo=1/ end end describe "#host" do it "returns a host" do worker.locale = "fr" worker.send(:host).should eql "ecs.amazonaws.fr" end end describe "#build_signed_query" do it "returns a signed query string" do query = worker.send :build_signed_query query.should match /&Signature=.*/ end end describe "#timestamp" do it "returns a timestamp" do worker.send(:timestamp)["Timestamp"].should match /^\d+-\d+-\d+T\d+:\d+:\d+Z$/ end end describe "#uri" do it "returns the URI with which to query Amazon" do worker.send(:uri).should be_an_instance_of URI::HTTP end end end end end
class Comby < Formula desc "Tool for changing code across many languages" homepage "https://comby.dev" url "https://github.com/comby-tools/comby/archive/0.13.1.tar.gz" sha256 "b9d8592070ba9912c82ce9eaf620b78dd92717f422cd94df5d04c9fb443196bd" bottle do cellar :any sha256 "9af7377e3a37fbbc19896b40a61dc5718396a080d752c3a9557b0b3e3faf96d7" => :catalina sha256 "d1d4351daf973c806da71fa970986837a6bf2ed0897f6178ad6909a2bc089f78" => :mojave sha256 "2741164707a47a18d9a750420d306730825332098be73f7eb02f29530f8b74aa" => :high_sierra end depends_on "gmp" => :build depends_on "ocaml" => :build depends_on "opam" => :build depends_on "pcre" depends_on "pkg-config" uses_from_macos "m4" uses_from_macos "unzip" uses_from_macos "zlib" def install ENV.deparallelize opamroot = buildpath/".opam" ENV["OPAMROOT"] = opamroot ENV["OPAMYES"] = "1" system "opam", "init", "--no-setup", "--disable-sandboxing" system "opam", "config", "exec", "--", "opam", "install", ".", "--deps-only", "-y" ENV.prepend_path "LIBRARY_PATH", opamroot/"default/lib/hack_parallel" # for -lhp system "opam", "config", "exec", "--", "make", "release" bin.install "_build/default/src/main.exe" => "comby" end test do assert_equal version.to_s, shell_output("#{bin}/comby -version").strip expect = <<~EXPECT --- /dev/null +++ /dev/null @@ -1,3 +1,3 @@ int main(void) { - printf("hello world!"); + printf("comby, hello!"); } EXPECT input = <<~INPUT EOF int main(void) { printf("hello world!"); } EOF INPUT match = 'printf(":[1] :[2]!")' rewrite = 'printf("comby, :[1]!")' assert_equal expect, shell_output("#{bin}/comby '#{match}' '#{rewrite}' .c -stdin -diff << #{input}") end end comby: update 0.13.1 bottle. class Comby < Formula desc "Tool for changing code across many languages" homepage "https://comby.dev" url "https://github.com/comby-tools/comby/archive/0.13.1.tar.gz" sha256 "b9d8592070ba9912c82ce9eaf620b78dd92717f422cd94df5d04c9fb443196bd" bottle do cellar :any sha256 "1465b299e04912cc3d1ef18af072e19404687af4b0ac1824d39f201aa13fe4d4" => :catalina sha256 "f252a786ccda897d815bbf7dd84769544252bd5ef77257e5c05403ac4d83d4e1" => :mojave sha256 "05bbe36e5a63af506ba97103a08bec8a95e9f97af15f22678b8254891c09dfa7" => :high_sierra end depends_on "gmp" => :build depends_on "ocaml" => :build depends_on "opam" => :build depends_on "pcre" depends_on "pkg-config" uses_from_macos "m4" uses_from_macos "unzip" uses_from_macos "zlib" def install ENV.deparallelize opamroot = buildpath/".opam" ENV["OPAMROOT"] = opamroot ENV["OPAMYES"] = "1" system "opam", "init", "--no-setup", "--disable-sandboxing" system "opam", "config", "exec", "--", "opam", "install", ".", "--deps-only", "-y" ENV.prepend_path "LIBRARY_PATH", opamroot/"default/lib/hack_parallel" # for -lhp system "opam", "config", "exec", "--", "make", "release" bin.install "_build/default/src/main.exe" => "comby" end test do assert_equal version.to_s, shell_output("#{bin}/comby -version").strip expect = <<~EXPECT --- /dev/null +++ /dev/null @@ -1,3 +1,3 @@ int main(void) { - printf("hello world!"); + printf("comby, hello!"); } EXPECT input = <<~INPUT EOF int main(void) { printf("hello world!"); } EOF INPUT match = 'printf(":[1] :[2]!")' rewrite = 'printf("comby, :[1]!")' assert_equal expect, shell_output("#{bin}/comby '#{match}' '#{rewrite}' .c -stdin -diff << #{input}") end end
# enabling the load of files from root (on RSpec) $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../') require 'spec/configuration' require 'lib/waz-blobs' describe "Windows Azure Containers interface API" do it "should should throw when no container name is provided" do lambda {WAZ::Blobs::Container.new}.should raise_error(WAZ::Storage::InvalidOption) end it "should list containers" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:list_containers).returns([{:name => 'my-container'}, {:name => 'other container'}]) containers = WAZ::Blobs::Container.list containers.size.should == 2 containers.first().name.should == "my-container" end it "should be able to create a container" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:create_container).with("my-container") container = WAZ::Blobs::Container.create('my-container') container.name.should == 'my-container' end it "should be able to return a container by name" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:name => "container-name", :x_ms_meta_name => "container-name"}).twice container = WAZ::Blobs::Container.find('container-name') container.metadata[:x_ms_meta_name].should == 'container-name' end it "should be able to return container metadata" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:create_container).with("container-name") WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) container = WAZ::Blobs::Container.create('container-name') container.metadata[:x_ms_meta_name].should == 'container-name' end it "should be able to say whether the container is public or not" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:get_container_acl).with("container-name").returns(false) container = WAZ::Blobs::Container.find("container-name") container.public_access?.should == false end it "should be able to set whether the container is public or not" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:set_container_acl).with('container-name', false) container = WAZ::Blobs::Container.find("container-name") container.public_access = false end it "should be able to set container properties" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:set_container_properties).with("container-name", {:x_ms_meta_meta1 => "meta1"}).returns(false) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) container = WAZ::Blobs::Container.find("container-name") container.put_properties!(:x_ms_meta_meta1 => "meta1") end it "should be able to return a list files within the container" do expected_blobs = [ {:name => 'blob1', :url => 'url', :content_type => 'app/xml'}, {:name => 'blob2', :url => 'url', :content_type => 'app/xml'} ] WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:list_blobs).with("container-name").returns(expected_blobs) container = WAZ::Blobs::Container.find("container-name") container_blobs = container.blobs container_blobs.first().name = expected_blobs[0][:name] container_blobs[1].name = expected_blobs[1][:name] end it "should be able to return statistics of the container" do options = {:maxresults => 100, :marker => "marker"} expected_values = {:size => 200, :files => 100, :next_marker => "next-marker"} WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:statistics).with("container-name", options).returns(expected_values) container = WAZ::Blobs::Container.find("container-name") statistics = container.statistics(options) statistics[:size].should == 200 statistics[:files].should == 100 statistics[:next_marker].should == "next-marker" end it "should destroy container" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:delete_container).with("container-name") container = WAZ::Blobs::Container.find("container-name") container.destroy! end it "should be able to return null when container not found by name" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").raises(RestClient::ResourceNotFound) container = WAZ::Blobs::Container.find('container-name') container.nil?.should == true end it "should be able to put blob inside given container" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:put_blob).with("container-name/my_blob", "this is the blob content", "text/plain; charset=UTF-8", {:x_ms_meta_custom_property => "customValue"}) container = WAZ::Blobs::Container.find("container-name") blob = container.store("my_blob", "this is the blob content", "text/plain; charset=UTF-8", {:x_ms_meta_custom_property => "customValue"}) blob.name.should == "my_blob" blob.url.should == "http://my_account.blob.core.windows.net/container-name/my_blob" blob.content_type.should == "text/plain; charset=UTF-8" end it "should be able to upload a stream to a blob inside a given container" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:put_block).with("container-name/my_blob", Base64.encode64('%064d' % 0), "this is the blob content") WAZ::Blobs::Service.any_instance.expects(:put_block_list).with("container-name/my_blob", [Base64.encode64('%064d' % 0)], "text/plain; charset=UTF-8", {:x_ms_meta_custom_property => "customValue"}) container = WAZ::Blobs::Container.find("container-name") blob = container.upload("my_blob", StringIO.new("this is the blob content"), "text/plain; charset=UTF-8", {:x_ms_meta_custom_property => "customValue"}) blob.name.should == "my_blob" blob.url.should == "http://my_account.blob.core.windows.net/container-name/my_blob" blob.content_type.should == "text/plain; charset=UTF-8" end it "should be able to put blob inside given container (when simulating fake containers)" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:put_blob).with("container-name/fake-container/blob", "this is the blob content", "text/plain; charset=UTF-8", {:x_ms_meta_custom_property => "customValue"}) container = WAZ::Blobs::Container.find("container-name") blob = container.store("/fake-container/blob", "this is the blob content", "text/plain; charset=UTF-8", {:x_ms_meta_custom_property => "customValue"}) blob.name.should == "fake-container/blob" blob.url.should == "http://my_account.blob.core.windows.net/container-name/fake-container/blob" blob.content_type.should == "text/plain; charset=UTF-8" end it "should return a specific blob for the given container" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:get_blob_properties).with("container-name/my_blob").returns({ :content_type => "application/xml" }) container = WAZ::Blobs::Container.find("container-name") blob = container['my_blob'] blob.name.should == 'my_blob' blob.content_type.should == 'application/xml' blob.url.should == 'http://my_account.blob.core.windows.net/container-name/my_blob' end it "should return nil when the file does not exist" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:get_blob_properties).with("container-name/my_blob").raises(RestClient::ResourceNotFound) container = WAZ::Blobs::Container.find('container-name') blob = container['my_blob'] blob.nil?.should == true end it "should raise an exception when container name starts with - (hypen)" do lambda { WAZ::Blobs::Container.create('-container') }.should raise_error(WAZ::Storage::InvalidParameterValue) end it "should raise an exception when container name ends with - (hypen)" do lambda { WAZ::Blobs::Container.create('container-') }.should raise_error(WAZ::Storage::InvalidParameterValue) end it "should raise an exception when container name is less than 3" do lambda { WAZ::Blobs::Container.create('co') }.should raise_error(WAZ::Storage::InvalidParameterValue) end it "should raise an exception when container name is longer than 63" do lambda { WAZ::Blobs::Container.create('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') }.should raise_error(WAZ::Storage::InvalidParameterValue) end end Added '$root' container name test Added a simple check to verify that naming a container with '$root' won't raise and exception. Added another one to verify that '$roots' (simple variation) will not be permitted, i.e raise and exception # enabling the load of files from root (on RSpec) $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../') require 'spec/configuration' require 'lib/waz-blobs' describe "Windows Azure Containers interface API" do it "should should throw when no container name is provided" do lambda {WAZ::Blobs::Container.new}.should raise_error(WAZ::Storage::InvalidOption) end it "should list containers" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:list_containers).returns([{:name => 'my-container'}, {:name => 'other container'}]) containers = WAZ::Blobs::Container.list containers.size.should == 2 containers.first().name.should == "my-container" end it "should be able to create a container" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:create_container).with("my-container") container = WAZ::Blobs::Container.create('my-container') container.name.should == 'my-container' end it "should be able to return a container by name" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:name => "container-name", :x_ms_meta_name => "container-name"}).twice container = WAZ::Blobs::Container.find('container-name') container.metadata[:x_ms_meta_name].should == 'container-name' end it "should be able to return container metadata" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:create_container).with("container-name") WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) container = WAZ::Blobs::Container.create('container-name') container.metadata[:x_ms_meta_name].should == 'container-name' end it "should be able to say whether the container is public or not" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:get_container_acl).with("container-name").returns(false) container = WAZ::Blobs::Container.find("container-name") container.public_access?.should == false end it "should be able to set whether the container is public or not" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:set_container_acl).with('container-name', false) container = WAZ::Blobs::Container.find("container-name") container.public_access = false end it "should be able to set container properties" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:set_container_properties).with("container-name", {:x_ms_meta_meta1 => "meta1"}).returns(false) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) container = WAZ::Blobs::Container.find("container-name") container.put_properties!(:x_ms_meta_meta1 => "meta1") end it "should be able to return a list files within the container" do expected_blobs = [ {:name => 'blob1', :url => 'url', :content_type => 'app/xml'}, {:name => 'blob2', :url => 'url', :content_type => 'app/xml'} ] WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:list_blobs).with("container-name").returns(expected_blobs) container = WAZ::Blobs::Container.find("container-name") container_blobs = container.blobs container_blobs.first().name = expected_blobs[0][:name] container_blobs[1].name = expected_blobs[1][:name] end it "should be able to return statistics of the container" do options = {:maxresults => 100, :marker => "marker"} expected_values = {:size => 200, :files => 100, :next_marker => "next-marker"} WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:statistics).with("container-name", options).returns(expected_values) container = WAZ::Blobs::Container.find("container-name") statistics = container.statistics(options) statistics[:size].should == 200 statistics[:files].should == 100 statistics[:next_marker].should == "next-marker" end it "should destroy container" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:delete_container).with("container-name") container = WAZ::Blobs::Container.find("container-name") container.destroy! end it "should be able to return null when container not found by name" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").raises(RestClient::ResourceNotFound) container = WAZ::Blobs::Container.find('container-name') container.nil?.should == true end it "should be able to put blob inside given container" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:put_blob).with("container-name/my_blob", "this is the blob content", "text/plain; charset=UTF-8", {:x_ms_meta_custom_property => "customValue"}) container = WAZ::Blobs::Container.find("container-name") blob = container.store("my_blob", "this is the blob content", "text/plain; charset=UTF-8", {:x_ms_meta_custom_property => "customValue"}) blob.name.should == "my_blob" blob.url.should == "http://my_account.blob.core.windows.net/container-name/my_blob" blob.content_type.should == "text/plain; charset=UTF-8" end it "should be able to upload a stream to a blob inside a given container" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:put_block).with("container-name/my_blob", Base64.encode64('%064d' % 0), "this is the blob content") WAZ::Blobs::Service.any_instance.expects(:put_block_list).with("container-name/my_blob", [Base64.encode64('%064d' % 0)], "text/plain; charset=UTF-8", {:x_ms_meta_custom_property => "customValue"}) container = WAZ::Blobs::Container.find("container-name") blob = container.upload("my_blob", StringIO.new("this is the blob content"), "text/plain; charset=UTF-8", {:x_ms_meta_custom_property => "customValue"}) blob.name.should == "my_blob" blob.url.should == "http://my_account.blob.core.windows.net/container-name/my_blob" blob.content_type.should == "text/plain; charset=UTF-8" end it "should be able to put blob inside given container (when simulating fake containers)" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:put_blob).with("container-name/fake-container/blob", "this is the blob content", "text/plain; charset=UTF-8", {:x_ms_meta_custom_property => "customValue"}) container = WAZ::Blobs::Container.find("container-name") blob = container.store("/fake-container/blob", "this is the blob content", "text/plain; charset=UTF-8", {:x_ms_meta_custom_property => "customValue"}) blob.name.should == "fake-container/blob" blob.url.should == "http://my_account.blob.core.windows.net/container-name/fake-container/blob" blob.content_type.should == "text/plain; charset=UTF-8" end it "should return a specific blob for the given container" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:get_blob_properties).with("container-name/my_blob").returns({ :content_type => "application/xml" }) container = WAZ::Blobs::Container.find("container-name") blob = container['my_blob'] blob.name.should == 'my_blob' blob.content_type.should == 'application/xml' blob.url.should == 'http://my_account.blob.core.windows.net/container-name/my_blob' end it "should return nil when the file does not exist" do WAZ::Storage::Base.stubs(:default_connection).returns({:account_name => "my_account", :access_key => "key"}) WAZ::Blobs::Service.any_instance.expects(:get_container_properties).with("container-name").returns({:x_ms_meta_name => "container-name"}) WAZ::Blobs::Service.any_instance.expects(:get_blob_properties).with("container-name/my_blob").raises(RestClient::ResourceNotFound) container = WAZ::Blobs::Container.find('container-name') blob = container['my_blob'] blob.nil?.should == true end it "should raise an exception when container name starts with - (hypen)" do lambda { WAZ::Blobs::Container.create('-container') }.should raise_error(WAZ::Storage::InvalidParameterValue) end it "should raise an exception when container name ends with - (hypen)" do lambda { WAZ::Blobs::Container.create('container-') }.should raise_error(WAZ::Storage::InvalidParameterValue) end it "should raise an exception when container name is less than 3" do lambda { WAZ::Blobs::Container.create('co') }.should raise_error(WAZ::Storage::InvalidParameterValue) end it "should raise an exception when container name is longer than 63" do lambda { WAZ::Blobs::Container.create('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') }.should raise_error(WAZ::Storage::InvalidParameterValue) end it "should raise an exception when container name include dollar but isn't root" do lambda { WAZ::Blobs::Container.create('$roots') }.should raise_error(WAZ::Storage::InvalidParameterValue) end it "should not raise an exception when container name is '$root'" do lambda { WAZ::Blobs::Container.create('$root') }.should_not raise_error(WAZ::Storage::InvalidParameterValue) end end
class Comby < Formula desc "Tool for changing code across many languages" homepage "https://comby.dev" url "https://github.com/comby-tools/comby/archive/0.18.3.tar.gz" sha256 "554ec0fa7c8da8aa9ae74bdd6d3f7ba32e0f553ff9bb12c7add6541cd4ec27d8" license "Apache-2.0" bottle do sha256 "959812e91094978e5373616ed3063ba60d3c931cb9aa01d25423f63afda70aa0" => :catalina sha256 "f939a6986d210cdd1c670f22c43ea2cb0826e57efc3b62a192e2b4271a7505e8" => :mojave sha256 "fcd39a3f32104e6fe6141ea87c93c334f2c30c57f44500070f8a8a0045e0e785" => :high_sierra end depends_on "gmp" => :build depends_on "ocaml" => :build depends_on "opam" => :build depends_on "pcre" depends_on "pkg-config" uses_from_macos "m4" uses_from_macos "unzip" uses_from_macos "zlib" on_linux do depends_on "sqlite" end def install ENV.deparallelize opamroot = buildpath/".opam" ENV["OPAMROOT"] = opamroot ENV["OPAMYES"] = "1" system "opam", "init", "--no-setup", "--disable-sandboxing" system "opam", "config", "exec", "--", "opam", "install", ".", "--deps-only", "-y" ENV.prepend_path "LIBRARY_PATH", opamroot/"default/lib/hack_parallel" # for -lhp system "opam", "config", "exec", "--", "make", "release" bin.install "_build/default/src/main.exe" => "comby" end test do expect = <<~EXPECT --- /dev/null +++ /dev/null @@ -1,3 +1,3 @@ int main(void) { - printf("hello world!"); + printf("comby, hello!"); } EXPECT input = <<~INPUT EOF int main(void) { printf("hello world!"); } EOF INPUT match = 'printf(":[1] :[2]!")' rewrite = 'printf("comby, :[1]!")' assert_equal expect, shell_output("#{bin}/comby '#{match}' '#{rewrite}' .c -stdin -diff << #{input}") end end comby: update 0.18.3 bottle. class Comby < Formula desc "Tool for changing code across many languages" homepage "https://comby.dev" url "https://github.com/comby-tools/comby/archive/0.18.3.tar.gz" sha256 "554ec0fa7c8da8aa9ae74bdd6d3f7ba32e0f553ff9bb12c7add6541cd4ec27d8" license "Apache-2.0" bottle do sha256 "959812e91094978e5373616ed3063ba60d3c931cb9aa01d25423f63afda70aa0" => :catalina sha256 "f939a6986d210cdd1c670f22c43ea2cb0826e57efc3b62a192e2b4271a7505e8" => :mojave sha256 "fcd39a3f32104e6fe6141ea87c93c334f2c30c57f44500070f8a8a0045e0e785" => :high_sierra sha256 "5a1e926baaf54b6d33227c3f854651a4f3fb8678be33e5a25c5606578011c266" => :x86_64_linux end depends_on "gmp" => :build depends_on "ocaml" => :build depends_on "opam" => :build depends_on "pcre" depends_on "pkg-config" uses_from_macos "m4" uses_from_macos "unzip" uses_from_macos "zlib" on_linux do depends_on "sqlite" end def install ENV.deparallelize opamroot = buildpath/".opam" ENV["OPAMROOT"] = opamroot ENV["OPAMYES"] = "1" system "opam", "init", "--no-setup", "--disable-sandboxing" system "opam", "config", "exec", "--", "opam", "install", ".", "--deps-only", "-y" ENV.prepend_path "LIBRARY_PATH", opamroot/"default/lib/hack_parallel" # for -lhp system "opam", "config", "exec", "--", "make", "release" bin.install "_build/default/src/main.exe" => "comby" end test do expect = <<~EXPECT --- /dev/null +++ /dev/null @@ -1,3 +1,3 @@ int main(void) { - printf("hello world!"); + printf("comby, hello!"); } EXPECT input = <<~INPUT EOF int main(void) { printf("hello world!"); } EOF INPUT match = 'printf(":[1] :[2]!")' rewrite = 'printf("comby, :[1]!")' assert_equal expect, shell_output("#{bin}/comby '#{match}' '#{rewrite}' .c -stdin -diff << #{input}") end end
class Conan < Formula include Language::Python::Virtualenv desc "Distributed, open source, package manager for C/C++" homepage "https://conan.io" url "https://files.pythonhosted.org/packages/7d/40/81ec3868964e21b251f4462d956ffffe619f915839fdcdd680286762e5a9/conan-1.42.0.tar.gz" sha256 "ad19a75ecaefc1ce67dc73cda92a502bad62a6961f1ebd6bf034045a7cb1323d" license "MIT" head "https://github.com/conan-io/conan.git", branch: "develop" bottle do sha256 cellar: :any_skip_relocation, arm64_big_sur: "25be2ea7fab5a6857229f17d3c2aed147b5585c6438d3a3132ba1be2b05e6885" sha256 cellar: :any_skip_relocation, big_sur: "e46f15bb4128fd1a438397ba2bead21d18a6559ca07e4ce6183175dcbb770db3" sha256 cellar: :any_skip_relocation, catalina: "ac3685af58f2739f0920f20eb7276e54f43e632e7179a43489262a9c8ea757cb" sha256 cellar: :any_skip_relocation, x86_64_linux: "afcf64fd04dff0e2c2166eff97a1c3051ded58f54cff5b58c5ba2583a07bb6be" end depends_on "pkg-config" => :build depends_on "cmake" => :test depends_on "libffi" depends_on "openssl@1.1" depends_on "python@3.10" depends_on "six" resource "bottle" do url "https://files.pythonhosted.org/packages/ea/80/3d2dca1562ffa1929017c74635b4cb3645a352588de89e90d0bb53af3317/bottle-0.12.19.tar.gz" sha256 "a9d73ffcbc6a1345ca2d7949638db46349f5b2b77dac65d6494d45c23628da2c" end resource "certifi" do url "https://files.pythonhosted.org/packages/6c/ae/d26450834f0acc9e3d1f74508da6df1551ceab6c2ce0766a593362d6d57f/certifi-2021.10.8.tar.gz" sha256 "78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872" end resource "charset-normalizer" do url "https://files.pythonhosted.org/packages/9f/c5/334c019f92c26e59637bb42bd14a190428874b2b2de75a355da394cf16c1/charset-normalizer-2.0.7.tar.gz" sha256 "e019de665e2bcf9c2b64e2e5aa025fa991da8720daa3c1138cadd2fd1856aed0" end resource "colorama" do url "https://files.pythonhosted.org/packages/1f/bb/5d3246097ab77fa083a61bd8d3d527b7ae063c7d8e8671b1cf8c4ec10cbe/colorama-0.4.4.tar.gz" sha256 "5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b" end resource "distro" do url "https://files.pythonhosted.org/packages/a5/26/256fa167fe1bf8b97130b4609464be20331af8a3af190fb636a8a7efd7a2/distro-1.6.0.tar.gz" sha256 "83f5e5a09f9c5f68f60173de572930effbcc0287bb84fdc4426cb4168c088424" end resource "fasteners" do url "https://files.pythonhosted.org/packages/28/e4/2888d41cdbd405828ccdb9a8536c5919939c2f4c6ab9b2ba63e9bd2570d5/fasteners-0.16.3.tar.gz" sha256 "b1ab4e5adfbc28681ce44b3024421c4f567e705cc3963c732bf1cba3348307de" end resource "idna" do url "https://files.pythonhosted.org/packages/62/08/e3fc7c8161090f742f504f40b1bccbfc544d4a4e09eb774bf40aafce5436/idna-3.3.tar.gz" sha256 "9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d" end resource "Jinja2" do url "https://files.pythonhosted.org/packages/4f/e7/65300e6b32e69768ded990494809106f87da1d436418d5f1367ed3966fd7/Jinja2-2.11.3.tar.gz" sha256 "a6d58433de0ae800347cab1fa3043cebbabe8baa9d29e668f1c768cb87a333c6" end resource "MarkupSafe" do url "https://files.pythonhosted.org/packages/bf/10/ff66fea6d1788c458663a84d88787bae15d45daa16f6b3ef33322a51fc7e/MarkupSafe-2.0.1.tar.gz" sha256 "594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a" end resource "node-semver" do url "https://files.pythonhosted.org/packages/f1/4e/1d9a619dcfd9f42d0e874a5b47efa0923e84829886e6a47b45328a1f32f1/node-semver-0.6.1.tar.gz" sha256 "4016f7c1071b0493f18db69ea02d3763e98a633606d7c7beca811e53b5ac66b7" end resource "patch-ng" do url "https://files.pythonhosted.org/packages/c1/b2/ad3cd464101435fdf642d20e0e5e782b4edaef1affdf2adfc5c75660225b/patch-ng-1.17.4.tar.gz" sha256 "627abc5bd723c8b481e96849b9734b10065426224d4d22cd44137004ac0d4ace" end resource "pluginbase" do url "https://files.pythonhosted.org/packages/f3/07/753451e80d2b0bf3bceec1162e8d23638ac3cb18d1c38ad340c586e90b42/pluginbase-1.0.1.tar.gz" sha256 "ff6c33a98fce232e9c73841d787a643de574937069f0d18147028d70d7dee287" end resource "Pygments" do url "https://files.pythonhosted.org/packages/b7/b3/5cba26637fe43500d4568d0ee7b7362de1fb29c0e158d50b4b69e9a40422/Pygments-2.10.0.tar.gz" sha256 "f398865f7eb6874156579fdf36bc840a03cab64d1cde9e93d68f46a425ec52c6" end resource "PyJWT" do url "https://files.pythonhosted.org/packages/2f/38/ff37a24c0243c5f45f5798bd120c0f873eeed073994133c084e1cf13b95c/PyJWT-1.7.1.tar.gz" sha256 "8d59a976fb773f3e6a39c85636357c4f0e242707394cadadd9814f5cbaa20e96" end resource "python-dateutil" do url "https://files.pythonhosted.org/packages/4c/c4/13b4776ea2d76c115c1d1b84579f3764ee6d57204f6be27119f13a61d0a9/python-dateutil-2.8.2.tar.gz" sha256 "0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86" end resource "PyYAML" do url "https://files.pythonhosted.org/packages/a0/a4/d63f2d7597e1a4b55aa3b4d6c5b029991d3b824b5bd331af8d4ab1ed687d/PyYAML-5.4.1.tar.gz" sha256 "607774cbba28732bfa802b54baa7484215f530991055bb562efbed5b2f20a45e" end resource "requests" do url "https://files.pythonhosted.org/packages/e7/01/3569e0b535fb2e4a6c384bdbed00c55b9d78b5084e0fb7f4d0bf523d7670/requests-2.26.0.tar.gz" sha256 "b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7" end resource "tqdm" do url "https://files.pythonhosted.org/packages/e3/c1/b3e42d5b659ca598508e2a9ef315d5eef0a970f874ef9d3b38d4578765bd/tqdm-4.62.3.tar.gz" sha256 "d359de7217506c9851b7869f3708d8ee53ed70a1b8edbba4dbcb47442592920d" end resource "urllib3" do url "https://files.pythonhosted.org/packages/80/be/3ee43b6c5757cabea19e75b8f46eaf05a2f5144107d7db48c7cf3a864f73/urllib3-1.26.7.tar.gz" sha256 "4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece" end def install virtualenv_install_with_resources end test do system bin/"conan", "search", "zlib", "--remote", "conancenter" system bin/"conan", "install", "zlib/1.2.11@", "--build" assert_predicate testpath/".conan/data/zlib/1.2.11", :exist? end end conan: update 1.42.0 bottle. class Conan < Formula include Language::Python::Virtualenv desc "Distributed, open source, package manager for C/C++" homepage "https://conan.io" url "https://files.pythonhosted.org/packages/7d/40/81ec3868964e21b251f4462d956ffffe619f915839fdcdd680286762e5a9/conan-1.42.0.tar.gz" sha256 "ad19a75ecaefc1ce67dc73cda92a502bad62a6961f1ebd6bf034045a7cb1323d" license "MIT" head "https://github.com/conan-io/conan.git", branch: "develop" bottle do sha256 cellar: :any_skip_relocation, arm64_monterey: "a4afe98decfd901de70f01252e4d8cb11616e3f2696b81863e73319b56262c3b" sha256 cellar: :any_skip_relocation, arm64_big_sur: "25be2ea7fab5a6857229f17d3c2aed147b5585c6438d3a3132ba1be2b05e6885" sha256 cellar: :any_skip_relocation, monterey: "b1bc7950d46bc3ddd4e8f1c2db301cb25b4939c4a732634ff49a008bff001321" sha256 cellar: :any_skip_relocation, big_sur: "e46f15bb4128fd1a438397ba2bead21d18a6559ca07e4ce6183175dcbb770db3" sha256 cellar: :any_skip_relocation, catalina: "ac3685af58f2739f0920f20eb7276e54f43e632e7179a43489262a9c8ea757cb" sha256 cellar: :any_skip_relocation, x86_64_linux: "afcf64fd04dff0e2c2166eff97a1c3051ded58f54cff5b58c5ba2583a07bb6be" end depends_on "pkg-config" => :build depends_on "cmake" => :test depends_on "libffi" depends_on "openssl@1.1" depends_on "python@3.10" depends_on "six" resource "bottle" do url "https://files.pythonhosted.org/packages/ea/80/3d2dca1562ffa1929017c74635b4cb3645a352588de89e90d0bb53af3317/bottle-0.12.19.tar.gz" sha256 "a9d73ffcbc6a1345ca2d7949638db46349f5b2b77dac65d6494d45c23628da2c" end resource "certifi" do url "https://files.pythonhosted.org/packages/6c/ae/d26450834f0acc9e3d1f74508da6df1551ceab6c2ce0766a593362d6d57f/certifi-2021.10.8.tar.gz" sha256 "78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872" end resource "charset-normalizer" do url "https://files.pythonhosted.org/packages/9f/c5/334c019f92c26e59637bb42bd14a190428874b2b2de75a355da394cf16c1/charset-normalizer-2.0.7.tar.gz" sha256 "e019de665e2bcf9c2b64e2e5aa025fa991da8720daa3c1138cadd2fd1856aed0" end resource "colorama" do url "https://files.pythonhosted.org/packages/1f/bb/5d3246097ab77fa083a61bd8d3d527b7ae063c7d8e8671b1cf8c4ec10cbe/colorama-0.4.4.tar.gz" sha256 "5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b" end resource "distro" do url "https://files.pythonhosted.org/packages/a5/26/256fa167fe1bf8b97130b4609464be20331af8a3af190fb636a8a7efd7a2/distro-1.6.0.tar.gz" sha256 "83f5e5a09f9c5f68f60173de572930effbcc0287bb84fdc4426cb4168c088424" end resource "fasteners" do url "https://files.pythonhosted.org/packages/28/e4/2888d41cdbd405828ccdb9a8536c5919939c2f4c6ab9b2ba63e9bd2570d5/fasteners-0.16.3.tar.gz" sha256 "b1ab4e5adfbc28681ce44b3024421c4f567e705cc3963c732bf1cba3348307de" end resource "idna" do url "https://files.pythonhosted.org/packages/62/08/e3fc7c8161090f742f504f40b1bccbfc544d4a4e09eb774bf40aafce5436/idna-3.3.tar.gz" sha256 "9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d" end resource "Jinja2" do url "https://files.pythonhosted.org/packages/4f/e7/65300e6b32e69768ded990494809106f87da1d436418d5f1367ed3966fd7/Jinja2-2.11.3.tar.gz" sha256 "a6d58433de0ae800347cab1fa3043cebbabe8baa9d29e668f1c768cb87a333c6" end resource "MarkupSafe" do url "https://files.pythonhosted.org/packages/bf/10/ff66fea6d1788c458663a84d88787bae15d45daa16f6b3ef33322a51fc7e/MarkupSafe-2.0.1.tar.gz" sha256 "594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a" end resource "node-semver" do url "https://files.pythonhosted.org/packages/f1/4e/1d9a619dcfd9f42d0e874a5b47efa0923e84829886e6a47b45328a1f32f1/node-semver-0.6.1.tar.gz" sha256 "4016f7c1071b0493f18db69ea02d3763e98a633606d7c7beca811e53b5ac66b7" end resource "patch-ng" do url "https://files.pythonhosted.org/packages/c1/b2/ad3cd464101435fdf642d20e0e5e782b4edaef1affdf2adfc5c75660225b/patch-ng-1.17.4.tar.gz" sha256 "627abc5bd723c8b481e96849b9734b10065426224d4d22cd44137004ac0d4ace" end resource "pluginbase" do url "https://files.pythonhosted.org/packages/f3/07/753451e80d2b0bf3bceec1162e8d23638ac3cb18d1c38ad340c586e90b42/pluginbase-1.0.1.tar.gz" sha256 "ff6c33a98fce232e9c73841d787a643de574937069f0d18147028d70d7dee287" end resource "Pygments" do url "https://files.pythonhosted.org/packages/b7/b3/5cba26637fe43500d4568d0ee7b7362de1fb29c0e158d50b4b69e9a40422/Pygments-2.10.0.tar.gz" sha256 "f398865f7eb6874156579fdf36bc840a03cab64d1cde9e93d68f46a425ec52c6" end resource "PyJWT" do url "https://files.pythonhosted.org/packages/2f/38/ff37a24c0243c5f45f5798bd120c0f873eeed073994133c084e1cf13b95c/PyJWT-1.7.1.tar.gz" sha256 "8d59a976fb773f3e6a39c85636357c4f0e242707394cadadd9814f5cbaa20e96" end resource "python-dateutil" do url "https://files.pythonhosted.org/packages/4c/c4/13b4776ea2d76c115c1d1b84579f3764ee6d57204f6be27119f13a61d0a9/python-dateutil-2.8.2.tar.gz" sha256 "0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86" end resource "PyYAML" do url "https://files.pythonhosted.org/packages/a0/a4/d63f2d7597e1a4b55aa3b4d6c5b029991d3b824b5bd331af8d4ab1ed687d/PyYAML-5.4.1.tar.gz" sha256 "607774cbba28732bfa802b54baa7484215f530991055bb562efbed5b2f20a45e" end resource "requests" do url "https://files.pythonhosted.org/packages/e7/01/3569e0b535fb2e4a6c384bdbed00c55b9d78b5084e0fb7f4d0bf523d7670/requests-2.26.0.tar.gz" sha256 "b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7" end resource "tqdm" do url "https://files.pythonhosted.org/packages/e3/c1/b3e42d5b659ca598508e2a9ef315d5eef0a970f874ef9d3b38d4578765bd/tqdm-4.62.3.tar.gz" sha256 "d359de7217506c9851b7869f3708d8ee53ed70a1b8edbba4dbcb47442592920d" end resource "urllib3" do url "https://files.pythonhosted.org/packages/80/be/3ee43b6c5757cabea19e75b8f46eaf05a2f5144107d7db48c7cf3a864f73/urllib3-1.26.7.tar.gz" sha256 "4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece" end def install virtualenv_install_with_resources end test do system bin/"conan", "search", "zlib", "--remote", "conancenter" system bin/"conan", "install", "zlib/1.2.11@", "--build" assert_predicate testpath/".conan/data/zlib/1.2.11", :exist? end end
class Cppad < Formula desc "Differentiation of C++ Algorithms" homepage "https://www.coin-or.org/CppAD" # Stable versions have numbers of the form 201x0000.y url "https://github.com/coin-or/CppAD/archive/20180000.0.tar.gz" sha256 "a5226e4c5aa2ad6d95668f987b39939315bf134a0a793231984e6d42d6488cca" version_scheme 1 head "https://github.com/coin-or/CppAD.git" bottle do cellar :any_skip_relocation sha256 "340b46441aaa2b6e42397a4bd544b48bf5bf27a7323d93d841ce80ead80ab1ee" => :high_sierra sha256 "340b46441aaa2b6e42397a4bd544b48bf5bf27a7323d93d841ce80ead80ab1ee" => :sierra sha256 "340b46441aaa2b6e42397a4bd544b48bf5bf27a7323d93d841ce80ead80ab1ee" => :el_capitan end depends_on "cmake" => :build def install mkdir "build" do system "cmake", "..", *std_cmake_args, "-Dcppad_prefix=#{prefix}" system "make", "install" end pkgshare.install "example" end test do (testpath/"test.cpp").write <<~EOS #include <cassert> #include <cppad/utility/thread_alloc.hpp> int main(void) { extern bool acos(void); bool ok = acos(); assert(ok); return static_cast<int>(!ok); } EOS system ENV.cxx, "#{pkgshare}/example/general/acos.cpp", "-I#{include}", "test.cpp", "-o", "test" system "./test" end end cppad: update 20180000.0 bottle. class Cppad < Formula desc "Differentiation of C++ Algorithms" homepage "https://www.coin-or.org/CppAD" # Stable versions have numbers of the form 201x0000.y url "https://github.com/coin-or/CppAD/archive/20180000.0.tar.gz" sha256 "a5226e4c5aa2ad6d95668f987b39939315bf134a0a793231984e6d42d6488cca" version_scheme 1 head "https://github.com/coin-or/CppAD.git" bottle do cellar :any_skip_relocation sha256 "b34a0370d6dad092cddb2198d27ff976d2bd146aefbaf16673f35e711776eda7" => :high_sierra sha256 "b34a0370d6dad092cddb2198d27ff976d2bd146aefbaf16673f35e711776eda7" => :sierra sha256 "b34a0370d6dad092cddb2198d27ff976d2bd146aefbaf16673f35e711776eda7" => :el_capitan end depends_on "cmake" => :build def install mkdir "build" do system "cmake", "..", *std_cmake_args, "-Dcppad_prefix=#{prefix}" system "make", "install" end pkgshare.install "example" end test do (testpath/"test.cpp").write <<~EOS #include <cassert> #include <cppad/utility/thread_alloc.hpp> int main(void) { extern bool acos(void); bool ok = acos(); assert(ok); return static_cast<int>(!ok); } EOS system ENV.cxx, "#{pkgshare}/example/general/acos.cpp", "-I#{include}", "test.cpp", "-o", "test" system "./test" end end
class Cppad < Formula desc "Differentiation of C++ Algorithms" homepage "https://www.coin-or.org/CppAD" url "https://github.com/coin-or/CppAD/archive/20220000.3.tar.gz" sha256 "7778c516a131a20e12c97dffe2b65fbf356d791741a6c63d39f16b9c4b747259" license "EPL-2.0" version_scheme 1 head "https://github.com/coin-or/CppAD.git", branch: "master" livecheck do url :stable regex(/^v?(\d+(?:\.\d+)+)$/i) end bottle do sha256 cellar: :any, arm64_monterey: "c3d520e2e241c46e3c00851cd18de2f9926bcf44aab38a8438213328d161b894" sha256 cellar: :any, arm64_big_sur: "19b705f49108fab8d83f09fd9ae6429c0c6f90622e41eea6bb573fb228017548" sha256 cellar: :any, monterey: "3762f8640dc15f82c67222c3580e9c7b2f22afe4718bfb4a094582e85cc3cd25" sha256 cellar: :any, big_sur: "050aae4237805f0c17171b680f62f9c6800b72a00f148ad39fe313f33a35bb77" sha256 cellar: :any, catalina: "6b4c71bc2acbafa390d4dfe2b569b2a744453c7947842dcfd5aa72a2dbb7591d" sha256 cellar: :any_skip_relocation, x86_64_linux: "7da097694f15fd7afa3bade6dd5c97ffeb400e0cf70acdfabc151b8adae00b5f" end depends_on "cmake" => :build def install ENV.cxx11 mkdir "build" do system "cmake", "..", *std_cmake_args, "-Dcppad_prefix=#{prefix}" system "make", "install" end pkgshare.install "example" end test do (testpath/"test.cpp").write <<~EOS #include <cassert> #include <cppad/utility/thread_alloc.hpp> int main(void) { extern bool acos(void); bool ok = acos(); assert(ok); return static_cast<int>(!ok); } EOS system ENV.cxx, "#{pkgshare}/example/general/acos.cpp", "-std=c++11", "-I#{include}", "test.cpp", "-o", "test" system "./test" end end cppad 20220000.4 Closes #102114. Signed-off-by: Sean Molenaar <2b250e3fea88cfef248b497ad5fc17f7dc435154@users.noreply.github.com> Signed-off-by: BrewTestBot <8a898ee6867e4f2028e63d2a6319b2224641c06c@users.noreply.github.com> class Cppad < Formula desc "Differentiation of C++ Algorithms" homepage "https://www.coin-or.org/CppAD" url "https://github.com/coin-or/CppAD/archive/20220000.4.tar.gz" sha256 "0f4e11f20f8436b2d04522b1279f0ed335b28f454e71425ecf39106497363cb4" license "EPL-2.0" version_scheme 1 head "https://github.com/coin-or/CppAD.git", branch: "master" livecheck do url :stable regex(/^v?(\d+(?:\.\d+)+)$/i) end bottle do sha256 cellar: :any, arm64_monterey: "c3d520e2e241c46e3c00851cd18de2f9926bcf44aab38a8438213328d161b894" sha256 cellar: :any, arm64_big_sur: "19b705f49108fab8d83f09fd9ae6429c0c6f90622e41eea6bb573fb228017548" sha256 cellar: :any, monterey: "3762f8640dc15f82c67222c3580e9c7b2f22afe4718bfb4a094582e85cc3cd25" sha256 cellar: :any, big_sur: "050aae4237805f0c17171b680f62f9c6800b72a00f148ad39fe313f33a35bb77" sha256 cellar: :any, catalina: "6b4c71bc2acbafa390d4dfe2b569b2a744453c7947842dcfd5aa72a2dbb7591d" sha256 cellar: :any_skip_relocation, x86_64_linux: "7da097694f15fd7afa3bade6dd5c97ffeb400e0cf70acdfabc151b8adae00b5f" end depends_on "cmake" => :build def install ENV.cxx11 mkdir "build" do system "cmake", "..", *std_cmake_args, "-Dcppad_prefix=#{prefix}" system "make", "install" end pkgshare.install "example" end test do (testpath/"test.cpp").write <<~EOS #include <cassert> #include <cppad/utility/thread_alloc.hpp> int main(void) { extern bool acos(void); bool ok = acos(); assert(ok); return static_cast<int>(!ok); } EOS system ENV.cxx, "#{pkgshare}/example/general/acos.cpp", "-std=c++11", "-I#{include}", "test.cpp", "-o", "test" system "./test" end end
require 'formula' class Csync < Formula homepage 'http://www.csync.org/' url 'http://www.csync.org/files/csync-0.49.9.tar.gz' sha1 'fd7df6c13aa6fc6de74cb48c2ac35ad11f6d895d' # Note: HEAD requires git:// protocol, https:// does not work. head 'git://git.csync.org/projects/csync.git' depends_on 'doxygen' => :build depends_on 'cmake' => :build depends_on 'check' => :build depends_on 'sqlite' depends_on 'iniparser' depends_on 'argp-standalone' depends_on 'libssh' => :optional if build.head? # Log4c and libsmbclient are optional in HEAD. See # http://git.csync.org/projects/csync.git/commit/?id=13f05db93484ad6100c1987d11e7a6d33bd5d754 # http://git.csync.org/projects/csync.git/commit/?id=f064dbcde4e25cb4661be77a76be7279946be3d6 depends_on 'log4c' => :optional depends_on 'samba' => :optional else depends_on 'log4c' depends_on 'samba' end def patches DATA end def install mkdir 'build' unless build.head? cd 'build' do system "cmake", "..", *std_cmake_args # We need to run make csync first to make the "core", # or the build system will freak out and try to link # modules against core functions that aren't compiled # yet. We also have to patch "link.txt" for all module # targets. This should probably be reported upstream. system "make csync" Dir['modules/CMakeFiles/*/link.txt'].each do |f| inreplace f do |s| s.gsub! '-o', "../src/libcsync.dylib ../src/std/libcstdlib.a -o" end end # Now we can make and install. system "make all" system "make install" end end def test system "csync", "-V" end end __END__ --- a/src/csync_propagate.c 2012-07-01 13:12:12.000000000 +0200 +++ b/src/csync_propagate.c 2012-07-01 13:12:59.000000000 +0200 @@ -101,10 +101,6 @@ /* Open the source file */ ctx->replica = srep; flags = O_RDONLY|O_NOFOLLOW; - /* O_NOATIME can only be set by the owner of the file or the superuser */ - if (st->uid == ctx->pwd.uid || ctx->pwd.euid == 0) { - flags |= O_NOATIME; - } sfp = csync_vio_open(ctx, suri, flags, 0); if (sfp == NULL) { if (errno == ENOMEM) { csync: style nits require 'formula' class Csync < Formula homepage 'http://www.csync.org/' head 'git://git.csync.org/projects/csync.git' url 'http://www.csync.org/files/csync-0.49.9.tar.gz' sha1 'fd7df6c13aa6fc6de74cb48c2ac35ad11f6d895d' depends_on 'check' => :build depends_on 'cmake' => :build depends_on 'doxygen' => :build depends_on 'argp-standalone' depends_on 'iniparser' depends_on 'sqlite' depends_on 'libssh' => :optional if build.head? # Log4c and libsmbclient are optional in HEAD. depends_on 'log4c' => :optional depends_on 'samba' => :optional else depends_on 'log4c' depends_on 'samba' end def patches DATA end def install mkdir 'build' unless build.head? cd 'build' do system "cmake", "..", *std_cmake_args # We need to run make csync first to make the "core", # or the build system will freak out and try to link # modules against core functions that aren't compiled # yet. We also have to patch "link.txt" for all module # targets. This should probably be reported upstream. system "make csync" inreplace Dir['modules/CMakeFiles/*/link.txt'] do |s| s.gsub! '-o', "../src/libcsync.dylib ../src/std/libcstdlib.a -o" end # Now we can make and install. system "make all" system "make install" end end def test system "csync", "-V" end end __END__ --- a/src/csync_propagate.c 2012-07-01 13:12:12.000000000 +0200 +++ b/src/csync_propagate.c 2012-07-01 13:12:59.000000000 +0200 @@ -101,10 +101,6 @@ /* Open the source file */ ctx->replica = srep; flags = O_RDONLY|O_NOFOLLOW; - /* O_NOATIME can only be set by the owner of the file or the superuser */ - if (st->uid == ctx->pwd.uid || ctx->pwd.euid == 0) { - flags |= O_NOATIME; - } sfp = csync_vio_open(ctx, suri, flags, 0); if (sfp == NULL) { if (errno == ENOMEM) {
class Dbxml < Formula desc "Embeddable XML database with XQuery support and other advanced features" homepage "http://www.oracle.com/us/products/database/berkeley-db/xml/overview/index.html" url "http://download.oracle.com/berkeley-db/dbxml-6.0.18.tar.gz" sha256 "5851f60a47920718b701752528a449f30b16ddbf5402a2a5e8cde8b4aecfabc8" bottle do cellar :any sha256 "e61af38290271e289d8f8e0fbb39f727fe6c9999d7a0cc9531caa59d4ed7c90b" => :el_capitan sha256 "9b17ab965313607cee1419b5172e81b54a2f1abc951d55471192571a55aa06b9" => :yosemite sha256 "7132f822ef547094f01340f3a4324bbf3726ec6ed9b39a569c44b3afd7736f63" => :mavericks end depends_on "xerces-c" depends_on "xqilla" depends_on "berkeley-db" def install inreplace "dbxml/configure" do |s| s.gsub! "lib/libdb-*.la | sed 's\/.*db-\\\(.*\\\).la", "lib/libdb-*.a | sed 's/.*db-\\(.*\\).a" s.gsub! "lib/libdb-*.la", "lib/libdb-*.a" end cd "dbxml" do system "./configure", "--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}", "--with-xqilla=#{HOMEBREW_PREFIX}", "--with-xerces=#{HOMEBREW_PREFIX}", "--with-berkeleydb=#{HOMEBREW_PREFIX}" system "make", "install" end end test do (testpath/"simple.xml").write <<-EOS.undent <breakfast_menu> <food> <name>Belgian Waffles</name> <calories>650</calories> </food> <food> <name>Homestyle Breakfast</name> <calories>950</calories> </food> </breakfast_menu> EOS (testpath/"dbxml.script").write <<-EOS.undent createContainer "" putDocument simple "simple.xml" f cquery 'sum(//food/calories)' print quit EOS assert_equal "1600", shell_output("#{bin}/dbxml -s #{testpath}/dbxml.script").chomp end end dbxml: update 6.0.18 bottle. class Dbxml < Formula desc "Embeddable XML database with XQuery support and other advanced features" homepage "http://www.oracle.com/us/products/database/berkeley-db/xml/overview/index.html" url "http://download.oracle.com/berkeley-db/dbxml-6.0.18.tar.gz" sha256 "5851f60a47920718b701752528a449f30b16ddbf5402a2a5e8cde8b4aecfabc8" bottle do cellar :any sha256 "fb36c58d1ccfcbd8a64aff8f6296ada9379ade8413382b70275b6209216aed64" => :el_capitan sha256 "2c1f4a931b7ffdf2a3a5d0a0aaf1be9434b4483549d47eda7868ee2fa4456837" => :yosemite sha256 "c6975e34ad3640650a9da0f08e99f9f763ec47bc3532c28466233e10eaeccaa1" => :mavericks end depends_on "xerces-c" depends_on "xqilla" depends_on "berkeley-db" def install inreplace "dbxml/configure" do |s| s.gsub! "lib/libdb-*.la | sed 's\/.*db-\\\(.*\\\).la", "lib/libdb-*.a | sed 's/.*db-\\(.*\\).a" s.gsub! "lib/libdb-*.la", "lib/libdb-*.a" end cd "dbxml" do system "./configure", "--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}", "--with-xqilla=#{HOMEBREW_PREFIX}", "--with-xerces=#{HOMEBREW_PREFIX}", "--with-berkeleydb=#{HOMEBREW_PREFIX}" system "make", "install" end end test do (testpath/"simple.xml").write <<-EOS.undent <breakfast_menu> <food> <name>Belgian Waffles</name> <calories>650</calories> </food> <food> <name>Homestyle Breakfast</name> <calories>950</calories> </food> </breakfast_menu> EOS (testpath/"dbxml.script").write <<-EOS.undent createContainer "" putDocument simple "simple.xml" f cquery 'sum(//food/calories)' print quit EOS assert_equal "1600", shell_output("#{bin}/dbxml -s #{testpath}/dbxml.script").chomp end end
require 'formula' class Dcmtk < Formula homepage 'http://dicom.offis.de/dcmtk.php.en' url 'ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/dcmtk360/dcmtk-3.6.0.tar.gz' sha1 '469e017cffc56f36e834aa19c8612111f964f757' option 'with-docs', 'Install development libraries/headers and HTML docs' depends_on 'cmake' => :build depends_on :libpng depends_on 'libtiff' depends_on 'doxygen' if build.include? 'with-docs' fails_with :clang do build 421 end def install ENV.m64 if MacOS.prefer_64_bit? args = std_cmake_args args << '-DDCMTK_WITH_DOXYGEN=YES' if build.include? 'with-docs' args << '..' mkdir 'build' do system 'cmake', *args system 'make DOXYGEN' if build.include? 'with-docs' system 'make install' end end end dcmtk: still fails with clang 425 require 'formula' class Dcmtk < Formula homepage 'http://dicom.offis.de/dcmtk.php.en' url 'ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/dcmtk360/dcmtk-3.6.0.tar.gz' sha1 '469e017cffc56f36e834aa19c8612111f964f757' option 'with-docs', 'Install development libraries/headers and HTML docs' depends_on 'cmake' => :build depends_on :libpng depends_on 'libtiff' depends_on 'doxygen' if build.include? 'with-docs' fails_with :clang do build 425 cause "error: use of undeclared identifier 'scaleData'" end def install ENV.m64 if MacOS.prefer_64_bit? args = std_cmake_args args << '-DDCMTK_WITH_DOXYGEN=YES' if build.include? 'with-docs' args << '..' mkdir 'build' do system 'cmake', *args system 'make DOXYGEN' if build.include? 'with-docs' system 'make install' end end end
require "base64" class Deark < Formula desc "File conversion utility for older formats" homepage "https://entropymine.com/deark/" url "https://entropymine.com/deark/releases/deark-1.5.0.tar.gz" sha256 "2243e98f9b75f7c8c9ab2881259221ba8d719a6903dd1fb013e6957411c9d6c7" bottle do cellar :any_skip_relocation sha256 "00f53a4073d77a67c2e8d295a68a955babfa90b6235ca3fe77e95810d183beb7" => :mojave sha256 "257c40c3b7e30b1c61846baf6b8f22c550f540967b9b7be0b1aaa7864dd3645a" => :high_sierra sha256 "7393b4d3b5034571e2b728d9a5fd290e4b3d8f809723de1f71dd5216bcc291ca" => :sierra end def install system "make" bin.install "deark" end test do (testpath/"test.gz").write ::Base64.decode64 <<~EOS H4sICKU51VoAA3Rlc3QudHh0APNIzcnJ11HwyM9NTSpKLVfkAgBuKJNJEQAAAA== EOS system "#{bin}/deark", "test.gz" file = (testpath/"output.000.test.txt").readlines.first assert_match "Hello, Homebrew!", file end end deark: update 1.5.0 bottle. Closes #11839. Signed-off-by: Michka Popoff <7b0496f66f66ee22a38826c310c38b415671b832@gmail.com> require "base64" class Deark < Formula desc "File conversion utility for older formats" homepage "https://entropymine.com/deark/" url "https://entropymine.com/deark/releases/deark-1.5.0.tar.gz" sha256 "2243e98f9b75f7c8c9ab2881259221ba8d719a6903dd1fb013e6957411c9d6c7" bottle do root_url "https://linuxbrew.bintray.com/bottles" cellar :any_skip_relocation sha256 "00f53a4073d77a67c2e8d295a68a955babfa90b6235ca3fe77e95810d183beb7" => :mojave sha256 "257c40c3b7e30b1c61846baf6b8f22c550f540967b9b7be0b1aaa7864dd3645a" => :high_sierra sha256 "7393b4d3b5034571e2b728d9a5fd290e4b3d8f809723de1f71dd5216bcc291ca" => :sierra sha256 "b801b46fdf8c2536f4b6504ac08286d69978b9eb2a9622973a5652b2dbdcad24" => :x86_64_linux end def install system "make" bin.install "deark" end test do (testpath/"test.gz").write ::Base64.decode64 <<~EOS H4sICKU51VoAA3Rlc3QudHh0APNIzcnJ11HwyM9NTSpKLVfkAgBuKJNJEQAAAA== EOS system "#{bin}/deark", "test.gz" file = (testpath/"output.000.test.txt").readlines.first assert_match "Hello, Homebrew!", file end end