bogy 1.1.0.1 → 1.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: ae5f8172026336360da584339aa6828cca89d03a
4
- data.tar.gz: 189ee0b2e3b8d012c6dec8ddc03b89194e795357
3
+ metadata.gz: 017b3b815d63846fd691bb52d4d00e1cd5a9fbfc
4
+ data.tar.gz: 5c179c98447f8da644bf1b18bee7335045b9e262
5
5
  SHA512:
6
- metadata.gz: b433efe21ce508cca6ef71205c287e3cace5b54b6ff67768a1f6bac5263abeca62e96086112c01a4ef31e29705f8347d749170c058536f505b88d16980bbd29a
7
- data.tar.gz: 292baa92592073b05829fb3578b8ab2600db2ef0a164f8bac5acdcbae6e93459282389a16869e4687174c0d9a5e71ff780247d80492c5b8feb7eabaa356c05e6
6
+ metadata.gz: 2821f00a1ca2b99d8d9e68aef66fafd60b7761b827560cd81d0038c2c5bd5466b91a3c54cb12065e45c5ef8ac6e85b421b8333168369e836c7e47ad1a2fad546
7
+ data.tar.gz: 9dec09f747276eec7aa02e47b75f7f9256893b5c68cb3caa7fdcad774b74f153bffc9810bdbf42953f16eb4a654c5c8d294458b359190cc31a10838d60ae7f19
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # nehm change log
2
2
 
3
+ ## 1.1.1
4
+ * Handle more errors
5
+ * Some optimizations
6
+
3
7
  ## 1.1.0.1
4
8
  * Add required Ruby version (>=1.9.3)
5
9
 
@@ -9,4 +13,4 @@
9
13
  * Add test coverage (RSpec)
10
14
 
11
15
  ## 1.0
12
- * First version
16
+ * First release
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- *bogy* is Ruby wrapper for YAML, which provides a little more convenient interaction with YAML
1
+ *bogy* is tiny Ruby tool, which provides a little more convenient interaction with YAML
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/bogy.svg)](http://badge.fury.io/rb/bogy)
4
4
  [![Build Status](https://travis-ci.org/bogem/bogy.svg?branch=master)](https://travis-ci.org/bogem/bogy)
@@ -7,7 +7,11 @@
7
7
 
8
8
  ## Installation
9
9
 
10
- $ gem install bogy
10
+ `gem install bogy`
11
+
12
+ **or**
13
+
14
+ add `gem 'bogy'` to your application's Gemfile
11
15
 
12
16
  ## Available methods
13
17
  ```ruby
@@ -15,20 +19,20 @@
15
19
  path = 'file.yml'
16
20
  yaml = Bogy.new(file: path)
17
21
 
22
+ # Parsing hashes
23
+ hash = { 'a' => 1, 'b' => 2 }
24
+ yaml = Bogy.new(hash: hash)
25
+
18
26
  # Parsing strings
19
- string = "---\n:a: 1\n:b: 2\n" # Looks {a: 1, b: 2} as hash
27
+ string = "---\na: 1\nb: 2\n" # Looks {'a' => 1, 'b' => 2} as hash
20
28
  yaml = Bogy.new(string: string)
21
29
 
22
30
  yaml['foo'] = 'bar' # => "bar". Automatically writes to file, if you parse file
23
31
  yaml['foo'] # => "bar"
24
32
  yaml.delete('foo') # => "bar". Also automatically writes to file, if you parse file
25
- yaml.to_h # => {:a=>1, :b=>2}
26
- yaml.to_yaml # => ---\n:a: 1\n:b: 2\n"
27
- yaml.write_to_file('another_yaml_file.yml') # Writes to 'another_yaml_file.yml' file
28
-
29
- # Also you can easy convert hash to YAML and write it to file
30
- hash = {a: 1, b:2}
31
- Bogy.new(hash: hash).write_to_file('file.yml') # Automatically converts to YAML
33
+ yaml.to_h # => {'a'=>1, 'b'=>2}
34
+ yaml.to_yaml # => ---\na: 1\nb: 2\n"
35
+ yaml.write_to_file('yaml_file.yml') # Converts to YAML and writes to 'yaml_file.yml' file
32
36
  ```
33
37
 
34
38
  ## License
data/bogy.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['albertnigma@gmail.com']
11
11
 
12
12
  spec.summary = %q{Ruby wrapper for YAML}
13
- spec.description = %q{bogy is Ruby wrapper for YAML, which provides a little more convenient interaction with YAML}
13
+ spec.description = %q{bogy is tiny Ruby tool, which provides a little more convenient interaction with YAML}
14
14
  spec.homepage = 'https://github.com/bogem/bogy'
15
15
  spec.license = 'MIT'
16
16
  spec.required_ruby_version = '>= 1.9.3'
data/lib/bogy.rb CHANGED
@@ -7,19 +7,17 @@ require 'bogy/hash_handler'
7
7
  require 'bogy/string_handler'
8
8
 
9
9
  class Bogy
10
- def initialize(options = nil)
11
- # If user provides no arguments
12
- fail ArgumentError, 'wrong number of arguments (0 for 1)' if options.nil?
13
-
14
- # If user provides more than one arguments
15
- fail ArgumentError, 'you should provide only one argument' if options.length > 1
10
+ def initialize(options = {})
11
+ # If user provides incorrect number of arguments (not one)
12
+ fail ArgumentError, "wrong number of arguments (#{options.length} for 1)" if options.length > 1 || options.empty?
16
13
 
17
14
  @handler =
18
- if options[:file]
15
+ case
16
+ when options[:file]
19
17
  FileHandler.new(options[:file])
20
- elsif options[:hash]
18
+ when options[:hash]
21
19
  HashHandler.new(options[:hash])
22
- elsif options[:string]
20
+ when options[:string]
23
21
  StringHandler.new(options[:string])
24
22
  end
25
23
  end
data/lib/bogy/handler.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  class Bogy
2
2
  # Abstract class for handlers (FileHandler, StringHandler...)
3
+ # Handler is object, which can work with certain data type (string, YAML file and etc.)
4
+ # and convert it to Ruby hash
3
5
  class Handler
4
6
  def hash
5
- load_to_hash
7
+ @hash ||= load
6
8
  end
7
9
 
10
+ # Abstract method
11
+ # Used to convert raw YAML data from specified format to Ruby hash
8
12
  def load; end
9
-
10
- def load_to_hash
11
- @hash ||= load
12
- end
13
13
  end
14
14
  end
data/lib/bogy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Bogy
2
- VERSION = '1.1.0.1'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  end
@@ -1,4 +1,6 @@
1
1
  class Bogy
2
+ # Abstract module
3
+ # Used to specify what handler can write
2
4
  module Writeable
3
5
  def write; end
4
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bogy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Nigmatzianov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-30 00:00:00.000000000 Z
11
+ date: 2015-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,8 +52,8 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.3.0
55
- description: bogy is Ruby wrapper for YAML, which provides a little more convenient
56
- interaction with YAML
55
+ description: bogy is tiny Ruby tool, which provides a little more convenient interaction
56
+ with YAML
57
57
  email:
58
58
  - albertnigma@gmail.com
59
59
  executables: []
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  version: '0'
96
96
  requirements: []
97
97
  rubyforge_project:
98
- rubygems_version: 2.4.8
98
+ rubygems_version: 2.4.5.1
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: Ruby wrapper for YAML