streamingly 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/streamingly/serde.rb +6 -1
- data/lib/streamingly/version.rb +1 -1
- data/spec/streamingly/serde_spec.rb +31 -0
- data/streamingly.gemspec +1 -1
- metadata +30 -27
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 45d8a9c657e19d5c57d2ac76e894b1c5507fbbe2
|
4
|
+
data.tar.gz: 7189cc2394882efacc17854af55ad164d15dc397
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea3e8af5b941d4b24686d25674bc36e6777f37995b422590466e6b6d7edaa73f744fc2f281e02466db54b05fa5a6cd163b6e0a0b16fb3ae8ea54b4387217130e
|
7
|
+
data.tar.gz: caa7454fd12f4c5724e6488bbe93dfb567f270e840b4e5772be0382051a4f4016bd780c47190c043008aa4f4732ee10ef41e260086f87dc3c4e1897e67124db5
|
data/lib/streamingly/serde.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'bigdecimal'
|
2
|
+
require 'csv'
|
2
3
|
|
3
4
|
module Streamingly
|
4
5
|
|
@@ -23,7 +24,7 @@ module Streamingly
|
|
23
24
|
|
24
25
|
def self.from_csv(string)
|
25
26
|
tokens = CSV.parse_line(string)
|
26
|
-
klass =
|
27
|
+
klass = resolve_class(tokens.first)
|
27
28
|
klass.new(*tokens[1..-1])
|
28
29
|
rescue NameError
|
29
30
|
tokens
|
@@ -33,6 +34,10 @@ module Streamingly
|
|
33
34
|
k,v = string.split("\t")
|
34
35
|
KV.new(from_csv(k), from_csv(v))
|
35
36
|
end
|
37
|
+
|
38
|
+
def self.resolve_class(class_name)
|
39
|
+
class_name.split('::').reduce(Kernel) { |parent, element| parent.const_get(element) }
|
40
|
+
end
|
36
41
|
end
|
37
42
|
|
38
43
|
end
|
data/lib/streamingly/version.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Streamingly::SerDe do
|
4
|
+
|
5
|
+
describe ".from_csv" do
|
6
|
+
let(:value) { '19' }
|
7
|
+
let(:text) { "#{type.name},#{value}" }
|
8
|
+
|
9
|
+
context "given a namespaced class" do
|
10
|
+
before do
|
11
|
+
Namespace = Module.new
|
12
|
+
Namespace::Namespaced = Struct.new(:value)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:type) { Namespace::Namespaced }
|
16
|
+
|
17
|
+
it { expect(described_class.from_csv(text)).to eq(type.new(value)) }
|
18
|
+
end
|
19
|
+
|
20
|
+
context "given a non-namespaced class" do
|
21
|
+
before do
|
22
|
+
NonNamespaced = Struct.new(:value)
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:type) { NonNamespaced }
|
26
|
+
|
27
|
+
it { expect(described_class.from_csv(text)).to eq(type.new(value)) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/streamingly.gemspec
CHANGED
metadata
CHANGED
@@ -1,49 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: streamingly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Matt Gillooly
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.3'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rake
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: rspec
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- -
|
45
|
+
- - ~>
|
42
46
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
47
|
+
version: '2.11'
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.11'
|
47
55
|
description: Helpful classes for writing streaming Hadoop jobs in Ruby
|
48
56
|
email:
|
49
57
|
- matt@swipely.com
|
@@ -65,38 +73,33 @@ files:
|
|
65
73
|
- lib/streamingly/version.rb
|
66
74
|
- spec/spec_helper.rb
|
67
75
|
- spec/streamingly/reducer_spec.rb
|
76
|
+
- spec/streamingly/serde_spec.rb
|
68
77
|
- streamingly.gemspec
|
69
78
|
homepage: http://github.com/swipely/streamingly
|
70
79
|
licenses:
|
71
80
|
- MIT
|
81
|
+
metadata: {}
|
72
82
|
post_install_message:
|
73
83
|
rdoc_options: []
|
74
84
|
require_paths:
|
75
85
|
- lib
|
76
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
87
|
requirements:
|
79
|
-
- -
|
88
|
+
- - '>='
|
80
89
|
- !ruby/object:Gem::Version
|
81
90
|
version: '0'
|
82
|
-
segments:
|
83
|
-
- 0
|
84
|
-
hash: -3836940608254705733
|
85
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
92
|
requirements:
|
88
|
-
- -
|
93
|
+
- - '>='
|
89
94
|
- !ruby/object:Gem::Version
|
90
95
|
version: '0'
|
91
|
-
segments:
|
92
|
-
- 0
|
93
|
-
hash: -3836940608254705733
|
94
96
|
requirements: []
|
95
97
|
rubyforge_project:
|
96
|
-
rubygems_version:
|
98
|
+
rubygems_version: 2.0.14
|
97
99
|
signing_key:
|
98
|
-
specification_version:
|
100
|
+
specification_version: 4
|
99
101
|
summary: Helpful classes for writing streaming Hadoop jobs in Ruby
|
100
102
|
test_files:
|
101
103
|
- spec/spec_helper.rb
|
102
104
|
- spec/streamingly/reducer_spec.rb
|
105
|
+
- spec/streamingly/serde_spec.rb
|