ishin 0.1.0 → 0.2.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: 9fd416241ae632c771e85f2cbb4a8ecb151b6226
4
- data.tar.gz: a2c3b7dccd9496fee3e790e58684bd782644e75f
3
+ metadata.gz: b5ed152cc96db8d638bde56aa627fc3fe4019038
4
+ data.tar.gz: 052b32431e70c55e0fe3497ca2e586ad86c031aa
5
5
  SHA512:
6
- metadata.gz: a06fd4e613aab614d59d635369ab2b4b4be16ed6aadbe9dcae441a9515ec962d93a55a16a29ce5e36c4afb52f19cae90a1da3dbce58cb1af566bbb6035fe0f54
7
- data.tar.gz: 5cff38f8588ed32d1b51eccafad2a97d7196983c406a365f8d2fff5ec1995bf44959020f54512fac1473aae05e9b735c47d0ff4aedb5cedf3110062fc1448850
6
+ metadata.gz: 087e9073b09d19c6001d386634165febbc9b9689343cdb00be535c3b2a0710b3862d3b8d79e7130efaa420e9c9fad4705c40f374ec50f09d406059428ef96f6c
7
+ data.tar.gz: aa5cb190539f3883c00b36204c8d4da0b19f66ed9c65dbb377aee7f50325dc20a5c2d022f7e838e09026a11a174f5f04cbf707084c3b1e37192328bcdd4c5318
data/.travis.yml CHANGED
@@ -1,3 +1,5 @@
1
+ script: "bundle exec rake"
1
2
  language: ruby
2
3
  rvm:
3
4
  - 2.2.0
5
+ - 2.2.2
data/README.md CHANGED
@@ -1,3 +1,8 @@
1
+ [![Code Climate](https://codeclimate.com/github/EddyLuten/ishin/badges/gpa.svg)](https://codeclimate.com/github/EddyLuten/ishin)
2
+ [![Test Coverage](https://codeclimate.com/github/EddyLuten/ishin/badges/coverage.svg)](https://codeclimate.com/github/EddyLuten/ishin)
3
+ [![Gem Version](https://img.shields.io/gem/v/ishin.svg)](https://rubygems.org/gems/ishin)
4
+ [![Build Status](https://travis-ci.org/EddyLuten/ishin.svg?branch=master)](https://travis-ci.org/EddyLuten/ishin)
5
+
1
6
  # Ishin
2
7
 
3
8
  Ishin converts Ruby objects into their Hash representations. It works with plain old classes, extended classes, classes with mixins, and hashes (see Usage for more on that).
@@ -18,7 +23,9 @@ Or install it manually by:
18
23
 
19
24
  gem install ishin
20
25
 
21
- ## Usage
26
+ ## Example
27
+
28
+ As a class method callable on any object:
22
29
 
23
30
  ```ruby
24
31
  require 'ishin'
@@ -26,7 +33,19 @@ require 'ishin'
26
33
  hash = Ishin.to_hash(my_object)
27
34
  ```
28
35
 
29
- ### Introduction
36
+ Or included in your object as a mixin:
37
+
38
+ ```ruby
39
+ class YourClass
40
+ include Ishin::Mixin
41
+ # etc.
42
+ end
43
+
44
+ instance = YourClass.new
45
+ hash = instance.to_hash
46
+ ```
47
+
48
+ ### Usage
30
49
 
31
50
  A simple example is worth a thousand words:
32
51
 
@@ -110,6 +129,19 @@ Ishin.to_hash(lassie, symbolize: false)
110
129
  ```
111
130
  When setting the `symbolize` option to `false`, the explicit conversion of strings to symbols is prevented. This, however, does *not* mean that hashes whose keys are already symbols are converted into string-based keys.
112
131
 
132
+ ## As a Mixin
133
+
134
+ To use Ishin as a mixin in your own objects, simply include `Ishin::Mixin`:
135
+
136
+ ```ruby
137
+ class MyObject
138
+ include Ishin::Mixin
139
+ # etc.
140
+ end
141
+ ```
142
+
143
+ Your object now exposes a method named `to_hash` taking the same options at the `Ishin::to_hash` class method documented above.
144
+
113
145
  ## Running the Specs
114
146
 
115
147
  Once `bundle` is executed, simply run:
data/ishin.gemspec CHANGED
@@ -20,8 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.8"
24
23
  spec.add_development_dependency "rake", "~> 10.0"
25
24
  spec.add_development_dependency "rspec"
26
- spec.add_development_dependency "rspec-nc"
25
+ spec.add_development_dependency "codeclimate-test-reporter"
27
26
  end
data/lib/ishin.rb CHANGED
@@ -2,6 +2,12 @@ require 'ishin/version'
2
2
 
3
3
  module Ishin
4
4
 
5
+ module Mixin
6
+ def to_hash options = {}
7
+ Ishin::to_hash(self, options)
8
+ end
9
+ end
10
+
5
11
  def self.to_hash(object, options = {})
6
12
  options = defaults.merge(options)
7
13
  result = {}
data/lib/ishin/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ishin
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ishin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eddy Luten
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.8'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.8'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +39,7 @@ dependencies:
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
- name: rspec-nc
42
+ name: codeclimate-test-reporter
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - ">="
@@ -81,7 +67,6 @@ files:
81
67
  - README.md
82
68
  - Rakefile
83
69
  - bin/console
84
- - bin/setup
85
70
  - ishin.gemspec
86
71
  - lib/ishin.rb
87
72
  - lib/ishin/version.rb
data/bin/setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here