simple_response 0.7.0 → 0.8.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: b8b127d41f2b2ef515fbdbb87348d006ad2212e6
4
- data.tar.gz: 16650b8be8ab004edd6fe2ef7540efc54906a305
3
+ metadata.gz: 79cca8c8031b036591d6dce700aa13183ca57191
4
+ data.tar.gz: 7f05f74e5c801c12deb3fa6b227e515795564fc7
5
5
  SHA512:
6
- metadata.gz: 26ffe67bb2833619847313145607b426f8075660fe90fd85882c4241e77074ec7489d8da527055787e590283afd8b35ae58278edc43eae2a3cbf342494b48ba2
7
- data.tar.gz: cf84ffd0d61d245c527230f89935c13f1b09b3e02e8678ffb1eec1a86f840677c9b2b2a4b2895cdbd8f7a05289a1e73914a28d1c1057819430e4266e98758286
6
+ metadata.gz: 4907e80e6b7b8d69e7c30956ab00802fa867743957e52a0ce32d3feb403f51a21eca83b0629433a574a4cc6cfcdeba1f0f937ff8efcc76691546b6f9c56d63b9
7
+ data.tar.gz: 3c248095bedca406875f10282438c2fa384286702874bace55cf992435bc5fd9f2fc91438a1f8fb4bf07dfaf704467ed2b13dbfde3ae9a3c999935b6c708a42b
data/.travis.yml CHANGED
@@ -3,3 +3,16 @@ language: ruby
3
3
  rvm:
4
4
  - 2.4.1
5
5
  before_install: gem install bundler -v 1.16.0
6
+
7
+ # CodeClimate Test Reporter
8
+ env:
9
+ global:
10
+ - CC_TEST_REPORTER_ID=85ec0a91376be74d800a1e40b70953d95e83c102d67489c6db7d31c5d3858e88
11
+ before_script:
12
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
13
+ - chmod +x ./cc-test-reporter
14
+ - ./cc-test-reporter before-build
15
+ script:
16
+ - bundle exec rspec
17
+ after_script:
18
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in simple_response.gemspec
6
6
  gemspec
7
+
8
+ gem 'simplecov', require: false, group: :test
data/Gemfile.lock CHANGED
@@ -1,12 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_response (0.5.0)
4
+ simple_response (0.8.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  diff-lcs (1.3)
10
+ docile (1.1.5)
11
+ json (2.1.0)
10
12
  rake (10.5.0)
11
13
  rspec (3.7.0)
12
14
  rspec-core (~> 3.7.0)
@@ -21,6 +23,11 @@ GEM
21
23
  diff-lcs (>= 1.2.0, < 2.0)
22
24
  rspec-support (~> 3.7.0)
23
25
  rspec-support (3.7.1)
26
+ simplecov (0.15.1)
27
+ docile (~> 1.1.0)
28
+ json (>= 1.8, < 3)
29
+ simplecov-html (~> 0.10.0)
30
+ simplecov-html (0.10.2)
24
31
 
25
32
  PLATFORMS
26
33
  ruby
@@ -30,6 +37,7 @@ DEPENDENCIES
30
37
  rake (~> 10.0)
31
38
  rspec (~> 3.0)
32
39
  simple_response!
40
+ simplecov
33
41
 
34
42
  BUNDLED WITH
35
43
  1.16.0
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  [![Maintainability](https://api.codeclimate.com/v1/badges/54e7c14cd8f10bd26aa5/maintainability)](https://codeclimate.com/github/giovannibenussi/simple-response/maintainability)
2
2
  [![Test Coverage](https://api.codeclimate.com/v1/badges/54e7c14cd8f10bd26aa5/test_coverage)](https://codeclimate.com/github/giovannibenussi/simple-response/test_coverage)
3
3
  <a target="_blank" href="https://badge.fury.io/rb/simple_response"><img src="https://badge.fury.io/rb/simple_response.svg" alt="Gem Version" height="18"></a>
4
+ [![Build Status](https://travis-ci.org/giovannibenussi/simple-response.svg?branch=master)](https://travis-ci.org/giovannibenussi/simple-response)
4
5
 
5
6
  # SimpleResponse
6
7
 
@@ -16,9 +16,5 @@ module SimpleResponse
16
16
  def failure?
17
17
  !success?
18
18
  end
19
-
20
- def keys
21
- to_h.keys
22
- end
23
19
  end
24
20
  end
@@ -1,17 +1,37 @@
1
1
  module SimpleResponse
2
- class SimpleStruct < OpenStruct
2
+ class SimpleStruct
3
3
  include SimpleResponse::QueryMethods
4
4
 
5
+ def initialize(*args)
6
+ @attributes = {}
7
+ end
8
+
5
9
  def method_missing(name, *args, &block)
6
10
  if existing_query_method?(name)
7
11
  query_method(name)
12
+ elsif write_method?(name)
13
+ @attributes[name[0...-1].to_sym] = args.first
14
+ elsif existing_attribute?(name)
15
+ @attributes[name.to_sym]
8
16
  else
9
17
  super
10
18
  end
11
19
  end
12
20
 
21
+ def existing_attribute?(name)
22
+ @attributes.has_key?(name.to_sym)
23
+ end
24
+
13
25
  def respond_to_missing?(name, include_private = false)
14
- existing_query_method?(name)
26
+ existing_attribute?(name) || existing_query_method?(name)
27
+ end
28
+
29
+ def write_method?(name)
30
+ name[-1] == '='
31
+ end
32
+
33
+ def keys
34
+ @attributes.keys
15
35
  end
16
36
  end
17
37
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleResponse
2
- VERSION = '0.7.0'.freeze
2
+ VERSION = '0.8.0'.freeze
3
3
  end
@@ -4,7 +4,7 @@ require "simple_response/response"
4
4
  module SimpleResponse
5
5
  def self.new(success: true, **attributes)
6
6
  SimpleResponse::Response.new(success: success).tap do |response|
7
- attributes.each { |k, v| response[k] = v }
7
+ attributes.each { |k, v| response.send("#{k}=", v) }
8
8
  end
9
9
  end
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_response
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Benussi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-17 00:00:00.000000000 Z
11
+ date: 2018-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler