Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3c276a7bd7aa
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c551b35cb170
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 16, 2016

  1. YAML.mapping setter/getter generation control

    Ary Borenszweig committed Nov 16, 2016
    Copy the full SHA
    da1b6a0 View commit details
  2. Updated Changelog

    Ary Borenszweig committed Nov 16, 2016
    Copy the full SHA
    c551b35 View commit details
Showing with 40 additions and 9 deletions.
  1. +26 −0 CHANGELOG.md
  2. +14 −9 src/yaml/mapping.cr
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
## Next

* **(breaking change)** Removed `ifdef` from the language
* **(breaking change)** Removed `PointerIO`
* **(breaking change)** The `body` property of `HTTP::Request` is now an `IO?` (previously it was `String`). Use `request.body.try(&.gets_to_end)` if you need the entire body as a String.
* **(breaking change)** The `Iterable` module is now generic
* Added support for HTTP client and server streaming.
* Added support for ARM (thanks @ysbaddaden)
* Added support for AArch64 (thanks @ysbaddaden)
* Added support for LLVM 3.9 (thanks @ysbaddaden)
* API docs have a nicer style now (thanks @samueleaton)
* Slight improvement to debugging support (thanks @ggiraldez)
* Added iteration times to `Benchmark.ips` (thanks @RX14)
* Allow `HTTP::Client` block initializer to be used when passing an URI (thanks @philnash)
* `JSON.mapping` and `YAML.mapping` getter/setter generation can now be controlled (thanks @zatherz)
* `Time` is now serializable to JSON and YAML using ISO 8601 date-time format
* Added `IO::MultiWriter` (thanks @RX14)
* Added `String#index(Regex)` and `String#rindex(Regex)` (thanks @zatherz)
* Added `String#partition` and `String#rpartition` (thanks @johnjansen)
* Added `FileUtils.cd`, `FileUtils.mkdir`, `FileUtils.mkdir_p`, `FileUtils.mv`, `FileUtils.pwd`, `FileUtils.rm`, `FileUtils.rm_r`, `FileUtils.rmdir` (thanks @ghivert)
* Added `JSON::Builder#raw_field` (thanks @kostya)
* Added `Enumerable#chunks` and `Iterator#chunk` (thanks @kostya)
* Added `Iterator#with_index`
* Several enhancements to the Random module: now works for any integer type and avoids overflows (thanks @BlaXpirit)
* [Several bug fixes](https://github.com/crystal-lang/crystal/issues?q=is%3Aclosed+milestone%3A0.20.0)

## 0.19.4 (07-10-2016)

* Added support for OpenBSD (thanks @wmoxam and @ysbaddaden)
23 changes: 14 additions & 9 deletions src/yaml/mapping.cr
Original file line number Diff line number Diff line change
@@ -57,10 +57,11 @@ module YAML
# * **default**: value to use if the property is missing in the YAML document, or if it's `null` and `nilable` was not set to `true`. If the default value creates a new instance of an object (for example `[1, 2, 3]` or `SomeObject.new`), a different instance will be used each time a YAML document is parsed.
# * *key* defines which key to read from a YAML document. It defaults to the name of the property.
# * *converter* takes an alternate type for parsing. It requires a `#from_yaml` method in that class, and returns an instance of the given type. Examples of converters are `Time::Format` and `Time::EpochConverter` for `Time`.
# * **setter**: if true, will generate a setter for the variable, true by default
# * **getter**: if true, will generate a getter for the variable, true by default
#
# The mapping also automatically defines Crystal properties (getters and setters) for each
# of the keys. It doesn't define a constructor accepting those arguments, but you can provide
# an overload.
# This macro by default defines getters and setters for each variable (this can be overrided with *setter* and *getter*).
# The mapping doesn't define a constructor accepting these variables as arguments, but you can provide an overload.
#
# The macro basically defines a constructor accepting a `YAML::PullParser` that reads from
# it and initializes this type's instance variables.
@@ -74,13 +75,17 @@ module YAML
{% for key, value in properties %}
@{{key.id}} : {{value[:type]}} {{ (value[:nilable] ? "?" : "").id }}

def {{key.id}}=(_{{key.id}} : {{value[:type]}} {{ (value[:nilable] ? "?" : "").id }})
@{{key.id}} = _{{key.id}}
end
{% if value[:setter] == nil ? true : value[:setter] %}
def {{key.id}}=(_{{key.id}} : {{value[:type]}} {{ (value[:nilable] ? "?" : "").id }})
@{{key.id}} = _{{key.id}}
end
{% end %}

def {{key.id}}
@{{key.id}}
end
{% if value[:getter] == nil ? true : value[:getter] %}
def {{key.id}}
@{{key.id}}
end
{% end %}
{% end %}

def initialize(%pull : YAML::PullParser)