alf-shell 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +4 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +35 -0
- data/LICENCE.md +22 -0
- data/Manifest.txt +13 -0
- data/README.md +11 -0
- data/Rakefile +11 -0
- data/bin/alf +17 -0
- data/lib/alf-shell.rb +1 -0
- data/lib/alf/shell.rb +48 -0
- data/lib/alf/shell/command.rb +21 -0
- data/lib/alf/shell/command/exec.rb +16 -0
- data/lib/alf/shell/command/help.rb +30 -0
- data/lib/alf/shell/command/main.rb +175 -0
- data/lib/alf/shell/command/show.rb +49 -0
- data/lib/alf/shell/doc_manager.rb +83 -0
- data/lib/alf/shell/ext/signature.rb +45 -0
- data/lib/alf/shell/from_argv.rb +78 -0
- data/lib/alf/shell/loader.rb +2 -0
- data/lib/alf/shell/operator.rb +63 -0
- data/lib/alf/shell/support.rb +28 -0
- data/lib/alf/shell/version.rb +16 -0
- data/spec/integration/__database__/group.alf +3 -0
- data/spec/integration/__database__/parts.rash +6 -0
- data/spec/integration/__database__/suppliers.rash +5 -0
- data/spec/integration/__database__/suppliers_csv.csv +6 -0
- data/spec/integration/__database__/supplies.rash +12 -0
- data/spec/integration/alf/alf.db +0 -0
- data/spec/integration/alf/alf_db.cmd +1 -0
- data/spec/integration/alf/alf_db.stdout +5 -0
- data/spec/integration/alf/alf_e.cmd +1 -0
- data/spec/integration/alf/alf_e.stdout +4 -0
- data/spec/integration/alf/alf_help.cmd +1 -0
- data/spec/integration/alf/alf_help.stdout +72 -0
- data/spec/integration/alf/alf_json.cmd +1 -0
- data/spec/integration/alf/alf_json.stdout +1 -0
- data/spec/integration/alf/alf_r.cmd +1 -0
- data/spec/integration/alf/alf_r.stdout +5 -0
- data/spec/integration/alf/alf_version.cmd +1 -0
- data/spec/integration/alf/alf_version.stdout +2 -0
- data/spec/integration/alf/alf_yaml.cmd +1 -0
- data/spec/integration/alf/alf_yaml.stdout +22 -0
- data/spec/integration/alf/rel.rash +1 -0
- data/spec/integration/autonum/autonum_0.cmd +1 -0
- data/spec/integration/autonum/autonum_0.stdout +9 -0
- data/spec/integration/autonum/autonum_1.cmd +1 -0
- data/spec/integration/autonum/autonum_1.stdout +9 -0
- data/spec/integration/clip/clip_0.cmd +1 -0
- data/spec/integration/clip/clip_0.stdout +9 -0
- data/spec/integration/clip/clip_1.cmd +1 -0
- data/spec/integration/clip/clip_1.stdout +9 -0
- data/spec/integration/coerce/coerce_1.cmd +1 -0
- data/spec/integration/coerce/coerce_1.stdout +5 -0
- data/spec/integration/compact/compact_0.cmd +1 -0
- data/spec/integration/compact/compact_0.stdout +9 -0
- data/spec/integration/defaults/defaults_0.cmd +1 -0
- data/spec/integration/defaults/defaults_0.stdout +9 -0
- data/spec/integration/defaults/defaults_1.cmd +1 -0
- data/spec/integration/defaults/defaults_1.stdout +9 -0
- data/spec/integration/defaults/defaults_2.cmd +1 -0
- data/spec/integration/defaults/defaults_2.stdout +9 -0
- data/spec/integration/extend/extend_0.cmd +1 -0
- data/spec/integration/extend/extend_0.stdout +16 -0
- data/spec/integration/generator/generator_1.cmd +1 -0
- data/spec/integration/generator/generator_1.stdout +10 -0
- data/spec/integration/generator/generator_2.cmd +1 -0
- data/spec/integration/generator/generator_2.stdout +5 -0
- data/spec/integration/generator/generator_3.cmd +1 -0
- data/spec/integration/generator/generator_3.stdout +5 -0
- data/spec/integration/group/group_0.cmd +1 -0
- data/spec/integration/group/group_0.stdout +32 -0
- data/spec/integration/group/group_1.cmd +1 -0
- data/spec/integration/group/group_1.stdout +32 -0
- data/spec/integration/help/help_1.cmd +1 -0
- data/spec/integration/help/help_1.stdout +25 -0
- data/spec/integration/intersect/intersect_0.cmd +1 -0
- data/spec/integration/intersect/intersect_0.stdout +9 -0
- data/spec/integration/join/join_0.cmd +1 -0
- data/spec/integration/join/join_0.stdout +16 -0
- data/spec/integration/matching/matching_0.cmd +1 -0
- data/spec/integration/matching/matching_0.stdout +8 -0
- data/spec/integration/minus/minus_0.cmd +1 -0
- data/spec/integration/minus/minus_0.stdout +4 -0
- data/spec/integration/not-matching/not-matching_0.cmd +1 -0
- data/spec/integration/not-matching/not-matching_0.stdout +5 -0
- data/spec/integration/project/project_0.cmd +1 -0
- data/spec/integration/project/project_0.stdout +9 -0
- data/spec/integration/project/project_1.cmd +1 -0
- data/spec/integration/project/project_1.stdout +9 -0
- data/spec/integration/quota/quota_0.cmd +1 -0
- data/spec/integration/quota/quota_0.stdout +16 -0
- data/spec/integration/rank/rank_1.cmd +1 -0
- data/spec/integration/rank/rank_1.stdout +10 -0
- data/spec/integration/rank/rank_2.cmd +1 -0
- data/spec/integration/rank/rank_2.stdout +10 -0
- data/spec/integration/rank/rank_3.cmd +1 -0
- data/spec/integration/rank/rank_3.stdout +10 -0
- data/spec/integration/rank/rank_4.cmd +1 -0
- data/spec/integration/rank/rank_4.stdout +6 -0
- data/spec/integration/rank/rank_5.cmd +1 -0
- data/spec/integration/rank/rank_5.stdout +6 -0
- data/spec/integration/rename/rename_0.cmd +1 -0
- data/spec/integration/rename/rename_0.stdout +9 -0
- data/spec/integration/restrict/restrict_0.cmd +1 -0
- data/spec/integration/restrict/restrict_0.stdout +6 -0
- data/spec/integration/restrict/restrict_1.cmd +1 -0
- data/spec/integration/restrict/restrict_1.stdout +6 -0
- data/spec/integration/show/show_base.cmd +1 -0
- data/spec/integration/show/show_base.stdout +5 -0
- data/spec/integration/show/show_base_sort_1.cmd +1 -0
- data/spec/integration/show/show_base_sort_1.stdout +9 -0
- data/spec/integration/show/show_base_sort_2.cmd +1 -0
- data/spec/integration/show/show_base_sort_2.stdout +9 -0
- data/spec/integration/show/show_conflictual.cmd +1 -0
- data/spec/integration/show/show_conflictual.stdout +5 -0
- data/spec/integration/show/show_ff.cmd +1 -0
- data/spec/integration/show/show_ff.stdout +10 -0
- data/spec/integration/show/show_rash.cmd +1 -0
- data/spec/integration/show/show_rash.stdout +5 -0
- data/spec/integration/show/show_rash_pretty.cmd +1 -0
- data/spec/integration/show/show_rash_pretty.stdout +30 -0
- data/spec/integration/show/show_yaml.cmd +1 -0
- data/spec/integration/show/show_yaml.stdout +22 -0
- data/spec/integration/sort/sort_0.cmd +1 -0
- data/spec/integration/sort/sort_0.stdout +9 -0
- data/spec/integration/sort/sort_1.cmd +1 -0
- data/spec/integration/sort/sort_1.stdout +9 -0
- data/spec/integration/sort/sort_2.cmd +1 -0
- data/spec/integration/sort/sort_2.stdout +9 -0
- data/spec/integration/sort/sort_3.cmd +1 -0
- data/spec/integration/sort/sort_3.stdout +9 -0
- data/spec/integration/summarize/summarize_0.cmd +1 -0
- data/spec/integration/summarize/summarize_0.stdout +8 -0
- data/spec/integration/test_shell.rb +56 -0
- data/spec/integration/union/union_0.cmd +1 -0
- data/spec/integration/union/union_0.stdout +9 -0
- data/spec/integration/unwrap/unwrap_0.cmd +1 -0
- data/spec/integration/unwrap/unwrap_0.stdout +9 -0
- data/spec/integration/wrap/wrap_0.cmd +1 -0
- data/spec/integration/wrap/wrap_0.stdout +9 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/test_shell.rb +10 -0
- data/spec/unit/doc_manager/dynamic.md +1 -0
- data/spec/unit/doc_manager/example.md +1 -0
- data/spec/unit/doc_manager/example_1.txt +11 -0
- data/spec/unit/doc_manager/static.md +1 -0
- data/spec/unit/doc_manager/test_call.rb +43 -0
- data/spec/unit/ext/signature/test_argv2args.rb +82 -0
- data/spec/unit/ext/signature/test_to_shell.rb +103 -0
- data/spec/unit/from_argv/test_to_attr_list.rb +30 -0
- data/spec/unit/from_argv/test_to_attr_name.rb +27 -0
- data/spec/unit/from_argv/test_to_boolean.rb +32 -0
- data/spec/unit/from_argv/test_to_heading.rb +37 -0
- data/spec/unit/from_argv/test_to_ordering.rb +28 -0
- data/spec/unit/from_argv/test_to_predicate.rb +26 -0
- data/spec/unit/from_argv/test_to_renaming.rb +23 -0
- data/spec/unit/from_argv/test_to_size.rb +32 -0
- data/spec/unit/from_argv/test_to_summarization.rb +19 -0
- data/spec/unit/from_argv/test_to_tuple_computation.rb +18 -0
- data/spec/unit/from_argv/test_to_tuple_expression.rb +38 -0
- data/spec/unit/main/test_class_methods.rb +44 -0
- data/spec/unit/operator/test_autonum.rb +28 -0
- data/spec/unit/operator/test_clip.rb +29 -0
- data/spec/unit/operator/test_coerce.rb +22 -0
- data/spec/unit/operator/test_compact.rb +16 -0
- data/spec/unit/operator/test_defaults.rb +29 -0
- data/spec/unit/operator/test_extend.rb +21 -0
- data/spec/unit/operator/test_generator.rb +37 -0
- data/spec/unit/operator/test_group.rb +32 -0
- data/spec/unit/operator/test_infer_heading.rb +16 -0
- data/spec/unit/operator/test_intersect.rb +18 -0
- data/spec/unit/operator/test_join.rb +18 -0
- data/spec/unit/operator/test_matching.rb +18 -0
- data/spec/unit/operator/test_minus.rb +18 -0
- data/spec/unit/operator/test_not_matching.rb +18 -0
- data/spec/unit/operator/test_project.rb +38 -0
- data/spec/unit/operator/test_quota.rb +23 -0
- data/spec/unit/operator/test_rank.rb +30 -0
- data/spec/unit/operator/test_rename.rb +21 -0
- data/spec/unit/operator/test_restrict.rb +36 -0
- data/spec/unit/operator/test_sort.rb +49 -0
- data/spec/unit/operator/test_summarize.rb +30 -0
- data/spec/unit/operator/test_ungroup.rb +28 -0
- data/spec/unit/operator/test_union.rb +18 -0
- data/spec/unit/operator/test_unwrap.rb +28 -0
- data/spec/unit/operator/test_wrap.rb +30 -0
- data/tasks/gem.rake +8 -0
- data/tasks/test.rake +6 -0
- metadata +317 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf
|
|
3
|
+
describe Shell, ".from_argv(argv, Size)" do
|
|
4
|
+
|
|
5
|
+
subject{ Shell.from_argv(argv, Size) }
|
|
6
|
+
|
|
7
|
+
context 'on an empty array' do
|
|
8
|
+
let(:argv){ [ ] }
|
|
9
|
+
it{ should eq(0) }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context 'with a single string' do
|
|
13
|
+
let(:argv){ [ "12" ] }
|
|
14
|
+
it{ should eq(12) }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context 'on a big array' do
|
|
18
|
+
let(:argv){ ["12", "hello"] }
|
|
19
|
+
specify{
|
|
20
|
+
lambda{ subject }.should raise_error(Myrrha::Error)
|
|
21
|
+
}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context 'when not coercable' do
|
|
25
|
+
let(:argv){ ["hello"] }
|
|
26
|
+
specify{
|
|
27
|
+
lambda{ subject }.should raise_error(Myrrha::Error)
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf
|
|
3
|
+
describe Shell, ".from_argv(argv, Summarization)" do
|
|
4
|
+
|
|
5
|
+
subject{ Shell.from_argv(argv, Summarization) }
|
|
6
|
+
|
|
7
|
+
context "from an Array" do
|
|
8
|
+
let(:argv){ ["s", "sum{ qty }", "m", "max{ size }"] }
|
|
9
|
+
|
|
10
|
+
it{ should be_a(Summarization) }
|
|
11
|
+
|
|
12
|
+
specify{
|
|
13
|
+
subject.to_hash.keys.to_set.should eq([:s, :m].to_set)
|
|
14
|
+
subject.to_hash.values.all?{|v| v.should be_a(Aggregator)}
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf
|
|
3
|
+
describe Shell, ".from_argv(argv, TupleComputation)" do
|
|
4
|
+
|
|
5
|
+
subject{ Shell.from_argv(argv, TupleComputation) }
|
|
6
|
+
|
|
7
|
+
describe "from an Array with coercions" do
|
|
8
|
+
let(:argv){ ["hello", "who", "hello2", "2"] }
|
|
9
|
+
let(:expected){
|
|
10
|
+
TupleComputation.new(
|
|
11
|
+
:hello => Alf::TupleExpression.coerce("who"),
|
|
12
|
+
:hello2 => Alf::TupleExpression.coerce("2"))
|
|
13
|
+
}
|
|
14
|
+
it{ should eql(expected) }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf
|
|
3
|
+
describe Shell, ".from_argv(argv, TupleExpression)" do
|
|
4
|
+
|
|
5
|
+
let(:scope) {
|
|
6
|
+
Support::TupleScope.new(:status => 10)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
subject{ Shell.from_argv(argv, TupleExpression) }
|
|
10
|
+
|
|
11
|
+
context "with a String (1)" do
|
|
12
|
+
let(:argv){ %w{true} }
|
|
13
|
+
it { should be_a(TupleExpression) }
|
|
14
|
+
specify{
|
|
15
|
+
subject.evaluate(scope).should eql(true)
|
|
16
|
+
subject.source.should eq("true")
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context "with a String (2)" do
|
|
21
|
+
let(:argv){ ["status > 10"] }
|
|
22
|
+
it { should be_a(TupleExpression) }
|
|
23
|
+
specify{
|
|
24
|
+
subject.evaluate(scope).should eql(false)
|
|
25
|
+
subject.source.should eq("status > 10")
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context "with two String" do
|
|
30
|
+
let(:argv){ %w{hello world} }
|
|
31
|
+
specify{
|
|
32
|
+
lambda{ subject }.should raise_error(Myrrha::Error)
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf
|
|
3
|
+
module Shell
|
|
4
|
+
describe Main, "class methods for doc" do
|
|
5
|
+
|
|
6
|
+
specify "relational_operators" do
|
|
7
|
+
Shell::Main.relational_operators.should_not be_empty
|
|
8
|
+
Shell::Main.relational_operators.each do |cmd|
|
|
9
|
+
cmd.should_not be_command
|
|
10
|
+
cmd.should be_operator
|
|
11
|
+
cmd.should respond_to(:run)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
specify "experimental_operators" do
|
|
16
|
+
Shell::Main.experimental_operators.should_not be_empty
|
|
17
|
+
Shell::Main.experimental_operators.each do |cmd|
|
|
18
|
+
cmd.should_not be_command
|
|
19
|
+
cmd.should be_operator
|
|
20
|
+
cmd.should respond_to(:run)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
specify "non_relational_operators" do
|
|
25
|
+
Shell::Main.non_relational_operators.should_not be_empty
|
|
26
|
+
Shell::Main.non_relational_operators.each do |cmd|
|
|
27
|
+
cmd.should_not be_command
|
|
28
|
+
cmd.should be_operator
|
|
29
|
+
cmd.should respond_to(:run)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
specify "other_non_relational_commands" do
|
|
34
|
+
Shell::Main.other_non_relational_commands.should_not be_empty
|
|
35
|
+
Shell::Main.other_non_relational_commands.each do |cmd|
|
|
36
|
+
cmd.should be_command
|
|
37
|
+
cmd.should_not be_operator
|
|
38
|
+
cmd.should respond_to(:run)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end # class methods for doc
|
|
43
|
+
end # module Shell
|
|
44
|
+
end # module Alf
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf::Shell::Operator
|
|
3
|
+
describe Autonum do
|
|
4
|
+
|
|
5
|
+
let(:input){ suppliers }
|
|
6
|
+
subject{ Autonum.run(argv) }
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
subject.should be_a(Alf::Algebra::Autonum)
|
|
10
|
+
subject.operands.should eq([input])
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context "with default attribute name" do
|
|
14
|
+
let(:argv){ [input] }
|
|
15
|
+
specify{
|
|
16
|
+
subject.as.should eq(:autonum)
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context "with explicit attribute name" do
|
|
21
|
+
let(:argv){ [input, "--", "unique"] }
|
|
22
|
+
specify{
|
|
23
|
+
subject.as.should eq(:unique)
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf::Shell::Operator
|
|
3
|
+
describe Clip do
|
|
4
|
+
|
|
5
|
+
let(:input){ suppliers }
|
|
6
|
+
subject{ Clip.run(argv) }
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
subject.should be_a(Alf::Algebra::Clip)
|
|
10
|
+
subject.attributes.should eq(Alf::AttrList[:a, :b])
|
|
11
|
+
subject.operands.should eq([input])
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "--no-allbut" do
|
|
15
|
+
let(:argv){ [input, "--", "a", "b"] }
|
|
16
|
+
specify{
|
|
17
|
+
subject.allbut.should be_false
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "--allbut" do
|
|
22
|
+
let(:argv){ [input, "--allbut", "--", "a", "b"] }
|
|
23
|
+
specify{
|
|
24
|
+
subject.allbut.should be_true
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf::Shell::Operator
|
|
3
|
+
describe Coerce do
|
|
4
|
+
|
|
5
|
+
let(:input){ suppliers }
|
|
6
|
+
subject{ Coerce.run(argv) }
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
subject.should be_a(Alf::Algebra::Coerce)
|
|
10
|
+
subject.operands.should eq([input])
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context "a typical coercion" do
|
|
14
|
+
let(:argv){ [input] + %w{-- a Integer b Float} }
|
|
15
|
+
specify{
|
|
16
|
+
expected = Alf::Heading[:a => Integer, :b => Float]
|
|
17
|
+
subject.coercions.should eq(expected)
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf::Shell::Operator
|
|
3
|
+
describe Compact do
|
|
4
|
+
|
|
5
|
+
let(:input){ suppliers }
|
|
6
|
+
subject{ Compact.run(argv) }
|
|
7
|
+
|
|
8
|
+
context "the default config" do
|
|
9
|
+
let(:argv){ [input] }
|
|
10
|
+
specify{
|
|
11
|
+
subject.should be_a(Alf::Algebra::Compact)
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf::Shell::Operator
|
|
3
|
+
describe Defaults do
|
|
4
|
+
|
|
5
|
+
let(:input){ suppliers }
|
|
6
|
+
subject{ Defaults.run(argv) }
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
subject.should be_a(Alf::Algebra::Defaults)
|
|
10
|
+
subject.defaults.should eq(Alf::TupleComputation[:a => Alf::TupleExpression["1"], :c => Alf::TupleExpression["'blue'"]])
|
|
11
|
+
subject.operands.should eq([input])
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "--no-strict" do
|
|
15
|
+
let(:argv){ [input] + %w{-- a 1 c 'blue'} }
|
|
16
|
+
specify{
|
|
17
|
+
subject.strict.should eq(false)
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "--strict" do
|
|
22
|
+
let(:argv){ [input] + %w{--strict -- a 1 c 'blue'} }
|
|
23
|
+
specify{
|
|
24
|
+
subject.strict.should eq(true)
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf::Shell::Operator
|
|
3
|
+
describe Extend do
|
|
4
|
+
|
|
5
|
+
let(:input){ suppliers }
|
|
6
|
+
subject{ Extend.run(argv) }
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
subject.should be_a(Alf::Algebra::Extend)
|
|
10
|
+
subject.operands.should eq([input])
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context "a typical config" do
|
|
14
|
+
let(:argv){ [input] + %w{-- big} + ["tested > 10"] }
|
|
15
|
+
specify{
|
|
16
|
+
subject.ext.should eq(Alf::TupleComputation[:big => Alf::TupleExpression["tested > 10"]])
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf::Shell::Operator
|
|
3
|
+
describe Generator do
|
|
4
|
+
|
|
5
|
+
subject{ Generator.run(argv) }
|
|
6
|
+
|
|
7
|
+
before do
|
|
8
|
+
subject.should be_a(Alf::Algebra::Generator)
|
|
9
|
+
subject.operands.should eq([])
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context "with empty args" do
|
|
13
|
+
let(:argv){ %w{} }
|
|
14
|
+
specify{
|
|
15
|
+
subject.size.should eq(10)
|
|
16
|
+
subject.as.should eq(:num)
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context "with a size" do
|
|
21
|
+
let(:argv){ %w{-- 2} }
|
|
22
|
+
specify{
|
|
23
|
+
subject.size.should eq(2)
|
|
24
|
+
subject.as.should eq(:num)
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context "with a size and a name" do
|
|
29
|
+
let(:argv){ %w{-- 2 -- generated} }
|
|
30
|
+
specify{
|
|
31
|
+
subject.size.should eq(2)
|
|
32
|
+
subject.as.should eq(:generated)
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf::Shell::Operator
|
|
3
|
+
describe Group do
|
|
4
|
+
|
|
5
|
+
let(:input){ suppliers }
|
|
6
|
+
subject{ Group.run(argv) }
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
subject.should be_a(Alf::Algebra::Group)
|
|
10
|
+
subject.operands.should eq([input])
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context "--no-allbut" do
|
|
14
|
+
let(:argv){ [input, "--", "time", "b", "--", "as"] }
|
|
15
|
+
specify{
|
|
16
|
+
subject.attributes.should eq(Alf::AttrList[:time, :b])
|
|
17
|
+
subject.as.should eq(:as)
|
|
18
|
+
subject.allbut.should eq(false)
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context "--allbut" do
|
|
23
|
+
let(:argv){ [input, "--allbut", "--","a", "--", "as"] }
|
|
24
|
+
specify{
|
|
25
|
+
subject.attributes.should eq(Alf::AttrList[:a])
|
|
26
|
+
subject.as.should eq(:as)
|
|
27
|
+
subject.allbut.should eq(true)
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf::Shell::Operator
|
|
3
|
+
describe InferHeading do
|
|
4
|
+
|
|
5
|
+
let(:input){ suppliers }
|
|
6
|
+
subject{ InferHeading.run(argv) }
|
|
7
|
+
|
|
8
|
+
context "the default config" do
|
|
9
|
+
let(:argv){ [input] }
|
|
10
|
+
specify{
|
|
11
|
+
subject.should be_a(Alf::Algebra::InferHeading)
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf::Shell::Operator
|
|
3
|
+
describe Intersect do
|
|
4
|
+
|
|
5
|
+
let(:left) { suppliers }
|
|
6
|
+
let(:right){ suppliers }
|
|
7
|
+
subject{ Intersect.run(argv) }
|
|
8
|
+
|
|
9
|
+
context "the default config" do
|
|
10
|
+
let(:argv){ [left, right] }
|
|
11
|
+
specify{
|
|
12
|
+
subject.should be_a(Alf::Algebra::Intersect)
|
|
13
|
+
subject.operands.should eq([left, right])
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf::Shell::Operator
|
|
3
|
+
describe Join do
|
|
4
|
+
|
|
5
|
+
let(:left) { suppliers }
|
|
6
|
+
let(:right){ suppliers }
|
|
7
|
+
subject{ Join.run(argv) }
|
|
8
|
+
|
|
9
|
+
context "the default config" do
|
|
10
|
+
let(:argv){ [left, right] }
|
|
11
|
+
specify{
|
|
12
|
+
subject.should be_a(Alf::Algebra::Join)
|
|
13
|
+
subject.operands.should eq([left, right])
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module Alf::Shell::Operator
|
|
3
|
+
describe Matching do
|
|
4
|
+
|
|
5
|
+
let(:left) { suppliers }
|
|
6
|
+
let(:right){ suppliers }
|
|
7
|
+
subject{ Matching.run(argv) }
|
|
8
|
+
|
|
9
|
+
context "the default config" do
|
|
10
|
+
let(:argv){ [left, right] }
|
|
11
|
+
specify{
|
|
12
|
+
subject.should be_a(Alf::Algebra::Matching)
|
|
13
|
+
subject.operands.should eq([left, right])
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|