ryan 1.0.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 291fea61132de8ec31f0e70fda31c930a41fc86a
4
- data.tar.gz: 9ec06895b0fbd8e8f24cb4333ef443d1e88ffdac
2
+ SHA256:
3
+ metadata.gz: b27b330b1dbb7aafbe79a37e1c8ad052862abd043cb9ce66176b0395faa21705
4
+ data.tar.gz: 1f5a038be755ed3b63cbc78e64d2ff3558ca9e3685afb8aa714a45b118634b3b
5
5
  SHA512:
6
- metadata.gz: df0bd56e2f47a7887c2dc5d84c5076665c5343a34cd3971a15efac6be4f323802e2dd6f7b55756d74a27d4ae41784805730d86e66336e967c5d374dc014d68bd
7
- data.tar.gz: 309d0f95cf4f7e952d6af7054300402cfb0b8282580179126fddbd8d74beb9df188062526396ccf0dc8ac7f6fb1b003970799716d3397d1c8f4fd234143f15c9
6
+ metadata.gz: 2d17d1ae82693a889ecc6f7df6066b1bc84ea1de150b12642777cb360883c62f9ad0558151be1482629e100f3e316914650ac117348adbd7c5277b8817b97f7b
7
+ data.tar.gz: c46e36144fba9cdec4432192c3d392d16ffcd55d28f0f2cd09d0cb8eed759aaaef6099ee92ba4aa10b3821eb5eb4b1e9bdb259c0ae09ca7b2445cdad258d8426
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --format documentation
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.2.2
1
+ ruby-3.1.2
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.1
4
- before_install: gem install bundler -v 1.10.4
3
+ - 2.7.8
4
+ before_install: gem install bundler
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/).
6
+
7
+ ## [1.1.0] - 2017-02-20
8
+ ### Added
9
+ - Explicit Ruby version requirement with `spec.required_ruby_version = '>= 1.9.3'`
10
+ - Allowed `Ryan.new` initializer to also accept raw ruby code string instead of just path to file
11
+ - Ryan.root method to make things easier
12
+
13
+ ## [1.0.0] - 2015-12-05
14
+ - Core functionality
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in ryan.gemspec
4
4
  gemspec
5
-
6
- gem 'byebug'
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) Ryan Buckley.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,21 +1,21 @@
1
- # Ryan
1
+ # Ryan [![Gem Version](https://badge.fury.io/rb/ryan.svg)](http://badge.fury.io/rb/ryan) [![Build Status](https://travis-ci.org/ridiculous/ryan.svg)](https://travis-ci.org/ridiculous/ryan)
2
2
 
