hink 0.0.1.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +0 -0
- data/bin/hink +66 -0
- data/lib/hink.rb +2 -0
- data/lib/hink/request.rb +52 -0
- data/lib/hink/version.rb +3 -0
- data/spec/hink/request_spec.rb +14 -0
- data/spec/spec_helper.rb +16 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9cb5cc8599e278b2cfde9d483daf4fdd94162dcf
|
4
|
+
data.tar.gz: c2cb33e4118cb861aab37c862225bdc41818937e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0f1fcc2e954e56782649dce38a629191824258dcaa2aba5d5ebcc842cf989d7b520fc90a93de353a24974b8fcc9e51358ab8efaa119a2345d90685079cf80391
|
7
|
+
data.tar.gz: 9604f042a0001ebde2448be228ef8f32ac0a2345e1c84263a3ced85148beb05c3e7f58f550debb4023bf0f0e7b8b95fccd623a6480997a2efc0bbaf55dab4f67
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 ChrisArcand, tippenein
|
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
File without changes
|
data/bin/hink
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'gli'
|
5
|
+
require 'hink'
|
6
|
+
|
7
|
+
module Hink
|
8
|
+
include GLI::App
|
9
|
+
extend self
|
10
|
+
|
11
|
+
program_desc 'Hink Command Line Utility'
|
12
|
+
version Hink::VERSION
|
13
|
+
|
14
|
+
wrap_help_text :verbatim
|
15
|
+
|
16
|
+
program_long_desc """
|
17
|
+
DOCUMENTATION
|
18
|
+
For documentation on Hink:
|
19
|
+
https://github.com/tippenein/hink
|
20
|
+
|
21
|
+
For documentation on Hink-server:
|
22
|
+
https://github.com/tippenein/hink-server
|
23
|
+
"""
|
24
|
+
|
25
|
+
switch :debug, :desc => 'Enable debug mode for detailed logs and backtraces', :negatable => false
|
26
|
+
switch :color, :desc => 'Use colored output', :default_value => true
|
27
|
+
|
28
|
+
pre do |global_options, command, options, args|
|
29
|
+
$debug = global_options[:debug]
|
30
|
+
$color = global_options[:color]
|
31
|
+
ENV['GLI_DEBUG'] = $debug.to_s
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "list tags"
|
36
|
+
arg_name '<specific tag>'
|
37
|
+
command :list do |c|
|
38
|
+
c.action do |global_options, options, args|
|
39
|
+
request = Hink::Request.new(global_options.merge(options))
|
40
|
+
request.list(*args)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "search"
|
45
|
+
arg_name '<query>'
|
46
|
+
command :search do |c|
|
47
|
+
c.action do |global_options, options, args|
|
48
|
+
# search
|
49
|
+
request = Hink::Request.new(global_options.merge(options))
|
50
|
+
request.search(*args)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "put"
|
55
|
+
arg_name '<title>'
|
56
|
+
arg_name '<content>'
|
57
|
+
arg_name '<tags>'
|
58
|
+
command :put do |c|
|
59
|
+
c.action do |global_options, options, args|
|
60
|
+
request = Hink::Request.new(global_options.merge(options))
|
61
|
+
request.put(*args)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
exit run(ARGV)
|
66
|
+
end
|
data/lib/hink.rb
ADDED
data/lib/hink/request.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'typhoeus'
|
2
|
+
require 'uri'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
module Hink
|
6
|
+
class Request
|
7
|
+
def initialize(opts)
|
8
|
+
env = opts[:env]
|
9
|
+
@request = Typhoeus::Request
|
10
|
+
@url = 'http://hink-server.herokuapp.com'
|
11
|
+
end
|
12
|
+
|
13
|
+
def list
|
14
|
+
puts Typhoeus.get(@url).body
|
15
|
+
end
|
16
|
+
|
17
|
+
def search(*args)
|
18
|
+
@request.new(
|
19
|
+
url_join("search"),
|
20
|
+
method: :post,
|
21
|
+
params: { q: args}
|
22
|
+
)
|
23
|
+
@request.response.body
|
24
|
+
end
|
25
|
+
|
26
|
+
def put(*args)
|
27
|
+
title, content, tags = get_content_from_args(args)
|
28
|
+
@request.new(
|
29
|
+
url_join("docs"),
|
30
|
+
method: :post,
|
31
|
+
params: { title: title,
|
32
|
+
content: content,
|
33
|
+
tags: tags }
|
34
|
+
)
|
35
|
+
@request.response.body
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def get_content_from_args(args)
|
41
|
+
title = args.pop
|
42
|
+
content = args.pop
|
43
|
+
tags = args.pop
|
44
|
+
return title, content, tags
|
45
|
+
end
|
46
|
+
|
47
|
+
def url_join path
|
48
|
+
URI.join @url, path
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
data/lib/hink/version.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Hink
|
4
|
+
describe Request do
|
5
|
+
subject { described_class.new(opts) }
|
6
|
+
let(:opts) { {} }
|
7
|
+
let(:args) { [:title, "some content", [:tag_one, :tag_two]] }
|
8
|
+
let(:url) { "http://www.example.com" }
|
9
|
+
let(:request) { double }
|
10
|
+
before do
|
11
|
+
allow(subject).to receive(:url) { url }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.raise_errors_for_deprecations!
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
# Run specs in random order to surface order dependencies. If you find an
|
12
|
+
# order dependency and want to debug it, you can fix the order by providing
|
13
|
+
# the seed, which is printed after each run.
|
14
|
+
# --seed 1234
|
15
|
+
config.order = 'random'
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hink
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ChrisArcand, tippenein
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gli
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.11'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: typhoeus
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
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.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
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.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.10'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.10'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: octopolo~> 0.2
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
executables:
|
114
|
+
- hink
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- LICENSE
|
119
|
+
- README.md
|
120
|
+
- bin/hink
|
121
|
+
- lib/hink.rb
|
122
|
+
- lib/hink/request.rb
|
123
|
+
- lib/hink/version.rb
|
124
|
+
- spec/hink/request_spec.rb
|
125
|
+
- spec/spec_helper.rb
|
126
|
+
homepage: https://github.com/tippenein/hink
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
metadata: {}
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: 1.3.1
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.2.2
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: A command line utility to interface with Hink
|
150
|
+
test_files:
|
151
|
+
- spec/hink/request_spec.rb
|
152
|
+
- spec/spec_helper.rb
|