debride2okuribito 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 133ff1d2e9e25d6bc54b0bf764d0370b8f2698bb
4
+ data.tar.gz: 11b691a85d84a895e10cf83cb61acbe283fdffab
5
+ SHA512:
6
+ metadata.gz: 81b774e11aab3b1ae03eb0eab80836313dd149b337050dc2f7150ce29c09104f04fbc049ae340973fae66843c52f35ac9f48594594c985a4af5ae454b38905bc
7
+ data.tar.gz: 64857b06dc513fdfa71c16b55d525b4c38d17bcc7372628dc39aaa4cb19b9fc23098ee0499848c8ad194478c665099a0ac16fed60e38701df1a9d5d60d7c2124
data/MIT-LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2016 Yasuhiro Matsumura
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,72 @@
1
+ [![CircleCI](https://circleci.com/gh/muramurasan/debride2okuribito/tree/master.svg?style=shield)](https://circleci.com/gh/muramurasan/debride2okuribito/tree/master)
2
+ [![Code Climate](https://codeclimate.com/github/muramurasan/debride2okuribito/badges/gpa.svg)](https://codeclimate.com/github/muramurasan/debride2okuribito)
3
+ [![Test Coverage](https://codeclimate.com/github/muramurasan/debride2okuribito/badges/coverage.svg)](https://codeclimate.com/github/muramurasan/debride2okuribito/coverage)
4
+
5
+ # DebrideToOkuribito
6
+
7
+ https://rubygems.org/gems/debride2okuribito
8
+
9
+ DebrideToOkuribito converts the execution result of "Debride" to yaml for "Okuribito".
10
+
11
+ ## Description citation
12
+
13
+ ### What is Debride
14
+
15
+ > Analyze code for potentially uncalled / dead methods, now with auto-removal.
16
+
17
+ Please, refer to the github repository for details: https://github.com/seattlerb/debride
18
+
19
+ ### What is Okuribito
20
+
21
+ > Okuribito monitors the method call with YAML, and exec specified code.
22
+ >
23
+ > In other words, it can be used in order to extract the really uncalled method.
24
+
25
+ Please, refer to the github repository for details: https://github.com/muramurasan/okuribito
26
+
27
+ ## Installation
28
+
29
+ Add this line to your application's Gemfile:
30
+
31
+ ```ruby
32
+ gem 'debride2okuribito'
33
+ ```
34
+
35
+ And then execute:
36
+
37
+ ```
38
+ $ bundle
39
+ ```
40
+
41
+ Or install it yourself as:
42
+
43
+ ```
44
+ $ gem install debride2okuribito
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ Usage is very easy.
50
+
51
+ If you enter the following command, you can get yaml for "Okuribito" with potentially uncalled methods written.
52
+
53
+ ```
54
+ $ debride2okuribito ./
55
+ --- Run debride...
56
+ --- Convert yaml...
57
+ --- 'okuribito.yml' has been generated.
58
+ ```
59
+
60
+ The available options are "Debride" compliant.
61
+
62
+ ```
63
+ $ debride2okuribito --rails app
64
+ --- Run debride...
65
+ --- Convert yaml...
66
+ --- 'okuribito.yml' has been generated.
67
+ ```
68
+
69
+ ## License
70
+
71
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
72
+ Copyright 2016 Yasuhiro Matsumura.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,3 @@
1
+ require "debride2okuribito"
2
+
3
+ DebrideToOkuribito::Converter.new.convert_yaml(ARGV)
@@ -0,0 +1,54 @@
1
+ require "debride"
2
+ require "yaml"
3
+
4
+ module DebrideToOkuribito
5
+ class Converter
6
+ FILE_NAME = "okuribito.yml".freeze
7
+
8
+ def convert_yaml(argv)
9
+ hash = read_debride(argv)
10
+ write_yaml(hash)
11
+ end
12
+
13
+ def read_debride(argv)
14
+ puts "--- Run debride and convert to yaml..."
15
+ debride = Debride.run(argv)
16
+ debride_to_hash(debride)
17
+ end
18
+
19
+ def write_yaml(hash)
20
+ yaml = YAML.dump(hash)
21
+
22
+ # Workaround...
23
+ yaml.gsub!(/^---\n/, "")
24
+ yaml.gsub!(/^- /, " - ")
25
+
26
+ generate_file(yaml, FILE_NAME)
27
+ puts "--- 'okuribito.yml' has been generated."
28
+ end
29
+
30
+ private
31
+
32
+ def debride_to_hash(debride)
33
+ hash = {}
34
+ debride.missing.each do |klass, methods|
35
+ ary = []
36
+ methods.each do |method|
37
+ if debride.method_locations["#{klass}##{method}"]
38
+ ary << "##{method}"
39
+ elsif debride.method_locations["#{klass}::#{method}"]
40
+ ary << ".#{method}"
41
+ end
42
+ end
43
+ hash.store(klass, ary) unless ary.empty?
44
+ end
45
+ hash
46
+ end
47
+
48
+ def generate_file(obj, filename)
49
+ f = File.open(filename, "w")
50
+ f.write(obj)
51
+ f.close
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,3 @@
1
+ module DebrideToOkuribito
2
+ VERSION = "0.1.0".freeze
3
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: debride2okuribito
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yasuhiro Matsumura
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-12-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: debride
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: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
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
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: codeclimate-test-reporter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0.0
83
+ description: It converts the execution result of 'Debride' to yaml for 'Okuribito'.
84
+ email:
85
+ - ym.contributor@gmail.com
86
+ executables:
87
+ - debride2okuribito
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - MIT-LICENSE
92
+ - README.md
93
+ - Rakefile
94
+ - exe/debride2okuribito
95
+ - lib/debride2okuribito.rb
96
+ - lib/debride2okuribito/version.rb
97
+ homepage: https://github.com/muramurasan/debride2okuribito
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.5.1
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: It converts the execution result of 'Debride' to yaml for 'Okuribito'.
121
+ test_files: []