Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
Fix English.
Browse files Browse the repository at this point in the history
I am so bad in English... :-(
  • Loading branch information
nicolasdespres committed May 21, 2013
1 parent dbbd9da commit 0a39503
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Welcome to Respect

_Respect_ is a DSL to concisely describe the structure of common data such as Hash and Array using
_Respect_ is a DSL to concisely describe the structure of common data such as hash and array using
Ruby code. It comes with a validator, a sanitizer and dumpers to generate valid
[json-schema.org](http://json-schema.org/) compliant specifications. Although it was designed to
specify JSON schema, it can be used for any data represented as Hash and Array. It does not require
Expand Down Expand Up @@ -33,7 +33,7 @@ Thus, it is ideal to specify JSON schema. I find it a way more concise than
[json-schema.org](http://json-schema.org/). And it is plain Ruby so you can rely on all great Ruby features
to factor your specification code.

For instance, this ruby code specify how one could structure a very simple user profile:
For instance, this ruby code specifies how one could structure a very simple user profile:

```ruby
schema = Respect::HashSchema.define do |s|
Expand Down Expand Up @@ -101,7 +101,7 @@ _Respect_ does not parse JSON document by default but it is easy to do so using
schema.validate?(JSON.parse('{ "name": "My name", "age": 20, "email": "[email protected]" }')) #=> true
```

Once a JSON document has been validated, we often want to turn its basic strings and integers into real object like `URI`.
Once a JSON document has been validated, we often want to turn its basic strings and integers into real objects like `URI`.
_Respect_ does that automatically for you for standard objects:

```ruby
Expand All @@ -113,7 +113,7 @@ schema.validate!(object) #=> true
object["homepage"].class #=> URI::HTTP
```

You can easily extend the sanitizer with your own object type. Let's assume you have an object type define like this:
You can easily extend the sanitizer with your own object type. Let's assume you have an object type defined like this:

```ruby
class Place
Expand All @@ -129,7 +129,7 @@ class Place
end
```

Then you must extend the Schema hierarchy with the new schema for your custom type.
Then you can extend the `Schema` class hierarchy with the new schema for your custom type.
The `CompositeSchema` class assists you in this task so you just have to overwrite
two methods.

Expand Down Expand Up @@ -188,12 +188,12 @@ end
```

In such case, you don't need a custom sanitizer. You just want to factor the definition of
identifier property. You can easily to it like this:
identifier property. You can easily do it like this:

```ruby
module MyMacros
def id(name, options = {})
unless name.nil? || name =~ /_id$/
def id(name = "id", options = {})
unless name.nil? || name == "id" || name =~ /_id$/
name += "_id"
end
integer(name, { greater_than: 0 }.merge(options))
Expand All @@ -202,7 +202,7 @@ end
Respect.extend_dsl_with(MyMacros)
```

Now you can rewrite the original schema this way:
Now you can rewrite your schema definition this way:

```ruby
Respect::HashSchema.define do |s|
Expand Down Expand Up @@ -247,7 +247,7 @@ Although, the semantics of the schema definition DSL available in this library m
_JSON schema standard_, we have tried to keep it as close as possible. For instance the `strict` option of
hash schema is not presented in the standard. However, when a schema is dumped to its _JSON Schema_ version
the syntax and semantic have been followed. You should note that there is no "loader" available yet in this
library. In other word, you cannot instantiate a Schema class from a _JSON Schema_ string representation.
library. In other word, you cannot instantiate a `Schema` class from a _JSON Schema_ string representation.

# Getting help

Expand Down Expand Up @@ -280,7 +280,7 @@ I would love to hear what you think about this library. Feel free to post any co

I spent quite a lot of time writing this gem but there is still a lot of work to do. Whether it
is a bug-fix, a new feature, some code re-factoring, or documentation clarification, I will be
glade to merge your pull request on GitHub. You just have to create a branch from `master` and
glade to merge your pull-request on GitHub. You just have to create a branch from `master` and
send me a pull request.

# License
Expand Down
2 changes: 1 addition & 1 deletion respect.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.email = ["[email protected]"]
s.homepage = "http://nicolasdespres.github.io/respect"
s.summary = "Object schema definition using a Ruby DSL."
s.description = "Respect let you specify object schema using a Ruby DSL. It also provides validators, sanitizers and dumpers to generate json-schema.org compliant spec. It is perfect to specify JSON document structure."
s.description = "Respect lets you specify object schema using a Ruby DSL. It also provides validators, sanitizers and dumpers to generate json-schema.org compliant spec. It is perfect to specify JSON document structure."

s.files = Dir["lib/**/*"] + [
"MIT-LICENSE",
Expand Down
7 changes: 5 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ class CoreDef < GlobalDef
# A module to test statement extension helper.
module EndUserDSLStatement

def id(name = "id")
integer name, greater_than: 0
def id(name = "id", options = {})
unless name.nil? || name == "id" || name =~ /_id$/
name += "_id"
end
integer(name, { greater_than: 0 }.merge(options))
end

def call_to_kernel
Expand Down

0 comments on commit 0a39503

Please sign in to comment.