dmorrill10-utils 1.2.1 → 2.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d69e455e5bbfc1b5dcc894606ed1a0a778ebce8
4
+ data.tar.gz: d1e1efb766d50d5acec49f9b848e050559c8a51f
5
+ SHA512:
6
+ metadata.gz: 2ab9cb4076ca6c9636e0bd2f7eceebe520fd36ed60cf51b80105c753ff6d712151a2e2fca4e86799f6325260ba64e5e4abaf38bf2642137c39c1ec323e7cc5b1
7
+ data.tar.gz: a8b400ed9b9c97ee524042490e64db38eeb11bb498f2cd2f48d7a1b2bb043789a46d627e93681faab6963447e5675a9137934293541036a64779c18f5b32d9bb
@@ -1,14 +1,9 @@
1
1
  require "dmorrill10-utils/version"
2
2
 
3
- require 'dmorrill10-utils/class'
4
- require 'dmorrill10-utils/enumerable'
5
- require 'dmorrill10-utils/integer'
6
3
  require 'dmorrill10-utils/string_form_manipulation'
7
- require 'dmorrill10-utils/process_runner'
8
4
  require 'dmorrill10-utils/singleton_logger'
9
5
  require 'dmorrill10-utils/debug_hash'
10
6
  require 'dmorrill10-utils/yaml'
11
- require 'dmorrill10-utils/object'
12
7
 
13
8
  module Dmorrill10
14
9
  module Utils
@@ -1,5 +1,5 @@
1
1
  module Dmorrill10
2
2
  module Utils
3
- VERSION = "1.2.1"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dmorrill10-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dustin Morrill
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-06 00:00:00.000000000 Z
11
+ date: 2013-05-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: awesome_print
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: mocha
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: simplecov
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: turn
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: My utilities.
@@ -88,12 +79,7 @@ files:
88
79
  - Rakefile
89
80
  - dmorrill10-utils.gemspec
90
81
  - lib/dmorrill10-utils.rb
91
- - lib/dmorrill10-utils/class.rb
92
82
  - lib/dmorrill10-utils/debug_hash.rb
93
- - lib/dmorrill10-utils/enumerable.rb
94
- - lib/dmorrill10-utils/integer.rb
95
- - lib/dmorrill10-utils/object.rb
96
- - lib/dmorrill10-utils/process_runner.rb
97
83
  - lib/dmorrill10-utils/singleton_logger.rb
98
84
  - lib/dmorrill10-utils/string_form_manipulation.rb
99
85
  - lib/dmorrill10-utils/version.rb
@@ -102,27 +88,26 @@ files:
102
88
  - spec/support/spec_helper.rb
103
89
  homepage: https://github.com/dmorrill10/dmorrill10-utils
104
90
  licenses: []
91
+ metadata: {}
105
92
  post_install_message:
106
93
  rdoc_options: []
107
94
  require_paths:
108
95
  - lib
109
96
  required_ruby_version: !ruby/object:Gem::Requirement
110
- none: false
111
97
  requirements:
112
- - - ! '>='
98
+ - - '>='
113
99
  - !ruby/object:Gem::Version
114
100
  version: '0'
115
101
  required_rubygems_version: !ruby/object:Gem::Requirement
116
- none: false
117
102
  requirements:
118
- - - ! '>='
103
+ - - '>='
119
104
  - !ruby/object:Gem::Version
120
105
  version: '0'
121
106
  requirements: []
122
107
  rubyforge_project:
123
- rubygems_version: 1.8.24
108
+ rubygems_version: 2.0.0.rc.2
124
109
  signing_key:
125
- specification_version: 3
110
+ specification_version: 4
126
111
  summary: Group of random Ruby mixin utility functions.
127
112
  test_files:
128
113
  - spec/process_runner_spec.rb
