twitest 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/bin/twitest +20 -0
- data/lib/twitest.rb +39 -0
- data/lib/twitest/version.rb +3 -0
- data/twitest.gemspec +34 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4ab1ed8f77695f8c9ec1dc80601f66529658e0b8
|
4
|
+
data.tar.gz: 182d3cea432316b18bf0ffe48d508242b91823b7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 30bc7d7981b6de91ba0d5bdb8d0370a23f21fb7474ce5892fb1a83d79cabb0921a47a12c604ac179fad643590686c773e00b46be356e711ab3703b05a11d7f75
|
7
|
+
data.tar.gz: 314607a993522724bc05cdec2c547a85d79ceb7a7b024d49a9294c70ed0c44870ff55ce833a537620b08b594c292f5d0607c94a744b585feb6a70055839e3fa4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 cncgl
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Twitest
|
2
|
+
|
3
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/cncgl/twitest.svg)](https://gemnasium.com/github.com/cncgl/twitest)
|
4
|
+
|
5
|
+
Estimate twitter engagement by Machine Learning.
|
6
|
+
|
7
|
+
## Setup
|
8
|
+
Create Indico account at [https://indico.io/](https://indico.io/).
|
9
|
+
API Key set enviroment variable ``INDICO_API_KEY``.
|
10
|
+
|
11
|
+
Create Microsoft Translator account [https://datamarket.azure.com/dataset/1899a118-d202-492c-aa16-ba21c33c06cb](https://datamarket.azure.com/dataset/1899a118-d202-492c-aa16-ba21c33c06cb).
|
12
|
+
Client ID and Client Secret set environment variable ``CLIENT_ID`` and ``CLIENT_SECRET``.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'twitest'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install twitest
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
It's OK even if SENTENSE in Japanese.
|
32
|
+
|
33
|
+
$ twitest <SENTENSE>
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/cncgl/twitest.
|
38
|
+
|
39
|
+
## License
|
40
|
+
|
41
|
+
[MIT](LICENSE)
|
data/Rakefile
ADDED
data/bin/twitest
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'twitest'
|
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
|
+
def usage
|
13
|
+
puts "Usage: #{$0} <sentense>"
|
14
|
+
end
|
15
|
+
|
16
|
+
if ARGV.first
|
17
|
+
Twitest.execute(ARGV.first)
|
18
|
+
else
|
19
|
+
usage
|
20
|
+
end
|
data/lib/twitest.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'twitest/version'
|
2
|
+
require 'faraday'
|
3
|
+
require 'uri'
|
4
|
+
require 'json'
|
5
|
+
require 'indico'
|
6
|
+
|
7
|
+
module Twitest
|
8
|
+
def self.execute(text)
|
9
|
+
english_text = translate text
|
10
|
+
engagement = Indico.twitter_engagement(english_text, {api_key: ENV['INDICO_API_KEY']})
|
11
|
+
puts "#{english_text} (#{engagement})"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.translate(text)
|
15
|
+
token = get_access_token
|
16
|
+
res = Faraday.new(:url => 'http://api.microsofttranslator.com')
|
17
|
+
.get("/V2/Ajax.svc/Translate?to=en&text=#{URI.decode(text)}&oncomplete=translated") do |req|
|
18
|
+
req.headers['Authorization'] = "Bearer #{token}"
|
19
|
+
end
|
20
|
+
eval(res.body)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def self.get_access_token
|
25
|
+
res = Faraday.new(:url => 'https://datamarket.accesscontrol.windows.net')
|
26
|
+
.post('/v2/OAuth2-13', {
|
27
|
+
client_id: ENV['CLIENT_ID'],
|
28
|
+
client_secret: ENV['CLIENT_SECRET'],
|
29
|
+
scope: URI.decode('http://api.microsofttranslator.com/'),
|
30
|
+
grant_type: 'client_credentials'
|
31
|
+
})
|
32
|
+
body = JSON.parse(res.body)
|
33
|
+
body['access_token']
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.translated(text)
|
37
|
+
text
|
38
|
+
end
|
39
|
+
end
|
data/twitest.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'twitest/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'twitest'
|
8
|
+
spec.version = Twitest::VERSION
|
9
|
+
spec.authors = ['cncgl']
|
10
|
+
spec.email = ['concigel@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Show Twitter Engagement.}
|
13
|
+
spec.description = %q{Show Twitter Engagement.}
|
14
|
+
spec.homepage = 'http://cncgl.github.io/'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = 'bin'
|
27
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
|
30
|
+
spec.add_dependency 'faraday', '~> 0.9.2'
|
31
|
+
spec.add_dependency 'indico', '~> 0.9.3'
|
32
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
33
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twitest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- cncgl
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: indico
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.9.3
|
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.11'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.11'
|
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
|
+
description: Show Twitter Engagement.
|
70
|
+
email:
|
71
|
+
- concigel@gmail.com
|
72
|
+
executables:
|
73
|
+
- twitest
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/twitest
|
83
|
+
- lib/twitest.rb
|
84
|
+
- lib/twitest/version.rb
|
85
|
+
- twitest.gemspec
|
86
|
+
homepage: http://cncgl.github.io/
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.2.5
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Show Twitter Engagement.
|
110
|
+
test_files: []
|