falkor 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +21 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- data/.github/logo.jpg +0 -0
- data/.github/workflows/coverage.yml +24 -0
- data/.github/workflows/lint.yml +19 -0
- data/.github/workflows/tests.yml +22 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +1600 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/Rakefile +12 -0
- data/bin/console +19 -0
- data/bin/publish +65 -0
- data/bin/setup +8 -0
- data/falkor.gemspec +35 -0
- data/lib/falkor.rb +16 -0
- data/lib/falkor/concerns/installable.rb +50 -0
- data/lib/falkor/concerns/trackable_progress.rb +14 -0
- data/lib/falkor/download.rb +70 -0
- data/lib/falkor/extract/gem.rb +46 -0
- data/lib/falkor/extract/tar_gz.rb +117 -0
- data/lib/falkor/gem.rb +93 -0
- data/lib/falkor/progress.rb +28 -0
- data/lib/falkor/ruby.rb +68 -0
- data/lib/falkor/version.rb +5 -0
- data/lib/falkor/yard/documentation.rb +67 -0
- data/lib/falkor/yard/parser.rb +31 -0
- data/lib/falkor/yard/parser/global_state.rb +24 -0
- metadata +152 -0
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 npezza93@gmail.com. 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
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
gem "pry"
|
10
|
+
gem "rubocop"
|
11
|
+
gem "rubocop-performance"
|
12
|
+
gem "simplecov"
|
13
|
+
gem "vcr"
|
14
|
+
gem "webmock"
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Nick Pezza
|
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,61 @@
|
|
1
|
+
<p align="center">
|
2
|
+
<a href="https://github.com/npezza93/falkor">
|
3
|
+
<img src="./.github/logo.jpg" width="350">
|
4
|
+
</a>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
|
8
|
+
# Falkor
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'falkor'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install falkor
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
|
29
|
+
#### Ruby Core and Stlib
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
store = Falkor::Ruby.new(version).generate do |action, progress, description|
|
33
|
+
puts action, progress, description
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
#### Remote Gem
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
store = Falkor::Gem.new(name, version: (optional)).generate do |action, progress, description|
|
41
|
+
puts action, progress, description
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
48
|
+
|
49
|
+
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).
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/npezza93/falkor. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
54
|
+
|
55
|
+
## License
|
56
|
+
|
57
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
58
|
+
|
59
|
+
## Code of Conduct
|
60
|
+
|
61
|
+
Everyone interacting in the Falkor project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/npezza93/falkor/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "falkor"
|
6
|
+
require "pry"
|
7
|
+
|
8
|
+
def reload!
|
9
|
+
puts "Reloading..."
|
10
|
+
old_verbose = $VERBOSE
|
11
|
+
$VERBOSE = nil
|
12
|
+
|
13
|
+
$LOADED_FEATURES.select { |feat| feat =~ /\/falkor\// }.each(&method(:load))
|
14
|
+
|
15
|
+
$VERBOSE = old_verbose
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
Pry.start
|
data/bin/publish
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "pathname"
|
5
|
+
require "fileutils"
|
6
|
+
require_relative "../lib/falkor/version"
|
7
|
+
|
8
|
+
# path to your application root.
|
9
|
+
APP_ROOT = Pathname.new File.expand_path("..", __dir__)
|
10
|
+
MASTER_CHECK = <<~MASTER_CHECK
|
11
|
+
if [ $(git symbolic-ref --short -q HEAD) != 'master' ];
|
12
|
+
then exit 1;
|
13
|
+
fi
|
14
|
+
MASTER_CHECK
|
15
|
+
VERSION_TYPES = %w(major minor patch).freeze
|
16
|
+
|
17
|
+
def system!(*args)
|
18
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
19
|
+
end
|
20
|
+
|
21
|
+
abort("\n== Version Type incorrect ==") unless VERSION_TYPES.include?(ARGV[0])
|
22
|
+
|
23
|
+
abort("\n== Not on master") unless system(MASTER_CHECK)
|
24
|
+
|
25
|
+
current_version = Falkor::VERSION.split(".").map(&:to_i)
|
26
|
+
|
27
|
+
case ARGV[0]
|
28
|
+
when "major"
|
29
|
+
current_version[0] += 1
|
30
|
+
current_version[1] = 0
|
31
|
+
current_version[2] = 0
|
32
|
+
when "minor"
|
33
|
+
current_version[1] += 1
|
34
|
+
current_version[2] = 0
|
35
|
+
when "patch"
|
36
|
+
current_version[2] += 1
|
37
|
+
end
|
38
|
+
|
39
|
+
joined_version = current_version.join(".")
|
40
|
+
|
41
|
+
FileUtils.chdir APP_ROOT do
|
42
|
+
contents = <<~FILE
|
43
|
+
# frozen_string_literal: true
|
44
|
+
|
45
|
+
module Falkor
|
46
|
+
VERSION = "#{joined_version}"
|
47
|
+
end
|
48
|
+
FILE
|
49
|
+
|
50
|
+
puts "== Updating version to #{joined_version} =="
|
51
|
+
File.write("lib/falkor/version.rb", contents)
|
52
|
+
|
53
|
+
system! "git add lib/falkor/version.rb"
|
54
|
+
|
55
|
+
puts "== Committing updated files =="
|
56
|
+
system! "git commit -m 'Version bump to #{joined_version}'"
|
57
|
+
system! "git push"
|
58
|
+
|
59
|
+
puts "== Publishing gem =="
|
60
|
+
system! "bundle exec rake release"
|
61
|
+
built_gem_path = "pkg/falkor-#{joined_version}.gem"
|
62
|
+
github_host = "https://rubygems.pkg.github.com/npezza93"
|
63
|
+
|
64
|
+
system! "gem push --key github --host #{github_host} #{built_gem_path}"
|
65
|
+
end
|
data/bin/setup
ADDED
data/falkor.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "falkor/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "falkor"
|
9
|
+
spec.version = Falkor::VERSION
|
10
|
+
spec.authors = "Nick Pezza"
|
11
|
+
spec.email = "npezza93@gmail.com"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.summary = %q(A parser that Just Works)
|
14
|
+
|
15
|
+
spec.homepage = "https://github.com/npezza93/falkor"
|
16
|
+
spec.metadata["github_repo"] = "ssh://github.com/npezza93/falkor"
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] =
|
20
|
+
"https://github.com/npezza93/falkor/releases"
|
21
|
+
|
22
|
+
spec.require_path = "lib"
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test)/}) }
|
25
|
+
end
|
26
|
+
|
27
|
+
spec.required_ruby_version = ">= 2.5.0"
|
28
|
+
|
29
|
+
spec.add_dependency "gems", "~> 1.1"
|
30
|
+
spec.add_dependency "yard", "< 0.10.0"
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", ">= 1.17", "< 3"
|
33
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
34
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
35
|
+
end
|
data/lib/falkor.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "falkor/version"
|
4
|
+
|
5
|
+
require "falkor/download"
|
6
|
+
|
7
|
+
require "falkor/extract/gem"
|
8
|
+
require "falkor/extract/tar_gz"
|
9
|
+
|
10
|
+
require "falkor/yard/documentation"
|
11
|
+
|
12
|
+
require "falkor/ruby"
|
13
|
+
require "falkor/gem"
|
14
|
+
|
15
|
+
module Falkor
|
16
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Falkor
|
4
|
+
module Installable
|
5
|
+
def download
|
6
|
+
return yard_filepath if Dir.exist? yard_filepath
|
7
|
+
|
8
|
+
block =
|
9
|
+
if block_given?
|
10
|
+
Proc.new
|
11
|
+
else
|
12
|
+
proc {}
|
13
|
+
end
|
14
|
+
|
15
|
+
generate_documentation(extract(download_source(&block), &block), &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def download_source
|
21
|
+
Falkor::Download.new(url, file_name).download do |progress|
|
22
|
+
yield :downloading, progress
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def extract(file_path)
|
27
|
+
Falkor::Extract::TarGz.
|
28
|
+
new(file_path, has_root_dir: true).
|
29
|
+
extract do |progress|
|
30
|
+
yield :extracting, progress
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def generate_documentation(file_path)
|
35
|
+
Falkor::Yard::Documentation.
|
36
|
+
new(file_path, yard_filepath).
|
37
|
+
generate do |progress, description|
|
38
|
+
yield :generating, progress, description
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def store
|
43
|
+
@store ||= begin
|
44
|
+
reg_store = YARD::RegistryStore.new
|
45
|
+
reg_store.load(download)
|
46
|
+
reg_store
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "falkor/progress"
|
4
|
+
|
5
|
+
module Falkor
|
6
|
+
module TrackableProgress
|
7
|
+
def report_progress(method_to_run, total, *args)
|
8
|
+
progress = Progress.new(total)
|
9
|
+
send(method_to_run, *args) do |amount, description = nil|
|
10
|
+
progress.increment!(amount, description, &Proc.new)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "falkor/concerns/trackable_progress"
|
4
|
+
|
5
|
+
module Falkor
|
6
|
+
class Download
|
7
|
+
include TrackableProgress
|
8
|
+
|
9
|
+
def initialize(url, file_name)
|
10
|
+
@url = url
|
11
|
+
@file_name = file_name
|
12
|
+
end
|
13
|
+
|
14
|
+
def download
|
15
|
+
return destination if File.exist?(destination)
|
16
|
+
|
17
|
+
request do |response, file_size|
|
18
|
+
next unless success?(response)
|
19
|
+
|
20
|
+
report_progress(:write_chunks, file_size, response, &Proc.new)
|
21
|
+
destination
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :url, :file_name
|
28
|
+
|
29
|
+
def request
|
30
|
+
return_value = nil
|
31
|
+
|
32
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: https?) do |http|
|
33
|
+
http.request(Net::HTTP::Get.new(uri)) do |response|
|
34
|
+
return_value = yield response, response["content-length"].to_i
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
return_value
|
39
|
+
end
|
40
|
+
|
41
|
+
def uri
|
42
|
+
@uri ||= URI(url)
|
43
|
+
end
|
44
|
+
|
45
|
+
def https?
|
46
|
+
uri.scheme == "https"
|
47
|
+
end
|
48
|
+
|
49
|
+
def write_chunks(response)
|
50
|
+
FileUtils.mkdir_p "tmp"
|
51
|
+
FileUtils.rm_rf destination
|
52
|
+
|
53
|
+
File.open(destination, "wb") do |file|
|
54
|
+
response.read_body do |chunk|
|
55
|
+
file.write chunk
|
56
|
+
|
57
|
+
yield(chunk.size)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def success?(response)
|
63
|
+
(200..299).cover?(response.code.to_i)
|
64
|
+
end
|
65
|
+
|
66
|
+
def destination
|
67
|
+
File.join(Dir.pwd, "tmp", file_name)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|