3
- A wrapper around the awesome [RubyParser](https://github.com/seattlerb/ruby_parser) gem that provides an OO interface for
3
+ A wrapper around the awesome [RubyParser](https://github.com/seattlerb/ruby_parser) gem that provides an OO interface for
4
4
  reading Ruby code.
5
5
 
6
6
  ## Installation
7
7
 
8
8
  ```ruby
9
- gem 'ryan'
9
+ gem 'ryan', '~> 1.1.0'
10
10
  ```
11
11
 
12
12
  ## Usage
13
13
 
14
- Give Ryan a Ruby file to play with. Test it out in an IRB session with `bin/console`
14
+ Give Ryan a Ruby file or code string to play with. Test it out in an IRB session with `bin/console`
15
15
 
16
16
  ```ruby
17
- ryan = Ryan.new FIXTURE_ROOT.join('report.rb')
18
- ryan.name
17
+ ryan = Ryan.new FIXTURE_ROOT.join('report.rb') # or Ryan.new("<valid ruby code here>")
18
+ ryan.name
19
19
  #=> "Report"
20
20
  ryan.class?
21
21
  #=> true
@@ -23,11 +23,11 @@ ryan.module?
23
23
  #=> false
24
24
  ryan.initialization_args
25
25
  #=> [:message]
26
- ryan.funcs.length
26
+ ryan.funcs.length
27
27
  #=> 12
28
- ryan.funcs.reject(&:private?).length
28
+ ryan.funcs.reject(&:private?).length
29
29
  #=> 10
30
- ryan.funcs.first.name
30
+ ryan.funcs.first.name
31
31
  #=> :enqueue
32
32
  ```
33
33
 
@@ -92,7 +92,7 @@ nested_condition.if_text
92
92
 
93
93
  ## Development
94
94
 
95
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests.
95
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests.
96
96
  You can also run `bin/console` for an interactive prompt that will allow you to experiment.
97
97
 
98
98
  ## Contributing
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rake/release'
1
2
  $LOAD_PATH.unshift './lib'
2
3
  require 'ryan'
3
4
  require 'rspec/core/rake_task'
@@ -59,8 +59,8 @@ class Ryan::Condition
59
59
 
60
60
  def edit_return_text(txt)
61
61
  txt = txt.to_s
62
- txt.sub! /^return\b/, 'returns'
63
- txt.sub! /^returns\s*$/, 'returns nil'
62
+ txt = txt.sub /^return\b/, 'returns'
63
+ txt = txt.sub /^returns\s*$/, 'returns nil'
64
64
  if txt.include?(' = ')
65
65
  txt = "assigns #{txt}"
66
66
  elsif !txt.empty? and txt !~ /^return/
@@ -89,7 +89,9 @@ class Ryan::Condition
89
89
  def create_nested_conditions
90
90
  nc = Set.new
91
91
  s = sexp.drop(1)
92
- s.flatten.include?(:if) && s.deep_each do |exp|
92
+ sexp = s
93
+ sexp = Sexp.new(s) unless s.respond_to?(:deep_each)
94
+ s.flatten.include?(:if) && sexp.deep_each do |exp|
93
95
  Ryan::SexpDecorator.new(exp).each_sexp_condition do |node|
94
96
  nc << self.class.new(node)
95
97
  end
data/lib/ryan/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Ryan
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
data/lib/ryan.rb CHANGED
@@ -18,9 +18,15 @@ class Ryan
18
18
  def_delegators :const,
19
19
  :name, :funcs, :type, :initialization_args, :func_by_name, :class?, :module?
20
20
 
21
- # @param [Pathname, String] file
22
- def initialize(file)
23
- @sexp = RubyParser.new.parse File.read(file)
21
+ def self.root
22
+ Pathname.new File.expand_path('../..', __FILE__)
23
+ end
24
+
25
+ # @note Attempts to read a file if a path is given, otherwise threats input as ruby code string
26
+ # @param [Pathname, String] input
27
+ def initialize(input)
28
+ input = File.read(input) if File.file?(input)
29
+ @sexp = RubyParser.new.parse(input)
24
30
  @const = Const.new(sexp)
25
31
  end
26
32
  end
data/ryan.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Ryan Buckley"]
10
10
  spec.email = ["arebuckley@gmail.com"]
11
11
 
12
- spec.summary = %q{Ryan meet Ruby}
13
- spec.description = %q{A wrapper around the RubyParser gem}
12
+ spec.summary = %q{Ryan meets Ruby}
13
+ spec.description = %q{Ryan turns Ruby code files into objects that can describe themselves}
14
14
  spec.homepage = "https://github.com/ridiculous/ryan"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -18,10 +18,14 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.10"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec", ">= 3.2", "< 4"
21
+ spec.required_ruby_version = '>= 1.9.3'
24
22
 
25
23
  spec.add_dependency 'ruby_parser', '>= 3.7.0', '< 4.0.0'
26
- spec.add_dependency 'ruby2ruby', '~> 2.2'
24
+ spec.add_dependency 'ruby2ruby', '~> 2.5'
25
+
26
+ spec.add_development_dependency "bundler", "~> 2.0"
27
+ spec.add_development_dependency "rake", "~> 13.0"
28
+ spec.add_development_dependency "rspec", ">= 3.2", "< 4"
29
+ spec.add_development_dependency 'pry', '~> 0.14'
30
+ spec.add_development_dependency 'rake-release', '~> 1.3'
27
31
  end
metadata CHANGED
@@ -1,43 +1,77 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ryan
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-05 00:00:00.000000000 Z
11
+ date: 2023-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby_parser
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.7.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 4.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 3.7.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 4.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: ruby2ruby
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.5'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.5'
13
47
  - !ruby/object:Gem::Dependency
14
48
  name: bundler
15
49
  requirement: !ruby/object:Gem::Requirement
16
50
  requirements:
17
51
  - - "~>"
18
52
  - !ruby/object:Gem::Version
19
- version: '1.10'
53
+ version: '2.0'
20
54
  type: :development
21
55
  prerelease: false
22
56
  version_requirements: !ruby/object:Gem::Requirement
23
57
  requirements:
24
58
  - - "~>"
25
59
  - !ruby/object:Gem::Version
26
- version: '1.10'
60
+ version: '2.0'
27
61
  - !ruby/object:Gem::Dependency
28
62
  name: rake
29
63
  requirement: !ruby/object:Gem::Requirement
30
64
  requirements:
31
65
  - - "~>"
32
66
  - !ruby/object:Gem::Version
33
- version: '10.0'
67
+ version: '13.0'
34
68
  type: :development
35
69
  prerelease: false
36
70
  version_requirements: !ruby/object:Gem::Requirement
37
71
  requirements:
38
72
  - - "~>"
39
73
  - !ruby/object:Gem::Version
40
- version: '10.0'
74
+ version: '13.0'
41
75
  - !ruby/object:Gem::Dependency
42
76
  name: rspec
43
77
  requirement: !ruby/object:Gem::Requirement
@@ -59,40 +93,34 @@ dependencies:
59
93
  - !ruby/object:Gem::Version
60
94
  version: '4'
61
95
  - !ruby/object:Gem::Dependency
62
- name: ruby_parser
96
+ name: pry
63
97
  requirement: !ruby/object:Gem::Requirement
64
98
  requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: 3.7.0
68
- - - "<"
99
+ - - "~>"
69
100
  - !ruby/object:Gem::Version
70
- version: 4.0.0
71
- type: :runtime
101
+ version: '0.14'
102
+ type: :development
72
103
  prerelease: false
73
104
  version_requirements: !ruby/object:Gem::Requirement
74
105
  requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: 3.7.0
78
- - - "<"
106
+ - - "~>"
79
107
  - !ruby/object:Gem::Version
80
- version: 4.0.0
108
+ version: '0.14'
81
109
  - !ruby/object:Gem::Dependency
82
- name: ruby2ruby
110
+ name: rake-release
83
111
  requirement: !ruby/object:Gem::Requirement
84
112
  requirements:
85
113
  - - "~>"
86
114
  - !ruby/object:Gem::Version
87
- version: '2.2'
88
- type: :runtime
115
+ version: '1.3'
116
+ type: :development
89
117
  prerelease: false
90
118
  version_requirements: !ruby/object:Gem::Requirement
91
119
  requirements:
92
120
  - - "~>"
93
121
  - !ruby/object:Gem::Version
94
- version: '2.2'
95
- description: A wrapper around the RubyParser gem
122
+ version: '1.3'
123
+ description: Ryan turns Ruby code files into objects that can describe themselves
96
124
  email:
97
125
  - arebuckley@gmail.com
98
126
  executables: []
@@ -100,10 +128,13 @@ extensions: []
100
128
  extra_rdoc_files: []
101
129
  files:
102
130
  - ".gitignore"
131
+ - ".rspec"
103
132
  - ".ruby-gemset"
104
133
  - ".ruby-version"
105
134
  - ".travis.yml"
135
+ - CHANGELOG.md
106
136
  - Gemfile
137
+ - LICENSE.md
107
138
  - README.md
108
139
  - Rakefile
109
140
  - bin/console
@@ -121,7 +152,7 @@ files:
121
152
  homepage: https://github.com/ridiculous/ryan
122
153
  licenses: []
123
154
  metadata: {}
124
- post_install_message:
155
+ post_install_message:
125
156
  rdoc_options: []
126
157
  require_paths:
127
158
  - lib
@@ -129,16 +160,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
129
160
  requirements:
130
161
  - - ">="
131
162
  - !ruby/object:Gem::Version
132
- version: '0'
163
+ version: 1.9.3
133
164
  required_rubygems_version: !ruby/object:Gem::Requirement
134
165
  requirements:
135
166
  - - ">="
136
167
  - !ruby/object:Gem::Version
137
168
  version: '0'
138
169
  requirements: []
139
- rubyforge_project:
140
- rubygems_version: 2.4.8
141
- signing_key:
170
+ rubygems_version: 3.3.7
171
+ signing_key:
142
172
  specification_version: 4
143
- summary: Ryan meet Ruby
173
+ summary: Ryan meets Ruby
144
174
  test_files: []