ure 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -8
  3. data/lib/ure.rb +5 -0
  4. data/lib/ure/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f70fe64c299b01a7ea6d18f7c2ffeb6a2ef04572
4
- data.tar.gz: 27b4ba48a4077d2f007b8cff162210c0bf3a3e25
3
+ metadata.gz: 4b6e4af6f9aceb6ccaae506d0f01b1570684f08d
4
+ data.tar.gz: a444a0e82e8e8af10231d6aa84f2b60177fb4db6
5
5
  SHA512:
6
- metadata.gz: a64ff371368b8ecd06ee910e98c3fd1402d2d452a21189105591b32edab30886f599834352d3b00efc34ecb4d3949c85a4c93186bcdd2aa1e61f1c852577babf
7
- data.tar.gz: 24f04a01da14333d93c74ce4956862e0cfa4b7a69a6145c308431997642bb107d847b461aef1e957db4ab28b2794d37e13c2faffe9da192ac9fd8c01b812fa47
6
+ metadata.gz: 4d5cea8d5056c9ed72023dfdf90f5be85c7faa7726a5be5bdd42ee97e1daeb6f2a665a30498e1fd096ba7af3441100955992ded9b95518267a2df05ef9f1d327
7
+ data.tar.gz: ceb805bd1094ee93722e1cce7d6d7abe204735f892751cb4d1484c7d276433fb5d75c16c40deb12ff2d00b9b72e917b1169f10332d7859fcf8c2c7a952c5eac8
data/README.md CHANGED
@@ -29,7 +29,7 @@ require 'ure'
29
29
  Car = Ure.new(:paint, :year)
30
30
  => Car
31
31
  scooby_van = Car.new(year: 1965, paint: :mural)
32
- => #ure {:year=>1968, :paint=>:mural}
32
+ => #<Ure Car {:year=>1968, :paint=>:mural}>
33
33
  ```
34
34
  Notice that it no longer matters what order `:year` and `:paint` are given to `Car`, because we have keyword arguments.
35
35
 
@@ -46,7 +46,7 @@ Also, what happens if we try to change the values in an existing Ure data object
46
46
 
47
47
  ```ruby
48
48
  scooby_van = Car.new(year: 1965, paint: :mural)
49
- => #ure {:year=>1968, :paint=>:mural}
49
+ => #<Ure Car {:year=>1968, :paint=>:mural}>
50
50
  scooby_van.year = 2000
51
51
  NoMethodError: undefined method `year=' for #<ure {:year=>1965, :paint=>:mural}
52
52
  ```
@@ -80,30 +80,32 @@ Ure's current public instance methods are:
80
80
 
81
81
  `#members` - Returns an array of the required keywords.
82
82
 
83
+ `#fields` - Returns a hash with members as keys, along with their values.
84
+
83
85
  `#[]` - Because Ure doesn't care about indexing, this allows users to treat instances of Ure as a hash.
84
86
 
85
87
  `#each(&block)` - Converts the fields into a hash and calls each on them.
86
88
 
87
89
  `#to_s` - Returns a string describing the object and its fields.
88
90
 
89
- `#inspect`- Alians for `.to_s`
91
+ `#inspect`- Alias for `#to_s`.
90
92
 
91
- `#to_a` - Alias for `.values`.
93
+ `#to_a` - Alias for `#values`.
92
94
 
93
- `#to_h` - Returns a hash of the fields.
95
+ `#to_h` - Alias for `#fields`.
94
96
 
95
97
  `#values` - Returns an array of the values in the fields.
96
98
 
97
99
  `#values_at` - Takes one or more keys as arguments, and returns an array of the corresponding values.
98
100
 
99
- `#class` - Returns `Ure`
101
+ `#class` - Returns the class the instance of Ure is defined on.
102
+
103
+ `#to_json` - Returns a JSON string of members and values.
100
104
 
101
105
  ## Development
102
106
 
103
107
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
104
108
 
105
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
106
-
107
109
  ## Contributing
108
110
 
109
111
  Bug reports and pull requests are welcome on GitHub at https://github.com/Calvyn82/ure. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
data/lib/ure.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "ure/version"
2
+ require "json"
2
3
  class Ure < BasicObject
3
4
  include ::Enumerable
4
5
  def self.members
@@ -96,4 +97,8 @@ class Ure < BasicObject
96
97
  def values_at(name, *args)
97
98
  [fields[name]] + args.map { |arg| fields[arg] }
98
99
  end
100
+
101
+ def to_json
102
+ fields.to_json
103
+ end
99
104
  end
@@ -1,3 +1,3 @@
1
1
  class Ure < BasicObject
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clayton Flesher
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-11-11 00:00:00.000000000 Z
12
+ date: 2015-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler