named_struct 0.0.3 → 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: 7904d5b46e59f5e547f6653815d5bf363329debf
4
- data.tar.gz: e27ead301505659b0556429dc3d2e3900fd2b9e0
3
+ metadata.gz: ae1793d1da62fd8718f8ef432325a042b3980490
4
+ data.tar.gz: 34a30c19895ded3b8d90b71b7c823d16873d886d
5
5
  SHA512:
6
- metadata.gz: 1df6d8ee0b37ec1c381520333c20d042c6d39226b5e52e6d418ae7dcc8fd1c1fd0fd3f1b05a2e9583199f960095ac2bde146ef216671744663e5f839ab31ae05
7
- data.tar.gz: 4f59ada8aa4d2af8be8f39cb6e6b3cf21e313594a06c95d87e6f743b58be6776a7723c4abc6410447bb87c5e1847ec8fe40adc8dd12b679cf34d674e3746a708
6
+ metadata.gz: f32cf81f1dd1f406adcca6876ceabf23d4929f014780b767c10e27712005dbbe9603fb9cfa54312cf186fa91d6301822fd275ffda2e7bf5ba1d8b9f073371ffd
7
+ data.tar.gz: ffc006124e55c8c6ee35e2ad13c2700f02554697907da791bcf2778bb0105cb3530f17da799ba2758873689997e65f63440b9907fb7edca35176a64daea0df55
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - 2.1.1
5
+ - 2.1.2
6
+ - 2.1.3
7
+ - ruby-head
8
+ - jruby-head
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # NamedStruct
1
+ # NamedStruct [![Build Status](https://travis-ci.org/mshytikov/named_struct.svg?branch=master)](https://travis-ci.org/mshytikov/named_struct) [![Code Climate](https://codeclimate.com/github/mshytikov/named_struct/badges/gpa.svg)](https://codeclimate.com/github/mshytikov/named_struct)
2
2
 
3
3
  Simple object to wrap your configuration, it can be instantiated only
4
4
  with required named arguments.
@@ -45,6 +45,8 @@ Or install it yourself as:
45
45
  ## Usage
46
46
 
47
47
  ```
48
+ require 'named_struct'
49
+
48
50
  class MyConfig < NamedStruct::Config
49
51
  attr_required :a, :b, :c
50
52
  end
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
8
+
@@ -29,6 +29,10 @@ module NamedStruct
29
29
  end
30
30
  args.each{|k, v| instance_variable_set("@#{k}".to_sym, v)}
31
31
  end
32
+
33
+ def to_h
34
+ self.class.members.map{|k| [k, public_send(k)] }.to_h
35
+ end
32
36
  end
33
37
 
34
38
  end
@@ -1,3 +1,3 @@
1
1
  module NamedStruct
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -32,6 +32,11 @@ RSpec.describe NamedStruct::Config do
32
32
  it { is_expected.to be_frozen }
33
33
  end
34
34
 
35
+ describe '#to_h' do
36
+ subject{ MyConfig.new(a: 10, b: 11).to_h }
37
+ it { is_expected.to eq({ a: 10, b: 11 }) }
38
+ end
39
+
35
40
  context "without arguments" do
36
41
  subject{ MyConfig.new}
37
42
  let(:error_message) { "missing keyword: a, b" }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: named_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Shytikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-08 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -88,6 +88,7 @@ extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
90
  - ".gitignore"
91
+ - ".travis.yml"
91
92
  - Gemfile
92
93
  - LICENSE.txt
93
94
  - README.md