jeremyf-comma_pile 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -5,7 +5,7 @@ A simple gem for processing and aggregating CSV files. CommaPile builds a table
5
5
 
6
6
  Config Options:
7
7
 
8
- * **source** - What is the name of the source csv file [**REQUIRED**, **SINGUL**]
8
+ * **source** - What is the name of the source csv file [**REQUIRED**, **SINGLE**]
9
9
  * **on** - Specify any number of columns [**REQUIRED**, **MULTIPLE**]
10
10
  * **sum_on** - Specify a column that you want to accumulate given [**OPTIONAL**, **MULTIPLE**]
11
11
  * **conditions** - Specify a lambda, key-value pair that must be met for line to be
data/Rakefile CHANGED
@@ -36,6 +36,15 @@ rescue LoadError
36
36
  end
37
37
  end
38
38
 
39
+ begin
40
+ require 'cucumber/rake/task'
41
+ Cucumber::Rake::Task.new(:features)
42
+ rescue LoadError
43
+ task :features do
44
+ abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
45
+ end
46
+ end
47
+
39
48
 
40
49
  task :default => :test
41
50
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 0
4
+ :patch: 1
data/comma_pile.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{comma_pile}
5
- s.version = "0.1.0"
5
+ s.version = "0.1.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jeremy Friesen"]
9
- s.date = %q{2009-08-13}
9
+ s.date = %q{2009-08-14}
10
10
  s.email = %q{jeremy.n.friesen@gmail.com}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -20,13 +20,13 @@ Gem::Specification.new do |s|
20
20
  "Rakefile",
21
21
  "VERSION.yml",
22
22
  "comma_pile.gemspec",
23
+ "examples/example_line_parser.rb",
23
24
  "lib/comma_pile.rb",
24
25
  "lib/comma_pile/config.rb",
25
26
  "lib/comma_pile/line_parser.rb",
26
27
  "lib/comma_pile/pivot_node.rb",
27
28
  "lib/comma_pile/report.rb",
28
29
  "test/comma_pile_test.rb",
29
- "test/example_line_parser.rb",
30
30
  "test/fixtures/report.csv",
31
31
  "test/test_helper.rb"
32
32
  ]
@@ -37,8 +37,8 @@ Gem::Specification.new do |s|
37
37
  s.summary = %q{Video Stats for an onstreammedia.com log}
38
38
  s.test_files = [
39
39
  "test/comma_pile_test.rb",
40
- "test/example_line_parser.rb",
41
- "test/test_helper.rb"
40
+ "test/test_helper.rb",
41
+ "examples/example_line_parser.rb"
42
42
  ]
43
43
 
44
44
  if s.respond_to? :specification_version then
@@ -1,16 +1,26 @@
1
+ require File.join(File.dirname(__FILE__) + '/../lib/comma_pile')
1
2
  class ExampleLineParser < CommaPile::LineParser
2
3
  INDEX_FOR_IP_ADDRESS = 0
3
4
  HEADER_VALUE_FOR_IP_ADDRESS = 'c_ip'
4
5
  INDEX_FOR_FILENAME = 65
5
6
  INDEX_FOR_CLIENT_SIDE_REFERRER = 14
6
7
  INDEX_FOR_VIEWER_EVENT = 54
7
- INDEX_FOR_FILESIZE = 69
8
+ INDEX_FOR_FILESIZE = 22
9
+ INDEX_FOR_BYTES_STREAMED = 68
8
10
  def self.with(line)
9
11
  super if line[INDEX_FOR_IP_ADDRESS] != HEADER_VALUE_FOR_IP_ADDRESS
10
12
  end
11
13
 
14
+ def live_stream?
15
+ line[INDEX_FOR_IP_ADDRESS].to_i == 0 ? "live-stream" : "pre-recorded-stream"
16
+ end
17
+
18
+ def bytes_streamed
19
+ line[INDEX_FOR_BYTES_STREAMED].to_i
20
+ end
21
+
12
22
  def filesize
13
- line[69].to_i
23
+ line[INDEX_FOR_FILESIZE].to_i
14
24
  end
15
25
 
16
26
  def viewer_geolocation
@@ -10,7 +10,11 @@ module CommaPile
10
10
  end
11
11
 
12
12
  def [](value)
13
- line[value]
13
+ if value.is_a?(Integer)
14
+ line[value]
15
+ else
16
+ send(value)
17
+ end
14
18
  end
15
19
  end
16
20
  end
@@ -1,5 +1,5 @@
1
1
  require 'test_helper'
2
- require 'example_line_parser'
2
+ require '../examples/example_line_parser'
3
3
 
4
4
  class CommaPileTest < Test::Unit::TestCase
5
5
  CSV_FILE_PATH = File.join(File.dirname(__FILE__), "../test/fixtures/report.csv")
@@ -147,10 +147,10 @@ class CommaPileTest < Test::Unit::TestCase
147
147
  config.input = CSV_FILE_PATH
148
148
  config.on << :viewer_geolocation
149
149
  config.on << 0
150
- config.sum_on << :filesize
150
+ config.sum_on << :bytes_streamed
151
151
  end
152
152
  report.generate!
153
- assert_match /^#{Regexp.escape('1,off-campus,71.103.212.224,92094')}$/, report.summary
153
+ assert_match /^#{Regexp.escape('1,off-campus,71.103.212.224,6817382')}$/, report.summary
154
154
  end
155
155
 
156
156
  should "allow one or more accumulators" do
@@ -159,11 +159,11 @@ class CommaPileTest < Test::Unit::TestCase
159
159
  config.input = CSV_FILE_PATH
160
160
  config.on << :viewer_geolocation
161
161
  config.on << 0
162
- config.sum_on << :filesize
162
+ config.sum_on << :bytes_streamed
163
163
  end
164
164
  report.generate!
165
165
 
166
- assert_equal 17155, report['on-campus'].sum[:filesize]
167
- assert_equal 371622045, report['off-campus'].sum[:filesize]
166
+ assert_equal 656567, report['on-campus'].sum[:bytes_streamed]
167
+ assert_equal 18919063132, report['off-campus'].sum[:bytes_streamed ]
168
168
  end
169
169
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jeremyf-comma_pile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Friesen
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-13 00:00:00 -07:00
12
+ date: 2009-08-14 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -30,13 +30,13 @@ files:
30
30
  - Rakefile
31
31
  - VERSION.yml
32
32
  - comma_pile.gemspec
33
+ - examples/example_line_parser.rb
33
34
  - lib/comma_pile.rb
34
35
  - lib/comma_pile/config.rb
35
36
  - lib/comma_pile/line_parser.rb
36
37
  - lib/comma_pile/pivot_node.rb
37
38
  - lib/comma_pile/report.rb
38
39
  - test/comma_pile_test.rb
39
- - test/example_line_parser.rb
40
40
  - test/fixtures/report.csv
41
41
  - test/test_helper.rb
42
42
  has_rdoc: false
@@ -68,5 +68,5 @@ specification_version: 3
68
68
  summary: Video Stats for an onstreammedia.com log
69
69
  test_files:
70
70
  - test/comma_pile_test.rb
71
- - test/example_line_parser.rb
72
71
  - test/test_helper.rb
72
+ - examples/example_line_parser.rb