rolltools 0.0.2

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: d83d7fad7aa7890332a1bd6ce35ce569f49fba1d
4
+ data.tar.gz: af6bcf94dd2c6e119ea6fdeba52bf67ffa0f040f
5
+ SHA512:
6
+ metadata.gz: d4bf46499590a7a0b0d9e448aa9ffa0e040f80d8e983df20d13678d263d30a509ed2e17b41bbbafa9dab80a78e30164f91dd261857f9f4b488ff370fdadc753e
7
+ data.tar.gz: b959548a26d415f2ec66545073ca922ac8265130ec4b93a859abdab3d1a2efad65fc09e3cad9b2e46c9d3bfaae25f54f46237ba98d246da8aa73f211d563ab11
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rolltools.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jonathan Slate
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
@@ -0,0 +1,40 @@
1
+ # Rolltools
2
+
3
+ Just a simple gem that gives you command line tools to display info from the Rollbar API. Only has a couple of commands for now.
4
+
5
+ ## Installation
6
+
7
+ git clone git@github.com:jslate/rolltools.git
8
+ cd rolltools
9
+ rake install
10
+
11
+ If you are using rbenv, don't forget:
12
+
13
+ rbenv rehash
14
+
15
+ ## Usage
16
+
17
+ Run 'rolltools' to get a list of commands.
18
+
19
+ Typical usage:
20
+
21
+ rolltools set_config read_token abc123...
22
+
23
+ rolltools user_agents 2269 -l 2 # user agents for #2269 TypeError: no implicit conversion of nil into String, limit 2
24
+
25
+ > Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
26
+ > Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
27
+
28
+ rolltools exceptions 2269 -l 2 # Exception messages for #2269, limit 2
29
+
30
+ > TypeError no implicit conversion of nil into String
31
+ > TypeError no implicit conversion of nil into String
32
+
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it ( http://github.com/jslate/rolltools/fork )
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/rolltools ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rolltools'
4
+ require 'thor'
5
+ require 'yaml'
6
+
7
+ class Rolltools::CLI < Thor
8
+
9
+ desc "exceptions COUNTER", "get the exceptions for the item specified by COUNTER"
10
+ method_option :limit, aliases: '-l', type: :numeric, default: 20, desc: 'number of items to query'
11
+ def exceptions(counter)
12
+ puts Rolltools::Utils.get_items(counter).first(options[:limit]).map{|i|i[:exception]}.join("\n")
13
+ end
14
+
15
+ desc "user_agents COUNTER", "get the user_agents for the item specified by COUNTER"
16
+ method_option :limit, aliases: '-l', type: :numeric, default: 20, desc: 'number of items to query'
17
+ def user_agents(counter)
18
+ puts Rolltools::Utils.get_items(counter).first(options[:limit]).map{|i|i[:user_agent]}.join("\n")
19
+ end
20
+
21
+ desc "urls COUNTER", "get the urls for the item specified by COUNTER"
22
+ method_option :limit, aliases: '-l', type: :numeric, default: 20, desc: 'number of items to query'
23
+ def urls(counter)
24
+ puts Rolltools::Utils.get_items(counter).first(options[:limit]).map{|i|i[:url]}.join("\n")
25
+ end
26
+
27
+ desc "instance_ids COUNTER", "get the instance_ids for the item specified by COUNTER"
28
+ method_option :limit, aliases: '-l', type: :numeric, default: 20, desc: 'number of items to query'
29
+ def instance_ids(counter)
30
+ puts Rolltools::Utils.get_items(counter).first(options[:limit]).map{|i|i[:instance_id]}.join("\n")
31
+ end
32
+
33
+ desc "set_config KEY, VALUE", "set a config value, valid values: read_token"
34
+ def set_config(key, value)
35
+ Rolltools::Settings.set key, value
36
+ end
37
+
38
+ end
39
+
40
+ Rolltools::CLI.start
@@ -0,0 +1,25 @@
1
+ require 'yaml'
2
+
3
+ module Rolltools::Settings
4
+
5
+ def self.settings=(settings)
6
+ @settings = settings
7
+ end
8
+
9
+ def self.settings
10
+ @settings ||= YAML::load_file "#{Dir.home}/.rolltools.yml" rescue nil
11
+ @settings ||= {}
12
+ end
13
+
14
+ def self.set(key, value)
15
+ settings[key] = value
16
+ File.open("#{Dir.home}/.rolltools.yml", "w") do |file|
17
+ file.write settings.to_yaml
18
+ end
19
+ end
20
+
21
+ def self.get(key)
22
+ settings[key]
23
+ end
24
+
25
+ end
@@ -0,0 +1,40 @@
1
+ require 'Faraday'
2
+ require 'json'
3
+
4
+ module Rolltools::Utils
5
+
6
+ def self.conn
7
+ @conn ||= Faraday.new("https://api.rollbar.com")
8
+ end
9
+
10
+ def self.get_item_for_counter(counter)
11
+ token = Rolltools::Settings.settings['read_token']
12
+ raise "token is not set, use 'rolltools set_config token VALUE'" if token.nil?
13
+ get_item_id_res = conn.get "/api/1/item_by_counter/#{counter}", access_token: token
14
+ JSON.parse(get_item_id_res.body)['result']['itemId']
15
+ end
16
+
17
+ def self.get_items(counter)
18
+ token = Rolltools::Settings.settings['read_token']
19
+ raise "token is not set, use 'rolltools set_config token VALUE'" if token.nil?
20
+ item_id = get_item_for_counter(counter)
21
+
22
+ Enumerator.new do |y|
23
+ page = 1
24
+ begin
25
+ get_item_res = conn.get "/api/1/item/#{item_id}/instances/", access_token: token, page: page
26
+ item = JSON.parse(get_item_res.body)
27
+ item['result']['instances'].each do |i|
28
+ e = i['data']['body']['trace']['exception']
29
+ y << { url: i['data']['request']['url'],
30
+ user_agent: i['data']['request']['headers']['User-Agent'],
31
+ instance_id: i['id'],
32
+ exception: "#{e['class']} #{e['message']}"
33
+ }
34
+ end
35
+ page += 1
36
+ end until item['result']['instances'].empty?
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,3 @@
1
+ module Rolltools
2
+ VERSION = "0.0.2"
3
+ end
data/lib/rolltools.rb ADDED
@@ -0,0 +1,3 @@
1
+ require "rolltools/version"
2
+ require "rolltools/utils"
3
+ require "rolltools/settings"
data/rolltools.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rolltools/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rolltools"
8
+ spec.version = Rolltools::VERSION
9
+ spec.authors = ["Jonathan Slate"]
10
+ spec.email = ["jslate@patientslikeme.com"]
11
+ spec.summary = %q{Tools for working with the Rollbar API.}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "thor"
21
+ spec.add_dependency "faraday"
22
+ spec.add_dependency "json"
23
+ spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "rake"
25
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rolltools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Slate
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
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: faraday
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: json
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: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - jslate@patientslikeme.com
86
+ executables:
87
+ - rolltools
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - bin/rolltools
97
+ - lib/rolltools.rb
98
+ - lib/rolltools/settings.rb
99
+ - lib/rolltools/utils.rb
100
+ - lib/rolltools/version.rb
101
+ - rolltools.gemspec
102
+ homepage: ''
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.4.4
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Tools for working with the Rollbar API.
126
+ test_files: []
127
+ has_rdoc: