aidir 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7eaf6330320e4fdf216523d062548d9aacd04b1
4
- data.tar.gz: 860bb28473a75a9af18664b4129e58e926126685
3
+ metadata.gz: c4b9543fd9053e1f38ef30b9905465846c1b6dcf
4
+ data.tar.gz: 50e84bdfd063f8cd6dac64ed71d5ca24fd0cdb15
5
5
  SHA512:
6
- metadata.gz: c4e6b55264d0286d1c20f2dd2af865e794fbb99794115467c0449bbc94041231a62227866a940cf0cbb7dc0cad0bcb8e956028f2c0954aa8c6bcc1071d85b47f
7
- data.tar.gz: ed4ccf478e8f37fa85c458f1891359fd6bf9d5c27b769cd73be38f115f1ba4caf3d8b1ed9cb76befad8ebc1ff83df7470f112f0680e9698bb840ecd8c364e31f
6
+ metadata.gz: 75b9ee4b9d739b981ecda663ad793740f14b0c576a1040c3715eab677324f9e1b054ec408eb4e1ddf04cd1af10ffb4b6390f1de50024be317fa339e4307e9dad
7
+ data.tar.gz: bdcefa6ba0a789632a226c57c0543d9de86ff8f0f55f09a3da15f37dd99733d4036534eae132a7249145f6165d5c5145ea211653b23eb12a50fdd03018f18b60
data/bin/aidir CHANGED
@@ -2,4 +2,5 @@
2
2
 
3
3
  require 'aidir'
4
4
 
5
- aidir = Aidir::start
5
+ aidir = Aidir.new
6
+ aidir.start
@@ -1,35 +1,42 @@
1
1
  require_relative 'aidir/git'
2
- require_relative 'aidir/flog'
2
+ require_relative 'aidir/aidir_flog'
3
3
  require_relative 'aidir/formatter'
4
4
  require_relative 'aidir/scoreboard'
5
5
  require 'open3'
6
6
 
7
7
  class Aidir
8
8
 
9
- def self.start
10
- @errors = []
11
- @results = {}
12
- git = nil
13
- files = nil
14
-
15
- git = Git.new(@errors)
16
- git.is_repository?
17
- if @errors.any?
18
- puts @errors
19
- return
9
+ def initialize
10
+ start
11
+ end
12
+
13
+ def start
14
+ git_errors = prepare_git
15
+ if git_errors
16
+ puts git_errors
17
+ return git_errors
20
18
  end
21
19
 
22
- files = git.ruby_files
20
+ scoreboard = Scoreboard.new(get_flog_results)
21
+ print scoreboard.results
22
+ return scoreboard.results
23
+ end
23
24
 
24
- files.each do |file|
25
- flog = Flog.new(file)
26
- @results[file] = flog.analyze
25
+ def get_flog_results
26
+ results = {}
27
+
28
+ @git.ruby_files.each do |file|
29
+ flog = AidirFlog.new(file)
30
+ results[file] = flog.analyze
27
31
  end
32
+ @git.clear_cached_files
28
33
 
29
- git.clear_cached_files
34
+ results
35
+ end
30
36
 
31
- scoreboard = Scoreboard.new(@results)
32
- print scoreboard.results
37
+ def prepare_git
38
+ @git = Git.new
39
+ return @git.errors unless @git.is_repository?
33
40
  end
34
41
 
35
42
  end
@@ -1,4 +1,6 @@
1
- class Flog
1
+ require 'flog_cli'
2
+
3
+ class AidirFlog
2
4
 
3
5
  def initialize(filename)
4
6
  @branch = filename
@@ -31,9 +33,13 @@ class Flog
31
33
  end
32
34
 
33
35
  def flog_file(filename)
34
- Open3.popen3("flog -a #{filename}") do |_, stdout, stderr|
35
- stdout.read
36
- end
36
+ out = StringIO.new
37
+ args = ['-a', filename]
38
+ options = FlogCLI.parse_options(args)
39
+ flogger = FlogCLI.new(options)
40
+ flogger.flog(args)
41
+ flogger.report(out)
42
+ out.string
37
43
  end
38
44
 
39
45
  def raw_to_hash(data)
@@ -1,16 +1,18 @@
1
1
  class Git
2
2
 
3
- def initialize(errors)
4
- @errors = errors
3
+ attr_accessor :errors, :changed_files
4
+
5
+ def initialize
6
+ @errors = []
5
7
  @changed_files = []
6
8
  end
7
9
 
8
10
  def is_repository?
9
- error = false
10
11
  Open3.popen3('git rev-parse') do |_, _, stderr|
11
12
  error = stderr.read
12
13
  @errors << error unless error.empty?
13
14
  end
15
+ @errors.empty?
14
16
  end
15
17
 
16
18
  def ruby_files
@@ -30,6 +32,8 @@ class Git
30
32
 
31
33
  def all_changed_files
32
34
  Open3.popen3("git diff --name-only origin/master...") do |_, stdout, stderr|
35
+ error = stderr.read
36
+ @errors << error and return unless error.empty?
33
37
  out = stdout.read
34
38
  @changed_files = out.split("\n") unless out.empty?
35
39
  end
@@ -41,7 +45,8 @@ class Git
41
45
 
42
46
  def cache_files
43
47
  @changed_files.each do |file|
44
- File.open(temp(file), 'w') do |f|
48
+ Dir.mkdir 'tmp' unless File.directory? 'tmp'
49
+ File.open(temp(file), 'w+') do |f|
45
50
  f.write(remote_file_contents(file))
46
51
  end
47
52
  end
@@ -58,5 +63,4 @@ class Git
58
63
  "#{Dir.pwd}/tmp/aidir_#{safe_filename}"
59
64
  end
60
65
 
61
-
62
66
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aidir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adomas Sliužinskas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-16 00:00:00.000000000 Z
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flog
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 4.1.2
19
+ version: '4.2'
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
- version: 4.1.2
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: flog
28
+ name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 4.1.2
33
+ version: '2.14'
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
- version: 4.1.2
40
+ version: '2.14'
41
41
  description: 'aidir - Am I Doing It Right: track and improve your Flog score before
42
42
  merging code to master by getting Flog score differences between current branch
43
43
  and master branch'
@@ -47,12 +47,12 @@ executables:
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
+ - bin/aidir
50
51
  - lib/aidir.rb
51
- - lib/aidir/flog.rb
52
+ - lib/aidir/aidir_flog.rb
52
53
  - lib/aidir/formatter.rb
53
54
  - lib/aidir/git.rb
54
55
  - lib/aidir/scoreboard.rb
55
- - bin/aidir
56
56
  homepage: http://github.com/adomas-s/aidir
57
57
  licenses:
58
58
  - MIT
@@ -63,17 +63,17 @@ require_paths:
63
63
  - lib
64
64
  required_ruby_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - '>='
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
75
  rubyforge_project:
76
- rubygems_version: 2.0.3
76
+ rubygems_version: 2.2.1
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Shows Flog score diff of current git branch vs. origin/master