-
Notifications
You must be signed in to change notification settings - Fork 9
DSL refactor and minor Ruby improvements and fixes #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
112c23c
Moved DSL classes to separate files
joelvh f1b09f0
Backport `yield_self` and replace `derp`
joelvh 2c49431
Moved param-related classes into `TLAW::Params` namespace
joelvh 937150e
Move `TLAW::Params::Param#make` to `TLAW::Params#make`
joelvh 3e27bcb
Update gem info
joelvh 57905fb
Require Ruby 2.3.0+
joelvh b52f08b
Rename `Params::Param` to `Params::Base`
joelvh 87782f5
Require `backports` gem
joelvh 3560172
Changed style back to `fetch -> validate -> create`
joelvh 3a9a42c
Invert logic
joelvh 5e09819
Bring back "GET-only APIs" wording
joelvh 152c030
Moved DSL comments to module
joelvh 9124081
Fix Rubocop issues
joelvh 191e677
Fix path to TLAW gem for examples
joelvh fb80fa9
Fix example
joelvh 86f7db6
Fix nil check
joelvh e55bbfe
Revert docs
joelvh 85e9db5
Fixed Rubocop warnings
joelvh c8dfd29
Fix Rubocop errors for latest Rubocop version
joelvh ed34e07
Expand path to run examples from parent directory
joelvh 1aa9a55
Removed duplicate docs from cherry-pick
joelvh 94c57af
Replaced TODO with some dummy docs
joelvh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.3.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ gemspec | |
|
||
group :test do | ||
gem 'coveralls', require: false | ||
gem 'saharspec', '= 0.0.4' | ||
gem 'saharspec', '0.0.4' | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require_relative 'namespace_wrapper' | ||
|
||
module TLAW | ||
module DSL | ||
class APIWrapper < NamespaceWrapper | ||
def base(url) | ||
@object.base_url = url | ||
end | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require_relative 'post_process_proxy' | ||
|
||
module TLAW | ||
module DSL | ||
class BaseWrapper | ||
def initialize(object) | ||
@object = object | ||
end | ||
|
||
def define(&block) | ||
instance_eval(&block) | ||
end | ||
|
||
def description(text) | ||
# first, remove spaces at a beginning of each line | ||
# then, remove empty lines before and after docs block | ||
@object.description = | ||
text | ||
.gsub(/^[ \t]+/, '') | ||
.gsub(/\A\n|\n\s*\Z/, '') | ||
end | ||
|
||
alias_method :desc, :description | ||
|
||
def docs(link) | ||
@object.docs_link = link | ||
end | ||
|
||
def param(name, type = nil, **opts) | ||
@object.param_set.add(name, **opts.merge(type: type)) | ||
end | ||
|
||
def post_process(key = nil, &block) | ||
@object.response_processor.add_post_processor(key, &block) | ||
end | ||
|
||
def post_process_replace(&block) | ||
@object.response_processor.add_replacer(&block) | ||
end | ||
|
||
def post_process_items(key, &block) | ||
PostProcessProxy | ||
.new(key, @object.response_processor) | ||
.instance_eval(&block) | ||
end | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require_relative 'base_wrapper' | ||
|
||
module TLAW | ||
module DSL | ||
class EndpointWrapper < BaseWrapper | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last thing that I noticed: let's probably remove this logic completely? It just repeats what Ruby 2.3 "squiggly heredoc" do, and as this PR specifies 2.3 as the minimum version, there is no need to replicating language features. One can just
...and be happy.