logvisual 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68cb53d0e54216014501781183022ebba6b16e25
4
- data.tar.gz: d0c5d177505bb8bf22607d2e95c4624c781c2b2b
3
+ metadata.gz: 41d401ad14915be01cc0933bc45bc7c952cf70f8
4
+ data.tar.gz: 2f06c846b04fd75dd0cd55990c6f374ff82104cd
5
5
  SHA512:
6
- metadata.gz: c82193c9c4d16595299d78fe453803223041a043bf1ff8ce6e53c538e92818749fdce31ef00de3e8fb2fcee6ce0dd3c8bfcf8a08d83f631f66574bc107a13b35
7
- data.tar.gz: 90cd8e3a47e11645e9d5346d0ff0c0285c9a4060d770e437a0237e948ad28b5fdb00d70dbdd6acd09e4f6bdd47e786e9d5783b4c4f81d67265e4db7c6b343385
6
+ metadata.gz: 6cd281e787d3c7a81000e1eabb469c00d1c606c788c3e8e77b40dcae9b630587d46abab82b31d2a8981119d8947c2a02d06dd8b595dd78f23a5ad86b3cb9d2be
7
+ data.tar.gz: b6659f347d265fb44319ea773e6d3664a94a2b6987456c8085af37ebfbaa4afb850c77836566fcd8c438e969dd1c654abb0378c692ce56a1c74b45c68f7d583b
data/bin/lv ADDED
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'commander/import'
4
+ require 'logvisual'
5
+
6
+ # Constants
7
+ @file_path = File.expand_path('~/.logvisual')
8
+
9
+ def session(type)
10
+ abort 'You are already connected!' if File.exist?(@file_path)
11
+
12
+ email = ask("email: ")
13
+ password = ask("password: ") { |q| q.echo = "*" }
14
+
15
+ result = case type
16
+ when :signup then Logvisual::Auth.signup(email, password)
17
+ when :signin then Logvisual::Auth.signin(email, password)
18
+ else Logvisual::Auth.signup(email, password)
19
+ end
20
+ if result.include?('user')
21
+ File.write(@file_path, result['user']['token'])
22
+ puts 'Welcome! ' + result['user']['email']
23
+ else
24
+ puts 'Error with your data try again.'
25
+ end
26
+ end
27
+
28
+ program :version, Logvisual::VERSION
29
+ program :description, 'Command line tools for logvisual.co'
30
+ program :help, 'Website', 'https://logvisual.co'
31
+ program :help_formatter, :compact
32
+
33
+ command :login do |c|
34
+ c.syntax = 'lv login'
35
+ c.summary = 'Login to your account'
36
+ c.description = 'Signin in your personal account in logvisual.co and track all :)'
37
+ c.action do |args, options|
38
+ session(:signin)
39
+ end
40
+ end
41
+
42
+ command :signup do |c|
43
+ c.syntax = 'lv signup'
44
+ c.summary = 'Create new account.'
45
+ c.description = 'Create new account in logvisual.co and track all :)'
46
+ c.action do |args, options|
47
+ session(:signup)
48
+ end
49
+ end
50
+
51
+ command :logout do |c|
52
+ c.syntax = 'lv logout'
53
+ c.summary = 'Logout to your account in this machine'
54
+ c.description = 'Remove all information off logvisual account this machine.'
55
+ c.action do |args, options|
56
+ File.delete(@file_path)
57
+ say 'Logout..'
58
+ end
59
+ end
60
+
61
+ command :create do |c|
62
+ c.syntax = 'lv create "[tasl content]"'
63
+ c.summary = 'Create new task in your account'
64
+ c.description = 'Create task for your account in logvisual.co'
65
+ c.example 'Create new task', 'lv create "Finished models for user in #logvisual"'
66
+ c.action do |args, options|
67
+ abort 'Please login, first' unless File.exist?(@file_path)
68
+ abort 'Please send task use "lv create --help for help"' if args.empty?
69
+ task = Logvisual::Task.create(args[0], File.read(@file_path))
70
+ say 'Task created: ' + task['task']['content']
71
+ end
72
+ end
73
+ alias_command :n, :create
74
+
75
+ command :list do |c|
76
+ c.syntax = 'lv list'
77
+ c.summary = 'List last 10 tasks your added'
78
+ c.description = ''
79
+ c.example 'description', 'command example'
80
+ c.option '--some-switch', 'Some switch that does something'
81
+ c.action do |args, options|
82
+ abort 'Please login, first' unless File.exist?(@file_path)
83
+ say '10 last tasks: '
84
+ Logvisual::Task.list(File.read(@file_path)).each do |task|
85
+ say task['task']['content']
86
+ end
87
+ end
88
+ end
89
+ alias_command :l, :create
@@ -2,5 +2,5 @@
2
2
  # Version logvisual gem
