okuribito 0.1.6 → 0.1.7

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: cc35f46ce36106eb6a9149613f52ca192cbf7524
4
- data.tar.gz: 5881ae7faa3258097b8c1743630f8854e951a465
3
+ metadata.gz: fc9af19e7f0b78f7d0f21ac0df0a4a26a1c889a9
4
+ data.tar.gz: dd829fe91a165a2c5cce1f4fb739159432bcc554
5
5
  SHA512:
6
- metadata.gz: 5bf5bf91ea0d4b31d535950464ddc61e828280854ecb728ec0e96340b072851657889b2cf027f444e1d8f4578ce71944ea6436096d6918e619e4c7235e609c41
7
- data.tar.gz: 4432307a669be481ac27a3c2b164f45cf2844aca691a818fd9b6f949e711687f0a378bd77f697d780942d2b1eb6d6eea65ad5ebcad2084a989a23b2d4b620c2d
6
+ metadata.gz: 418b2c05bc94edd1c476fc9af80a88c10ef5b50ea4977acc67dd6f3a81534c9c6e0420745a3a44519401d7ed16fbee896922c78a0312d1626ad4002e72584c44
7
+ data.tar.gz: 73583471d425c019db1d7c6f95b4b5d838247411ac281cbd810f76bc05de266fbd9468b03fc1459155edda04fc437bf0e167be4af8304d07b3206a833ee29b47
data/.rubocop.yml CHANGED
@@ -20,10 +20,10 @@ Metrics/CyclomaticComplexity:
20
20
  Max: 10
21
21
 
22
22
  Metrics/PerceivedComplexity:
23
- Max: 9
23
+ Max: 10
24
24
 
25
25
  Metrics/MethodLength:
26
- Max: 20
26
+ Max: 35
27
27
 
28
28
  Metrics/AbcSize:
