yt_data_checker 0.1.3
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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +3 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +32 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/bin/yt_data_checker +7 -0
- data/lib/yt_data_checker/csv_hash_converter.rb +30 -0
- data/lib/yt_data_checker/differ.rb +57 -0
- data/lib/yt_data_checker/integer_formatter.rb +15 -0
- data/lib/yt_data_checker/version.rb +3 -0
- data/lib/yt_data_checker/youtube_channel_formatter.rb +15 -0
- data/lib/yt_data_checker.rb +19 -0
- data/yt_data_checker.gemspec +29 -0
- metadata +146 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 179a041091e93725edb4892693b86730df03b850
|
|
4
|
+
data.tar.gz: 6fe8f4d5ebe0468689930533f3f10264981f27d7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8c999a668dcae5fa37eebca334b56e7011f8d2a7c16aefd435bd17176f09c6ea5c0b83af645b015778a3f75e8226b1397301d349d30713d567b67a6830ac5a87
|
|
7
|
+
data.tar.gz: c0b47c646a9db6eaca58ab2e3f5b90dd0d5fbc83551bf4deff64f90c04c8cbe2d751fa568bee6778a3f6b7fe6d9cde7461faf55b99a8278bc87403d40ab9dc73
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# YtDataChecker
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to
|
|
4
|
+
be able to package up your Ruby library into a gem. Put your Ruby code in the
|
|
5
|
+
file `lib/yt_data_checker`. To experiment with that code, run `bin/console` for
|
|
6
|
+
an interactive prompt.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
Add this line to your application's Gemfile:
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
gem 'yt_data_checker'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
And then execute:
|
|
17
|
+
|
|
18
|
+
$ bundle
|
|
19
|
+
|
|
20
|
+
Or install it yourself as:
|
|
21
|
+
|
|
22
|
+
$ gem install yt_data_checker
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
yt_data_checker diff file_1.csv file_2.csv
|
|
28
|
+
|
|
29
|
+
# or with optional concerns
|
|
30
|
+
yt_data_checker diff file_1.csv file_2.csv --concern=subscriber_account
|
|
31
|
+
yt_data_checker diff file_1.csv file_2.csv --concern=channel_ownership
|
|
32
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "yt_data_checker"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/bin/yt_data_checker
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require_relative 'youtube_channel_formatter'
|
|
2
|
+
require_relative 'integer_formatter'
|
|
3
|
+
require 'csv'
|
|
4
|
+
|
|
5
|
+
module YtDataChecker
|
|
6
|
+
class CsvHashConverter
|
|
7
|
+
def initialize(csv_filename)
|
|
8
|
+
@csv_filename = csv_filename
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def create_hash
|
|
12
|
+
CSV.read(
|
|
13
|
+
csv_filename,
|
|
14
|
+
headers: true,
|
|
15
|
+
header_converters: ->(header) { header.strip }
|
|
16
|
+
).each_with_object({}) do |row, object|
|
|
17
|
+
object[row.fetch('Account Email')] = {
|
|
18
|
+
youtube_channel: YouTubeChannelFormatter.new(
|
|
19
|
+
row.fetch('YouTube Channel')).format,
|
|
20
|
+
subscriber_count: IntegerFormatter.new(
|
|
21
|
+
row.fetch('Subscriber Count')).format
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
attr_reader :csv_filename
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require 'hash_diff'
|
|
2
|
+
|
|
3
|
+
module YtDataChecker
|
|
4
|
+
class Differ
|
|
5
|
+
def initialize(hash_1, hash_2, concern: nil)
|
|
6
|
+
@hash_1 = hash_1
|
|
7
|
+
@hash_2 = hash_2
|
|
8
|
+
@concern = concern
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def diff
|
|
12
|
+
case concern
|
|
13
|
+
when 'subscriber_count' then subscriber_count_format
|
|
14
|
+
when 'channel_ownership' then channel_ownership_format
|
|
15
|
+
else default_format
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
attr_reader :hash_1, :hash_2, :concern
|
|
22
|
+
|
|
23
|
+
def hash_diff
|
|
24
|
+
@_hash_diff ||= HashDiff::Comparison.new(hash_1, hash_2).diff
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def default_format
|
|
28
|
+
hash_diff.map do |key, attributes|
|
|
29
|
+
message = "#{key} has different data. "
|
|
30
|
+
|
|
31
|
+
attributes.reduce(message) do |message, (attribute, value)|
|
|
32
|
+
message += "The value of #{attribute} in the first file is "\
|
|
33
|
+
"#{value.first} while the second file is #{value.last}. "
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def channel_ownership_format
|
|
39
|
+
hash_diff.keys
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def subscriber_count_format
|
|
43
|
+
hash_diff.map do |key, attributes|
|
|
44
|
+
attribute = attributes.find { |a| a.first == :subscriber_count }
|
|
45
|
+
|
|
46
|
+
next unless attribute
|
|
47
|
+
|
|
48
|
+
attribute_differences = attribute.last
|
|
49
|
+
|
|
50
|
+
"#{key} has subscriber_count data. The value of "\
|
|
51
|
+
"subscriber_count in the first file is "\
|
|
52
|
+
"#{attribute_differences.first} while the second "\
|
|
53
|
+
"file is #{attribute_differences.last}."
|
|
54
|
+
end.compact
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require_relative 'yt_data_checker/version'
|
|
2
|
+
require_relative 'yt_data_checker/csv_hash_converter'
|
|
3
|
+
require_relative 'yt_data_checker/differ'
|
|
4
|
+
|
|
5
|
+
module YtDataChecker
|
|
6
|
+
class Cli < ::Thor
|
|
7
|
+
default_command :diff
|
|
8
|
+
|
|
9
|
+
desc 'diff', 'Diff two formatted CSV Files with Youtube Information'
|
|
10
|
+
option :concern
|
|
11
|
+
|
|
12
|
+
def diff(file_1, file_2)
|
|
13
|
+
hash_1 = CsvHashConverter.new(file_1).create_hash
|
|
14
|
+
hash_2 = CsvHashConverter.new(file_2).create_hash
|
|
15
|
+
|
|
16
|
+
puts Differ.new(hash_1, hash_2, concern: options[:concern]).diff
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'yt_data_checker/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "yt_data_checker"
|
|
8
|
+
spec.version = YtDataChecker::VERSION
|
|
9
|
+
spec.authors = ["Nicholas Shook"]
|
|
10
|
+
spec.email = ["nicholas.shook@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.description = %q{compare to youtube csv files}
|
|
13
|
+
spec.summary = %q{compare to youtube csv files}
|
|
14
|
+
|
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
|
17
|
+
end
|
|
18
|
+
spec.bindir = "bin"
|
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
20
|
+
spec.require_paths = ["lib"]
|
|
21
|
+
|
|
22
|
+
spec.add_dependency 'hash_diff'
|
|
23
|
+
spec.add_dependency 'thor'
|
|
24
|
+
|
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
27
|
+
spec.add_development_dependency "pry"
|
|
28
|
+
spec.add_development_dependency "rspec"
|
|
29
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: yt_data_checker
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Nicholas Shook
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-11-19 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: hash_diff
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: thor
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.10'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.10'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rake
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '10.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '10.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: pry
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rspec
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description: compare to youtube csv files
|
|
98
|
+
email:
|
|
99
|
+
- nicholas.shook@gmail.com
|
|
100
|
+
executables:
|
|
101
|
+
- console
|
|
102
|
+
- setup
|
|
103
|
+
- yt_data_checker
|
|
104
|
+
extensions: []
|
|
105
|
+
extra_rdoc_files: []
|
|
106
|
+
files:
|
|
107
|
+
- ".gitignore"
|
|
108
|
+
- ".rspec"
|
|
109
|
+
- ".travis.yml"
|
|
110
|
+
- Gemfile
|
|
111
|
+
- README.md
|
|
112
|
+
- Rakefile
|
|
113
|
+
- bin/console
|
|
114
|
+
- bin/setup
|
|
115
|
+
- bin/yt_data_checker
|
|
116
|
+
- lib/yt_data_checker.rb
|
|
117
|
+
- lib/yt_data_checker/csv_hash_converter.rb
|
|
118
|
+
- lib/yt_data_checker/differ.rb
|
|
119
|
+
- lib/yt_data_checker/integer_formatter.rb
|
|
120
|
+
- lib/yt_data_checker/version.rb
|
|
121
|
+
- lib/yt_data_checker/youtube_channel_formatter.rb
|
|
122
|
+
- yt_data_checker.gemspec
|
|
123
|
+
homepage:
|
|
124
|
+
licenses: []
|
|
125
|
+
metadata: {}
|
|
126
|
+
post_install_message:
|
|
127
|
+
rdoc_options: []
|
|
128
|
+
require_paths:
|
|
129
|
+
- lib
|
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
|
+
requirements:
|
|
132
|
+
- - ">="
|
|
133
|
+
- !ruby/object:Gem::Version
|
|
134
|
+
version: '0'
|
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
|
+
requirements:
|
|
137
|
+
- - ">="
|
|
138
|
+
- !ruby/object:Gem::Version
|
|
139
|
+
version: '0'
|
|
140
|
+
requirements: []
|
|
141
|
+
rubyforge_project:
|
|
142
|
+
rubygems_version: 2.4.5.1
|
|
143
|
+
signing_key:
|
|
144
|
+
specification_version: 4
|
|
145
|
+
summary: compare to youtube csv files
|
|
146
|
+
test_files: []
|