watson-ruby 1.6.1 → 1.6.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +45 -33
- data/lib/watson/command.rb +14 -3
- data/lib/watson/config.rb +95 -8
- data/lib/watson/github.rb +68 -29
- data/lib/watson/parser.rb +11 -3
- data/lib/watson/version.rb +1 -1
- data/spec/config_spec.rb +3 -1
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 514fedab81cf81f62c7a4fb415d83750ebf05ad5
|
4
|
+
data.tar.gz: 4b63e079270286b0fd7bea2a3d1a5fc3e17310ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db6f2c055827b284eb40682f5bb137c7ee21cbdb85dde8924f3a2653c9f334922f6493af9c974d603957b0d3901cbd3f80fa31b84ebf8ef0be7a95dcd243dc10
|
7
|
+
data.tar.gz: 14a2b0d85756bb5357c49de86029be86d6a467f955d687af9269326049196809d16d342cc41b49de1dd6ad22ba65ae3924c3923245c60b63eba82aba94a9ff9e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# watson-ruby [](http://badge.fury.io/rb/watson-ruby) [](https://travis-ci.org/nhmood/watson-ruby)
|
1
|
+
# watson-ruby [](http://badge.fury.io/rb/watson-ruby) [](https://travis-ci.org/nhmood/watson-ruby)
|
2
2
|
|
3
3
|
### an inline issue manager
|
4
4
|
[watson](http://goosecode.com/watson) ([mirror](http://nhmood.github.io/watson-ruby)) is a tool for creating and tracking bug reports, issues, and internal notes in code.
|
@@ -8,11 +8,11 @@ It is avaliable in two flavors, [watson-ruby](http://github.com/nhmood/watson-ru
|
|
8
8
|
### See the RDoc documentation [here](http://goosecode.com/watson/ruby/doc/) ([mirror](http://nhmood.github.io/watson-ruby/ruby/doc/))
|
9
9
|
|
10
10
|
## Installation
|
11
|
-
watson-ruby has been tested with **Ruby v2.
|
11
|
+
watson-ruby has been tested with **Ruby v2.1** and **RubyGems v2.0.3** (on **Arch Linux**)
|
12
12
|
watson-ruby requires the ```json``` gem
|
13
13
|
|
14
14
|
### From Repo
|
15
|
-
watson-ruby is avaliable as a RubyGems ([link](https://rubygems.org/gems/watson-ruby)).
|
15
|
+
watson-ruby is avaliable as a RubyGems ([link](https://rubygems.org/gems/watson-ruby)).
|
16
16
|
You can either download it directory from ```gem``` using
|
17
17
|
```
|
18
18
|
gem install watson-ruby
|
@@ -38,10 +38,10 @@ bundle exec rake
|
|
38
38
|
|
39
39
|
## Usage
|
40
40
|
For a quick idea of how to use watson, check out the [app demo](http://goosecode.com/watson)! ([mirror](http://nhmood.github.io/watson-ruby))
|
41
|
-
See below for a description of what all the command line arguments do.
|
41
|
+
See below for a description of what all the command line arguments do.
|
42
42
|
|
43
43
|
### Supported Languages
|
44
|
-
If you see something missing from the list please either file an issue or
|
44
|
+
If you see something missing from the list please either file an issue or
|
45
45
|
submit a pull request (comment parsing happens in **lib/watson/paser.rb**)
|
46
46
|
|
47
47
|
- **C / C++**
|
@@ -69,6 +69,7 @@ submit a pull request (comment parsing happens in **lib/watson/paser.rb**)
|
|
69
69
|
- **Markdown**
|
70
70
|
- **HTML**
|
71
71
|
- **Emacslisp**
|
72
|
+
- **LaTex**
|
72
73
|
|
73
74
|
|
74
75
|
## Command line arguments
|
@@ -79,36 +80,37 @@ If no RC file exists, default RC file will be created
|
|
79
80
|
|
80
81
|
-c, --context-depth lines of context to provide with posted issue
|
81
82
|
-d, --dirs list of directories to search in
|
83
|
+
--debug enable debug prints from specified class
|
84
|
+
all debug prints enabled if no arguments passed
|
82
85
|
-f, --files list of files to search in
|
83
86
|
--format set output format for watson
|
84
87
|
[print, json, unite, silent]
|
85
88
|
-h, --help print help
|
86
89
|
-i, --ignore list of files, directories, or types to ignore
|
87
90
|
-p, --parse-depth depth to recursively parse directories
|
88
|
-
-r, --remote list / create tokens for
|
89
|
-
[github, bitbucket, gitlab, asana]
|
91
|
+
-r, --remote list / create tokens for Bitbucket/GitHub
|
90
92
|
-s, --show filter results (files listed) based on issue status
|
91
93
|
[all, clean, dirty]
|
92
94
|
-t, --tags list of tags to search for
|
93
95
|
-u, --update update remote repos with current issues
|
94
96
|
-v, --version print watson version and info
|
95
97
|
|
96
|
-
|
97
98
|
Any number of files, tags, dirs, and ignores can be listed after flag
|
98
99
|
Ignored files should be space separated
|
99
100
|
To use *.filetype identifier, encapsulate in "" to avoid shell substitutions
|
100
101
|
|
101
102
|
Report bugs to: watson@goosecode.com
|
102
|
-
watson home page: <http://goosecode.com/
|
103
|
+
watson home page: <http://goosecode.com/watson>
|
103
104
|
[goosecode] labs | 2012-2013
|
104
105
|
|
106
|
+
|
105
107
|
```
|
106
108
|
### All file/directory/tag related parameters support relative as well as absolute paths.
|
107
109
|
|
108
110
|
### -c, --context-lines [LINES]
|
109
111
|
This parameter specifies how many lines of context watson should include when posting issues to remote repos.
|
110
112
|
When this parameter is set from the command line, the .watsonrc config file is written with the value; the command line option effectively sets the default value for this feature in the current directory.
|
111
|
-
The default value is set to 15 (and can be found in the lib/watson/command.rb file).
|
113
|
+
The default value is set to 15 (and can be found in the lib/watson/command.rb file).
|
112
114
|
|
113
115
|
|
114
116
|
### -d, --dirs [DIRS]
|
@@ -120,7 +122,7 @@ If watson is run without this parameter, the current directory is parsed.
|
|
120
122
|
### --debug [CLASS]
|
121
123
|
This parameter enables debug prints for the specified class.
|
122
124
|
It should be followed by a space separated list of classes that should print debug messages.
|
123
|
-
The list of classes are found in `lib/watson`.
|
125
|
+
The list of classes are found in `lib/watson`.
|
124
126
|
If passed without arguments, debug prints in **ALL** classes of watson will be enabled.
|
125
127
|
|
126
128
|
|
@@ -134,19 +136,19 @@ This parameter specifies how watson should output the issues that it finds.
|
|
134
136
|
If passed with `print`, the regular printing will occur, either to Unix less or STDOUT (depending on system).
|
135
137
|
If passed with `json`, the output will be in the form of JSON, and will be stored in `.watsonresults`.
|
136
138
|
|
137
|
-
- This particular option is useful if attempting to intergrate watson into other tools / platforms.
|
139
|
+
- This particular option is useful if attempting to intergrate watson into other tools / platforms.
|
138
140
|
|
139
141
|
If passed with `unite`, the output will be compatible with the unite.vim plugin
|
140
142
|
(see the **Unite** section below or visit [alpaca-tc/vim-unite-watson](https://github.com/alpaca-tc/vim-unite-watson.vim)
|
141
143
|
|
142
144
|
If passed with `silent`, watson will have no output.
|
143
145
|
|
144
|
-
- This particular option is useful if remote posting to GitHub, Bitbucket, or GitLab is desired without the visual component of watson.
|
146
|
+
- This particular option is useful if remote posting to GitHub, Bitbucket, or GitLab is desired without the visual component of watson.
|
145
147
|
- For example, you could set up a **git commit hook** to post issues to GitHub/Bitbucket/GitLab, but avoid the giant print out every time.
|
146
148
|
|
147
149
|
|
148
150
|
### -h, --help
|
149
|
-
This parameter displays the list of avaliable options for watson.
|
151
|
+
This parameter displays the list of avaliable options for watson.
|
150
152
|
|
151
153
|
|
152
154
|
### -i, --ignore [IGNORES]
|
@@ -159,13 +161,13 @@ This parameter should be used as an opposite to -d/-f, when there are more files
|
|
159
161
|
This parameter specifies how deep watson should recursively parse directories.
|
160
162
|
The 'depth' is defined as how many levels deep from the top-most specified directory to parse.
|
161
163
|
If individual directories are passed with the -d (--dirs) flag, each will be parsed PARSE_DEPTH layers, regardless of their depth from the current directory.
|
162
|
-
If watson is run without this parameter, the parsing depth is unlimited and will search through all subdirectories found.
|
164
|
+
If watson is run without this parameter, the parsing depth is unlimited and will search through all subdirectories found.
|
163
165
|
|
164
166
|
|
165
167
|
### -r, --remote [GITHUB, BITBUCKET, GITLAB, ASANA]
|
166
168
|
This parameter is used to both list currently established remotes as well as setup new ones.
|
167
169
|
If passed without any options, the currently established remotes will be listed.
|
168
|
-
If passed with a github, bitbucket, gitlab, asana argument, watson will proceed to ask some questions to set up the corresponding remote.
|
170
|
+
If passed with a github, bitbucket, gitlab, asana argument, watson will proceed to ask some questions to set up the corresponding remote.
|
169
171
|
|
170
172
|
|
171
173
|
### -s, --show [ALL, CLEAN, DIRTY]
|
@@ -194,19 +196,21 @@ This parameter displays the current version of watson you are running.
|
|
194
196
|
watson supports an RC file that allows for reusing commong settings without repeating command line arguments every time.
|
195
197
|
|
196
198
|
The .watsonrc is placed in every directory that watson is run from as opposed to a unified file (in ~/.watsonrc for example). The thought process behind this is that each project may have a different set of folders to ignore, directories to search through, and tags to look for.
|
197
|
-
For example, a C/C++ project might want to look in src/ and ignore obj/ whereas a Ruby project might want to look in lib/ and ignore assets/.
|
199
|
+
For example, a C/C++ project might want to look in src/ and ignore obj/ whereas a Ruby project might want to look in lib/ and ignore assets/.
|
198
200
|
|
199
201
|
A base `.watsonrc` is created in the users `$HOME` directory and used as the template for creating all subsequent config files.
|
200
202
|
Any changes made in the `$HOME/.watsonrc` will carry on towards new configs, but will **not** update previously created configs.
|
201
203
|
The `$HOME/.watsonrc` is directly copied, not merged, as to avoid confusion as to the source of config parameters.
|
204
|
+
The `$HOME/.watsonrc` contains all remote GitHub API tokens created. The individual project `.watsonrc` will contain only the username
|
205
|
+
associated with the API token, and will reference `$HOME/.watsonrc` to obtain the API token on runtime.
|
202
206
|
|
203
207
|
The .watsonrc file is fairly straightforward...
|
204
|
-
**[dirs]** - This is a newline separated list of directories to look in while parsing.
|
208
|
+
**[dirs]** - This is a newline separated list of directories to look in while parsing.
|
205
209
|
|
206
|
-
**[tags]** - This is a newline separated list of tags to look for while parsing.
|
210
|
+
**[tags]** - This is a newline separated list of tags to look for while parsing.
|
207
211
|
|
208
|
-
**[ignore]** - This is a newline separated list of files / folders to ignore while parsing.
|
209
|
-
This supports wildcard type selecting by providing .filename (no * required)
|
212
|
+
**[ignore]** - This is a newline separated list of files / folders to ignore while parsing.
|
213
|
+
This supports wildcard type selecting by providing .filename (no * required)
|
210
214
|
|
211
215
|
**[context_depth]** - This value determines how many lines of context should be grabbed for each issue when posting to a remote.
|
212
216
|
|
@@ -216,12 +220,20 @@ The format of filetype entries should be
|
|
216
220
|
".type" => ["comment1", "comment2"]
|
217
221
|
".nhmood" => ["@@", "***"]
|
218
222
|
".cc" => ["//"]
|
219
|
-
```
|
223
|
+
```
|
224
|
+
|
225
|
+
**[show_type]** - This field allows for setting the default show type, similar to the -s/--show command line arg
|
226
|
+
If set to `clean`, only files that watson did *NOT* find issues in will be displayed.
|
227
|
+
If set to `dirty`, only files that watson *DID* find issues in will be displayed.
|
228
|
+
If set to `all`, watson will display all files, regardless of their issue status.
|
229
|
+
The default behavior of watson is the `all` option.
|
230
|
+
|
231
|
+
**[tag_format]** - Customize the tag format for your project. Defaults to `[TAG] - COMMENT`. "TAG" and "COMMENT" are required keywords.
|
220
232
|
|
221
|
-
**[(github/bitbucket/gitlab/asana)_api]** - If a remote is established, the API key for the corresponding remote is stored here.
|
222
|
-
Currently, OAuth has yet to be implemented for Bitbucket so the Bitbucket username is stored here.
|
233
|
+
**[(github/bitbucket/gitlab/asana)_api]** - If a remote is established, the API key for the corresponding remote is stored here.
|
234
|
+
Currently, OAuth has yet to be implemented for Bitbucket so the Bitbucket username is stored here.
|
223
235
|
|
224
|
-
**[(github/bitbucket/gitlab)_repo]** - The repo name / path is stored here.
|
236
|
+
**[(github/bitbucket/gitlab)_repo]** - The repo name / path is stored here.
|
225
237
|
|
226
238
|
**[(github/gitlab)_endpoint]** - The endpoint in case of GitHub Enterprise of GitLab configuration.
|
227
239
|
|
@@ -229,19 +241,19 @@ Currently, OAuth has yet to be implemented for Bitbucket so the Bitbucket userna
|
|
229
241
|
|
230
242
|
**[asana_workspace]** - The Asana workspace in case of Asana integration is stored here.
|
231
243
|
|
232
|
-
The remote related .watsonrc options shouldn't need to be edited manually, as they are automatically populated when the -r, --remote setup is called.
|
244
|
+
The remote related .watsonrc options shouldn't need to be edited manually, as they are automatically populated when the -r, --remote setup is called.
|
233
245
|
|
234
246
|
## unite.vim
|
235
|
-
### [vim-unite-watson.vim](https://github.com/alpaca-tc/vim-unite-watson.vim) by [alpaca-tc](http://github.com/alpaca-tc)
|
247
|
+
### [vim-unite-watson.vim](https://github.com/alpaca-tc/vim-unite-watson.vim) by [alpaca-tc](http://github.com/alpaca-tc)
|
236
248
|
**alpaca-tc** was kind enough to create a [unite.vim](https://github.com/Shougo/unite.vim) plugin to integrate with watson!
|
237
249
|
**unite.vim** allows you to create user interfaces within vim and lets you search and display any kind of information.
|
238
|
-
The **unite-vim-watson.vim** plugin allows you to:
|
250
|
+
The **unite-vim-watson.vim** plugin allows you to:
|
239
251
|
|
240
|
-
- Generate a list of issues directly inside vim
|
241
|
-
- Search and select files displayed in the watson output
|
242
|
-
- Jump directly to the line where the issue is located (!!)
|
252
|
+
- Generate a list of issues directly inside vim
|
253
|
+
- Search and select files displayed in the watson output
|
254
|
+
- Jump directly to the line where the issue is located (!!)
|
243
255
|
|
244
|
-
If you use vim I ***definitely*** recommend using **vim-unite-watson.vim**, it works wonders for productivity!
|
256
|
+
If you use vim I ***definitely*** recommend using **vim-unite-watson.vim**, it works wonders for productivity!
|
245
257
|
|
246
258
|
### See it in action [here (GIF demo)](https://github.com/alpaca-tc/vim-unite-watson.vim)
|
247
259
|
|
@@ -251,7 +263,7 @@ Special thanks to [@eugenekolo](http://twitter.com/eugenekolo) [[email](eugenek@
|
|
251
263
|
Special thanks to [@crowell](http://github.com/crowell) for testing out watson-ruby!
|
252
264
|
|
253
265
|
## FAQ
|
254
|
-
- **Will inline issues get deleted if I close them on GitHub/Bitbucket/GitLab?**
|
266
|
+
- **Will inline issues get deleted if I close them on GitHub/Bitbucket/GitLab?**
|
255
267
|
No, watson won't touch your source code, it will only inform you that issues have been closed remotely.
|
256
268
|
|
257
269
|
- **Why Ruby?**
|
data/lib/watson/command.rb
CHANGED
@@ -450,20 +450,31 @@ module Watson
|
|
450
450
|
formatter = Printer.new(@config).build_formatter
|
451
451
|
formatter.print_header
|
452
452
|
|
453
|
+
# Get $HOME/.watsonrc to check for remotes
|
454
|
+
_home_conf = Watson::Config.home_conf
|
455
|
+
|
453
456
|
print BOLD + "Existing Remotes:\n" + RESET
|
454
457
|
|
455
458
|
# Check the config for any remote entries (GitHub or Bitbucket) and print
|
456
459
|
# We *should* always have a repo + API together, but API should be enough
|
457
|
-
if
|
460
|
+
if _home_conf.github_api.empty? && @config.bitbucket_api.empty? && @config.asana_api.empty?
|
458
461
|
formatter.print_status "!", YELLOW
|
459
462
|
print BOLD + "No remotes currently exist\n\n" + RESET
|
460
463
|
end
|
461
464
|
|
462
|
-
|
463
|
-
print BOLD + "GitHub
|
465
|
+
unless _home_conf.github_api.empty?
|
466
|
+
print BOLD + "- GitHub APIs -\n" + RESET
|
467
|
+
_home_conf.github_api.each_with_index do |_api, _i|
|
468
|
+
print BOLD + "#{_i+1}. #{_api[0]}" + RESET + " : #{_api[1]}\n"
|
469
|
+
end
|
470
|
+
print "\n\n"
|
471
|
+
end
|
472
|
+
|
473
|
+
unless @config.github_repo.empty?
|
464
474
|
print BOLD + "GitHub Repo : " + RESET + "#{ @config.github_repo }\n\n"
|
465
475
|
end
|
466
476
|
|
477
|
+
|
467
478
|
if !@config.bitbucket_api.empty?
|
468
479
|
print BOLD + "Bitbucket User : " + RESET + "#{ @config.bitbucket_api }\n" + RESET
|
469
480
|
print BOLD + "Bitbucket Repo : " + RESET + "#{ @config.bitbucket_repo }\n\n" + RESET
|
data/lib/watson/config.rb
CHANGED
@@ -4,12 +4,26 @@ module Watson
|
|
4
4
|
# that are accessed throughout watson
|
5
5
|
class Config
|
6
6
|
|
7
|
+
class << self
|
8
|
+
def home_conf
|
9
|
+
# Return Conf object for $HOME/.watsonrc
|
10
|
+
_home_conf = Watson::Config.new()
|
11
|
+
_home_conf.rc_file = File.expand_path('~') + '/.watsonrc'
|
12
|
+
_home_conf.read_conf
|
13
|
+
return _home_conf
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
7
18
|
# Include for debug_print
|
8
19
|
include Watson
|
9
20
|
|
10
21
|
# [review] - Combine into single statement (for performance or something?)
|
11
22
|
# [todo] - Add config options (rc file) for default max depth and context lines
|
12
23
|
|
24
|
+
# Location of .watsonrc, modified when working with remote API tokens
|
25
|
+
attr_accessor :rc_file
|
26
|
+
|
13
27
|
# List of all files/folders to ignore when parsing
|
14
28
|
attr_accessor :ignore_list
|
15
29
|
# List of directories to parse
|
@@ -18,6 +32,8 @@ module Watson
|
|
18
32
|
attr_accessor :file_list
|
19
33
|
# List of tags to look for when parsing
|
20
34
|
attr_accessor :tag_list
|
35
|
+
# Tag format for look for
|
36
|
+
attr_accessor :tag_format
|
21
37
|
# List of custom filetypes to accept
|
22
38
|
attr_accessor :type_list
|
23
39
|
# Number of directories to parse recursively
|
@@ -132,11 +148,13 @@ module Watson
|
|
132
148
|
@type_list = Hash.new()
|
133
149
|
@issue_count = 0
|
134
150
|
|
151
|
+
@tag_format = "[TAG] - COMMENT"
|
152
|
+
|
135
153
|
# Remote options
|
136
154
|
@remote_valid = false
|
137
155
|
|
138
156
|
@github_valid = false
|
139
|
-
@github_api =
|
157
|
+
@github_api = Hash.new
|
140
158
|
@github_endpoint = ""
|
141
159
|
@github_repo = ""
|
142
160
|
@github_issues = Hash.new()
|
@@ -394,6 +412,9 @@ module Watson
|
|
394
412
|
end
|
395
413
|
debug_print "@tag_list --> #{ @tag_list }\n"
|
396
414
|
|
415
|
+
when "tag_format"
|
416
|
+
@tag_format = _line.chomp!
|
417
|
+
debug_print @tag_format
|
397
418
|
|
398
419
|
when "type"
|
399
420
|
# Regex to grab ".type" => ["param1", "param2"]
|
@@ -427,10 +448,43 @@ module Watson
|
|
427
448
|
debug_print "@ignore_list --> #{ @ignore_list }\n"
|
428
449
|
|
429
450
|
|
451
|
+
when "show_type"
|
452
|
+
# No need for parsing, just check case
|
453
|
+
|
454
|
+
case _line.chomp.downcase
|
455
|
+
when "clean"
|
456
|
+
@show_type = "clean"
|
457
|
+
debug_print "@show_type set to \"clean\" from config\n"
|
458
|
+
|
459
|
+
when "dirty"
|
460
|
+
@show_type = "dirty"
|
461
|
+
debug_print "@show_type set to \"dirty\" from config\n"
|
462
|
+
|
463
|
+
else
|
464
|
+
@show_type = "all"
|
465
|
+
debug_print "@show_type set to \"all\" from config\n"
|
466
|
+
|
467
|
+
end
|
468
|
+
|
469
|
+
|
470
|
+
# Project directories reference $HOME/.watsonrc for GitHub API token
|
471
|
+
# If we don't find a username=token format string, use username
|
472
|
+
# as Hash reference to $HOME/.watsonrc --> github_api
|
430
473
|
when "github_api"
|
431
|
-
#
|
432
|
-
|
433
|
-
|
474
|
+
# Regex for username=token
|
475
|
+
_mtch = _line.chomp.match(/(\S+)=(\S+)/)
|
476
|
+
|
477
|
+
# If no = match, then it is a hash reference
|
478
|
+
if _mtch.nil?
|
479
|
+
_home = Watson::Config.home_conf
|
480
|
+
@github_api[_line.chomp] = _home.github_api[_line.chomp]
|
481
|
+
|
482
|
+
# If we do find match, this is a $HOME/.watsonrc
|
483
|
+
# Populate home conf with all API tokens
|
484
|
+
else
|
485
|
+
@github_api[_mtch[1]] = _mtch[2]
|
486
|
+
end
|
487
|
+
|
434
488
|
debug_print "GitHub API: #{ @github_api }\n"
|
435
489
|
|
436
490
|
|
@@ -511,7 +565,7 @@ module Watson
|
|
511
565
|
|
512
566
|
# Check if RC exists, if not create one
|
513
567
|
if !Watson::FS.check_file(@rc_file)
|
514
|
-
print "Unable to open #{ @rc_file },
|
568
|
+
print "Unable to open #{ @rc_file }, attempting to create\n"
|
515
569
|
create_conf
|
516
570
|
else
|
517
571
|
debug_print "Opened #{ @rc_file } for reading\n"
|
@@ -592,15 +646,48 @@ module Watson
|
|
592
646
|
end
|
593
647
|
|
594
648
|
# Now that we have skipped all the things that need to be updated, write them in
|
595
|
-
params.each do |
|
596
|
-
_update.write("[#{
|
597
|
-
|
649
|
+
params.each do | _name |
|
650
|
+
_update.write("[#{ _name }]\n")
|
651
|
+
_param = self.instance_variable_get("@#{ _name }")
|
652
|
+
|
653
|
+
if _param.is_a?(Hash)
|
654
|
+
# If the config file we are dealing with is in $HOME/.watsonrc
|
655
|
+
# then write as username=token, else write just username
|
656
|
+
pp(_param)
|
657
|
+
if @rc_file == File.expand_path('~') + '/.watsonrc'
|
658
|
+
_param.each do |val|
|
659
|
+
_update.write("#{val[0]}=#{val[1]}\n")
|
660
|
+
end
|
661
|
+
else
|
662
|
+
_param.each do |val|
|
663
|
+
_update.write("#{val[0]}\n")
|
664
|
+
end
|
665
|
+
end
|
666
|
+
|
667
|
+
elsif _param.is_a?(Array)
|
668
|
+
_param.each do |val|
|
669
|
+
_update.write("#{val}\n")
|
670
|
+
end
|
671
|
+
|
672
|
+
else
|
673
|
+
_update.write("#{_param}\n")
|
674
|
+
end
|
675
|
+
|
598
676
|
_update.write("\n\n\n")
|
599
677
|
end
|
600
678
|
|
601
679
|
_update.close
|
602
680
|
end
|
603
681
|
|
682
|
+
|
683
|
+
|
684
|
+
###########################################################
|
685
|
+
# Get first key from API list (hash)
|
686
|
+
def github_token
|
687
|
+
self.github_api[github_api.keys[0]]
|
688
|
+
end
|
689
|
+
|
690
|
+
|
604
691
|
end
|
605
692
|
end
|
606
693
|
|
data/lib/watson/github.rb
CHANGED
@@ -16,6 +16,7 @@ module Watson
|
|
16
16
|
# Include for debug_print
|
17
17
|
include Watson
|
18
18
|
|
19
|
+
|
19
20
|
#############################################################################
|
20
21
|
# Setup remote access to GitHub
|
21
22
|
# Get Username, Repo, and PW and perform necessary HTTP calls to check validity
|
@@ -25,21 +26,52 @@ module Watson
|
|
25
26
|
debug_print "#{ self.class } : #{ __method__ }\n"
|
26
27
|
|
27
28
|
formatter = Printer.new(config).build_formatter
|
29
|
+
|
30
|
+
# Create new RC for $HOME/.watsonrc and check for existing remotes there
|
31
|
+
_home_conf = Watson::Config.home_conf
|
32
|
+
|
33
|
+
return false if !get_token(config, _home_conf, formatter)
|
34
|
+
return false if !get_repo(config, formatter)
|
35
|
+
|
36
|
+
# Give user some info
|
37
|
+
print "\n"
|
38
|
+
formatter.print_status "o", GREEN
|
39
|
+
print BOLD + "GitHub successfully setup\n" + RESET
|
40
|
+
print " Issues will now automatically be retrieved from GitHub by default\n"
|
41
|
+
print " Use -u, --update to post issues to GitHub\n"
|
42
|
+
print " See help or README for more details on GitHub/Bitbucket access\n\n"
|
43
|
+
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
#############################################################################
|
49
|
+
# Obtain API token fom GitHub
|
50
|
+
# Either generate new Auth Token or use existing for current dir/project
|
51
|
+
def get_token(config, home_conf, formatter)
|
52
|
+
|
53
|
+
# Avaliable GitHub APIs
|
54
|
+
_github = home_conf.github_api
|
55
|
+
|
28
56
|
formatter.print_status "+", GREEN
|
29
57
|
print BOLD + "Obtaining OAuth Token for GitHub...\n" + RESET
|
30
58
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
print
|
35
|
-
print " (Y)es/(N)o: "
|
59
|
+
unless _github.empty?
|
60
|
+
formatter.print_status "!", YELLOW
|
61
|
+
print BOLD + "Previous GitHub APIs found do you want to use one that is listed?\n" + RESET
|
62
|
+
print " Enter # of API key (blank will create new): "
|
36
63
|
|
37
64
|
# Get user input
|
38
|
-
|
39
|
-
|
40
|
-
|
65
|
+
unless (_api = $stdin.gets.chomp).empty?
|
66
|
+
print "\n"
|
67
|
+
_api = _api.to_i - 1
|
68
|
+
|
69
|
+
# Return specified API token if # selected is valid
|
70
|
+
return _github[_github.keys[_api]] if _api >= 0 && _api < _github.length
|
71
|
+
|
41
72
|
formatter.print_status "x", RED
|
42
|
-
print BOLD + "
|
73
|
+
print BOLD + "Invalid API selected\n" + RESET
|
74
|
+
print " Make sure the correct # was selected from the list!\n" + RESET
|
43
75
|
return false
|
44
76
|
end
|
45
77
|
end
|
@@ -53,6 +85,7 @@ module Watson
|
|
53
85
|
print BOLD + "Is this a GitHub Enterprise account?\n" + RESET
|
54
86
|
print " (Y)es/(N)o: "
|
55
87
|
|
88
|
+
|
56
89
|
# Get user input
|
57
90
|
_enterprise = $stdin.gets.chomp
|
58
91
|
if ["yes", "y"].include?(_enterprise.downcase)
|
@@ -144,13 +177,32 @@ module Watson
|
|
144
177
|
return false
|
145
178
|
end
|
146
179
|
|
180
|
+
# Add to $HOME/.watsonrc and current .watsonrc
|
181
|
+
home_conf.github_api[_username] = _json["token"]
|
182
|
+
home_conf.update_conf("github_api")
|
183
|
+
|
147
184
|
# Store endpoint and API key obtained from POST to @config.github_api
|
148
185
|
config.github_endpoint = _endpoint
|
149
|
-
|
186
|
+
|
187
|
+
# If we are currently in $HOME then don't touch the .watsonrc
|
188
|
+
# [todo] - Better way of selecting API if in $HOME, or just don't use in $HOME...
|
189
|
+
unless Dir.pwd.eql?(File.expand_path('~'))
|
190
|
+
config.github_api = {_username => _json["token"]}
|
191
|
+
config.update_conf("github_api", "github_endpoint")
|
192
|
+
end
|
193
|
+
|
194
|
+
|
150
195
|
debug_print "Config GitHub API Endpoint updated to: #{ config.github_endpoint }\n"
|
151
196
|
debug_print "Config GitHub API Key updated to: #{ config.github_api }\n"
|
152
197
|
|
198
|
+
true
|
199
|
+
end
|
200
|
+
|
153
201
|
|
202
|
+
#############################################################################
|
203
|
+
# Obtain repo info for GitHub
|
204
|
+
# Set repo for current dir/project
|
205
|
+
def get_repo(config, formatter)
|
154
206
|
# Get repo information, if blank give error
|
155
207
|
formatter.print_status "!", YELLOW
|
156
208
|
print BOLD + "Repo information required\n" + RESET
|
@@ -186,10 +238,10 @@ module Watson
|
|
186
238
|
#
|
187
239
|
# Auth token
|
188
240
|
opts = {
|
189
|
-
:url => "#{
|
241
|
+
:url => "#{ config.github_endpoint }/repos/#{ _owner }/#{ _repo }/labels",
|
190
242
|
:ssl => true,
|
191
243
|
:method => "POST",
|
192
|
-
:auth => config.
|
244
|
+
:auth => config.github_token,
|
193
245
|
:data => {"name" => "watson",
|
194
246
|
"color" => "00AEEF" },
|
195
247
|
:verbose => false
|
@@ -217,6 +269,7 @@ module Watson
|
|
217
269
|
|
218
270
|
# Store owner/repo obtained from POST to @config.github_repo
|
219
271
|
config.github_repo = "#{ _owner }/#{ _repo }"
|
272
|
+
config.update_conf("github_repo")
|
220
273
|
debug_print "Config GitHub API Key updated to: #{ config.github_repo }\n"
|
221
274
|
|
222
275
|
# Inform user of label creation status (created above)
|
@@ -234,21 +287,7 @@ module Watson
|
|
234
287
|
print " Status: #{ _resp.code } - #{ _resp.message }\n"
|
235
288
|
end
|
236
289
|
|
237
|
-
|
238
|
-
# Call config updater/writer from @config to write config
|
239
|
-
debug_print "Updating config with new GitHub info\n"
|
240
|
-
config.update_conf("github_api", "github_repo", "github_endpoint")
|
241
|
-
|
242
|
-
# Give user some info
|
243
|
-
print "\n"
|
244
|
-
formatter.print_status "o", GREEN
|
245
|
-
print BOLD + "GitHub successfully setup\n" + RESET
|
246
|
-
print " Issues will now automatically be retrieved from GitHub by default\n"
|
247
|
-
print " Use -u, --update to post issues to GitHub\n"
|
248
|
-
print " See help or README for more details on GitHub/Bitbucket access\n\n"
|
249
|
-
|
250
|
-
return true
|
251
|
-
|
290
|
+
true
|
252
291
|
end
|
253
292
|
|
254
293
|
|
@@ -278,7 +317,7 @@ module Watson
|
|
278
317
|
:url => "#{ config.github_endpoint }/repos/#{ config.github_repo }/issues?labels=watson",
|
279
318
|
:ssl => true,
|
280
319
|
:method => "GET",
|
281
|
-
:auth => config.
|
320
|
+
:auth => config.github_token,
|
282
321
|
:verbose => false
|
283
322
|
}
|
284
323
|
|
@@ -361,7 +400,7 @@ module Watson
|
|
361
400
|
:url => "#{ config.github_endpoint }/repos/#{ config.github_repo }/issues",
|
362
401
|
:ssl => true,
|
363
402
|
:method => "POST",
|
364
|
-
:auth => config.
|
403
|
+
:auth => config.github_token,
|
365
404
|
:data => { "title" => issue[:title] + " [#{ issue[:path] }]",
|
366
405
|
"labels" => [issue[:tag], "watson"],
|
367
406
|
"body" => _body },
|
data/lib/watson/parser.rb
CHANGED
@@ -208,8 +208,15 @@ module Watson
|
|
208
208
|
# [review] - It is possible to embed the valid tags in the regexp,
|
209
209
|
# with a ~5% performance gain, but this would loose the warning about
|
210
210
|
# unrecognized tags.
|
211
|
-
|
211
|
+
_tag_format = Regexp.escape(@config.tag_format).gsub('\\ ', ' ')
|
212
|
+
_tag_format_regex = _tag_format
|
213
|
+
.gsub("TAG", '(\w+)')
|
214
|
+
.gsub("COMMENT", '(.+)')
|
215
|
+
.gsub(' ' , '\s+')
|
212
216
|
|
217
|
+
_comment_regex = /^(?:\s*[#{_comment_type}]+\s*)+#{_tag_format_regex}/
|
218
|
+
|
219
|
+
debug_print "Comment regex: #{_comment_regex}\n"
|
213
220
|
|
214
221
|
# Open file and read in entire thing into an array
|
215
222
|
# Use an array so we can look ahead when creating issues later
|
@@ -245,7 +252,7 @@ module Watson
|
|
245
252
|
end
|
246
253
|
|
247
254
|
# Set tag
|
248
|
-
_tag = _mtch[1]
|
255
|
+
_tag = _mtch[1].downcase
|
249
256
|
|
250
257
|
# Make sure that the tag that was found is something we accept
|
251
258
|
# If not, skip it but tell user about an unrecognized tag
|
@@ -409,7 +416,8 @@ module Watson
|
|
409
416
|
'.el' => [';'], # Emacslisp
|
410
417
|
'.sqf' => ['//','/*'], # SQF
|
411
418
|
'.sqs' => [';'], # SQS
|
412
|
-
'.d' => ['//','/*']
|
419
|
+
'.d' => ['//','/*'], # D
|
420
|
+
'.tex' => ['%'] # LaTex
|
413
421
|
}
|
414
422
|
|
415
423
|
# Merge config file type list with defaults
|
data/lib/watson/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -86,10 +86,12 @@ describe Config do
|
|
86
86
|
@config.file_list.should == []
|
87
87
|
@config.tag_list.should == []
|
88
88
|
|
89
|
+
@config.tag_format.should == "[TAG] - COMMENT"
|
90
|
+
|
89
91
|
@config.remote_valid.should be_false
|
90
92
|
|
91
93
|
@config.github_valid.should be_false
|
92
|
-
@config.github_api.should ==
|
94
|
+
@config.github_api.should == Hash.new()
|
93
95
|
@config.github_repo.should == ''
|
94
96
|
@config.github_issues.should == Hash.new()
|
95
97
|
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watson-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nhmood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: an inline issue manager with GitHub and Bitbucket support
|
@@ -59,8 +59,8 @@ executables:
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- .gitignore
|
63
|
-
- .travis.yml
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
64
|
- Gemfile
|
65
65
|
- Gemfile.lock
|
66
66
|
- LICENSE
|
@@ -104,17 +104,17 @@ require_paths:
|
|
104
104
|
- lib
|
105
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: 2.0.0
|
110
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
|
-
- -
|
112
|
+
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.0
|
117
|
+
rubygems_version: 2.2.0
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: an inline issue manager
|