mire 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 361606807951fe02817f5a4f71a2810c914f79c7
4
- data.tar.gz: bfd3d06e0f857abb7709c5992bb647c1493486e2
3
+ metadata.gz: 1603bd748f593fd4a5423f5461f266cf09d04a0f
4
+ data.tar.gz: 781777b904e415c5fd27a5be2c26db943cdaa776
5
5
  SHA512:
6
- metadata.gz: 5b1c3198a31536633dd44ec35d1f89cdb4f36011b6bdf5071b8d43b1d296f85597eb6d3b3b02f63e1972cd08aee3b47f1aa65970a4cb366df7db5be732544971
7
- data.tar.gz: 7759ff2bd79fd0ace1be9375c7058604ec0e2a278134fa059673d393ba1110d07c80539cea7d3d963fdbb17221bb51e7f6650a6f1af3329d79f13c02d8a8fbc3
6
+ metadata.gz: 969308cbf177d9a4d7c6ad4b6600a39610025048a4c4ac4f5085428863f1fd7c5dd27aab40e18831654f02318b4514a0e0d9dcd0b59445cda1f2e0d5f63dce59
7
+ data.tar.gz: f4f47838e4382c4aaee2d91529f37c285ff6d534074600dc4ac35cc4be22d91c68c74b951babfc0da57923555f65fc4269676b686808015a2483e6950933cde7
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1
5
+ - ruby-head
6
+ matrix:
7
+ allow_failures:
8
+ - rvm: ruby-head
9
+ script:
10
+ - bundle exec rspec
11
+ # - bundle exec rubocop
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.1.2
6
+
7
+ * Add travis configuration and build status image
8
+ * Remove slop to solve dependency problem
9
+ * Add version (-v, --version) cli option
10
+
5
11
  ## 0.1.1
6
12
 
7
13
  * Add configuration option to exclude files / folders from analyzing
data/README.md CHANGED
@@ -1,3 +1,8 @@
1
+ [![Build
2
+ Status](https://travis-ci.org/xing/mire.svg?branch=master)](https://travis-ci.org/xing/mire)
3
+ [![Code
4
+ Climate](https://codeclimate.com/github/xing/mire/badges/gpa.svg)](https://codeclimate.com/github/xing/mire)
5
+
1
6
  # mire [ˈmɪʀɛ]
2
7
 
3
8
  mire analyzes a Ruby project and helps you to find dependencies, call
@@ -1,9 +1,9 @@
1
1
  require 'parser/current'
2
2
  require 'yaml'
3
- require 'slop'
4
3
  require 'ruby-progressbar'
5
4
  require 'haml_lint'
6
5
 
6
+ require 'mire/version'
7
7
  require 'mire/configuration'
8
8
  require 'mire/configuration_methods'
9
9
  require 'mire/analyzer'
@@ -2,37 +2,55 @@ module Mire
2
2
  # Command line interface for mire
3
3
  class CLI
4
4
  class << self
5
- def parse # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
6
- slop = Slop.parse do |opts|
7
- opts.on('-h', '--help', 'Show this help') do
8
- puts opts
9
- exit
10
- end
11
- opts.on('-a', '--analyze', 'Analyze ruby project') do
12
- analyze
13
- exit
14
- end
15
- opts.on('-c', '--check TERM', 'Check term and find usages') do |f|
16
- check(f)
17
- exit
18
- end
19
- opts.on('-u', '--unused', 'Check for unused methods') do
20
- unused
21
- exit
22
- end
23
- opts.on('-i', '--initialize', 'Create initial configuration file') do
24
- init
25
- exit
26
- end
27
- end
5
+ METHODS = [
6
+ [:analyze, 'Analyze ruby project'],
7
+ [:check, 'Check term and find usages', arguments: [:term]],
8
+ [:unused, 'Check for unused methods'],
9
+ [:init, 'Create initial configuration file'],
10
+ [:help, 'Show this help'],
11
+ [:version, 'Prints out version']
12
+ ]
13
+
14
+ def parse
15
+ return help unless ARGV[0]
16
+ fail UnknownCommand if unknown_command?
28
17
 
29
- puts slop
30
- rescue Slop::UnknownOption
31
- puts 'Unknown option - use --help to see all options'
18
+ METHODS.each do |command, _description, _config|
19
+ next unless options(command).include?(ARGV[0])
20
+ arguments = ARGV
21
+ arguments.shift
22
+ send(command, *arguments)
23
+ end
24
+ rescue UnknownCommand
25
+ puts "Unknown command Argument.\n\n"
26
+ help
27
+ rescue MissingArgument
28
+ puts "Missing Argument.\n\n"
29
+ help
32
30
  end
33
31
 
34
32
  private
35
33
 
34
+ def unknown_command?
35
+ METHODS.none? { |command, _, _| options(command).include?(ARGV[0]) }
36
+ end
37
+
38
+ def help
39
+ puts "Usage:\n mire [option]\n\n"
40
+ puts 'Options:'
41
+
42
+ METHODS.each do |command, description, config|
43
+ config ||= {}
44
+ arguments = config[:arguments] || []
45
+ opts = "#{options(command).join(', ')} #{arguments.join(' ').upcase}"
46
+ puts " #{opts}#{' ' * (25 - opts.length)}#{description}"
47
+ end
48
+ end
49
+
50
+ def version
51
+ puts Mire::VERSION
52
+ end
53
+
36
54
  def init
37
55
  Mire::Configuration.copy_example
38
56
  puts "Configuration file #{Mire::Configuration::FILE} created"
@@ -47,7 +65,8 @@ module Mire
47
65
  analyzer.save
48
66
  end
49
67
 
50
- def check(f)
68
+ def check(f = nil)
69
+ fail MissingArgument unless f
51
70
  puts "Checking term #{f}"
52
71
  occurrence = Output::Occurrence.new
53
72
  puts occurrence.check(f)
@@ -58,6 +77,13 @@ module Mire
58
77
  occurrence = Output::Unused.new
59
78
  puts occurrence.check
60
79
  end
80
+
81
+ def options(command)
82
+ ["-#{command[0]}", "--#{command}"]
83
+ end
61
84
  end
85
+
86
+ class MissingArgument < Exception; end
87
+ class UnknownCommand < Exception; end
62
88
  end
63
89
  end
@@ -1,3 +1,3 @@
1
1
  module Mire
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ['lib']
23
23
 
24
24
  spec.add_runtime_dependency 'parser'
25
- spec.add_runtime_dependency 'slop', '~> 4.0'
26
25
  spec.add_runtime_dependency 'ruby-progressbar'
27
26
  spec.add_runtime_dependency 'haml-lint'
28
27
  spec.add_development_dependency 'bundler', '~> 1.7'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nils Gemeinhardt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-02 00:00:00.000000000 Z
12
+ date: 2015-06-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parser
@@ -25,20 +25,6 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
- - !ruby/object:Gem::Dependency
29
- name: slop
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: '4.0'
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '4.0'
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: ruby-progressbar
44
30
  requirement: !ruby/object:Gem::Requirement
@@ -165,6 +151,7 @@ files:
165
151
  - ".gitignore"
166
152
  - ".rubocop.yml"
167
153
  - ".rubocop_todo.yml"
154
+ - ".travis.yml"
168
155
  - CHANGELOG.md
169
156
  - Gemfile
170
157
  - LICENSE.txt