tasc 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 +15 -0
- data/README.md +94 -0
- data/bin/tasc +81 -0
- data/lib/tasc/config.rb +85 -0
- data/lib/tasc/create.rb +28 -0
- data/lib/tasc/delete.rb +23 -0
- data/lib/tasc/download.rb +43 -0
- data/lib/tasc/list.rb +22 -0
- data/lib/tasc/remove.rb +28 -0
- data/lib/tasc/show.rb +24 -0
- data/lib/tasc/update.rb +28 -0
- data/lib/tasc/upload.rb +28 -0
- data/lib/tasc/version.rb +4 -0
- data/lib/tasc.rb +11 -0
- metadata +183 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YjhiMDlmYTY4ODc1YTBiNzI5ZWI4OTllOWM1NmMxNjVhYTQzNTM2Ng==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ODU0ZjdiNWUwMTVlZjE0ZTljYzE1Mzg3YzBmNTUyNzliMmUyNWNlYw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Y2Q4YjBjOWQ3OTk5MGVlMWJjZDU0ZTg3MDljMjJhNGQ4M2Y0ZGE1NDMxYjU5
|
10
|
+
ZTM5OGJjZmRjOThlYmJhYTFmYTY1YmQ2ZmQ2NmFmYWM0Y2YwNGJjYzZiMzQx
|
11
|
+
MTM2MDk0Yjg2NzNkMjdhMWViMTA4NmE0ZDg4MGIzNDVlZDIxMmY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NWRhMmY1ZTc2NzEyMzc2ZGVkODA0MWNiMzVlYmZlNzhlMWRlYWVjMzcyYThk
|
14
|
+
MTQxN2JkYTA5YjMwNzhiMDgyYzM4N2ExYzg1ZmIwYTg0ZWVlNjVlYjEyYWRk
|
15
|
+
NWUzOGViODU5ZDlmMjJiNjE5YWMzOWZhYzY3YzZjZDQ4OTk1ZGI=
|
data/README.md
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# tasc CLI
|
2
|
+
tasc is a command-line interface (CLI) for maintaining and managing the
|
3
|
+
lists of terms that are available for auto-complete from the TrieService.
|
4
|
+
|
5
|
+
tasc is a ruby gem built on top of the gli (aka, "git-like interface")
|
6
|
+
library.
|
7
|
+
|
8
|
+
### Installing
|
9
|
+
$ gem install tasc
|
10
|
+
|
11
|
+
Alternatively, clone this repo and execute the following commands from within this
|
12
|
+
directory
|
13
|
+
$ rake
|
14
|
+
$ gem install tasc
|
15
|
+
|
16
|
+
### Features
|
17
|
+
Some of the more basic feeatures are described below to help get you
|
18
|
+
started. To see all available commands simply type
|
19
|
+
|
20
|
+
$ tasc
|
21
|
+
|
22
|
+
#### Client Configuration
|
23
|
+
tasc will create a configuration file of servers you may connect to in
|
24
|
+
your user directory under _.tasc/servers.yaml_. You can use the _config_
|
25
|
+
command to display your current config settings or alter them.
|
26
|
+
|
27
|
+
$ tasc config
|
28
|
+
Configuration:
|
29
|
+
+----------------+--------------------+
|
30
|
+
| Key | Value |
|
31
|
+
+----------------+--------------------+
|
32
|
+
| current_server | dev |
|
33
|
+
| default | localhost:8080 |
|
34
|
+
| testsvr | 127.0.0.1:81 |
|
35
|
+
| foo | bar:80 |
|
36
|
+
| dev | 10.45.205.204:8080 |
|
37
|
+
| testingsq | 1.1.02.10:3333 |
|
38
|
+
| bchee | 10.115.100.77:8080 |
|
39
|
+
+----------------+--------------------+
|
40
|
+
|
41
|
+
#### List Management
|
42
|
+
|
43
|
+
* upload & download a list in a file
|
44
|
+
* add, update, remove entries from a list
|
45
|
+
* create, delete, update, show a list
|
46
|
+
|
47
|
+
#### List Configuration
|
48
|
+
Supports 2 types of lists:
|
49
|
+
* static - list of pre-determined items, use the _upload_ command
|
50
|
+
* dynamic - list is generated by usage, use the _create_ command
|
51
|
+
|
52
|
+
Dynamic lists are self-maintaining. The TrieService keeps track of each
|
53
|
+
entry's usage and age. You can configure a maximum number of entries
|
54
|
+
that will be maintained. When the max size is reached, the usage and age is used to sort
|
55
|
+
the list and remove the least-recently, least-frequently used item (LRLFU).
|
56
|
+
|
57
|
+
### Building
|
58
|
+
|
59
|
+
The included Rakefile will build the tasc gem, e.g.,
|
60
|
+
|
61
|
+
```shell
|
62
|
+
$ rake
|
63
|
+
Using rake (10.0.3)
|
64
|
+
Using ffi (1.4.0)
|
65
|
+
Using childprocess (0.3.9)
|
66
|
+
Using builder (3.2.0)
|
67
|
+
Using diff-lcs (1.2.1)
|
68
|
+
Using json (1.7.7)
|
69
|
+
Using gherkin (2.11.6)
|
70
|
+
Using multi_json (1.6.1)
|
71
|
+
Using cucumber (1.2.2)
|
72
|
+
Using rspec-expectations (2.13.0)
|
73
|
+
Using aruba (0.5.1)
|
74
|
+
Using awesome_print (1.1.0)
|
75
|
+
Using gli (2.5.4)
|
76
|
+
Using hirb (0.7.0)
|
77
|
+
Using mime-types (1.21)
|
78
|
+
Using rdoc (4.0.0)
|
79
|
+
Using rest-client (1.6.7)
|
80
|
+
Using wopen3 (0.3)
|
81
|
+
Using tasc (0.1.0)
|
82
|
+
Using bundler (1.3.1)
|
83
|
+
Your bundle is complete! Use `bundle show [gemname]` to see where a
|
84
|
+
bundled gem is installed.
|
85
|
+
Latest version currently installed. Aborting.
|
86
|
+
Updating installed gems
|
87
|
+
Nothing to update
|
88
|
+
WARNING: licenses is empty
|
89
|
+
WARNING: no description specified
|
90
|
+
Successfully built RubyGem
|
91
|
+
Name: tasc
|
92
|
+
Version: 0.1.0
|
93
|
+
File: tasc-0.1.0.gem
|
94
|
+
```
|
data/bin/tasc
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
4
|
+
|
5
|
+
require 'gli'
|
6
|
+
require 'tasc'
|
7
|
+
|
8
|
+
include GLI::App
|
9
|
+
|
10
|
+
program_desc 'a command line app for managing lists of terms available for auto-complete from the TrieService'
|
11
|
+
version Tasc::VERSION
|
12
|
+
preserve_argv
|
13
|
+
|
14
|
+
# config_file stored in .tasc subdirectory of user's home directory
|
15
|
+
# ruby handles finding it, so it's platform agnostic
|
16
|
+
CFG_FILE = config_file('.tasc/servers.yaml')
|
17
|
+
|
18
|
+
|
19
|
+
# **********************************
|
20
|
+
# List Global Switches here, but command-specific switches in the ./command/<command>.rb
|
21
|
+
# Switches are value-less options passed to the command
|
22
|
+
# Example: --lb would specify that the command is to operate on the Load Balancer
|
23
|
+
# desc 'Describe your switch here'
|
24
|
+
# switch [:s,:switch]
|
25
|
+
|
26
|
+
# ***********************************
|
27
|
+
# List Global Flags here, but command-specific flags in the ./command/<command>.rb
|
28
|
+
# Flags are name value pairs passed to the command
|
29
|
+
# Example: -h 10.20.41.256 tells the command to operate against this specific server
|
30
|
+
# desc 'Describe your flag here'
|
31
|
+
# arg_name 'name of flag arg'
|
32
|
+
# flag [:f,:flag]
|
33
|
+
|
34
|
+
pre do |global,command,options,args|
|
35
|
+
# Pre logic here
|
36
|
+
# Return true to proceed; false to abort and not call the
|
37
|
+
# chosen command
|
38
|
+
# Use skips_pre before a command to skip this block
|
39
|
+
# on that command only
|
40
|
+
|
41
|
+
# Create directory and config if they don't already exist
|
42
|
+
@conf_dir = File.join(File.expand_path(ENV['HOME']),'.tasc')
|
43
|
+
#ap "config directory: " + @conf_dir
|
44
|
+
unless File.exists?(CFG_FILE)
|
45
|
+
unless Dir.exists?(@conf_dir) then Dir.mkdir @conf_dir end
|
46
|
+
|
47
|
+
tasc_conf = YAML::Store.new(CFG_FILE)
|
48
|
+
tasc_conf.transaction do
|
49
|
+
tasc_conf["current_server"] = "default"
|
50
|
+
tasc_conf["default"] = "localhost:8080"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
56
|
+
post do |global,command,options,args|
|
57
|
+
# Post logic here
|
58
|
+
# Use skips_post before a command to skip this
|
59
|
+
# block on that command only
|
60
|
+
end
|
61
|
+
|
62
|
+
# Initialization for each command
|
63
|
+
around do |global,command,options,args,code|
|
64
|
+
#ap "Executing around ..."
|
65
|
+
if (File.exist?(CFG_FILE))
|
66
|
+
$tasc_conf = YAML::load(File.open(CFG_FILE, 'r'))
|
67
|
+
$server = $tasc_conf['current_server']
|
68
|
+
if ( $tasc_conf.has_key?($server) )
|
69
|
+
$host = $tasc_conf[$server]
|
70
|
+
code.call
|
71
|
+
else
|
72
|
+
exit_now!("No server label '#{$server}' configured")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
# put commands into the './lib/tasc' subdirectory
|
79
|
+
commands_from 'tasc'
|
80
|
+
|
81
|
+
exit run(ARGV)
|
data/lib/tasc/config.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
desc 'Lets you add, remove, list, or use a service connection'
|
2
|
+
long_desc 'Controls the configuration of tasc. The default sub-command is "list"'
|
3
|
+
|
4
|
+
command :config do |c|
|
5
|
+
|
6
|
+
c.desc 'Displays the configured service connections'
|
7
|
+
c.long_desc 'Arguments are ignored'
|
8
|
+
c.command :list do |l|
|
9
|
+
l.action do |global_options,options,args|
|
10
|
+
unless args.empty?
|
11
|
+
ap "Warning: Arguments to 'config list' are ignored."
|
12
|
+
end
|
13
|
+
entries = $tasc_conf.to_a
|
14
|
+
puts "Configuration:"
|
15
|
+
puts Hirb::Helpers::Table.render entries, :description=>false, :headers=>["Key", "Value"]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
c.desc 'Switch tasc to use a different service'
|
20
|
+
c.long_desc '[label] argument required. Changes the value of "current_server". e.g., tasc use dev'
|
21
|
+
c.command :use do |u|
|
22
|
+
u.action do |global_options,options,args|
|
23
|
+
if (args[0] == nil)
|
24
|
+
help_now! 'Missing label identifying the service to use.'
|
25
|
+
else
|
26
|
+
if (args.length > 1)
|
27
|
+
help_now! "Too many arguments given for 'config use' command."
|
28
|
+
else
|
29
|
+
label = args[0]
|
30
|
+
if ($tasc_conf.has_key?(label))
|
31
|
+
$tasc_conf['current_server'] = label
|
32
|
+
File.open(CFG_FILE, 'w') do |out|
|
33
|
+
YAML.dump($tasc_conf, out)
|
34
|
+
end
|
35
|
+
ap "Switched connection to '#{label}'"
|
36
|
+
else
|
37
|
+
help_now! "Config label '#{label}' does not exist"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
c.desc 'Adds a service connection'
|
46
|
+
c.long_desc '[label] [server] arguments are required. The label "current_server" is reserved. e.g., tasc add dev 127.0.0.1'
|
47
|
+
c.command :add do |a|
|
48
|
+
a.action do |global_options,options,args|
|
49
|
+
if args.length == 2
|
50
|
+
$tasc_conf[args[0]] = args[1]
|
51
|
+
File.open(CFG_FILE, 'w') do |out|
|
52
|
+
YAML.dump($tasc_conf, out)
|
53
|
+
end
|
54
|
+
ap "Configured new connection"
|
55
|
+
ap " '#{args[0]}' : '#{args[1]}'"
|
56
|
+
else
|
57
|
+
help_now! "Wrong number of arguments to 'config add'"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
c.desc 'Delete a service connection named label'
|
63
|
+
c.long_desc '[label] argument required. The "current_server" label cannot be deleted. e.g., tasc delete dev'
|
64
|
+
c.command :delete do |d|
|
65
|
+
d.action do |global_options,options,args|
|
66
|
+
if args.length == 1
|
67
|
+
label = args[0]
|
68
|
+
if ($tasc_conf.has_key?(label))
|
69
|
+
$tasc_conf.delete(label)
|
70
|
+
File.open(CFG_FILE, 'w') do |out|
|
71
|
+
YAML.dump($tasc_conf, out)
|
72
|
+
end
|
73
|
+
ap "Deleted connection #{args[0]}"
|
74
|
+
else
|
75
|
+
help_now! "Service connection #{args[0]} does not exist."
|
76
|
+
end
|
77
|
+
else
|
78
|
+
help_now! "Wrong number of arguments to 'config delete'"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
c.default_command :list
|
84
|
+
|
85
|
+
end
|
data/lib/tasc/create.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
desc 'Create a self-maintaining entity list'
|
2
|
+
long_desc '[name] [maxSize] arguments - [name] is required; [maxSize] is optional and will default to 10,000'
|
3
|
+
|
4
|
+
command :create do |c|
|
5
|
+
c.action do |global_options,options,args|
|
6
|
+
if (args[0] == nil)
|
7
|
+
help_now! "Missing required argument to create command: Name of list to create."
|
8
|
+
else
|
9
|
+
if (args[1] == nil)
|
10
|
+
args[1] = 10000
|
11
|
+
end
|
12
|
+
if (args[1].to_i < 1)
|
13
|
+
args[1] = 10000
|
14
|
+
end
|
15
|
+
# Construct URL to REST-ful service
|
16
|
+
uristr = "http://#{$host}/typeahead/createCache?entity=#{args[0]}&maxSize=#{args[1]}"
|
17
|
+
uri = URI(uristr)
|
18
|
+
resp = Net::HTTP.get_response(uri)
|
19
|
+
if (resp.code == '200')
|
20
|
+
ap "List created: #{args[0]}"
|
21
|
+
else
|
22
|
+
ap "Server Error: #{resp.code} - #{resp.message}"
|
23
|
+
ap "URI: #{uristr}"
|
24
|
+
ap "response body: #{resp.body}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/tasc/delete.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
desc 'Deletes an entity list from the server'
|
2
|
+
long_desc '[name] argument required'
|
3
|
+
|
4
|
+
command :delete do |c|
|
5
|
+
c.action do |global_options,options,args|
|
6
|
+
ap "Executing delete command"
|
7
|
+
if ( args[0] == nil)
|
8
|
+
help_now! "Missing required argument: Name of list to remove."
|
9
|
+
else
|
10
|
+
if ( args.length > 1 )
|
11
|
+
help_now! "Delete takes only one argument."
|
12
|
+
else
|
13
|
+
uristr = "http://#{$host}/typeahead/deleteTrie?entity=#{args[0]}"
|
14
|
+
resp = Net::HTTP.get_response(URI(uristr))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
if (resp.code == '200')
|
18
|
+
ap "Delete command successful. #{args[0]} deleted."
|
19
|
+
else
|
20
|
+
ap "Server Error: #{resp.code} - #{resp.message}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
desc "Downloads an existing entity list from the server in CSV format gzip'd"
|
2
|
+
long_desc '[name] [filepath] arguments - [name] required; [filepath] optional, defaults to the list name in the current directory.'
|
3
|
+
|
4
|
+
command :download do |c|
|
5
|
+
c.action do |global_options,options,args|
|
6
|
+
ap "Executing download command ..."
|
7
|
+
if (args[0] == nil)
|
8
|
+
help_now! "Missing required argument: Name of list to download."
|
9
|
+
else
|
10
|
+
if (args.length > 2)
|
11
|
+
help_now! "Too many arguments given."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
uristr = "http://#{$host}/typeahead/download?entity=#{args[0]}"
|
16
|
+
resp = Net::HTTP.get_response(URI(uristr))
|
17
|
+
|
18
|
+
if (args[1] != nil)
|
19
|
+
filename = args[1]
|
20
|
+
else
|
21
|
+
filename = args[0]
|
22
|
+
end
|
23
|
+
|
24
|
+
begin
|
25
|
+
file = File.open("#{filename}.csv.gz", "w")
|
26
|
+
file.write(resp.body)
|
27
|
+
rescue IOError => e
|
28
|
+
ap "Failed to write file #{filename}.csv.gz."
|
29
|
+
ensure
|
30
|
+
file.close unless file == nil
|
31
|
+
end
|
32
|
+
|
33
|
+
if (resp.code == '200')
|
34
|
+
ap "Downloaded #{args[0]} to #{filename}.csv.gz"
|
35
|
+
else
|
36
|
+
ap "Server Error: #{resp.code} - #{resp.message}"
|
37
|
+
ap "URI: #{uristr}"
|
38
|
+
ap "response body: #{resp.body}"
|
39
|
+
end
|
40
|
+
|
41
|
+
ap "download command ran"
|
42
|
+
end
|
43
|
+
end
|
data/lib/tasc/list.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
desc 'Displays a list of available entity types for auto-complete selection'
|
2
|
+
long_desc 'takes no arguments'
|
3
|
+
|
4
|
+
command :list do |c|
|
5
|
+
c.action do |global_options,options,args|
|
6
|
+
ap "Executing list command ..."
|
7
|
+
if ( !args.empty? || args.length != 0 )
|
8
|
+
help_now! "Wrong number of arguments to 'list'"
|
9
|
+
else
|
10
|
+
resp = Net::HTTP.get_response(URI("http://#{$host}/typeahead/listEntities"))
|
11
|
+
if resp.code == '200'
|
12
|
+
puts "List of Labels:"
|
13
|
+
entries = JSON resp.body
|
14
|
+
entries.sort!.each do |e|
|
15
|
+
puts " #{e}"
|
16
|
+
end
|
17
|
+
else
|
18
|
+
ap "Server Error: #{resp.code} - #{resp.message}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/tasc/remove.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
desc 'Removes an existing key and its associated value from an entity list'
|
2
|
+
long_desc '[name] [key] arguments are required'
|
3
|
+
|
4
|
+
command :remove do |c|
|
5
|
+
c.action do |global_options,options,args|
|
6
|
+
|
7
|
+
ap "Executing remove command ..."
|
8
|
+
if (args[0] == nil) || (args[1] == nil)
|
9
|
+
help_now! "Missing required arguments to remove command."
|
10
|
+
else
|
11
|
+
if (args.length > 2)
|
12
|
+
help_now! "Too many arguments given."
|
13
|
+
else
|
14
|
+
uristr = "http://#{$host}/typeahead/remove?entity=#{args[0]}&key=#{args[1]}"
|
15
|
+
uri = URI(uristr)
|
16
|
+
resp = Net::HTTP.get_response(uri)
|
17
|
+
if (resp.code == '200')
|
18
|
+
ap "Removed #{args[1]} from #{args[0]}"
|
19
|
+
else
|
20
|
+
ap "Server Error: #{resp.code} - #{resp.message}"
|
21
|
+
ap "URI: #{uristr}"
|
22
|
+
ap "response body: #{resp.body}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/lib/tasc/show.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
desc 'Display an existing entity list'
|
2
|
+
long_desc '[name] argument required'
|
3
|
+
|
4
|
+
command :show do |c|
|
5
|
+
c.action do |global_options,options,args|
|
6
|
+
if ( args.empty? || args.length != 1 )
|
7
|
+
help_now! "Wrong number of arguments to 'show'"
|
8
|
+
else
|
9
|
+
name = args[0]
|
10
|
+
resp = Net::HTTP.get_response(URI("http://#{$host}/typeahead/listTrie?entity=#{name}"))
|
11
|
+
if resp.code == '200'
|
12
|
+
entries = JSON resp.body
|
13
|
+
puts "Entries from #{name}:"
|
14
|
+
puts Hirb::Helpers::Table.render entries, :headers=>["Key", "Value", "Weight"]
|
15
|
+
elsif resp.code == '202'
|
16
|
+
puts "List '#{name}' too long to display"
|
17
|
+
elsif resp.code == '204'
|
18
|
+
puts "Unknown list: '#{name}'"
|
19
|
+
else
|
20
|
+
puts "Server Error: #{resp.code} - #{resp.message}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/tasc/update.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
desc 'Updates an existing value on an entity list. If the value does not exist, it will be added.'
|
2
|
+
long_desc '[name] [key] [value] [rank] are all required; e.g., tasc update state massachusetts MA 1'
|
3
|
+
|
4
|
+
command :update do |c|
|
5
|
+
c.action do |global_options,options,args|
|
6
|
+
|
7
|
+
ap "Executing update command ..."
|
8
|
+
if (args[0] == nil) || (args[1] == nil) || (args[2] == nil) || (args[3] == nil)
|
9
|
+
help_now! "Missing required arguments to update command."
|
10
|
+
else
|
11
|
+
if (args.length > 4)
|
12
|
+
help_now! "Too many arguments given."
|
13
|
+
else
|
14
|
+
uristr = "http://#{$host}/typeahead/update?entity=#{args[0]}&key=#{args[1]}&value=#{args[2]}&rank=#{args[3]}"
|
15
|
+
uri = URI(uristr)
|
16
|
+
resp = Net::HTTP.get_response(uri)
|
17
|
+
if (resp.code == '200')
|
18
|
+
ap "Added #{args[1]} to #{args[0]} with value #{args[2]} rank #{args[3]}"
|
19
|
+
else
|
20
|
+
ap "Server Error: #{resp.code} - #{resp.message}"
|
21
|
+
ap "URI: #{uristr}"
|
22
|
+
ap "response body: #{resp.body}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/lib/tasc/upload.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
desc "Upload a CSV file (gzip'd or not) containing a comma-separated list of values and meta-data on which to auto-complete. Replaces an existing entity list if it already exists, creates a new one otherwise."
|
2
|
+
long_desc '[filepath] argument required'
|
3
|
+
|
4
|
+
command :upload do |c|
|
5
|
+
c.action do |global_options,options,args|
|
6
|
+
unless args.empty?
|
7
|
+
filepath = args[0]
|
8
|
+
url = "http://#{$host}/typeahead/upload"
|
9
|
+
# see http://stackoverflow.com/questions/184178/ruby-how-to-post-a-file-via-http-as-multipart-form-data
|
10
|
+
# and https://wincent.com/products/wopen3
|
11
|
+
# orig: curl -F media=@#{photo.path} -F username=#{@username} -F password=#{@password} -F message='#{photo.title}' http://twitpic.com/api/uploadAndPost`
|
12
|
+
# adapted: curl -F file=@#{filepath} #{url}
|
13
|
+
file = "file=@#{filepath}"
|
14
|
+
result = Wopen3.system('curl', '-F', file, url)
|
15
|
+
if result.success?
|
16
|
+
puts "Successfully uploaded '#{filepath}'"
|
17
|
+
puts "stdout: #{result.stdout}"
|
18
|
+
puts "stderr: #{result.stderr}"
|
19
|
+
else
|
20
|
+
puts "Failed to upload"
|
21
|
+
puts "stdout: #{result.stdout}"
|
22
|
+
puts "stderr: #{result.stderr}"
|
23
|
+
end
|
24
|
+
else
|
25
|
+
help_now! "Wrong number of arguments to 'upload'"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/tasc/version.rb
ADDED
data/lib/tasc.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'tasc/version.rb'
|
2
|
+
|
3
|
+
# Add requires for other files you add to your project here, so
|
4
|
+
# you just need to require this one file in your bin file
|
5
|
+
require 'json'
|
6
|
+
require 'rest-client'
|
7
|
+
require 'awesome_print'
|
8
|
+
require 'yaml/store'
|
9
|
+
require 'net/http'
|
10
|
+
require 'hirb'
|
11
|
+
require 'wopen3'
|
metadata
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tasc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Steve Quince
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
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: awesome_print
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hirb
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: wopen3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rdoc
|
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
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: aruba
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: gli
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 2.5.4
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 2.5.4
|
139
|
+
description:
|
140
|
+
email: squince@glgroup.com
|
141
|
+
executables:
|
142
|
+
- tasc
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- bin/tasc
|
147
|
+
- lib/tasc/config.rb
|
148
|
+
- lib/tasc/create.rb
|
149
|
+
- lib/tasc/delete.rb
|
150
|
+
- lib/tasc/download.rb
|
151
|
+
- lib/tasc/list.rb
|
152
|
+
- lib/tasc/remove.rb
|
153
|
+
- lib/tasc/show.rb
|
154
|
+
- lib/tasc/update.rb
|
155
|
+
- lib/tasc/upload.rb
|
156
|
+
- lib/tasc/version.rb
|
157
|
+
- lib/tasc.rb
|
158
|
+
- README.md
|
159
|
+
homepage: http://github.com/glg/AutoComplete
|
160
|
+
licenses: []
|
161
|
+
metadata: {}
|
162
|
+
post_install_message:
|
163
|
+
rdoc_options: []
|
164
|
+
require_paths:
|
165
|
+
- lib
|
166
|
+
- lib
|
167
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ! '>='
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ! '>='
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
requirements: []
|
178
|
+
rubyforge_project:
|
179
|
+
rubygems_version: 2.0.2
|
180
|
+
signing_key:
|
181
|
+
specification_version: 4
|
182
|
+
summary: TrieService Auto-Suggest Command-Line Client for managing term lists
|
183
|
+
test_files: []
|