ar2dto 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 95a346915889755102f7d55c39719a0b9448072537b4b5f5eb0fa2236be8e94b
4
+ data.tar.gz: 80a22c29ae6e5cc0544ff5b8bfc8592e22aead54188168fffd59edd7cc851424
5
+ SHA512:
6
+ metadata.gz: 5fb6538cecb77a3b787249405692c9664d177e276a2ba51f942afd2546a0bdd1137731e58cb220bd094265e991e7d1d73061e63c9996125c56b7ecd2d6b5527d
7
+ data.tar.gz: 73be4eecaedcc6ab2a2904284f0251eb4e7259d590336eb0cf8ae6214617aba52fb5ed1465b5026b4212f2a6b9450ba5ca3c7e7cbcdb3071357c48e267d638d0
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Santiago Bartesaghi
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,63 @@
1
+ # AR2DTO ![AR2DTO](docs/images/logo.png)
2
+
3
+ AR2DTO (ActiveRecord to DTO, pronounced R2-D2 or Artoo-Detoo) is a gem that lets you create DTOs (data transfer objects) from your ActiveRecord models. It is a simple and small gem with the goal of encouraging the usage of simpler objects across an app rather than ActiveRecord models, to help with coupling issues in large Rails apps.
4
+
5
+ ![CI](https://github.com/santib/ar2dto/workflows/CI/badge.svg)
6
+
7
+ ## Table of Contents
8
+
9
+ - [Motivation](#motivation)
10
+ - [Why AR2DTO?](#why-ar2dto)
11
+ - [Installation](#installation)
12
+ - [Usage](#usage)
13
+ - [Setting up your models](#setting-up-your-models)
14
+ - [Development](#development)
15
+ - [Contributing](#contributing)
16
+ - [License](#license)
17
+ - [Code of Conduct](#code-of-conduct)
18
+
19
+ ## Motivation
20
+ TBD
21
+
22
+ ### Why AR2DTO?
23
+ TBD
24
+
25
+ ## Installation
26
+
27
+ Add this line to your application's Gemfile:
28
+
29
+ ```ruby
30
+ gem 'ar2dto'
31
+ ```
32
+
33
+ And then execute:
34
+
35
+ $ bundle install
36
+
37
+ Or install it yourself as:
38
+
39
+ $ gem install ar2dto
40
+
41
+ ## Usage
42
+ TBD
43
+
44
+ ### Setting up your models
45
+ TBD
46
+
47
+ ## Development
48
+
49
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
50
+
51
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
52
+
53
+ ## Contributing
54
+
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/santib/ar2dto. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/santib/ar2dto/blob/main/CODE_OF_CONDUCT.md).
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
60
+
61
+ ## Code of Conduct
62
+
63
+ Everyone interacting in the AR2DTO project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/santib/ar2dto/blob/main/CODE_OF_CONDUCT.md).
@@ -0,0 +1,26 @@
1
+ module AR2DTO
2
+ module Base
3
+ def self.included(model)
4
+ namespace = model.name.deconstantize.presence&.constantize || Object
5
+
6
+ namespace.const_set("#{model.name.split('::').last}DTO", Class.new do
7
+ include ::ActiveModel::Model
8
+ attr_reader :attributes
9
+ attr_accessor *model.column_names
10
+
11
+ def initialize(attributes)
12
+ @attributes = attributes
13
+ super
14
+ end
15
+
16
+ def ==(other)
17
+ attributes == other.attributes
18
+ end
19
+ end)
20
+ end
21
+
22
+ def to_dto
23
+ "#{self.class.name}DTO".constantize.new(attributes)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AR2DTO
4
+ VERSION = "0.1.0"
5
+ end
data/lib/ar2dto.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ar2dto/version"
4
+
5
+ module AR2DTO
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ar2dto
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Santiago Bartesaghi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-06-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5.2'
27
+ description:
28
+ email:
29
+ - santib@hey.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE.txt
35
+ - README.md
36
+ - lib/ar2dto.rb
37
+ - lib/ar2dto/base.rb
38
+ - lib/ar2dto/version.rb
39
+ homepage: https://github.com/santib/ar2dto
40
+ licenses:
41
+ - MIT
42
+ metadata:
43
+ homepage_uri: https://github.com/santib/ar2dto
44
+ source_code_uri: https://github.com/santib/ar2dto
45
+ bug_tracker_uri: https://github.com/santib/ar2dto/issues
46
+ changelog_uri: https://github.com/santib/ar2dto/releases
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 2.5.0
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubygems_version: 3.1.6
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Easing the creation of DTOs from your ActiveRecord models.
66
+ test_files: []