diff --git a/.circleci/config.yml b/.circleci/config.yml index 5feeeb4..ed97a0b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ jobs: - image: cimg/postgres:14.1 environment: POSTGRES_USER: circleci - POSTGRES_DB: serialized_attributes_test + POSTGRES_DB: serialize_attributes_test POSTGRES_PASSWORD: "" POSTGRES_HOST_AUTH_METHOD: trust @@ -55,12 +55,12 @@ jobs: - checkout - run: name: Build package - command: gem build serialized_attributes.gemspec + command: gem build serialize_attributes.gemspec - run: name: Push package command: | - VERSION=$(ruby -r "./lib/serialized_attributes/version.rb" -e "print SerializedAttributes::VERSION") - gem push serialized_attributes-${VERSION}.gem + VERSION=$(ruby -r "./lib/serialize_attributes/version.rb" -e "print SerializeAttributes::VERSION") + gem push serialize_attributes-${VERSION}.gem workflows: default: diff --git a/Gemfile.lock b/Gemfile.lock index 2bb45e5..1d8f139 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - serialized_attributes (0.1.0) + serialize_attributes (0.1.0) activemodel (>= 6) GEM @@ -175,7 +175,7 @@ DEPENDENCIES rake rubocop rubocop-rails - serialized_attributes! + serialize_attributes! BUNDLED WITH 2.2.30 diff --git a/README.md b/README.md index 62f1c31..c115d44 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# serialized_attributes +# serialize_attributes Serialize ActiveModel attributes in JSON using type casting: @@ -24,7 +24,7 @@ Add `serialized_atributes` to your Gemfile: $ bundle add serialized_atributes ``` -Next, include `SerializedAttributes` in your model class (or `ApplicationRecord` if you want to make +Next, include `SerializeAttributes` in your model class (or `ApplicationRecord` if you want to make it available everywhere). Your model should have a JSON (or JSONB) attribute, for example this one is called `settings`: @@ -38,7 +38,7 @@ Then, tell the model what attributes we'll be storing there: ```ruby class MyModel < ActiveRecord::Base - include SerializedAttributes + include SerializeAttributes serialize_attributes :settings do attribute :user_name, :string @@ -125,7 +125,7 @@ It's also possible to use this library without `ActiveRecord`: class MyModel include ActiveModel::Model include ActiveModel::Attributes - include SerializedAttributes + include SerializeAttributes # ActiveModel doesn't include a native Hash type, we can just use the Value # type here for demo purposes: diff --git a/lib/serialized_attributes.rb b/lib/serialize_attributes.rb similarity index 79% rename from lib/serialized_attributes.rb rename to lib/serialize_attributes.rb index 22e02a3..53fc3b2 100644 --- a/lib/serialized_attributes.rb +++ b/lib/serialize_attributes.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require "serialized_attributes/version" -require "serialized_attributes/store" +require "serialize_attributes/version" +require "serialize_attributes/store" # Serialize ActiveModel attributes in JSON using type casting -module SerializedAttributes +module SerializeAttributes extend ActiveSupport::Concern class_methods do - # Configure a SerializedAttributes::Store, using the given column to store each + # Configure a SerializeAttributes::Store, using the given column to store each # attribute. # # class Person @@ -25,7 +25,7 @@ def serialize_attributes(column_name, &block) @serialized_attribute_stores[column_name] = Store.new(self, column_name, &block) end - # Retrieve a SerializedAttributes registered against the given column + # Retrieve a SerializeAttributes registered against the given column # # Person.serialized_attributes_store(:settings) def serialized_attributes_store(column_name) @@ -40,7 +40,7 @@ def serialized_attribute_names(column_name) end end - # Retrieve all of the SerializedAttributes attributes, including their default values + # Retrieve all of the SerializeAttributes attributes, including their default values # # person = Person.new # person.serialized_attributes_on(:settings) diff --git a/lib/serialized_attributes/store.rb b/lib/serialize_attributes/store.rb similarity index 97% rename from lib/serialized_attributes/store.rb rename to lib/serialize_attributes/store.rb index 19abd95..b989140 100644 --- a/lib/serialized_attributes/store.rb +++ b/lib/serialize_attributes/store.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -module SerializedAttributes - # SerializedAttributes::Store is the individual store, keyed by name. You can get a +module SerializeAttributes + # SerializeAttributes::Store is the individual store, keyed by name. You can get a # reference to the store by calling `Model.serialized_attributes_store(column_name)`. class Store def initialize(model_class, column_name, &block) # :nodoc: diff --git a/lib/serialized_attributes/version.rb b/lib/serialize_attributes/version.rb similarity index 66% rename from lib/serialized_attributes/version.rb rename to lib/serialize_attributes/version.rb index fddf3ac..fc17118 100644 --- a/lib/serialized_attributes/version.rb +++ b/lib/serialize_attributes/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -module SerializedAttributes +module SerializeAttributes VERSION = "0.1.0" end diff --git a/serialized_attributes.gemspec b/serialize_attributes.gemspec similarity index 67% rename from serialized_attributes.gemspec rename to serialize_attributes.gemspec index 89693e9..68cad7f 100644 --- a/serialized_attributes.gemspec +++ b/serialize_attributes.gemspec @@ -1,19 +1,19 @@ # frozen_string_literal: true -require_relative "lib/serialized_attributes/version" +require_relative "lib/serialize_attributes/version" Gem::Specification.new do |spec| - spec.name = "serialized_attributes" - spec.version = SerializedAttributes::VERSION + spec.name = "serialize_attributes" + spec.version = SerializeAttributes::VERSION spec.authors = ["Zaikio"] spec.email = ["support@zaikio.com"] - spec.homepage = "https://github.com/zaikio/serialized_attributes" + spec.homepage = "https://github.com/zaikio/serialize_attributes" spec.summary = "Serialize ActiveModel attributes in JSON using type casting" spec.license = "MIT" spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = "https://github.com/zaikio/serialized_attributes" - spec.metadata["changelog_uri"] = "https://github.com/zaikio/serialized_attributes/blob/main/CHANGELOG.md" + spec.metadata["source_code_uri"] = "https://github.com/zaikio/serialize_attributes" + spec.metadata["changelog_uri"] = "https://github.com/zaikio/serialize_attributes/blob/main/CHANGELOG.md" spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] diff --git a/serialized_attributes-0.1.0.gem b/serialized_attributes-0.1.0.gem new file mode 100644 index 0000000..9658d62 Binary files /dev/null and b/serialized_attributes-0.1.0.gem differ diff --git a/test/dummy/app/models/application_record.rb b/test/dummy/app/models/application_record.rb index a4b6ca7..d0a5f2f 100644 --- a/test/dummy/app/models/application_record.rb +++ b/test/dummy/app/models/application_record.rb @@ -1,5 +1,5 @@ class ApplicationRecord < ActiveRecord::Base self.abstract_class = true - include SerializedAttributes + include SerializeAttributes end diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index ad3c331..823e61e 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -5,7 +5,7 @@ # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -require "serialized_attributes" +require "serialize_attributes" module Dummy class Application < Rails::Application diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml index aacd2fc..745fac8 100644 --- a/test/dummy/config/database.yml +++ b/test/dummy/config/database.yml @@ -5,11 +5,11 @@ default: &default development: <<: *default - database: serialized_attributes_development + database: serialize_attributes_development # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default - database: serialized_attributes_test + database: serialize_attributes_test diff --git a/test/serialized_attributes_test.rb b/test/serialized_attributes_test.rb index c5ba31e..dcfbc45 100644 --- a/test/serialized_attributes_test.rb +++ b/test/serialized_attributes_test.rb @@ -2,7 +2,7 @@ require "test_helper" -class SerializedAttributesTest < ActiveSupport::TestCase +class SerializeAttributesTest < ActiveSupport::TestCase test "loading and reloading a complex model" do record = MyModel.create!(normal_column: "yes", data: { "booly" => false, "stringy" => "present" }) @@ -54,7 +54,7 @@ def secret local = Class.new do include ActiveModel::Model include ActiveModel::Attributes - include SerializedAttributes + include SerializeAttributes attribute :settings, ActiveModel::Type::Value.new