sentiment-all 1.2.0beta

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c321a29189195824fc656683e9f2b1f7ed00f958efd4a5fa5f19c32f4c0d8156
4
+ data.tar.gz: 69e91da7edffa600921aa21923073c3466028ae16611be5a97539de9b3d6dc7b
5
+ SHA512:
6
+ metadata.gz: 4c47f4d5c87cc482d722f9a7fdd7bca79e8316bf427e4d195592760414ee9fa7dc8c0af6cd4a77d5b3c4499a6a615b50a2eee470f8333f1cb1d3a81a6f25de74
7
+ data.tar.gz: '0981182ceac7d3b0f9d046d0c4f954c4eade2e2ef64c08a44ea395fcf1f7a77febe9e52f8b086cd4f68e3d6145c6a42f188d7cdfa18640c01c951ebb9e7d579e'
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.2
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in sentiment.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,60 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sentiment-all (1.2.0beta)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.3)
10
+ coveralls (0.8.23)
11
+ json (>= 1.8, < 3)
12
+ simplecov (~> 0.16.1)
13
+ term-ansicolor (~> 1.3)
14
+ thor (>= 0.19.4, < 2.0)
15
+ tins (~> 1.6)
16
+ diff-lcs (1.4.4)
17
+ docile (1.3.2)
18
+ json (2.3.1)
19
+ method_source (1.0.0)
20
+ pry (0.13.1)
21
+ coderay (~> 1.1)
22
+ method_source (~> 1.0)
23
+ rake (12.3.3)
24
+ rspec (3.9.0)
25
+ rspec-core (~> 3.9.0)
26
+ rspec-expectations (~> 3.9.0)
27
+ rspec-mocks (~> 3.9.0)
28
+ rspec-core (3.9.3)
29
+ rspec-support (~> 3.9.3)
30
+ rspec-expectations (3.9.2)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.9.0)
33
+ rspec-mocks (3.9.1)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.9.0)
36
+ rspec-support (3.9.3)
37
+ simplecov (0.16.1)
38
+ docile (~> 1.1)
39
+ json (>= 1.8, < 3)
40
+ simplecov-html (~> 0.10.0)
41
+ simplecov-html (0.10.2)
42
+ sync (0.5.0)
43
+ term-ansicolor (1.7.1)
44
+ tins (~> 1.0)
45
+ thor (1.0.1)
46
+ tins (1.26.0)
47
+ sync
48
+
49
+ PLATFORMS
50
+ ruby
51
+
52
+ DEPENDENCIES
53
+ coveralls
54
+ pry (~> 0.13.1)
55
+ rake (~> 12.0)
56
+ rspec (~> 3.0)
57
+ sentiment-all!
58
+
59
+ BUNDLED WITH
60
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 TODO: Write your name
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,63 @@
1
+ # sentiment-al
2
+
3
+ sentiment-al is Sentiment Analysis Service that allow the analysis of text throught [SENTIM-API](https://sentim-api.herokuapp.com/).
4
+
5
+ [![Build Status](https://travis-ci.com/armando1339/sentiment-al.svg?branch=master)](https://travis-ci.com/armando1339/sentiment-al) [![Coverage Status](https://coveralls.io/repos/github/armando1339/sentiment-al/badge.svg?branch=master)](https://coveralls.io/github/armando1339/sentiment-al?branch=master)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'sentiment-al'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ ```bash
18
+ $ bundle install
19
+ ```
20
+
21
+ Or install it yourself as:
22
+
23
+ ```bash
24
+ $ gem install sentiment-al
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ```ruby
30
+
31
+ # => Execute the service
32
+ sentiment_al.call text: "Candy"
33
+
34
+ # => Verify the SENTIM-API responce
35
+ sentiment_al.successfully?
36
+
37
+ # => Verify the response
38
+ sentiment_al.response
39
+
40
+ # => Response to hash
41
+ sentiment_al.response_to_hash
42
+
43
+ ```
44
+
45
+ Verify the status of HTTP Request
46
+
47
+ ```ruby
48
+ sentiment_al.response
49
+ sentiment_al.response.code
50
+ sentiment_al.response.message
51
+ sentiment_al.response.body
52
+ ```
53
+
54
+ ## Development
55
+
56
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
57
+
58
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
59
+
60
+
61
+ ## License
62
+
63
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sentiment"
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(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,12 @@
1
+ require "sentiment_al/version"
2
+ require "net/http"
3
+ require "json"
4
+
5
+ # => *
6
+ require "sentiment_al/http_request"
7
+ require "sentiment_al/service"
8
+
9
+ # => load sentiment_al object
10
+ def sentiment_al
11
+ SentimentAl::Service
12
+ end
@@ -0,0 +1,33 @@
1
+ module SentimentAl
2
+ class HttpRequest
3
+ attr_accessor :uri, :protocol, :request
4
+
5
+ def initialize(params)
6
+ @uri = build_uri
7
+ @protocol = ::Net::HTTP.new(uri.host, uri.port)
8
+ @request = ::Net::HTTP::Post.new(uri.path, headers)
9
+
10
+ request.body = params.to_json
11
+ yield self if block_given?
12
+ end
13
+
14
+ def start
15
+ protocol.use_ssl = true
16
+ protocol.start{ |http| http.request(request) }
17
+ end
18
+
19
+ private
20
+
21
+ def build_uri
22
+ URI("#{sentim_api_url}/api/v1/")
23
+ end
24
+
25
+ def headers
26
+ { 'Accept' => 'application/json', 'Content-Type' => 'application/json' }
27
+ end
28
+
29
+ def sentim_api_url
30
+ 'https://sentim-api.herokuapp.com'
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,57 @@
1
+ module SentimentAl
2
+ class Service
3
+ class << self
4
+ attr_reader :params, :response, :unincluded_params
5
+
6
+ # => Run the service if it has
7
+ # all the necessary data
8
+ #
9
+ def call(params)
10
+ @params = params
11
+ unincluded_error unless required_params?
12
+
13
+ HttpRequest.new(params) do |request|
14
+ @response = request.start
15
+ end
16
+
17
+ self
18
+ end
19
+
20
+ def successfully?
21
+ response.code.start_with?('2')
22
+ end
23
+
24
+ def response_to_hash
25
+ JSON.parse(response.body)
26
+ end
27
+
28
+ private
29
+
30
+ # => Search information about
31
+ # missing data in parameters and
32
+ # response true/false
33
+ #
34
+ def required_params?
35
+ @unincluded_params = []
36
+
37
+ required_params.each do |param|
38
+ unless params.include?(param)
39
+ unincluded_params << param
40
+ end
41
+ end
42
+
43
+ unincluded_params.empty?
44
+ end
45
+
46
+ # => *
47
+ def required_params
48
+ %i(text)
49
+ end
50
+
51
+ # => *
52
+ def unincluded_error
53
+ raise Exception, "required params #{unincluded_params}"
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,3 @@
1
+ module SentimentAl
2
+ VERSION = "1.2.0beta"
3
+ end
@@ -0,0 +1,33 @@
1
+ require_relative 'lib/sentiment_al/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "sentiment-all"
5
+ spec.version = SentimentAl::VERSION
6
+ spec.authors = ["Armando Alejandre"]
7
+ spec.email = ["armando1339@gmail.com"]
8
+
9
+ spec.summary = %q{Sentiment Analysis Service.}
10
+ spec.description = %q{sentiment-al is Sentiment Analysis Service that allow the analysis of text throught SENTIM-API.}
11
+ spec.homepage = "https://github.com/armando1339"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/armando1339"
19
+ # spec.metadata["changelog_uri"] = "Put your gem's CHANGELOG.md URL here."
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ # => Development
31
+ spec.add_development_dependency "pry", "~> 0.13.1"
32
+ spec.add_development_dependency "coveralls"
33
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sentiment-all
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0beta
5
+ platform: ruby
6
+ authors:
7
+ - Armando Alejandre
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-10-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.13.1
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.13.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: sentiment-al is Sentiment Analysis Service that allow the analysis of
42
+ text throught SENTIM-API.
43
+ email:
44
+ - armando1339@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".coveralls.yml"
50
+ - ".gitignore"
51
+ - ".rspec"
52
+ - ".travis.yml"
53
+ - Gemfile
54
+ - Gemfile.lock
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - bin/console
59
+ - bin/setup
60
+ - lib/sentiment_al.rb
61
+ - lib/sentiment_al/http_request.rb
62
+ - lib/sentiment_al/service.rb
63
+ - lib/sentiment_al/version.rb
64
+ - sentiment_al.gemspec
65
+ homepage: https://github.com/armando1339
66
+ licenses:
67
+ - MIT
68
+ metadata:
69
+ allowed_push_host: https://rubygems.org/
70
+ homepage_uri: https://github.com/armando1339
71
+ source_code_uri: https://github.com/armando1339
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 2.3.0
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">"
84
+ - !ruby/object:Gem::Version
85
+ version: 1.3.1
86
+ requirements: []
87
+ rubygems_version: 3.1.4
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Sentiment Analysis Service.
91
+ test_files: []