adncv 0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3a843bae488bf56dee3ee1fa6f878c941fe07b1d
4
+ data.tar.gz: 91698f20ad8b7832fcdc65f8ac0a292c96507c1d
5
+ SHA512:
6
+ metadata.gz: c437e4d77d0bbfa981f5ebb8f9080dc6f3bbda91d3f2ff21f8eb8a0171adefd536df43b1182958788847a9344be0da9d53f3db82823dc634cf413623e80f1472
7
+ data.tar.gz: 5f1f2713534688c79af0b51542ed0cb67a4da9e3a896b536c7ad2bf8054ddb5c5f82c28c72b2bff37babc74f90f90e11bbaf9c45888c9e8d8606c4494c78554b
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/ADNCV.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ADNCV/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "adncv"
8
+ spec.version = ADNCV::VERSION
9
+ spec.authors = ["Eric Dejonckheere"]
10
+ spec.email = ["eric@aya.io"]
11
+ spec.summary = %q{Statistics from your App.net data.}
12
+ spec.description = %q{Statistics from your downloaded App.net data.}
13
+ spec.homepage = "https://github.com/ericdke/ADNCV"
14
+ spec.license = "MIT"
15
+
16
+ spec.bindir = 'bin'
17
+ spec.files = `git ls-files`.split("\n")
18
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ spec.executables = %w{adncv}
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "thor", "~> 0.19"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ADNCV.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Eric Dejonckheere
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # ADNCV
2
+
3
+ Statistics from your App.net data.
4
+
5
+ 1. Download your ADN data
6
+ 2. Install: `gem install adncv`
7
+ 2. Run the Gem:
8
+
9
+ ```
10
+ adncv /path/to/appdotnet-data-you-xxxxx-posts.json
11
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/adncv ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # Author: Eric DEJONCKHEERE (http://app.net/ericd)
4
+
5
+ $PROGRAM_NAME = 'adncv'
6
+ require_relative '../lib/adncv.rb'
7
+
8
+ ADNCV::App.start ARGV
data/lib/ADNCV/app.rb ADDED
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+ module ADNCV
3
+ class App < Thor
4
+ package_name "ADNCV"
5
+ require_relative "display"
6
+ require_relative "data"
7
+
8
+ desc "display", "Extract"
9
+ map "-d" => :display
10
+ def display(file)
11
+ data = Data.new
12
+ display = Display.new
13
+ display.analyzing
14
+ data.extract(file)
15
+ display.done
16
+ data.display
17
+ end
18
+
19
+ desc "export", "Export"
20
+ map "-e" => :export
21
+ def export(file)
22
+ data = Data.new
23
+ display = Display.new
24
+ display.analyzing
25
+ data.extract(file)
26
+ display.done
27
+ data.export
28
+ display.exported(data.export_path)
29
+ end
30
+
31
+ desc "version", "Show the current version (-v)"
32
+ map "-v" => :version
33
+ def version
34
+ display = Display.new
35
+ display.version
36
+ end
37
+
38
+ end
39
+ end
data/lib/ADNCV/data.rb ADDED
@@ -0,0 +1,108 @@
1
+ # encoding: utf-8
2
+ module ADNCV
3
+ class Data
4
+
5
+ attr_reader :filename, :count, :leadings, :without_mentions, :mentions_not_directed, :replies, :mentions_not_replies, :with_links, :sources, :all_links, :directed_users, :names, :clients, :mentions, :all_clients, :all_mentioned
6
+ attr_accessor :export_path
7
+
8
+ def initialize
9
+
10
+ end
11
+
12
+ def extract(file)
13
+ @filename = file
14
+ decoded = JSON.parse(File.read(file))
15
+ @count = decoded.size
16
+
17
+ links = []
18
+ @mentions = 0
19
+ @leadings = 0
20
+ @replies = 0
21
+ @with_links = 0
22
+ mentioned = Hash.new(0)
23
+ directed = Hash.new(0)
24
+ is_reply = Hash.new(0)
25
+ @clients = Hash.new(0)
26
+
27
+ decoded.each do |post|
28
+ @clients[post["source"]["name"]] += 1
29
+ m = post["entities"]["mentions"]
30
+ l = post["entities"]["links"]
31
+ unless m.empty?
32
+ @mentions += 1
33
+ first = m[0]["name"]
34
+ if m[0]["is_leading"] == true
35
+ @leadings += 1
36
+ directed[first] += 1
37
+ unless post["reply_to"].nil?
38
+ @replies += 1
39
+ is_reply[first] += 1
40
+ end
41
+ end
42
+ m.each do |obj|
43
+ mentioned[obj["name"]] += 1
44
+ end
45
+ end
46
+ unless l.empty?
47
+ @with_links += 1
48
+ l.each do |link|
49
+ links << link['url']
50
+ end
51
+ end
52
+ end
53
+
54
+ all_directed = directed.sort_by {|k,v| v}
55
+ @all_clients = @clients.sort_by {|k,v| v}
56
+ @all_mentioned = mentioned.sort_by {|k,v| v}.uniq
57
+ @all_links = links.uniq.sort
58
+ @names = @all_mentioned.map {|k,v| "#{k} (#{v})"}
59
+ @sources = @all_clients.map {|k,v| "#{k} (#{v})"}
60
+ @directed_users = all_directed.uniq.map {|k,v| "#{k} (#{v})"}
61
+
62
+ @without_mentions = count - @mentions
63
+ @mentions_not_directed = @mentions - @leadings
64
+ @mentions_not_replies = @mentions - @replies
65
+
66
+ end
67
+
68
+ def export
69
+ export = {
70
+ meta: {
71
+ created_at: Time.now,
72
+ from_file: @filename,
73
+ with_version: VERSION
74
+ },
75
+ data: {
76
+ posts: {
77
+ total: @count,
78
+ data: [{
79
+ without_mentions: @without_mentions,
80
+ directed: @leadings,
81
+ directed_to_unique_users: @directed_users.size,
82
+ with_mentions_not_directed: @mentions_not_directed,
83
+ with_mentions_are_replies: @replies,
84
+ with_mentions_are_not_replies: @mentions_not_replies,
85
+ with_links: @with_links
86
+ }]
87
+ },
88
+ users: {
89
+ total: @all_mentioned.size,
90
+ data: @all_mentioned.reverse
91
+ },
92
+ clients: {
93
+ total: @all_clients.size,
94
+ data: @all_clients.reverse
95
+ },
96
+ links: {
97
+ total: @with_links,
98
+ data: @all_links
99
+ }
100
+ }
101
+ }
102
+
103
+ @export_path = "#{Dir.home}/adndata_export.json"
104
+ File.write(@export_path, export.to_json)
105
+ end
106
+
107
+ end
108
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ module ADNCV
3
+ class Display
4
+
5
+ def initialize
6
+ @thor = Thor::Shell::Color.new
7
+ end
8
+
9
+ def version
10
+ @thor.say_status :version, "#{VERSION}", :red
11
+ end
12
+
13
+ def analyzing
14
+ @thor.say_status :working, "Analyzing JSON file", :yellow
15
+ end
16
+
17
+ def done
18
+ @thor.say_status :done, "Parsed and sorted", :green
19
+ end
20
+
21
+ def exported(filename)
22
+ @thor.say_status :done, "Data exported in #{filename}", :green
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module ADNCV
2
+ VERSION = "0.1"
3
+ end
data/lib/ADNCV.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'thor'
2
+ require 'json'
3
+ require_relative "ADNCV/version"
4
+ require_relative "ADNCV/app"
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adncv
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Eric Dejonckheere
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Statistics from your downloaded App.net data.
56
+ email:
57
+ - eric@aya.io
58
+ executables:
59
+ - adncv
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ADNCV.gemspec
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/adncv
70
+ - lib/ADNCV.rb
71
+ - lib/ADNCV/app.rb
72
+ - lib/ADNCV/data.rb
73
+ - lib/ADNCV/display.rb
74
+ - lib/ADNCV/version.rb
75
+ homepage: https://github.com/ericdke/ADNCV
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.2.2
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Statistics from your App.net data.
99
+ test_files: []