has_magic_fields 0.0.1 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb713aa099438a9901feff56b085d42bdad641b2
4
- data.tar.gz: 847b8af1426f1ece5b7977287daf2285b8df9029
3
+ metadata.gz: 31bc757d95225e509a6013dc6b53f782b6699d34
4
+ data.tar.gz: 723cf257a31047170f431c91e4bbf2caeb927ec7
5
5
  SHA512:
6
- metadata.gz: 7c10c59001c407cc3919d991917daa638e4c7f26cf5b9729564b00df3988c0b2be400be2e6555a1e5c9920f26fea614b96bcb8dbc9fe25a6ab758006852cb3aa
7
- data.tar.gz: 57d5d0600678bba874dc9d45a7a49529e94383a089f4ef7499b2d852e340d88c090bd2005515cf86adf53f1f68ba975a830bb35b7fbe44c8933afc20c7b10ff3
6
+ metadata.gz: 6a15a87a56202a8a068f069639528abe982964dea3b385f4cffafbc884345042a5e7033529c4cc0e5b09e7f60c48a17a8c743105d33241297124b8afdcc8f225
7
+ data.tar.gz: e3f5cbad80d4192ab97860574178492cb988c926e7670c31b4b28c79389c16df9938d120bde08f9741a03d71a7255a93279942e6c70310008697f07a30087240
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ bundler_args: --without development
3
+
4
+ env:
5
+ - USE_OFFICIAL_GEM_SOURCE=1
6
+
7
+ rvm:
8
+ - 2.0.0
9
+
10
+ script: RAILS_ENV=test rake test:default
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
- source "http://ruby.taobao.org"
1
+ # source "http://ruby.taobao.org"
2
+ source 'https://rubygems.org'
2
3
 
3
4
  gem 'rails', ' >= 4.0.0'
4
5
 
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # HasMagicFields
2
2
  [![Gem Version](https://badge.fury.io/rb/has_magic_fields.png)](http://badge.fury.io/rb/has_magic_fields)
3
+ [![CI Status](https://travis-ci.org/ikeqiao/has_magic_fields.svg)](https://travis-ci.org/ikeqiao/has_magic_fields)
3
4
 
4
5
  Allows the addition of custom "magic" fields and attributes on a per-model
5
6
  or per-parent-model basis. This is useful for situations where custom fields are
@@ -41,15 +42,15 @@ Add magic fields to your model:
41
42
 
42
43
  ```ruby
43
44
  @charlie = Person.create(:email => "charlie@example.com")
44
- @charlie.create_magic_fields(:name => "first_name")
45
+ @charlie.create_magic_field(:name => "first_name")
45
46
  ```
46
47
 
47
48
  Supply additional options if you have more specific requirements for your fields:
48
49
 
49
50
  ```ruby
50
- @charlie.create_magic_fields(:name => "last_name", :is_required => true)
51
- @charlie.create_magic_fields(:name => "birthday", :datatype => :date)
52
- @charlie.create_magic_fields(:name => "salary", :default => "40000", :pretty_name => "Yearly Salary")
51
+ @charlie.create_magic_field(:name => "last_name", :is_required => true)
52
+ @charlie.create_magic_field(:name => "birthday", :datatype => :date)
53
+ @charlie.create_magic_field(:name => "salary", :default => "40000", :pretty_name => "Yearly Salary")
53
54
  ```
54
55
 
55
56
  The `:datatype` option supports: `:check_box_boolean`, `:date`, `:datetime`, `:integer`
@@ -107,14 +108,14 @@ To see all the magic fields available for a type_scoped(User) child from its par
107
108
  To add magic fields, go through the parent or child:
108
109
 
109
110
  ```ruby
110
- @alice.create_magic_fields(...)
111
- @account.create_magic_fields(…,:type_scoped => "User")
111
+ @alice.create_magic_field(...)
112
+ @account.create_magic_field(…,:type_scoped => "User")
112
113
  ```
113
114
 
114
115
  All User children for a given parent will have access to the same magic fields:
115
116
 
116
117
  ```ruby
117
- @alice.create_magic_fields(:name => "salary")
118
+ @alice.create_magic_field(:name => "salary")
118
119
  @alice.salary = "40000"
119
120
 
120
121
  @bob = User.create(:name => "bob", :account => @account)
@@ -140,7 +141,7 @@ end
140
141
 
141
142
  parent @account also haven't salary magic field
142
143
 
143
- ## get all magic fields
144
+ ## Get All Magic Fields
144
145
  ```ruby
145
146
  @account.magic_fields #get all meagic_fields both self and children
146
147
  @account.magic_fields_with_scoped #get all meagic_fields self
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require 'rake'
2
- require "rspec"
3
- require File.expand_path('../spec/spec_helper', __FILE__)
1
+ namespace :test do
2
+ desc "run rspec spec "
4
3
 
5
- task :default do
6
- system 'bundle exec rspec spec'
7
- end
4
+ task :default do
5
+ system 'rspec spec'
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module HasMagicFields
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_magic_fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ikeqiao
@@ -61,6 +61,7 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - .gitignore
63
63
  - .rspec
64
+ - .travis.yml
64
65
  - Gemfile
65
66
  - LICENSE.txt
66
67
  - README.md