logvisual 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6a970368f1e2e7ea7bcf7de8564a84c1a17218f3
4
+ data.tar.gz: 1d42db60afa19a916c005058b96e6e92cc9b124c
5
+ SHA512:
6
+ metadata.gz: 3837dc8bf1e053080d6b296deb071ed7ffb1becd7210625630a105e6fe52258f6bbc5bb25d1b382caffa34d776d7b519aeaa53c91fdd43804bb1b42ccb2bb0dc
7
+ data.tar.gz: d0f63c03468922a94a793594a6dc9caca37405dffabebcf93fa327136c7fb741d0425ff1308f42d69d5fc7f83af59b229c910f299ab846bc767fbb7e26a5f130
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in logvisual.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 angelbotto
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.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Logvisual
2
+
3
+ gem for logvisual
4
+ TODO: create readme xD
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'logvisual'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install logvisual
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage instructions here
25
+
26
+ ## Development
27
+
28
+ 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.
29
+
30
+ 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).
31
+
32
+ ## Contributing
33
+
34
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/logvisual. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
35
+
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
40
+
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bundler/setup'
3
+ require 'logvisual'
4
+ require 'irb'
5
+
6
+ IRB.start
data/bin/lgv ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'logvisual'
4
+ require 'cli'
5
+
6
+ log = LogvisualCli.new
7
+
8
+ case ARGV[0]
9
+ when 'auth:signin' then log.signin
10
+ when 'auth:signup' then log.signup
11
+ when 'auth:logout' then log.logout
12
+ when 'task:create' then log.create(ARGV[1] || nil)
13
+ when 'task:list' then log.list
14
+ else log.show_help
15
+ end
data/bin/setup ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
data/lib/cli.rb ADDED
@@ -0,0 +1,77 @@
1
+ ##
2
+ # Logline commandtool
3
+ class LogvisualCli
4
+ def initialize
5
+ @file = File.expand_path('~/.logvisual')
6
+ end
7
+
8
+ ##
9
+ # Login
10
+ #
11
+ def signin
12
+ session(:signin)
13
+ end
14
+
15
+ ##
16
+ # Signup
17
+ #
18
+ def signup
19
+ session(:signup)
20
+ end
21
+
22
+ ##
23
+ # Create
24
+ def create(task)
25
+ abort 'Please login, first' unless validate_session
26
+ task = Logvisual::Task.create(task, get_token)
27
+ print 'Task created: '
28
+ puts task['task']['content']
29
+ end
30
+
31
+ def list
32
+ abort 'Please login, first' unless validate_session
33
+ Logvisual::Task.list(get_token).each do |task|
34
+ puts task['task']['content']
35
+ end
36
+ end
37
+
38
+ def show_help
39
+ puts 'Hola que ace'
40
+ end
41
+
42
+ private
43
+
44
+ def validate_session
45
+ File.exist?(@file)
46
+ end
47
+
48
+ def get_token
49
+ File.read(@file)
50
+ end
51
+
52
+ def save_token(token)
53
+ File.write(@file, token)
54
+ end
55
+
56
+ def session(type)
57
+ abort 'You are already connected!' if validate_session
58
+
59
+ print 'Insert your email: '
60
+ email = STDIN.gets.chomp
61
+
62
+ print 'Inser your password: '
63
+ password = STDIN.gets.chomp
64
+
65
+ result = case type
66
+ when :signup then Logvisual::Auth.signup(email, password)
67
+ when :signin then Logvisual::Auth.signin(email, password)
68
+ else Logvisual::Auth.signup(email, password)
69
+ end
70
+ if result.include?('user')
71
+ save_token(result['user']['token'])
72
+ puts 'Welcome! ' + result['user']['email']
73
+ else
74
+ puts 'Error with your data try again.'
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,21 @@
1
+ require 'net/http'
2
+ require 'json'
3
+ ##
4
+ # Api logvisual gem
5
+ #
6
+ module Logvisual
7
+ ##
8
+ # Api class
9
+ #
10
+ class Api
11
+ def self.send_request(endpoint, data = {}, token = nil)
12
+ uri = URI('http://api.logvisual.co/v1' + endpoint)
13
+ http = Net::HTTP.new(uri.host, uri.port)
14
+ body = URI.encode_www_form(data)
15
+ req = Net::HTTP::Post.new(uri)
16
+ req.add_field('AUTHORIZATION', token) if token
17
+ req.body = body
18
+ JSON.parse(http.request(req).body)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,31 @@
1
+ ##
2
+ # Auth logvisual gem
3
+ #
4
+ module Logvisual
5
+ ##
6
+ # Auth api
7
+ class Auth < Api
8
+ def self.signup(email, password)
9
+ data = { email: email, password: password }
10
+ request(:signup, data)
11
+ end
12
+
13
+ def self.signin(email, password)
14
+ data = { email: email, password: password }
15
+ request(:signin, data)
16
+ end
17
+
18
+ def self.request(type, data = {})
19
+ fail 'Email is required' if data[:email].nil?
20
+ fail 'Password is required' if data[:password].nil?
21
+
22
+ path = case type
23
+ when :signup then '/auth/signup'
24
+ when :signin then '/auth/signin'
25
+ else '/auth/signup'
26
+ end
27
+
28
+ send_request(path, data)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,24 @@
1
+ ##
2
+ # Task logvisual gem
3
+ #
4
+ module Logvisual
5
+ ##
6
+ # Task
7
+ #
8
+ class Task < Api
9
+ ##
10
+ # Create new task
11
+ #
12
+ def self.create(task, token)
13
+ fail 'Please send task' if task.empty?
14
+ send_request('/task/create', { content: task }, token)
15
+ end
16
+
17
+ ##
18
+ # Get list
19
+ #
20
+ def self.list(token)
21
+ send_request('/task/list', {}, token)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,6 @@
1
+ ##
2
+ # Version logvisual gem
3
+ #
4
+ module Logvisual
5
+ VERSION = '0.1.0'
6
+ end
data/lib/logvisual.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'logvisual/version'
2
+ require 'logvisual/api'
3
+ require 'logvisual/auth'
4
+ require 'logvisual/task'
data/logvisual.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 'logvisual/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'logvisual'
8
+ spec.version = Logvisual::VERSION
9
+ spec.authors = ['angelbotto']
10
+ spec.email = ['angelbotto@gmail.com']
11
+
12
+ spec.summary = 'Track anything :)'
13
+ spec.description = 'Track anything using hashtags to categorize.'
14
+ spec.homepage = 'http://logvisual.co'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.bindir = 'bin'
19
+ spec.executables = ['lgv']
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.required_ruby_version = '>= 2.0.0'
23
+ spec.add_development_dependency 'bundler', '~> 1.10'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec'
26
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Logvisual do
4
+ it 'has a version number' do
5
+ expect(Logvisual::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'logvisual'
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logvisual
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - angelbotto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Track anything using hashtags to categorize.
56
+ email:
57
+ - angelbotto@gmail.com
58
+ executables:
59
+ - lgv
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/console
72
+ - bin/lgv
73
+ - bin/setup
74
+ - lib/cli.rb
75
+ - lib/logvisual.rb
76
+ - lib/logvisual/api.rb
77
+ - lib/logvisual/auth.rb
78
+ - lib/logvisual/task.rb
79
+ - lib/logvisual/version.rb
80
+ - logvisual.gemspec
81
+ - spec/logvisual_spec.rb
82
+ - spec/spec_helper.rb
83
+ homepage: http://logvisual.co
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 2.0.0
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.4.5.1
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Track anything :)
107
+ test_files: []