29
- Max: 30
29
+ Max: 32
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  [![CircleCI](https://circleci.com/gh/muramurasan/okuribito/tree/master.svg?style=svg)](https://circleci.com/gh/muramurasan/okuribito/tree/master)
2
+ [![Code Climate](https://codeclimate.com/github/muramurasan/okuribito.png)](https://codeclimate.com/github/muramurasan/okuribito)
3
+ [![Test Coverage](https://codeclimate.com/github/muramurasan/okuribito/badges/coverage.svg)](https://codeclimate.com/github/muramurasan/okuribito/coverage)
2
4
 
3
5
  # Okuribito
4
6
 
@@ -43,9 +45,9 @@ By writing the following code to start the monitoring of the method.
43
45
 
44
46
  ```ruby
45
47
  okuribito = Okuribito::OkuribitoPatch.new do |method_name, obj_name, caller_info|
46
- # TODO: do something as you like!
48
+ # do something as you like!
47
49
  end
48
- okuribito.apply("okuribito.yml")
50
+ okuribito.apply("config/okuribito.yml")
49
51
  ```
50
52
 
51
53
  You can also give the option.
@@ -54,9 +56,9 @@ You can also give the option.
54
56
 
55
57
  ```ruby
56
58
  okuribito = Okuribito::OkuribitoPatch.new(once_detect: true) do |method_name, obj_name, caller_info|
57
- # TODO: do something as you like!
59
+ # do something as you like!
58
60
  end
59
- okuribito.apply("okuribito.yml")
61
+ okuribito.apply("config/okuribito.yml")
60
62
  ```
61
63
 
62
64
  ### ex: Ruby On Rails
@@ -67,9 +69,9 @@ Edit `application.rb`
67
69
  class OkuribitoSetting < Rails::Railtie
68
70
  config.after_initialize do
69
71
  okuribito = Okuribito::OkuribitoPatch.new do |method_name, obj_name, caller_info|
70
- # TODO: do something as you like!
72
+ # do something as you like!
71
73
  end
72
- okuribito.apply("okuribito.yml")
74
+ okuribito.apply("config/okuribito.yml")
73
75
  end
74
76
  end
75
77
  ```
@@ -91,7 +93,7 @@ end
91
93
  okuribito = Okuribito::OkuribitoPatch.new do |method_name, obj_name, caller_info|
92
94
  puts "#{obj_name} #{method_name} #{caller_info[0]}"
93
95
  end
94
- okuribito.apply("okuribito.yml")
96
+ okuribito.apply("config/okuribito.yml")
95
97
 
96
98
  TestTarget.deprecated_self_method
97
99
  TestTarget.new.deprecated_method
@@ -124,6 +126,7 @@ okuribito = Okuribito::OkuribitoPatch.new do |method_name, obj_name, caller_info
124
126
  puts "#############################################################"
125
127
  puts caller_info
126
128
  end
129
+ okuribito.apply("config/okuribito.yml")
127
130
  ```
128
131
 
129
132
  ### Other ideas
data/circle.yml CHANGED
@@ -1,4 +1,9 @@
1
1
  machine:
2
2
  timezone: Asia/Tokyo
3
3
  ruby:
4
- version: 2.0.0
4
+ version:
5
+ 2.2.2
6
+ test:
7
+ override:
8
+ - bundle exec rspec
9
+ - bundle exec codeclimate-test-reporter
data/lib/okuribito.rb CHANGED
@@ -43,36 +43,32 @@ module Okuribito
43
43
  end
44
44
  end
45
45
 
46
+ def self.module(opt, patch_name)
47
+ if opt.present?
48
+ if FunctionalPatchModule.const_defined?(patch_name)
49
+ Module.new.extend(FunctionalPatchModule)
50
+ else
51
+ FunctionalPatchModule.const_set(patch_name, Module.new.extend(FunctionalPatchModule))
52
+ end
53
+ else
54
+ Module.new.extend(SimplePatchModule)
55
+ end
56
+ end
57
+
46
58
  def patch_okuribito(class_name, observe_methods)
59
+ return unless Object.const_defined?(class_name) && Object.const_get(class_name).is_a?(Class)
60
+
47
61
  callback = @callback
48
62
  opt ||= @opt
49
63
  klass = class_name.constantize
64
+ i_method_patch = Okuribito::OkuribitoPatch.module(opt, "#{class_name}InstancePatch")
65
+ c_method_patch = Okuribito::OkuribitoPatch.module(opt, "#{class_name}ClassPatch")
66
+ i_method_patched = 0
67
+ c_method_patched = 0
50
68
 
51
69
  klass.class_eval do
52
- if opt.present?
53
- i_patch_name = "#{class_name}InstancePatch"
54
- c_patch_name = "#{class_name}ClassPatch"
55
- if FunctionalPatchModule.const_defined?(i_patch_name.to_sym)
56
- i_method_patch = Module.new.extend(FunctionalPatchModule)
57
- else
58
- i_method_patch = FunctionalPatchModule
59
- .const_set(i_patch_name, Module.new.extend(FunctionalPatchModule))
60
- end
61
- if FunctionalPatchModule.const_defined?(c_patch_name.to_sym)
62
- c_method_patch = Module.new.extend(FunctionalPatchModule)
63
- else
64
- c_method_patch = FunctionalPatchModule
65
- .const_set(c_patch_name, Module.new.extend(FunctionalPatchModule))
66
- end
67
- else
68
- i_method_patch = Module.new.extend(SimplePatchModule)
69
- c_method_patch = Module.new.extend(SimplePatchModule)
70
- end
71
- i_method_patched = 0
72
- c_method_patched = 0
73
-
74
70
  observe_methods.each do |observe_method|
75
- next unless md = PATTERN.match(observe_method)
71
+ next unless (md = PATTERN.match(observe_method))
76
72
  symbol = md[:symbol]
77
73
  method_name = md[:method_name].to_sym
78
74
 
@@ -81,7 +77,7 @@ module Okuribito
81
77
  next unless klass.instance_methods.include?(method_name)
82
78
  i_method_patch.module_eval do
83
79
  define_patch(method_name, i_method_patch, "i", opt) do |obj_name, caller_info|
84
- callback.call(method_name, obj_name, caller_info, class_name, INSTANCE_METHOD_SYMBOL)
80
+ callback.call(method_name, obj_name, caller_info, class_name, symbol)
85
81
  end
86
82
  end
87
83
  i_method_patched += 1
@@ -89,7 +85,7 @@ module Okuribito
89
85
  next unless klass.respond_to?(method_name)
90
86
  c_method_patch.module_eval do
91
87
  define_patch(method_name, c_method_patch, "c", opt) do |obj_name, caller_info|
92
- callback.call(method_name, obj_name, caller_info, class_name, CLASS_METHOD_SYMBOL)
88
+ callback.call(method_name, obj_name, caller_info, class_name, symbol)
93
89
  end
94
90
  end
95
91
  c_method_patched += 1
@@ -1,3 +1,3 @@
1
1
  module Okuribito
2
- VERSION = "0.1.6".freeze
2
+ VERSION = "0.1.7".freeze
3
3
  end
data/okuribito.gemspec CHANGED
@@ -16,14 +16,6 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.required_ruby_version = '>= 2.0.0'
18
18
 
19
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
- # to allow pushing to a single host or delete this section to allow pushing to any host.
21
- if spec.respond_to?(:metadata)
22
- # spec.metadata['allowed_push_host'] = "http://mygemserver.com"
23
- else
24
- raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
25
- end
26
-
27
19
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
20
  spec.bindir = "exe"
29
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -31,8 +23,8 @@ Gem::Specification.new do |spec|
31
23
 
32
24
  spec.add_dependency "activesupport", ">= 4.0"
33
25
 
34
- spec.add_development_dependency "bundler", "~> 1.12"
35
- spec.add_development_dependency "rake", "~> 10.0"
36
26
  spec.add_development_dependency "rspec", "~> 3.0"
37
27
  spec.add_development_dependency "rubocop"
28
+ spec.add_development_dependency "simplecov"
29
+ spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
38
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: okuribito
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - muramurasan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-30 00:00:00.000000000 Z
11
+ date: 2016-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -25,61 +25,61 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '1.12'
33
+ version: '3.0'
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: '1.12'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: simplecov
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rubocop
70
+ name: codeclimate-test-reporter
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 1.0.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 1.0.0
83
83
  description: Okuribito monitors the method call by the yaml.
84
84
  email:
85
85
  - ym.works1985@gmail.com
@@ -90,7 +90,6 @@ files:
90
90
  - .gitignore
91
91
  - .rspec
92
92
  - .rubocop.yml
93
- - CODE_OF_CONDUCT.md
94
93
  - Gemfile
95
94
  - LICENSE.txt
96
95
  - README.md
data/CODE_OF_CONDUCT.md DELETED
@@ -1,49 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
7
-
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
12
-
13
- Examples of unacceptable behavior by participants include:
14
-
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
18
- * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
22
-
23
- Project maintainers have the right and responsibility to remove, edit, or
24
- reject comments, commits, code, wiki edits, issues, and other contributions
25
- that are not aligned to this Code of Conduct, or to ban temporarily or
26
- permanently any contributor for other behaviors that they deem inappropriate,
27
- threatening, offensive, or harmful.
28
-
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
33
-
34
- This code of conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at yasuhiro.matsumura@pixta.co.jp. All
39
- complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
43
-
44
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
- version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
47
-
48
- [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/