<commit_before>/*
 Copyright 2016-present The Material Motion Authors. All Rights Reserved.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

import UIKit

/** Retrieve a scoped property builder for the given CALayer. */
public func propertyOf(_ layer: CALayer) -> CALayerReactivePropertyBuilder {
  return CALayerReactivePropertyBuilder(layer)
}

/** A scoped property builder for CALayer instances. */
public class CALayerReactivePropertyBuilder {

  /** A property representing the layer's .opacity value. */
  public func opacity() -> ReactiveProperty<CGFloat> {
    let layer = self.layer
    return property(read: { CGFloat(layer.opacity) },
                    write: { layer.opacity = Float($0) },
                    keyPath: "opacity")
  }

  /** A property representing the layer's .position value. */
  public func position() -> ReactiveProperty<CGPoint> {
    let layer = self.layer
    return property(read: { layer.position },
                    write: { layer.position = $0 },
                    keyPath: "position")
  }

  /** A property representing the layer's .position.y value. */
  public func positionY() -> ReactiveProperty<CGFloat> {
    let layer = self.layer
    return property(read: { layer.position.y },
                    write: { layer.position.y = $0 },
                    keyPath: "position.y")
  }

  /** A property representing the layer's .transform.rotation.z value. */
  public func rotation() -> ReactiveProperty<CGFloat> {
    let layer = self.layer
    return property(read: { layer.value(forKeyPath: "transform.rotation.z") as! CGFloat },
                    write: { layer.setValue($0, forKeyPath: "transform.rotation.z") },
                    keyPath: "transform.rotation.z")
  }
<commit_msg>Add scale reactive property to CALayer.<commit_after>/*
 Copyright 2016-present The Material Motion Authors. All Rights Reserved.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

import UIKit

/** Retrieve a scoped property builder for the given CALayer. */
public func propertyOf(_ layer: CALayer) -> CALayerReactivePropertyBuilder {
  return CALayerReactivePropertyBuilder(layer)
}

/** A scoped property builder for CALayer instances. */
public class CALayerReactivePropertyBuilder {

  /** A property representing the layer's .opacity value. */
  public func opacity() -> ReactiveProperty<CGFloat> {
    let layer = self.layer
    return property(read: { CGFloat(layer.opacity) },
                    write: { layer.opacity = Float($0) },
                    keyPath: "opacity")
  }

  /** A property representing the layer's .position value. */
  public func position() -> ReactiveProperty<CGPoint> {
    let layer = self.layer
    return property(read: { layer.position },
                    write: { layer.position = $0 },
                    keyPath: "position")
  }

  /** A property representing the layer's .position.y value. */
  public func positionY() -> ReactiveProperty<CGFloat> {
    let layer = self.layer
    return property(read: { layer.position.y },
                    write: { layer.position.y = $0 },
                    keyPath: "position.y")
  }

  /** A property representing the layer's .transform.rotation.z value. */
  public func rotation() -> ReactiveProperty<CGFloat> {
    let layer = self.layer
    return property(read: { layer.value(forKeyPath: "transform.rotation.z") as! CGFloat },
                    write: { layer.setValue($0, forKeyPath: "transform.rotation.z") },
                    keyPath: "transform.rotation.z")
  }

  /** A property representing the layer's .transform.scale value. */
  public func scale() -> ReactiveProperty<CGFloat> {
    let layer = self.layer
    return property(read: { layer.value(forKeyPath: "transform.scale") as! CGFloat },
                    write: { layer.setValue($0, forKeyPath: "transform.scale") },
                    keyPath: "transform.scale")
  }

{'fraction_non_alphanumeric': 0.10247422680412371, 'fraction_numerical': 0.005154639175257732, 'mean_word_length': 2.893258426966292, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1774121', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1236, 'n_words': 449}