watson-ruby 1.0.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 +7 -0
- data/.gitignore +6 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +28 -0
- data/LICENSE +19 -0
- data/README.md +147 -0
- data/Rakefile +21 -0
- data/assets/defaultConf +21 -0
- data/assets/watson.svg +25 -0
- data/bin/watson +18 -0
- data/lib/watson.rb +69 -0
- data/lib/watson/bitbucket.rb +373 -0
- data/lib/watson/command.rb +470 -0
- data/lib/watson/config.rb +493 -0
- data/lib/watson/fs.rb +69 -0
- data/lib/watson/github.rb +369 -0
- data/lib/watson/parser.rb +405 -0
- data/lib/watson/printer.rb +293 -0
- data/lib/watson/remote.rb +120 -0
- data/lib/watson/version.rb +3 -0
- data/spec/config_spec.rb +119 -0
- data/spec/fs_spec.rb +56 -0
- data/spec/helper_spec.rb +32 -0
- data/spec/parser_spec.rb +128 -0
- data/watson.gemspec +33 -0
- metadata +116 -0
data/spec/fs_spec.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
module Watson
|
2
|
+
|
3
|
+
require_relative 'helper_spec'
|
4
|
+
|
5
|
+
describe FS do
|
6
|
+
before(:each) do
|
7
|
+
silence_output
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
enable_output
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.check_file' do
|
15
|
+
context 'blank input file' do
|
16
|
+
it 'should return false' do
|
17
|
+
FS.check_file('').should be_false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'invalid input file' do
|
22
|
+
it 'should return false' do
|
23
|
+
FS.check_file('chickensoup.rb').should be_false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'valid input file' do
|
28
|
+
it 'should return true' do
|
29
|
+
FS.check_file('spec/fs_spec.rb').should be_true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.check_dir' do
|
35
|
+
context 'blank input dir' do
|
36
|
+
it 'should return false' do
|
37
|
+
FS.check_dir('').should be_false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'invalid input dir' do
|
42
|
+
it 'should return false' do
|
43
|
+
FS.check_dir('./chickensoup').should be_false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'valid input dir' do
|
48
|
+
it 'should return true' do
|
49
|
+
FS.check_dir('spec/').should be_true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
data/spec/helper_spec.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# [review] - Using own funky path loading because traditional way seems wrong?
|
2
|
+
# Commented out version is traditional, seen in many apps. If you use that and
|
3
|
+
# look at load_path you get path/../lib (I'd expect those to be separate?)
|
4
|
+
# My funky version adds path/., path/bin, path/assets separately
|
5
|
+
# Maybe I don't get how the load path is supposed to look though...
|
6
|
+
|
7
|
+
#$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
8
|
+
$:.unshift *%w[. assets lib].map { |m| __dir__.gsub(/\/test(.?)+/, '') + '/' + m }
|
9
|
+
#p($:)
|
10
|
+
|
11
|
+
require 'watson'
|
12
|
+
|
13
|
+
|
14
|
+
def silence_output
|
15
|
+
# Store the original stderr and stdout in order to restore them later
|
16
|
+
@original_stderr = $stderr
|
17
|
+
@original_stdout = $stdout
|
18
|
+
|
19
|
+
# Redirect stderr and stdout
|
20
|
+
$stderr = File.new(File.join(__dir__, 'null.txt'), 'w')
|
21
|
+
$stdout = File.new(File.join(__dir__, 'null.txt'), 'w')
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def enable_output
|
26
|
+
$stderr = @original_stderr
|
27
|
+
$stdout = @original_stdout
|
28
|
+
@original_stderr = nil
|
29
|
+
@original_stdout = nil
|
30
|
+
|
31
|
+
File.delete(File.join(__dir__, 'null.txt'))
|
32
|
+
end
|
data/spec/parser_spec.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
module Watson
|
2
|
+
require_relative 'helper_spec'
|
3
|
+
|
4
|
+
describe Parser do
|
5
|
+
before(:each) do
|
6
|
+
@config = Config.new
|
7
|
+
@config.run
|
8
|
+
@parser = Parser.new(@config)
|
9
|
+
silence_output
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:each) do
|
13
|
+
@file = @config.instance_variable_get(:@rc_file)
|
14
|
+
File.delete(@file) if File.exists?(@file)
|
15
|
+
enable_output
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
describe '#get_comment_type' do
|
20
|
+
context 'known extension' do
|
21
|
+
it 'return correct extension (# for ruby)' do
|
22
|
+
@parser.get_comment_type('lib/watson.rb').should eql '#'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'return correct extension (// for c/c++)' do
|
26
|
+
@parser.get_comment_type('lib/watson.cpp').should eql '//'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'unknown extension' do
|
31
|
+
it 'return false for unknown extension' do
|
32
|
+
@parser.get_comment_type('lib/chickensoup').should be_false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#parse_file' do
|
38
|
+
context 'invalid file parse' do
|
39
|
+
it 'return false on empty file input' do
|
40
|
+
@parser.parse_file('').should be_false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'blank file parse' do
|
45
|
+
before do
|
46
|
+
FileUtils.mkdir('test_dir')
|
47
|
+
FileUtils.touch('test_dir/test_file')
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'generate (blank) hash structure' do
|
51
|
+
@structure = @parser.parse_file('test_dir/test_file')
|
52
|
+
|
53
|
+
@structure[:relative_path].should == 'test_dir/test_file'
|
54
|
+
@structure[:has_issues].should be_false
|
55
|
+
|
56
|
+
@structure['fix'].should == []
|
57
|
+
@structure['review'].should == []
|
58
|
+
@structure['todo'].should == []
|
59
|
+
end
|
60
|
+
|
61
|
+
after do
|
62
|
+
FileUtils.rm_rf('test_dir')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'valid file parse' do
|
67
|
+
before do
|
68
|
+
FileUtils.mkdir('test_dir')
|
69
|
+
FileUtils.cp('assets/examples/main.cpp', 'test_dir/')
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'generate populated hash structure from file' do
|
73
|
+
@structure = @parser.parse_file('test_dir/main.cpp')
|
74
|
+
|
75
|
+
@structure[:relative_path].should == 'test_dir/main.cpp'
|
76
|
+
@structure[:has_issues].should be_true
|
77
|
+
@structure['fix'][0][:line_number].should == 16
|
78
|
+
end
|
79
|
+
|
80
|
+
after do
|
81
|
+
FileUtils.rm_rf('test_dir')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#parse_dir' do
|
88
|
+
context 'empty dir parsing' do
|
89
|
+
before do
|
90
|
+
FileUtils.mkdir('test_dir')
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'generate (blank) hash stucture' do
|
94
|
+
@structure = @parser.parse_dir('test_dir/', 0)
|
95
|
+
|
96
|
+
@structure[:curdir].should == 'test_dir/'
|
97
|
+
@structure[:files].should == []
|
98
|
+
@structure[:subdirs].should == []
|
99
|
+
end
|
100
|
+
|
101
|
+
after do
|
102
|
+
FileUtils.rm_rf('test_dir')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'single file in dir parsing' do
|
107
|
+
before do
|
108
|
+
FileUtils.mkdir('test_dir')
|
109
|
+
FileUtils.cp('assets/examples/main.cpp', 'test_dir/')
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'generate hash structure with parsed file' do
|
113
|
+
@structure = @parser.parse_dir('test_dir/', 0)
|
114
|
+
@structure[:files][0][:relative_path].should == 'test_dir/main.cpp'
|
115
|
+
@structure[:files][0][:has_issues].should be_true
|
116
|
+
@structure[:files][0]["fix"][0][:line_number].should == 16
|
117
|
+
end
|
118
|
+
|
119
|
+
after do
|
120
|
+
FileUtils.rm_rf('test_dir')
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
data/watson.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# [review] - Should this match same style as bin/watson?
|
3
|
+
$:.push File.expand_path("../lib", __FILE__)
|
4
|
+
require "watson/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'watson-ruby'
|
8
|
+
s.version = Watson::VERSION
|
9
|
+
s.date = '2013-11-06'
|
10
|
+
|
11
|
+
s.authors = ["nhmood"]
|
12
|
+
s.email = 'nhmood@goosecode.com'
|
13
|
+
s.homepage = 'http://goosecode.com/watson'
|
14
|
+
|
15
|
+
s.summary = "an inline issue manager"
|
16
|
+
s.description = "an inline issue manager with GitHub and Bitbucket support"
|
17
|
+
|
18
|
+
s.license = 'MIT'
|
19
|
+
s.files = `git ls-files`.split("\n").delete_if { |file| file.include?("assets/examples") }
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
22
|
+
|
23
|
+
s.require_paths = ["assets", "bin", "lib"]
|
24
|
+
|
25
|
+
# Runtime Dependencies
|
26
|
+
s.add_runtime_dependency 'json'
|
27
|
+
|
28
|
+
# Development Dependencies
|
29
|
+
s.add_development_dependency 'rake'
|
30
|
+
s.add_development_dependency 'rspec'
|
31
|
+
end
|
32
|
+
|
33
|
+
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: watson-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nhmood
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
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: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: an inline issue manager with GitHub and Bitbucket support
|
56
|
+
email: nhmood@goosecode.com
|
57
|
+
executables:
|
58
|
+
- watson
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- assets/defaultConf
|
69
|
+
- assets/watson.svg
|
70
|
+
- bin/watson
|
71
|
+
- lib/watson.rb
|
72
|
+
- lib/watson/bitbucket.rb
|
73
|
+
- lib/watson/command.rb
|
74
|
+
- lib/watson/config.rb
|
75
|
+
- lib/watson/fs.rb
|
76
|
+
- lib/watson/github.rb
|
77
|
+
- lib/watson/parser.rb
|
78
|
+
- lib/watson/printer.rb
|
79
|
+
- lib/watson/remote.rb
|
80
|
+
- lib/watson/version.rb
|
81
|
+
- spec/config_spec.rb
|
82
|
+
- spec/fs_spec.rb
|
83
|
+
- spec/helper_spec.rb
|
84
|
+
- spec/parser_spec.rb
|
85
|
+
- watson.gemspec
|
86
|
+
homepage: http://goosecode.com/watson
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- assets
|
94
|
+
- bin
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.0.3
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: an inline issue manager
|
112
|
+
test_files:
|
113
|
+
- spec/config_spec.rb
|
114
|
+
- spec/fs_spec.rb
|
115
|
+
- spec/helper_spec.rb
|
116
|
+
- spec/parser_spec.rb
|