proc_source 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/example/sample.rb +7 -0
- data/lib/proc_source/version.rb +3 -0
- data/lib/proc_source.rb +42 -0
- data/proc_source.gemspec +27 -0
- data.tar.gz.sig +0 -0
- metadata +124 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6fe8043cfcce870c3509c2e56c6cb51cc0eb44be
|
4
|
+
data.tar.gz: b34817a31ce5bf8a07f4789afd8b0e9ba884b4e7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5f8a1f34b39b1205e9d4457b159c8711e0ece409a861e3ab2342705730f1d4d9a80102dbe0c857fc2385d6c5ba76f1df4734cffd95debae79e44b82984fca647
|
7
|
+
data.tar.gz: d09852136f0e14c73950bab3629623a71af2339c302ebd8f95f56c9351f5a8c01859961380f68513263b1d262b55168699e1ff4a608dbb561f2c602c7276583c
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at k128585@ie.u-ryukyu.ac.jp. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 siman-man
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# proc_source
|
2
|
+
|
3
|
+
get the sourcecode for a Proc object
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
install it yourself as:
|
8
|
+
|
9
|
+
$ gem install proc_source
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
require "proc_source"
|
15
|
+
|
16
|
+
proc1 = Proc.new do |i|
|
17
|
+
puts i
|
18
|
+
end
|
19
|
+
|
20
|
+
puts proc1.proc_source
|
21
|
+
```
|
22
|
+
|
23
|
+
```
|
24
|
+
Proc.new do |i|
|
25
|
+
puts i
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
## License
|
30
|
+
|
31
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
32
|
+
|
33
|
+
## Code of Conduct
|
34
|
+
|
35
|
+
Everyone interacting in the ProcSource project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/siman-man/proc_source/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "proc_source"
|
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__)
|
data/bin/setup
ADDED
data/example/sample.rb
ADDED
data/lib/proc_source.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "ripper"
|
2
|
+
require "proc_source/version"
|
3
|
+
|
4
|
+
class Proc
|
5
|
+
def proc_source
|
6
|
+
return @source if @source
|
7
|
+
filepath, start_pos = source_location
|
8
|
+
|
9
|
+
code = File.readlines(filepath)[(start_pos-1)..-1].join
|
10
|
+
tokens = Ripper.lex(code).drop_while do |t|
|
11
|
+
!proc_token?(t)
|
12
|
+
end
|
13
|
+
|
14
|
+
@source = " " * tokens[0][0][1].to_i
|
15
|
+
|
16
|
+
while token = tokens.shift
|
17
|
+
@source += token[2]
|
18
|
+
break if valid_proc_source?(@source)
|
19
|
+
end
|
20
|
+
|
21
|
+
@source
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def proc_token?(token)
|
27
|
+
_pos, event, ident = *token
|
28
|
+
return true if event == :on_const && ident == "Proc"
|
29
|
+
return true if event == :on_ident && ident == "lambda"
|
30
|
+
return true if event == :on_kw && ident == "do"
|
31
|
+
return true if event == :on_lbrace
|
32
|
+
return true if event == :on_tlambda
|
33
|
+
false
|
34
|
+
end
|
35
|
+
|
36
|
+
def valid_proc_source?(source)
|
37
|
+
source = "Proc.new " + source if source =~ /\A\s*(do|{)/
|
38
|
+
eval(source).instance_of?(Proc)
|
39
|
+
rescue SyntaxError, ArgumentError
|
40
|
+
false
|
41
|
+
end
|
42
|
+
end
|
data/proc_source.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "proc_source/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "proc_source"
|
8
|
+
spec.version = ProcSource::VERSION
|
9
|
+
spec.authors = ["siman-man"]
|
10
|
+
spec.email = ["tmshuichi@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{get the sourcecode for a Proc object}
|
13
|
+
spec.description = %q{get the sourcecode for a Proc object}
|
14
|
+
spec.homepage = "https://github.com/siman-man/proc_source"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
end
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: proc_source
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- siman-man
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIID0jCCArqgAwIBAgIBATANBgkqhkiG9w0BAQUFADBoMRAwDgYDVQQDDAdrMTI4
|
14
|
+
NTg1MRIwEAYKCZImiZPyLGQBGRYCaWUxGDAWBgoJkiaJk/IsZAEZFgh1LXJ5dWt5
|
15
|
+
dTESMBAGCgmSJomT8ixkARkWAmFjMRIwEAYKCZImiZPyLGQBGRYCanAwHhcNMTcw
|
16
|
+
NTEyMDg0MzI4WhcNMTgwNTEyMDg0MzI4WjBoMRAwDgYDVQQDDAdrMTI4NTg1MRIw
|
17
|
+
EAYKCZImiZPyLGQBGRYCaWUxGDAWBgoJkiaJk/IsZAEZFgh1LXJ5dWt5dTESMBAG
|
18
|
+
CgmSJomT8ixkARkWAmFjMRIwEAYKCZImiZPyLGQBGRYCanAwggEiMA0GCSqGSIb3
|
19
|
+
DQEBAQUAA4IBDwAwggEKAoIBAQDhT8SPklRNY2T0/6okadJNRaqDTwHHY5q0qPzl
|
20
|
+
0oujYej1lP2C4U2FncEyjC+Z+yAakkj0+X6F7JCc+OhOUBOOkBZPt2VF/QqWaGOZ
|
21
|
+
N4QmBYs+MZulAKh8jI1X5nfLjVdyqcumlz4KdfeQBU80hiHF1Uw5W7zAbZS71yQ2
|
22
|
+
kwSZckteT9JU3seZg0K0e9/AaXXeKGjCDI0THfa9uB2kZ2d3IhOKWColKlHmw8aw
|
23
|
+
xtTU3WVJRGZbnjblPVjb+usasbmIWc+dYtAmwUdB35vK3YgVrlbjHNFhxgytH78Q
|
24
|
+
apnc/5nBgYnI10sjqVJUfG1sh96jxwR9eGJR4Xl5tHcWvoN3AgMBAAGjgYYwgYMw
|
25
|
+
CQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFDTJcguBmHUquwQKqeNZ
|
26
|
+
7GDtU1QDMCQGA1UdEQQdMBuBGWsxMjg1ODVAaWUudS1yeXVreXUuYWMuanAwJAYD
|
27
|
+
VR0SBB0wG4EZazEyODU4NUBpZS51LXJ5dWt5dS5hYy5qcDANBgkqhkiG9w0BAQUF
|
28
|
+
AAOCAQEAyfJKJtV98mZEvXU+grxn40blFVmgzMNhKGVAJI1YDy6X2LW50CvCUXBb
|
29
|
+
WIbO58QHwXvsytMGbMHggCYTLvHcYXArXnEMBJdACt1LoufAUIxytIkqdXtBtNuM
|
30
|
+
zT1+OBWvES2aeKcx+g7gcbAc5DicNMtdLHCbenjhR1glcHWXdasoKQ6HrVekm2fp
|
31
|
+
zzZxEHIvijfuL7FyNm9YraQd10vNG433pLsTMxIry/d29pssgbq+T6V3ez560If8
|
32
|
+
FDRi8p0CR5Kr8eZGeaIfpMKn4nbQQq4w5wLzNxnecBb26xn4EPHn3dVLF24+NJkf
|
33
|
+
BLzd24MyvHKRaGDWAmiJAd9Z04Vkyw==
|
34
|
+
-----END CERTIFICATE-----
|
35
|
+
date: 2017-10-06 00:00:00.000000000 Z
|
36
|
+
dependencies:
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: bundler
|
39
|
+
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.15'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - "~>"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '1.15'
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rake
|
53
|
+
requirement: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '10.0'
|
58
|
+
type: :development
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - "~>"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '10.0'
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: rspec
|
67
|
+
requirement: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '3.0'
|
72
|
+
type: :development
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - "~>"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '3.0'
|
79
|
+
description: get the sourcecode for a Proc object
|
80
|
+
email:
|
81
|
+
- tmshuichi@gmail.com
|
82
|
+
executables: []
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files: []
|
85
|
+
files:
|
86
|
+
- ".gitignore"
|
87
|
+
- ".rspec"
|
88
|
+
- ".travis.yml"
|
89
|
+
- CODE_OF_CONDUCT.md
|
90
|
+
- Gemfile
|
91
|
+
- LICENSE.txt
|
92
|
+
- README.md
|
93
|
+
- Rakefile
|
94
|
+
- bin/console
|
95
|
+
- bin/setup
|
96
|
+
- example/sample.rb
|
97
|
+
- lib/proc_source.rb
|
98
|
+
- lib/proc_source/version.rb
|
99
|
+
- proc_source.gemspec
|
100
|
+
homepage: https://github.com/siman-man/proc_source
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.6.13
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: get the sourcecode for a Proc object
|
124
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|