lingohub_utils 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  class Array
4
2
 
5
3
  # Raises an ArgumentError if the array is empty (contains no items at all, nil objects count as item).
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require "lh/core_extensions/object/raise_if_nil"
3
2
 
4
3
  class Array
@@ -1,10 +1,14 @@
1
1
  require "enumerator"
2
2
 
3
3
  class Array
4
- def to_h
4
+ def to_h(&block)
5
5
  hash = Hash.new
6
6
  self.each_with_index do |item, index|
7
- hash[item] = index
7
+ if block_given?
8
+ hash[item] = yield(item)
9
+ else
10
+ hash[item] = index
11
+ end
8
12
  end
9
13
  hash
10
14
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Hash
3
2
 
4
3
  def raise_if_value_nil(key, message=nil)
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Hash
3
2
 
4
3
  def raise_unless_has_key(key, message=nil)
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Object
3
2
 
4
3
  # Raises an ArgumentError if the object is nil.
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Struct
3
2
 
4
3
  def to_hash
@@ -1,7 +1,6 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require "lh/dependency_injection/context"
3
2
 
4
- module LH
3
+ module Lh
5
4
  module DependencyInjection
6
5
  module Autowire
7
6
  def self.included(base)
@@ -1,4 +1,4 @@
1
- module LH
1
+ module Lh
2
2
  module DependencyInjection
3
3
  class ContextHash
4
4
 
@@ -1,5 +1,4 @@
1
- # -*- encoding : utf-8 -*-
2
- module LH
1
+ module Lh
3
2
  module Exceptions
4
3
  class BaseError < ::StandardError
5
4
  @nested
@@ -1,7 +1,7 @@
1
- # -*- encoding : utf-8 -*-
1
+
2
2
  require 'lh/exceptions/base_error'
3
3
 
4
- module LH
4
+ module Lh
5
5
  module Exceptions
6
6
  class NotFoundError < BaseError
7
7
  def initialize(message = nil)
@@ -1,3 +1,3 @@
1
1
  module LingohubUtils
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -1,5 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  require "spec_helper"
4
2
 
5
3
  describe Array do
@@ -1,5 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  require "spec_helper"
4
2
 
5
3
  describe Array do
@@ -1,5 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  require "spec_helper"
4
2
 
5
3
  describe Array do
@@ -16,6 +14,11 @@ describe Array do
16
14
  ['a', 'b', 'c'].to_h.should eql({'a' => 0, 'b' => 1, 'c' => 2})
17
15
  end
18
16
  end
19
- end
20
17
 
18
+ context "using a block" do
19
+ it "should leave the item as key and the value passed thru the given block as value" do
20
+ ['a', 'b', 'c'].to_h { |i| "#{i}!" }.should eql({'a' => 'a!', 'b' => 'b!', 'c' => 'c!'})
21
+ end
22
+ end
23
+ end
21
24
  end
@@ -1,5 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  require "spec_helper"
4
2
 
5
3
  describe Hash do
@@ -1,5 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  require "spec_helper"
4
2
 
5
3
  describe Hash do
@@ -1,5 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  require "spec_helper"
4
2
 
5
3
  describe Object do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lingohub_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-21 00:00:00.000000000 Z
12
+ date: 2013-11-30 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Util library used by lingohub
15
15
  email:
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  version: '0'
67
67
  requirements: []
68
68
  rubyforge_project:
69
- rubygems_version: 1.8.24
69
+ rubygems_version: 1.8.23
70
70
  signing_key:
71
71
  specification_version: 3
72
72
  summary: This gem contains general util classes and extensions used by other lingohub