keen-cli 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +11 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +54 -0
- data/LICENSE +21 -0
- data/README.md +176 -0
- data/Rakefile +10 -0
- data/bin/keen +6 -0
- data/keen-cli.gemspec +28 -0
- data/lib/keen-cli/cli.rb +150 -0
- data/lib/keen-cli/utils.rb +49 -0
- data/lib/keen-cli/version.rb +3 -0
- data/lib/keen-cli.rb +10 -0
- data/spec/keen-cli/cli_spec.rb +20 -0
- data/spec/spec_helper.rb +7 -0
- metadata +175 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.env
|
data/.travis.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.1.0
|
4
|
+
env:
|
5
|
+
global:
|
6
|
+
- secure: dyzAKPD91LvwtjcX0mo4ENPhpjCgtkrS1Z5mgodYHafMz+GBTrMLdwnA/jE2EnzUhVcTieuAvIsYP7sGsG43qxtYNIl7FMXdz1PywgQVZuPbmNV6Y2iBaU61TlQvR1rtLA+G4N8TOxdVQxThpYlNv1rNHGSqtgOOICMNZLTY224=
|
7
|
+
- secure: SAfN4kwEsqEBSSr8Fr2h2ySxFz7P+6rgysgEjF24fL6JW5N+YmKmwHh1en81d4R+BYcYIMQRwe1owpyqisvx0kASUVnWdPT0+loHm5rH22IEFsYjTEiuYOAZCj1/4yLcVmdX6EH34cNmoGbxUUziD9k9ctVGoehxaK9te+xphvc=
|
8
|
+
- secure: k2owfccj86F/b7X/WRsi8HGdJ9v+zuDek/Vu7XzNN+fqqja4rlXTtWSJyOTikklOMRN0AlUh1GjRWp+eT8YXKdiN4gk7WUGiryaTGATKWn1nLaIDtEjugMMmqXq7YwCih1GulPhMlRSwHU4b9q/MsciTFwzxREsxecjrQYL8HQY=
|
9
|
+
- secure: PXsUN/cmCwMbBjkJ6HLdWPmOEtk6+G1HMP5RhejImbUII7MJ1GRhHdehMCgc74wNfVt/MX/de2AgB17EQc5tDSKoQqV9dCZ4cRDPjlh82MK3gN1L2ZUgD+wJeY/29bZak6NMnVXVN18HGfIMjCVnS3t2rkQ94nwZVtIuhCkAWRk=
|
10
|
+
script:
|
11
|
+
- bundle exec rake spec
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
keen-cli (0.1.0)
|
5
|
+
dotenv
|
6
|
+
http
|
7
|
+
keen
|
8
|
+
thor
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
addressable (2.3.6)
|
14
|
+
columnize (0.8.9)
|
15
|
+
debugger (1.6.8)
|
16
|
+
columnize (>= 0.3.1)
|
17
|
+
debugger-linecache (~> 1.2.0)
|
18
|
+
debugger-ruby_core_source (~> 1.3.5)
|
19
|
+
debugger-linecache (1.2.0)
|
20
|
+
debugger-ruby_core_source (1.3.5)
|
21
|
+
diff-lcs (1.2.5)
|
22
|
+
dotenv (0.11.1)
|
23
|
+
dotenv-deployment (~> 0.0.2)
|
24
|
+
dotenv-deployment (0.0.2)
|
25
|
+
http (0.6.1)
|
26
|
+
http_parser.rb (~> 0.6.0)
|
27
|
+
http_parser.rb (0.6.0)
|
28
|
+
keen (0.8.2)
|
29
|
+
addressable (~> 2.3.5)
|
30
|
+
multi_json (~> 1.3)
|
31
|
+
multi_json (1.10.1)
|
32
|
+
rake (10.3.2)
|
33
|
+
rspec (3.0.0)
|
34
|
+
rspec-core (~> 3.0.0)
|
35
|
+
rspec-expectations (~> 3.0.0)
|
36
|
+
rspec-mocks (~> 3.0.0)
|
37
|
+
rspec-core (3.0.2)
|
38
|
+
rspec-support (~> 3.0.0)
|
39
|
+
rspec-expectations (3.0.2)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.0.0)
|
42
|
+
rspec-mocks (3.0.2)
|
43
|
+
rspec-support (~> 3.0.0)
|
44
|
+
rspec-support (3.0.2)
|
45
|
+
thor (0.19.1)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
debugger
|
52
|
+
keen-cli!
|
53
|
+
rake
|
54
|
+
rspec
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Author Josh Dzielak
|
2
|
+
Copyright (c) 2012-2014 Keen Labs
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
# keen-cli
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/keenlabs/keen-cli.svg?branch=master)](https://travis-ci.org/keenlabs/keen-cli)
|
4
|
+
|
5
|
+
A command line interface for the Keen IO analytics API.
|
6
|
+
|
7
|
+
### Installation
|
8
|
+
|
9
|
+
keen-cli is built with Ruby, so you'll need a working Ruby 1.9+ environment to use it. You can find Ruby installation instructions [here](https://www.ruby-lang.org/en/installation/).
|
10
|
+
|
11
|
+
Install the gem:
|
12
|
+
|
13
|
+
``` shell
|
14
|
+
$ gem install keen-cli
|
15
|
+
```
|
16
|
+
|
17
|
+
Verify the `keen` command is in your path by running it:
|
18
|
+
|
19
|
+
``` shell
|
20
|
+
$ keen
|
21
|
+
Commands:
|
22
|
+
keen help [COMMAND] # Describe available commands or one specific command
|
23
|
+
keen project:open # Open the current project
|
24
|
+
keen project:show # Show the current project
|
25
|
+
keen version # Print the keen-cli version
|
26
|
+
```
|
27
|
+
|
28
|
+
You should see information about available commands.
|
29
|
+
|
30
|
+
If `keen` can't be found there might be an issue with your Ruby installation. If you're using [rbenv](https://github.com/sstephenson/rbenv) try running `rbenv rehash` after installation.
|
31
|
+
|
32
|
+
### Environment configuration
|
33
|
+
|
34
|
+
Most keen-cli functions require the presence of a project and one or more API keys to do meaningful actions. By default, keen-cli attempts to find these in the process environment or a `.env` file in the current directory. This is the same heuristic that [keen-gem](https://github.com/keenlabs/keen-gem) uses.
|
35
|
+
|
36
|
+
An example .env file looks like this:
|
37
|
+
|
38
|
+
```
|
39
|
+
KEEN_PROJECT_ID=aaaaaaaaaaaaaaa
|
40
|
+
KEEN_MASTER_KEY=xxxxxxxxxxxxxxx
|
41
|
+
KEEN_WRITE_KEY=yyyyyyyyyyyyyyy
|
42
|
+
KEEN_READ_KEY=zzzzzzzzzzzzzzz
|
43
|
+
```
|
44
|
+
|
45
|
+
If you run `keen` from a directory with this .env file, it will assume the project in context is the one specified by `KEEN_PROJECT_ID`.
|
46
|
+
|
47
|
+
To override the project context use the `--project` option:
|
48
|
+
|
49
|
+
``` shell
|
50
|
+
$ keen project:show --project XXXXXXXXXXXXXXX
|
51
|
+
```
|
52
|
+
|
53
|
+
Similar overrides are available for specifiying API keys: `--master-key`, `--read-key` and `--write-key`.
|
54
|
+
|
55
|
+
For example:
|
56
|
+
|
57
|
+
``` shell
|
58
|
+
$ keen project:show --project XXXXXXXXXXXXXXX --master-key AAAAAAAAAAAAAA
|
59
|
+
```
|
60
|
+
|
61
|
+
Shorter aliases exist as well: `-p` for project, `-k` for master key, `-r` for read key, and `-w` for write key.
|
62
|
+
|
63
|
+
``` shell
|
64
|
+
$ keen project:show -p XXXXXXXXXXXXXXX -k AAAAAAAAAAAAAA
|
65
|
+
```
|
66
|
+
|
67
|
+
### Usage
|
68
|
+
|
69
|
+
keen-cli has a variety of commands, and most are namespaced for clarity.
|
70
|
+
|
71
|
+
* `version` - Print version information
|
72
|
+
|
73
|
+
##### Projects
|
74
|
+
|
75
|
+
* `project:open` - Open the Project Overview page in a browser
|
76
|
+
* `project:show` - Get data about the project, uses the [project row resource](https://keen.io/docs/api/reference/#project-row-resource).
|
77
|
+
|
78
|
+
##### Events
|
79
|
+
|
80
|
+
`events:add` - Add an event.
|
81
|
+
|
82
|
+
Parameters:
|
83
|
+
|
84
|
+
+ `--collection` (alias `-c`): The collection to add the event to. Alternately you can set `KEEN_COLLECTION_NAME` on the environment if you're working with the same collection frequently.
|
85
|
+
+ `--data` (alias `-d`). The properties of the event. The value can be JSON or key=value pairs delimited by & (just like a query string). Data can also be piped in via STDIN.
|
86
|
+
|
87
|
+
Various examples:
|
88
|
+
|
89
|
+
``` shell
|
90
|
+
# create an empty event
|
91
|
+
$ keen events:add --collection cli-tests
|
92
|
+
|
93
|
+
# use the shorter form of collection
|
94
|
+
$ keen events:add -c cli-tests
|
95
|
+
|
96
|
+
# add a blank event to a collection specified in the .env file:
|
97
|
+
# KEEN_COLLECTION_NAME=cli-tests
|
98
|
+
$ keen events:add
|
99
|
+
|
100
|
+
# create an event from JSON
|
101
|
+
$ keen events:add -c cli-tests -d "{ \"username\" : \"dzello\", \"zsh\": 1 }"
|
102
|
+
|
103
|
+
# create an event from key value pairs
|
104
|
+
$ keen events:add -c cli-tests -d "username=dzello&zsh=1"
|
105
|
+
|
106
|
+
# pipe in events as JSON
|
107
|
+
$ echo "{ \"username\" : \"dzello\", \"zsh\": 1 }" | keen events:add -c cli-tests
|
108
|
+
|
109
|
+
# pipe in events in querystring format
|
110
|
+
$ echo "username=dzello&zsh=1" | keen events:add -c cli-test
|
111
|
+
|
112
|
+
# pipe in events from a file of newline delimited json
|
113
|
+
# { "username" : "dzello", "zsh" : 1 }
|
114
|
+
# { "username" : "dkador", "zsh" : 1 }
|
115
|
+
# { "username" : "gphat", "zsh" : 1 }
|
116
|
+
$ cat events.json | keen events:add -c cli-test
|
117
|
+
```
|
118
|
+
|
119
|
+
##### Queries
|
120
|
+
|
121
|
+
`queries:run` - Runs a query and prints the result in pretty JSON.
|
122
|
+
|
123
|
+
Parameters:
|
124
|
+
|
125
|
+
+ `--collection` (alias -c) – The collection name to query against. Can also be set on the environment via `KEEN_COLLECTION_NAME`
|
126
|
+
+ `--analysis-type` (alias -a)
|
127
|
+
+ `--group-by` (alias -g)
|
128
|
+
+ `--target-property` (alias -y)
|
129
|
+
+ `--timeframe` (alias -t)
|
130
|
+
+ `--interval` (alias -i)
|
131
|
+
+ `--filters` (alias -f)
|
132
|
+
+ `--percentile`
|
133
|
+
|
134
|
+
Some examples:
|
135
|
+
|
136
|
+
``` shell
|
137
|
+
# run a count
|
138
|
+
$ keen queries:run -a count -c cli-tests
|
139
|
+
|
140
|
+
# run a count with collection name from .env
|
141
|
+
# KEEN_COLLECTION_NAME=cli-tests
|
142
|
+
$ keen queries:run -a count
|
143
|
+
1000
|
144
|
+
|
145
|
+
# run a count with a group by
|
146
|
+
$ keen queries:run -a count -g a
|
147
|
+
[
|
148
|
+
{
|
149
|
+
"a": 1,
|
150
|
+
"result": 1000
|
151
|
+
}
|
152
|
+
]
|
153
|
+
|
154
|
+
# run a query with a timeframe, target property, group by, and interval
|
155
|
+
$ keen queries:run -c cli-tests --analysis-type median --target-property value --group-by cohort --timeframe last_24_hours --interval hourly
|
156
|
+
|
157
|
+
{
|
158
|
+
"timeframe": {
|
159
|
+
"start": "2014-06-27T01:00:00.000Z",
|
160
|
+
"end": "2014-06-27T02:00:00.000Z"
|
161
|
+
},
|
162
|
+
"value": [
|
163
|
+
...
|
164
|
+
...
|
165
|
+
...
|
166
|
+
```
|
167
|
+
|
168
|
+
### Contributing
|
169
|
+
|
170
|
+
keen-cli is open source, and contributions are very welcome!
|
171
|
+
|
172
|
+
Running the tests with:
|
173
|
+
|
174
|
+
```
|
175
|
+
$ bundle exec rake spec
|
176
|
+
```
|
data/Rakefile
ADDED
data/bin/keen
ADDED
data/keen-cli.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "keen-cli/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "keen-cli"
|
7
|
+
s.version = KeenCli::VERSION
|
8
|
+
s.authors = ["Josh Dzielak"]
|
9
|
+
s.email = "josh@keen.io"
|
10
|
+
s.homepage = "https://github.com/keenlabs/keen-cli"
|
11
|
+
s.summary = "Command line interface to Keen IO"
|
12
|
+
s.description = "Record events and run queries from the comfort of your command line"
|
13
|
+
s.license = "MIT"
|
14
|
+
|
15
|
+
s.add_dependency "keen"
|
16
|
+
s.add_dependency "thor"
|
17
|
+
s.add_dependency "dotenv"
|
18
|
+
s.add_dependency "http"
|
19
|
+
|
20
|
+
s.add_development_dependency 'rake'
|
21
|
+
s.add_development_dependency 'rspec'
|
22
|
+
s.add_development_dependency 'debugger'
|
23
|
+
|
24
|
+
s.files = `git ls-files`.split("\n")
|
25
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
27
|
+
s.require_paths = ["lib"]
|
28
|
+
end
|
data/lib/keen-cli/cli.rb
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'http'
|
2
|
+
require 'thor'
|
3
|
+
require 'keen'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
require 'keen-cli/utils'
|
7
|
+
|
8
|
+
module KeenCli
|
9
|
+
|
10
|
+
class CLI < Thor
|
11
|
+
|
12
|
+
def self.shared_options
|
13
|
+
option :project, :aliases => ['-p']
|
14
|
+
option :"master-key", :aliases => ['-k']
|
15
|
+
option :"read-key", :aliases => ['-r']
|
16
|
+
option :"write-key", :aliases => ['-w']
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.data_options
|
20
|
+
option :data, :aliases => ['-d']
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.collection_options
|
24
|
+
option :collection, :aliases => ['-c']
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.query_options
|
28
|
+
self.collection_options
|
29
|
+
option :"analysis-type", :aliases => ['-a']
|
30
|
+
option :"group-by", :aliases => ['-g']
|
31
|
+
option :"target-property", :aliases => ['-y']
|
32
|
+
option :interval, :aliases => ['-i']
|
33
|
+
option :timeframe, :aliases => ['-t']
|
34
|
+
option :filters, :aliases => ['-f']
|
35
|
+
option :percentile
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'version', 'Print the keen-cli version'
|
39
|
+
map %w(-v --version) => :version
|
40
|
+
|
41
|
+
def version
|
42
|
+
"keen-cli version #{KeenCli::VERSION}".tap do |s|
|
43
|
+
puts s
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'project:show', 'Show the current project'
|
48
|
+
map 'project:show' => :project_show
|
49
|
+
shared_options
|
50
|
+
|
51
|
+
def project_show
|
52
|
+
Utils.process_options!(options)
|
53
|
+
response = HTTP.get(
|
54
|
+
"https://api.keen.io/3.0/projects/#{Keen.project_id}?api_key=#{Keen.master_key}")
|
55
|
+
JSON.pretty_generate(JSON.parse(response.to_s)).tap do |s| puts s end
|
56
|
+
end
|
57
|
+
|
58
|
+
desc 'project:open', 'Open the current project'
|
59
|
+
map 'project:open' => :project_open
|
60
|
+
shared_options
|
61
|
+
|
62
|
+
def project_open
|
63
|
+
Utils.process_options!(options)
|
64
|
+
"https://keen.io/project/#{Keen.project_id}".tap do |project_url|
|
65
|
+
`open #{project_url}`
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
desc 'queries:run', 'Run a query'
|
70
|
+
map 'queries:run' => :queries_run
|
71
|
+
shared_options
|
72
|
+
query_options
|
73
|
+
def queries_run
|
74
|
+
|
75
|
+
Utils.process_options!(options)
|
76
|
+
|
77
|
+
# convert dashes
|
78
|
+
q_options = options.inject({}) do |memo, element|
|
79
|
+
if ['analysis-type', 'group-by', 'target-property'].include?(element.first)
|
80
|
+
memo[element.first.sub('-', '_')] = element.last
|
81
|
+
else
|
82
|
+
memo[element.first] = element.last
|
83
|
+
end
|
84
|
+
memo
|
85
|
+
end
|
86
|
+
|
87
|
+
collection = Utils.get_collection_name(options)
|
88
|
+
|
89
|
+
Keen.send(q_options["analysis_type"], collection, q_options).tap do |result|
|
90
|
+
if result.is_a?(Hash) || result.is_a?(Array)
|
91
|
+
puts JSON.pretty_generate(result)
|
92
|
+
else
|
93
|
+
puts result
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
desc 'events:add', 'Add an event'
|
99
|
+
map 'events:add' => :events_add
|
100
|
+
|
101
|
+
shared_options
|
102
|
+
data_options
|
103
|
+
collection_options
|
104
|
+
|
105
|
+
def events_add
|
106
|
+
|
107
|
+
events = []
|
108
|
+
|
109
|
+
if $stdin.tty?
|
110
|
+
events.push(options[:data] || {})
|
111
|
+
else
|
112
|
+
ARGV.clear
|
113
|
+
ARGF.each_line do |line|
|
114
|
+
events.push(line)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
events = events.map do |event|
|
119
|
+
begin
|
120
|
+
JSON.parse(event)
|
121
|
+
rescue
|
122
|
+
begin
|
123
|
+
Utils.parse_data_as_querystring(event)
|
124
|
+
rescue
|
125
|
+
event
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
collection = Utils.get_collection_name(options)
|
131
|
+
|
132
|
+
if events.length > 1
|
133
|
+
|
134
|
+
Keen.publish_batch(collection => events).tap do |result|
|
135
|
+
puts JSON.pretty_generate(result)
|
136
|
+
end
|
137
|
+
|
138
|
+
else
|
139
|
+
|
140
|
+
Keen.publish(collection, events.first).tap do |result|
|
141
|
+
puts JSON.pretty_generate(result)
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module KeenCli
|
2
|
+
|
3
|
+
class Utils
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def process_options!(options)
|
8
|
+
|
9
|
+
if project_id = options[:project]
|
10
|
+
Keen.project_id = project_id
|
11
|
+
end
|
12
|
+
|
13
|
+
if master_key = options[:"master-key"]
|
14
|
+
Keen.master_key = master_key
|
15
|
+
end
|
16
|
+
|
17
|
+
if read_key = options[:"read-key"]
|
18
|
+
Keen.read_key = read_key
|
19
|
+
end
|
20
|
+
|
21
|
+
if write_key = options[:"write-key"]
|
22
|
+
Keen.write_key = write_key
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_collection_name(options)
|
28
|
+
options["collection"] || ENV['KEEN_COLLECTION_NAME']
|
29
|
+
end
|
30
|
+
|
31
|
+
def parse_data_as_querystring(query)
|
32
|
+
keyvals = query.split('&').inject({}) do |result, q|
|
33
|
+
k,v = q.split('=')
|
34
|
+
if !v.nil?
|
35
|
+
result.merge({k => v})
|
36
|
+
elsif !result.key?(k)
|
37
|
+
result.merge({k => true})
|
38
|
+
else
|
39
|
+
result
|
40
|
+
end
|
41
|
+
end
|
42
|
+
keyvals
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/lib/keen-cli.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe KeenCli::CLI do
|
4
|
+
it 'prints help by default' do
|
5
|
+
_, options = KeenCli::CLI.start
|
6
|
+
expect(_).to be_empty
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'prints version info if -v is used' do
|
10
|
+
_, options = KeenCli::CLI.start(%w[-v])
|
11
|
+
expect(_).to match /version/
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'project:show' do
|
15
|
+
it 'gets the project' do
|
16
|
+
_, options = KeenCli::CLI.start(%w[project:show])
|
17
|
+
expect(_).to match /\/3.0\/projects\/#{Keen.project_id}\/events/
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: keen-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Josh Dzielak
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-06-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: keen
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: dotenv
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: http
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rake
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: debugger
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
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
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: Record events and run queries from the comfort of your command line
|
127
|
+
email: josh@keen.io
|
128
|
+
executables:
|
129
|
+
- keen
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- .travis.yml
|
135
|
+
- Gemfile
|
136
|
+
- Gemfile.lock
|
137
|
+
- LICENSE
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- bin/keen
|
141
|
+
- keen-cli.gemspec
|
142
|
+
- lib/keen-cli.rb
|
143
|
+
- lib/keen-cli/cli.rb
|
144
|
+
- lib/keen-cli/utils.rb
|
145
|
+
- lib/keen-cli/version.rb
|
146
|
+
- spec/keen-cli/cli_spec.rb
|
147
|
+
- spec/spec_helper.rb
|
148
|
+
homepage: https://github.com/keenlabs/keen-cli
|
149
|
+
licenses:
|
150
|
+
- MIT
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
none: false
|
157
|
+
requirements:
|
158
|
+
- - ! '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 1.8.23
|
170
|
+
signing_key:
|
171
|
+
specification_version: 3
|
172
|
+
summary: Command line interface to Keen IO
|
173
|
+
test_files:
|
174
|
+
- spec/keen-cli/cli_spec.rb
|
175
|
+
- spec/spec_helper.rb
|