pobject 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20dc0805c434c64cf463c8d9b466592c07c05f08
4
- data.tar.gz: ee6b8c53b78befa5a1ef90e3e74b0a330fecced3
3
+ metadata.gz: 623314560836424e756ded9a17712557f2c8d0c1
4
+ data.tar.gz: 360cb6821ec9dda6a64b7f7ec3e26063fa321eaa
5
5
  SHA512:
6
- metadata.gz: d15a6cbca9c7fdb0af9b99433cea357d1c4c78e696736ed41b5e8d15d260660a2e80a430c83cada6a4f35c4160b7634e2e9e47e69e68a502beb428cb5dd904dd
7
- data.tar.gz: 8cd94ca4e4692ddb785c1eaa66821e9ec9eb9462e833d49238bea4ea901aaa037a01d7797c8dabe2bbee29b7fd3b359e703f7ed8ff41e353b692f7c8ed34f7fb
6
+ metadata.gz: 195d279f3842c41b4e24b9ac03a2ccba68122071d1bf12929b576d9d00590bb968ce4368ecdc939c10e0cd2defbdf567efcf4cc9402bd244ff8efc387860b867
7
+ data.tar.gz: 100f4672e6c69c6a76bfb44ae9c19da24a26d303035a16407f164270b7dff7a44f77d9980f369b53de8fdedebf00404aec3161c495e633ef2b20d87e3cff713f
data/README.md CHANGED
@@ -28,7 +28,7 @@ gem 'pobject'
28
28
  Usage
29
29
  --------------------------------------------------
30
30
 
31
- Your object should inherit from PObject.
31
+ Your object should inherit from `PObject`.
32
32
 
33
33
  ```ruby
34
34
  require 'pobject'
@@ -37,8 +37,8 @@ class Settings < PObject
37
37
  end
38
38
  ```
39
39
 
40
- Now, any time you access a property, it is saved to a file. By default, we will
41
- svae a YAML file with the same name as the class:
40
+ Now, any time you access a property, it is saved to a file. By default, we
41
+ will save a YAML file with the same name as the class.
42
42
 
43
43
 
44
44
  ```ruby
@@ -50,9 +50,9 @@ config.port = 3000
50
50
  # Will create a 'settings.yml' file and store the port value
51
51
  ```
52
52
 
53
- You can access any attributes by either dot notation or hash notation.
53
+ You can access any property by either dot notation or hash notation.
54
54
 
55
- ```
55
+ ```ruby
56
56
  config.port
57
57
  # => 3000
58
58
 
@@ -74,8 +74,9 @@ config.port = 3000
74
74
  # Will create a 'config/local.yml'
75
75
  ```
76
76
 
77
- Whenever you use the `.yml` extension, PObject will store a YAML file. If you
78
- wish to store a `PStore` object instead, provide any other extension:
77
+ Whenever you use the `.yml` (or `.yaml`) extension, we will store a YAML
78
+ file. If you wish to store a `PStore` object instead, use any other
79
+ extension.
79
80
 
80
81
  ```ruby
81
82
  class Settings < PObject
@@ -105,6 +106,8 @@ raynor = Hero.new :raynor
105
106
 
106
107
  hammer.name = 'Sgt. Hammer'
107
108
  raynor.name = 'Raynor'
109
+
110
+ puts File.read 'heroes.yml'
108
111
  # =>
109
112
  # ---
110
113
  # :hammer:
@@ -115,7 +118,7 @@ raynor.name = 'Raynor'
115
118
 
116
119
  By default, PObject will raise an error when accessing a property that does
117
120
  not exist. To change this behavior, call `allow_missing` at the beinning of
118
- your object
121
+ your class.
119
122
 
120
123
  ```ruby
121
124
  class Book < PObject
@@ -48,7 +48,7 @@ class PObject
48
48
  # Return a nice string when inspecting or printing.
49
49
  # This will load values from the store if they were not already loaded.
50
50
  def inspect
51
- properties = attributes.map { |var| [var, get(var)].join(":") }.join ', '
51
+ properties = attributes.sort.map { |var| [var, get(var).to_s].join(":") }.join ', '
52
52
  properties = " #{properties}" unless properties.empty?
53
53
  "<#{self.class.name}#{properties}>"
54
54
  end
@@ -63,7 +63,16 @@ class PObject
63
63
  # Return attribute names from the store.
64
64
  # TODO: Maybe also merge with instance_variables. Pay attention to @s.
65
65
  def attributes!
66
- store.transaction { store.roots }.sort
66
+ result = []
67
+ store.transaction do
68
+ if store_key
69
+ result = store[store_key] || {}
70
+ result = result.keys
71
+ else
72
+ result = store.roots
73
+ end
74
+ end
75
+ result = result.select { |a| a.is_a? Symbol }
67
76
  end
68
77
 
69
78
  private
@@ -1,3 +1,3 @@
1
1
  class PObject
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pobject
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-29 00:00:00.000000000 Z
11
+ date: 2016-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: runfile