piglet 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piglet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo Hultberg
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-07 00:00:00 +01:00
12
+ date: 2010-01-11 00:00:00 +01:00
13
13
  default_executable: piglet
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -41,9 +41,9 @@ files:
41
41
  - lib/piglet.rb
42
42
  - lib/piglet/field/binary_conditional.rb
43
43
  - lib/piglet/field/call_expression.rb
44
+ - lib/piglet/field/field.rb
44
45
  - lib/piglet/field/infix_expression.rb
45
46
  - lib/piglet/field/literal.rb
46
- - lib/piglet/field/operators.rb
47
47
  - lib/piglet/field/prefix_expression.rb
48
48
  - lib/piglet/field/reference.rb
49
49
  - lib/piglet/field/rename.rb
@@ -71,10 +71,18 @@ files:
71
71
  - lib/piglet/relation/split.rb
72
72
  - lib/piglet/relation/stream.rb
73
73
  - lib/piglet/relation/union.rb
74
+ - lib/piglet/schema/bag.rb
75
+ - lib/piglet/schema/tuple.rb
76
+ - spec/piglet/field/binary_conditional_spec.rb
77
+ - spec/piglet/field/field_spec.rb
78
+ - spec/piglet/field/infix_expression_spec.rb
79
+ - spec/piglet/field/literal_spec.rb
74
80
  - spec/piglet/field/reference_spec.rb
75
81
  - spec/piglet/interpreter_spec.rb
76
82
  - spec/piglet/relation/relation_spec.rb
77
83
  - spec/piglet/relation/split_spec.rb
84
+ - spec/piglet/relation/union_spec.rb
85
+ - spec/piglet/schema/tuple_spec.rb
78
86
  - spec/piglet_spec.rb
79
87
  - spec/spec.opts
80
88
  - spec/spec_helper.rb
@@ -110,9 +118,15 @@ signing_key:
110
118
  specification_version: 3
111
119
  summary: Piglet is a DSL for Pig scripts
112
120
  test_files:
121
+ - spec/piglet/field/binary_conditional_spec.rb
122
+ - spec/piglet/field/field_spec.rb
123
+ - spec/piglet/field/infix_expression_spec.rb
124
+ - spec/piglet/field/literal_spec.rb
113
125
  - spec/piglet/field/reference_spec.rb
114
126
  - spec/piglet/interpreter_spec.rb
115
127
  - spec/piglet/relation/relation_spec.rb
116
128
  - spec/piglet/relation/split_spec.rb
129
+ - spec/piglet/relation/union_spec.rb
130
+ - spec/piglet/schema/tuple_spec.rb
117
131
  - spec/piglet_spec.rb
118
132
  - spec/spec_helper.rb
@@ -1,80 +0,0 @@
1
- module Piglet
2
- module Field
3
- module Operators # :nodoc:
4
- SYMBOLIC_OPERATORS = [:==, :>, :<, :>=, :<=, :%, :+, :-, :*, :/]
5
- FUNCTIONS = [:avg, :count, :diff, :max, :min, :size, :sum, :tokenize]
6
-
7
- FUNCTIONS.each do |fun|
8
- define_method(fun) do
9
- CallExpression.new(fun.to_s.upcase, self)
10
- end
11
- end
12
-
13
- def empty?
14
- CallExpression.new('IsEmpty', self)
15
- end
16
-
17
- def as(new_name)
18
- Rename.new(new_name, self)
19
- end
20
-
21
- def not
22
- PrefixExpression.new('NOT', self)
23
- end
24
-
25
- def null?
26
- SuffixExpression.new('is null', self)
27
- end
28
-
29
- def not_null?
30
- SuffixExpression.new('is not null', self)
31
- end
32
-
33
- def cast(type)
34
- PrefixExpression.new("(#{type.to_s})", self)
35
- end
36
-
37
- def matches(pattern)
38
- regex_options_pattern = /^\(\?.+?:(.*)\)$/
39
- pattern = pattern.to_s.sub(regex_options_pattern, '\1') if pattern.is_a?(Regexp) && pattern.to_s =~ regex_options_pattern
40
- InfixExpression.new('matches', self, "'#{pattern.to_s}'")
41
- end
42
-
43
- def neg
44
- PrefixExpression.new('-', self, false)
45
- end
46
-
47
- def ne(other)
48
- InfixExpression.new('!=', self, other)
49
- end
50
-
51
- def and(other)
52
- InfixExpression.new('AND', self, other)
53
- end
54
-
55
- def or(other)
56
- InfixExpression.new('OR', self, other)
57
- end
58
-
59
- SYMBOLIC_OPERATORS.each do |op|
60
- define_method(op) do |other|
61
- InfixExpression.new(op.to_s, self, other)
62
- end
63
- end
64
-
65
- protected
66
-
67
- def parenthesise(expr)
68
- if expr.respond_to?(:simple?) && ! expr.simple?
69
- "(#{expr})"
70
- else
71
- expr.to_s
72
- end
73
- end
74
-
75
- def escape(str)
76
- str.gsub(/("|'|\\)/) { |m| "\\#{$1}" }
77
- end
78
- end
79
- end
80
- end