@@ -1,30 +0,0 @@
1
-
2
- require File.expand_path('../string_form_manipulation', __FILE__)
3
-
4
- class Class
5
- # @param [Array] names A list of exception names that the calling class would
6
- # like to define.
7
- def exceptions(*names)
8
- names.each do |name|
9
- error_name = name.to_class_name
10
- const_set(error_name, Class.new(RuntimeError))
11
- end
12
- end
13
-
14
- def alias_new(alias_of_new)
15
- alias_class_method alias_of_new, :new
16
- end
17
-
18
- # @param [#to_sym] alias_method A class method to alias the class method, +method_to_alias+.
19
- # @param [#to_sym] method_to_alias A class method to be aliased by +alias_method+.
20
- def alias_class_method(alias_method, method_to_alias)
21
- singleton_class.alias_method_in_singleton_context alias_method.to_sym, method_to_alias.to_sym
22
- end
23
-
24
- # Must do this operation in singleton context
25
- class << self
26
- def alias_method_in_singleton_context(alias_method, method_to_alias)
27
- alias_method alias_method, method_to_alias
28
- end
29
- end
30
- end
@@ -1,14 +0,0 @@
1
- module Enumerable
2
- # @return [Integer] Sum of the elements in this instance. All elements must
3
- # have a +to_i+ method, which converts the element into a form that may be
4
- # summed with an +Integer+.
5
- def sum
6
- flatten.inject(0){ |sum, element_amount| sum += element_amount.to_i }
7
- end
8
-
9
- # @return [Array] The array resulting from summing all elements in
10
- # this instance. All elements must have a +sum+ or +to_i+ method.
11
- def mapped_sum
12
- map { |element| if element.respond_to? :sum then element.sum else element.to_i end }
13
- end
14
- end
@@ -1,69 +0,0 @@
1
-
2
- require File.expand_path('../class', __FILE__)
3
-
4
- ########### Table game specific ##########
5
- class Integer
6
-
7
- exceptions :seat_out_of_bounds, :relative_position_out_of_bounds
8
-
9
- # @param [Integer] seat The seat to which the relative position is desired.
10
- # @param [Integer] number_of_players The number of players at the table.
11
- # @return [Integer] The relative position of +self+ to +seat+, given the
12
- # number of players at the table, +number_of_players+, indexed such that
13
- # the seat immediately to the left of +seat+ has a +position_relative_to+ of
14
- # zero.
15
- # @example <code>1.position_relative_to 0, 3</code> == 0
16
- # @example <code>1.position_relative_to 1, 3</code> == 2
17
- def position_relative_to(seat, number_of_players)
18
- raise SeatOutOfBounds unless seat.seat_in_bounds?(number_of_players) &&
19
- seat_in_bounds?(number_of_players)
20
-
21
- adjusted_seat = if self > seat
22
- self
23
- else
24
- self + number_of_players
25
- end
26
- adjusted_seat - seat - 1
27
- end
28
-
29
- # Inverse operation of +position_relative_to+.
30
- # Given
31
- # <code>relative_position = seat.position_relative_to to_seat, number_of_players</code>
32
- # then
33
- # <code>to_seat = seat.seat_from_relative_position relative_position, number_of_players</code>
34
- #
35
- # @param [Integer] relative_position_of_self_to_result The relative position
36
- # of seat +self+ to the seat that is returned by this function.
37
- # @param [Integer] number_of_players The number of players at the table.
38
- # @return [Integer] The seat to which the relative position,
39
- # +relative_position_of_self_to_result+, of +self+ was derived, given the
40
- # number of players at the table, +number_of_players+, indexed such that
41
- # the seat immediately to the left of +from_seat+ has a
42
- # +position_relative_to+ of zero.
43
- # @example <code>1.seat_from_relative_position 0, 3</code> == 0
44
- # @example <code>1.seat_from_relative_position 2, 3</code> == 1
45
- def seat_from_relative_position(relative_position_of_self_to_result,
46
- number_of_players)
47
- raise SeatOutOfBounds unless seat_in_bounds?(number_of_players)
48
-
49
- unless relative_position_of_self_to_result.seat_in_bounds?(number_of_players)
50
- raise RelativePositionOutOfBounds
51
- end
52
-
53
- position_adjustment = relative_position_of_self_to_result + 1
54
-
55
- to_seat = self + number_of_players - position_adjustment
56
- if self > to_seat || !to_seat.seat_in_bounds?(number_of_players)
57
- self - position_adjustment
58
- else
59
- to_seat
60
- end
61
- end
62
-
63
- # @param [Integer] number_of_players The number of players at the table.
64
- # @return [Bool] Reports whether or not +self+ represents an out of bounds
65
- # seat.
66
- def seat_in_bounds?(number_of_players)
67
- self < number_of_players && self >= 0
68
- end
69
- end
@@ -1,7 +0,0 @@
1
- class Object
2
- def to_h
3
- Hash[instance_variables.map do |var|
4
- [var[1..-1].to_sym, instance_variable_get(var)]
5
- end]
6
- end
7
- end
@@ -1,13 +0,0 @@
1
- class ProcessRunner
2
-
3
- # Starts an independent process asynchronously with the given +command+.
4
- # @param [Array] command The command to run.
5
- # @param [Hash] options Options with which the process should be started.
6
- # => (see IO#popen) for more information on available options.
7
- # @return [Integer] The process ID of the started process.
8
- # @raise (see Process#spawn)
9
- # @raise (see Process#detach)
10
- def self.go(command, options={})
11
- Process.detach(Process.spawn(command.join(' '), options)).pid
12
- end
13
- end