sparrow-entity 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76e688bd5ae2f8719fc59ffff9a0bfd183066fd824749d6844ee82b1a8ae841d
4
- data.tar.gz: a3ed6511da567a4ebdf639e88c324a4827d8583c524c93e6c48ca4c944dff3fb
3
+ metadata.gz: ba7f73f798ef8f46951bba6feb55e71b9809c4a4b54e3e1be7840c6b5f4193d4
4
+ data.tar.gz: 2e7646185c12d2c10b407899f6d0c71d4a8260653821d38c1c4cf3a9849b2af8
5
5
  SHA512:
6
- metadata.gz: 694719ed28c757b29df505ebc55b836561ae24aa6df84d51c6956e30dd99b8f84bc1eb79edd63af64c3c2fe6b2d25c4875386214f9c81e2c98584eafe1ecd354
7
- data.tar.gz: dd6f355238fe4a7b120dc35007a5cdf5cd27d22f5803d4b1c2a8f87984f82f896645489f82a94ccbbfc5e9cb937a9e62fcfc090fc23ab51b7097c6d51a86e099
6
+ metadata.gz: cc06044da994a650876616956624c65cfb454f632f748212172ddb9c7e5bb6dd6e55e310253315d0693c007128923500193028ec7bf37ea10ded236743f0f186
7
+ data.tar.gz: 67cd395f4c53fae5d0c28576c2525d087a2e00cdc200272df7fa6167712c347361aa670f4e65d2770a189ad4f8cf59cdce0392711e509cea0756217117236a97
data/.rubocop.yml CHANGED
@@ -5,6 +5,9 @@ AllCops:
5
5
  NewCops: enable
6
6
  SuggestExtensions: false
7
7
 
8
+ # 暂时无法添加验证
9
+ Gemspec/RequireMFA:
10
+ Enabled: false
8
11
  # 弱ruby版本的gem,所有目前不需要检测ruby版本
9
12
  Gemspec/RequiredRubyVersion:
10
13
  Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sparrow-entity (0.1.0)
4
+ sparrow-entity (0.1.1)
5
5
  activemodel
6
6
  activemodel_object_info (~> 0.2.0)
7
7
  activesupport
@@ -0,0 +1,11 @@
1
+ Description:
2
+ Create a new sparrow entity class file that inherite from Sparrow::Base.
3
+
4
+ Example:
5
+ rails generate sparrow:entity MyNameSpace::MyEntity
6
+
7
+ will create files as below:
8
+ app
9
+ entities
10
+ my_name_space
11
+ my_entity.rb
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sparrow
4
+ #
5
+ # 创建一个自定义的创建 Sparrow::Base 的类。
6
+ #
7
+ # @author Shiner <shiner527@hotmail.com>
8
+ #
9
+ class EntityGenerator < Rails::Generators::NamedBase
10
+ # 默认的引入应用的相对安装路径
11
+ TARGET_RELATIVE_PATH = 'app/entities'
12
+
13
+ source_root File.expand_path('templates', __dir__)
14
+
15
+ #
16
+ # 复制模板文件到对应 Rails 项目中
17
+ #
18
+ def create_sparrow_class_file
19
+ sparrow_file_path = ::File.join(TARGET_RELATIVE_PATH, class_path, "#{file_name}.rb")
20
+ template 'sparrow_entity.rb.erb', sparrow_file_path
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SparrowEntity
4
+ #
5
+ # Create a sparrow entity class named <%= class_name %> by generator.
6
+ #
7
+ class <%= class_name %> < ::Sparrow::Base
8
+ #
9
+ # Useage:
10
+ #
11
+ # use field DSL to define attribute.
12
+ # like: <tt>field :name, String</tt> to define an string attribute called +name+.
13
+ #
14
+ end
15
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Sparrow
4
4
  # 当前版本号
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  # 当前综述
7
7
  SUMMARY = 'Provide an easy approach to build entity object for data that can not be reflected to database tables.'
8
8
  # 当前详述
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparrow-entity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - shiner
@@ -176,6 +176,9 @@ files:
176
176
  - bin/setup
177
177
  - lib/config/locales/sparrow/base.en.yml
178
178
  - lib/config/locales/sparrow/base.zh-CN.yml
179
+ - lib/generators/sparrow/entity/USAGE
180
+ - lib/generators/sparrow/entity/entity_generator.rb
181
+ - lib/generators/sparrow/entity/templates/sparrow_entity.rb.erb
179
182
  - lib/sparrow.rb
180
183
  - lib/sparrow/base.rb
181
184
  - lib/sparrow/class_methods.rb