activigit 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 71ba7d28901db68616b4d5c2bc211d5241d5185d
4
+ data.tar.gz: 05513e6c0daf96fb9254774ab93654a3d685e62e
5
+ SHA512:
6
+ metadata.gz: 43403c042ea00404f3c97db3eab481a701c9ca3b8c2150add5206ca904b390baa9bd3baac6932e33496c01675a4e8fbb37d64c9d213e8386cececc6c411b2557
7
+ data.tar.gz: ccd4da2a1b203ba7d8322bfbd7b1097331b3533b724fe536e8423e2b7532f6e938d5004e9069f3fa737d1d04d673e41f943b024f55f34fb345223422153d1e60
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .rake_tasks~
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in activigit.gemspec
6
+ gemspec
@@ -0,0 +1,24 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ activigit (0.1.0)
5
+ gruff (~> 0.7)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ gruff (0.7.0)
11
+ rmagick (~> 2.13, >= 2.13.4)
12
+ rake (10.5.0)
13
+ rmagick (2.16.0)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ activigit!
20
+ bundler (~> 1.17)
21
+ rake (~> 10.0)
22
+
23
+ BUNDLED WITH
24
+ 1.17.2
@@ -0,0 +1,39 @@
1
+ # Activigit
2
+
3
+ Visualize commit over time into a beautifull graphic.
4
+
5
+ ![Example of output using Monthly option](example.png)
6
+
7
+ ## Installation
8
+
9
+ ~~~bash
10
+ $ sudo apt-get install libmagickwand-dev imagemagick
11
+ $ gem install activigit
12
+ ~~~
13
+
14
+ ## Usage
15
+
16
+ ~~~
17
+ Draw an activity graph for the given Git golder
18
+
19
+ Usage: activigit.rb [options] <git_folder_path>
20
+ -b, --group_by=FIELD Counts commit by months or days
21
+ possibles values are `months` or `days`
22
+ -f, --group_by_format=FORMAT Counts commit by given date format
23
+ -h, --help Display this message
24
+ ~~~
25
+
26
+
27
+ ~~~bash
28
+ $ activigit.rb ~/gitea/isignif/website/
29
+ ~~~
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/madeindjs/activigit.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,41 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'activigit/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'activigit'
7
+ spec.version = Activigit::VERSION
8
+ spec.authors = ['Alexandre Rousseau']
9
+ spec.email = ['contact@rousseau-alexandre.fr']
10
+
11
+ spec.summary = 'Visualize commit over time into a beautifull graphic'
12
+ # spec.description = 'TODO: Write a longer description or delete this line.'
13
+ spec.homepage = 'https://github.com/madeindjs/activigit'
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
19
+
20
+ spec.metadata['homepage_uri'] = spec.homepage
21
+ spec.metadata['source_code_uri'] = 'https://github.com/madeindjs/activigit'
22
+ # spec.metadata['changelog_uri'] = "https://github.com/madeindjs/activigit"
23
+ else
24
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
25
+ 'public gem pushes.'
26
+ end
27
+
28
+ # Specify which files should be added to the gem when it is released.
29
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
31
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
+ end
33
+ spec.bindir = 'bin'
34
+ spec.executables = ['activigit.rb']
35
+ spec.require_paths = ['lib']
36
+
37
+ spec.add_dependency 'gruff', '~> 0.7'
38
+
39
+ spec.add_development_dependency 'bundler', '~> 1.17'
40
+ spec.add_development_dependency 'rake', '~> 10.0'
41
+ end
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/ruby
2
+ require 'activigit'
3
+ require 'optparse'
4
+
5
+ folder = ARGV.first
6
+
7
+ method = 'group_by_months'
8
+ format = nil
9
+
10
+ options = {}
11
+ OptionParser.new do |opts|
12
+ opts.banner = "Draw an activity graph for the given Git golder\n\nUsage: activigit.rb [options] <git_folder_path>"
13
+
14
+ opts.on('-bNAME', '--group_by=FIELD', 'Counts commit by months or days', 'possibles values are `months` or `days` ') do |n|
15
+ method = "group_by_#{n}"
16
+ end
17
+
18
+ opts.on('-fNAME', '--group_by_format=FORMAT', 'Counts commit by given date format') do |f|
19
+ format = f
20
+ end
21
+
22
+ opts.on('-h', '--help', 'Display this message') do
23
+ puts opts
24
+ exit
25
+ end
26
+
27
+ if folder.nil? || folder.empty?
28
+ warn 'Please provide a Git repository'
29
+ warn opts
30
+ exit 1
31
+ end
32
+ end.parse!
33
+
34
+ if format.nil?
35
+ Activigit::Repository.new(folder).send method
36
+ else
37
+ Activigit::Repository.new(folder).group_with_format format
38
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "activigit"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
Binary file
@@ -0,0 +1,76 @@
1
+ require 'activigit/version'
2
+ require 'gruff'
3
+ require 'date'
4
+
5
+ module Activigit
6
+ class Error < StandardError; end
7
+
8
+ class Repository
9
+ def initialize(path)
10
+ @path = path
11
+ end
12
+
13
+ def group_by_days
14
+ group_with_format '%Y-%m-%d'
15
+ end
16
+
17
+ def group_by_months
18
+ group_with_format '%Y-%m'
19
+ end
20
+
21
+ def group_with_format(format)
22
+ logs = ''
23
+ Dir.chdir(@path) do
24
+ logs = `git log --branches --format=%cI`.split("\n")
25
+ end
26
+
27
+ logs_grouped = logs.group_by { |log| Date.parse(log).strftime(format) }
28
+
29
+ last_commit_date = Date.parse logs.first
30
+ current_date = Date.parse logs.last
31
+
32
+ counts = {}
33
+
34
+ while current_date != last_commit_date
35
+ current_date_str = current_date.strftime(format)
36
+ counts[current_date_str] = if logs_grouped[current_date_str].nil?
37
+ 0
38
+ else
39
+ logs_grouped[current_date_str].count
40
+ end
41
+
42
+ current_date += 1
43
+ end
44
+
45
+ g = Gruff::Line.new
46
+ g.title = name(format)
47
+ # transform `['a', 'b', 'c']` into `{0=>'a', 1=>'b', 2=>'c'}`
48
+ g.labels = counts.map.with_index { |k, i| [i, k.first] }.to_h
49
+ g.data :commits, counts.values
50
+ g.write filename(format)
51
+ end
52
+
53
+ private
54
+
55
+ def name(format)
56
+ repository_name = File.basename @path
57
+ format('%s %s', repository_name, format_name(format))
58
+ end
59
+
60
+ def filename(format)
61
+ name(format).gsub(/[^0-9A-Z]/i, '_') + '.png'
62
+ end
63
+
64
+ def format_name(format)
65
+ case format
66
+ when '%y'
67
+ 'yearly'
68
+ when '%y-%m'
69
+ 'monthly'
70
+ when '%y-%m-%d'
71
+ 'daily'
72
+
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,3 @@
1
+ module Activigit
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activigit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexandre Rousseau
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-02-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gruff
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.17'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.17'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description:
56
+ email:
57
+ - contact@rousseau-alexandre.fr
58
+ executables:
59
+ - activigit.rb
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - README.md
67
+ - Rakefile
68
+ - activigit.gemspec
69
+ - bin/activigit.rb
70
+ - bin/console
71
+ - bin/setup
72
+ - example.png
73
+ - lib/activigit.rb
74
+ - lib/activigit/version.rb
75
+ homepage: https://github.com/madeindjs/activigit
76
+ licenses: []
77
+ metadata:
78
+ allowed_push_host: https://rubygems.org
79
+ homepage_uri: https://github.com/madeindjs/activigit
80
+ source_code_uri: https://github.com/madeindjs/activigit
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.6.14
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Visualize commit over time into a beautifull graphic
101
+ test_files: []