iripper 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5417625c477cf66e125f37bdce0926239de530f4ad76798d7b660f3f2ca49d7b
4
+ data.tar.gz: 9cdc9f0ab0ed714b8063d345d30d96febcf11428461ec49e33a38cdcbb5c0f16
5
+ SHA512:
6
+ metadata.gz: 90083635314428892336d64f603a569c77e0d48daa3cc37653809c5ad22fabb67eb66fa9ab322299d822046fdf01f6e59b0e952e619b1ff85c1dc6a39e116a81
7
+ data.tar.gz: 21e31420266e7000d42ee7947b04373502df483a059a32e1b0efd518f9026171bbfdf80538cdb7d51afe5cfa0aa80745652151449eb68b78b94dad9084b0ab57
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in iripper.gemspec
6
+ gemspec
@@ -0,0 +1,57 @@
1
+ # IRipper
2
+
3
+ IRipper is a REPL to parse a Ruby script interactively.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'iripper'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install iripper
20
+
21
+ ## Usage
22
+
23
+ Run `iripper` command, then enter a parsing command and scripts.
24
+
25
+ ```
26
+ $ iripper
27
+ iripper> tokenize 1 + 1
28
+ ["1", " ", "+", " ", "1"]
29
+ iripper> sexp 1 + 1
30
+ [:program, [[:binary, [:@int, "1", [1, 0]], :+, [:@int, "1", [1, 4]]]]]
31
+ ```
32
+
33
+ Available parsing commands are `lex`, `sexp`, `tokenize`.
34
+
35
+ You can specify the default command via the booting argument, or `default` command. Also it can be canceled.
36
+
37
+ ```
38
+ $ iripper tokenize
39
+ iripper(tokenize)> 1 + 1
40
+ ["1", " ", "+", " ", "1"]
41
+ iripper(tokenize)> default sexp
42
+ iripper(sexp)> 1 + 1
43
+ [:program, [[:binary, [:@int, "1", [1, 0]], :+, [:@int, "1", [1, 4]]]]]
44
+ iripper(sexp)> default
45
+ iripper> tokenize 1 + 1
46
+ ["1", " ", "+", " ", "1"]
47
+ ```
48
+
49
+ ## Development
50
+
51
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
52
+
53
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/a2ikm/iripper.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "iripper"
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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "pp"
4
+ require "ripper"
5
+ require "iripper"
6
+
7
+ DELIM_RE = /[[:space:]]+/
8
+ BLANK_RE = /\A[[:space:]]*\z/
9
+
10
+ def show_version
11
+ puts IRipper::VERSION
12
+ end
13
+
14
+ def show_help
15
+ puts "TODO: Show help"
16
+ end
17
+
18
+ RIPPER_COMMANDS = %w(lex sexp tokenize).freeze
19
+
20
+ def ripper_command?(cmd)
21
+ RIPPER_COMMANDS.include?(cmd)
22
+ end
23
+
24
+ def warn_unknown_ripper_command(cmd)
25
+ if ripper_command?(cmd)
26
+ false
27
+ else
28
+ warn <<-TEXT
29
+ Unknown ripper command `#{cmd}`. Available ripper commands are #{RIPPER_COMMANDS.join(", ")}.
30
+ TEXT
31
+
32
+ true
33
+ end
34
+ end
35
+
36
+ default = ARGV[0] ? ARGV[0].strip : nil
37
+
38
+ if default
39
+ case default
40
+ when "help"
41
+ show_help
42
+ exit
43
+ when "version"
44
+ show_version
45
+ exit
46
+ else
47
+ if warn_unknown_ripper_command(default)
48
+ default = nil
49
+ end
50
+ end
51
+ end
52
+
53
+ loop do
54
+ if default
55
+ print "iripper(#{default})> "
56
+ else
57
+ print "iripper> "
58
+ end
59
+
60
+ begin
61
+ line = $stdin.gets.chomp
62
+ rescue NoMethodError, Interrupt
63
+ exit
64
+ end
65
+
66
+ cmd, src = line.split(DELIM_RE, 2)
67
+ case cmd
68
+ when "default"
69
+ if src.nil? || BLANK_RE.match?(src)
70
+ default = nil
71
+ else
72
+ src.strip!
73
+ if warn_unknown_ripper_command(src)
74
+ next
75
+ end
76
+ default = src
77
+ end
78
+ next
79
+ when "help"
80
+ show_help
81
+ next
82
+ when "version"
83
+ show_version
84
+ next
85
+ when "exit", "quit"
86
+ exit
87
+ when nil, BLANK_RE
88
+ next
89
+ end
90
+
91
+ if default
92
+ cmd, src = default, line
93
+ end
94
+
95
+ if ripper_command?(cmd)
96
+ pp Ripper.send(cmd, src)
97
+ next
98
+ end
99
+
100
+ warn "Unknown command: #{cmd}."
101
+ end
@@ -0,0 +1,24 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "iripper/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "iripper"
8
+ spec.version = IRipper::VERSION
9
+ spec.authors = ["Masato Ikeda"]
10
+ spec.email = ["masato.ikeda@gmail.com"]
11
+
12
+ spec.summary = %q{IRipper is a REPL to parse a Ruby script interactively.}
13
+ spec.homepage = "https://github.com/a2ikm/iripper"
14
+
15
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
16
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ end
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.16"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
@@ -0,0 +1,5 @@
1
+ require "iripper/version"
2
+
3
+ module IRipper
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module IRipper
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iripper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masato Ikeda
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-10-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description:
42
+ email:
43
+ - masato.ikeda@gmail.com
44
+ executables:
45
+ - iripper
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - README.md
52
+ - Rakefile
53
+ - bin/console
54
+ - bin/setup
55
+ - exe/iripper
56
+ - iripper.gemspec
57
+ - lib/iripper.rb
58
+ - lib/iripper/version.rb
59
+ homepage: https://github.com/a2ikm/iripper
60
+ licenses: []
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.7.6
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: IRipper is a REPL to parse a Ruby script interactively.
82
+ test_files: []