3
3
  #
4
4
  module Logvisual
5
- VERSION = '0.1.3'
5
+ VERSION = '0.1.4'
6
6
  end
data/logvisual.gemspec CHANGED
@@ -16,10 +16,11 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0")
18
18
  spec.bindir = 'bin'
19
- spec.executables = ['lgv']
19
+ spec.executables = ['lv']
20
20
  spec.require_paths = ['lib']
21
21
 
22
22
  spec.required_ruby_version = '>= 2.0.0'
23
+ spec.add_runtime_dependency 'commander', '~> 4.0'
23
24
  spec.add_development_dependency 'bundler', '~> 1.10'
24
25
  spec.add_development_dependency 'rake', '~> 10.0'
25
26
  spec.add_development_dependency 'rspec'
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logvisual
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - angelbotto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-03 00:00:00.000000000 Z
11
+ date: 2015-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: commander
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -56,7 +70,7 @@ description: Track anything using hashtags to categorize.
56
70
  email:
57
71
  - angelbotto@gmail.com
58
72
  executables:
59
- - lgv
73
+ - lv
60
74
  extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
@@ -69,9 +83,8 @@ files:
69
83
  - README.md
70
84
  - Rakefile
71
85
  - bin/console
72
- - bin/lgv
86
+ - bin/lv
73
87
  - bin/setup
74
- - lib/cli.rb
75
88
  - lib/logvisual.rb
76
89
  - lib/logvisual/api.rb
77
90
  - lib/logvisual/auth.rb
data/bin/lgv DELETED
@@ -1,15 +0,0 @@
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/lib/cli.rb DELETED
@@ -1,88 +0,0 @@
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 'Logvisual version ' + Logvisual::VERSION
40
-
41
- puts ''
42
- puts '-- Auth'
43
- puts '----- auth:signup Create account'
44
- puts '----- auth:signin Login account'
45
- puts ''
46
- puts '-- Task'
47
- puts '----- task:list List tasks'
48
- puts '----- task:create Create task'
49
- puts ''
50
- puts 'ola k ace '
51
- end
52
-
53
- private
54
-
55
- def validate_session
56
- File.exist?(@file)
57
- end
58
-
59
- def get_token
60
- File.read(@file)
61
- end
62
-
63
- def save_token(token)
64
- File.write(@file, token)
65
- end
66
-
67
- def session(type)
68
- abort 'You are already connected!' if validate_session
69
-
70
- print 'Insert your email: '
71
- email = STDIN.gets.chomp
72
-
73
- print 'Inser your password: '
74
- password = STDIN.gets.chomp
75
-
76
- result = case type
77
- when :signup then Logvisual::Auth.signup(email, password)
78
- when :signin then Logvisual::Auth.signin(email, password)
79
- else Logvisual::Auth.signup(email, password)
80
- end
81
- if result.include?('user')
82
- save_token(result['user']['token'])
83
- puts 'Welcome! ' + result['user']['email']
84
- else
85
- puts 'Error with your data try again.'
86
- end
87
- end
88
- end