gorillib 0.1.11 → 0.4.0pre
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.
- data/.gitignore +1 -0
- data/.rspec +1 -2
- data/.yardopts +9 -0
- data/{CHANGELOG.textile → CHANGELOG.md} +35 -9
- data/Gemfile +21 -14
- data/Guardfile +19 -0
- data/{LICENSE.textile → LICENSE.md} +43 -29
- data/README.md +47 -52
- data/Rakefile +31 -30
- data/TODO.md +32 -0
- data/VERSION +1 -1
- data/examples/builder/ironfan.rb +133 -0
- data/examples/model/simple.rb +17 -0
- data/gorillib.gemspec +106 -86
- data/lib/alt/kernel/call_stack.rb +56 -0
- data/lib/gorillib/array/wrap.rb +53 -0
- data/lib/gorillib/base.rb +3 -3
- data/lib/gorillib/builder/field.rb +5 -0
- data/lib/gorillib/builder.rb +260 -0
- data/lib/gorillib/collection/has_collection.rb +31 -0
- data/lib/gorillib/collection.rb +129 -0
- data/lib/gorillib/configurable.rb +28 -0
- data/lib/gorillib/datetime/{flat.rb → to_flat.rb} +0 -0
- data/lib/gorillib/exception/confidence.rb +17 -0
- data/lib/gorillib/exception/raisers.rb +78 -0
- data/lib/gorillib/hash/mash.rb +202 -0
- data/lib/gorillib/hashlike/slice.rb +53 -19
- data/lib/gorillib/hashlike.rb +5 -3
- data/lib/gorillib/io/system_helpers.rb +30 -0
- data/lib/gorillib/logger/log.rb +18 -0
- data/lib/gorillib/metaprogramming/concern.rb +124 -0
- data/lib/gorillib/model/active_model_conversion.rb +68 -0
- data/lib/gorillib/model/active_model_naming.rb +87 -0
- data/lib/gorillib/model/active_model_shim.rb +33 -0
- data/lib/gorillib/model/base.rb +341 -0
- data/lib/gorillib/model/defaults.rb +71 -0
- data/lib/gorillib/model/errors.rb +14 -0
- data/lib/gorillib/model/factories.rb +372 -0
- data/lib/gorillib/model/field.rb +146 -0
- data/lib/gorillib/model/named_schema.rb +53 -0
- data/lib/gorillib/{struct/hashlike_iteration.rb → model/overlay.rb} +0 -0
- data/lib/gorillib/model/record_schema.rb +9 -0
- data/lib/gorillib/model/serialization.rb +23 -0
- data/lib/gorillib/model/validate.rb +22 -0
- data/lib/gorillib/model.rb +23 -0
- data/lib/gorillib/pathname.rb +78 -0
- data/lib/gorillib/{serialization.rb → serialization/to_wire.rb} +0 -0
- data/lib/gorillib/some.rb +11 -9
- data/lib/gorillib/string/constantize.rb +21 -14
- data/lib/gorillib/string/inflections.rb +6 -76
- data/lib/gorillib/string/inflector.rb +192 -0
- data/lib/gorillib/string/simple_inflector.rb +267 -0
- data/lib/gorillib/type/extended.rb +52 -0
- data/lib/gorillib/utils/capture_output.rb +28 -0
- data/lib/gorillib/utils/console.rb +131 -0
- data/lib/gorillib/utils/nuke_constants.rb +9 -0
- data/lib/gorillib/utils/stub_module.rb +33 -0
- data/spec/examples/builder/ironfan_spec.rb +37 -0
- data/spec/extlib/hash_spec.rb +64 -0
- data/spec/extlib/mash_spec.rb +312 -0
- data/spec/{array → gorillib/array}/compact_blank_spec.rb +2 -2
- data/spec/{array → gorillib/array}/extract_options_spec.rb +2 -2
- data/spec/gorillib/builder_spec.rb +187 -0
- data/spec/gorillib/collection_spec.rb +20 -0
- data/spec/gorillib/configurable_spec.rb +62 -0
- data/spec/{datetime → gorillib/datetime}/parse_spec.rb +3 -3
- data/spec/{datetime/flat_spec.rb → gorillib/datetime/to_flat_spec.rb} +4 -4
- data/spec/{enumerable → gorillib/enumerable}/sum_spec.rb +5 -5
- data/spec/gorillib/exception/raisers_spec.rb +60 -0
- data/spec/{hash → gorillib/hash}/compact_spec.rb +2 -2
- data/spec/{hash → gorillib/hash}/deep_compact_spec.rb +3 -3
- data/spec/{hash → gorillib/hash}/deep_merge_spec.rb +2 -2
- data/spec/{hash → gorillib/hash}/keys_spec.rb +2 -2
- data/spec/{hash → gorillib/hash}/reverse_merge_spec.rb +2 -2
- data/spec/{hash → gorillib/hash}/slice_spec.rb +2 -2
- data/spec/{hash → gorillib/hash}/zip_spec.rb +2 -2
- data/spec/{hashlike → gorillib/hashlike}/behave_same_as_hash_spec.rb +6 -3
- data/spec/{hashlike → gorillib/hashlike}/deep_hash_spec.rb +2 -2
- data/spec/{hashlike → gorillib/hashlike}/hashlike_behavior_spec.rb +32 -30
- data/spec/{hashlike → gorillib/hashlike}/hashlike_via_accessors_spec.rb +3 -3
- data/spec/{hashlike_spec.rb → gorillib/hashlike_spec.rb} +3 -3
- data/spec/{logger → gorillib/logger}/log_spec.rb +2 -2
- data/spec/{metaprogramming → gorillib/metaprogramming}/aliasing_spec.rb +3 -3
- data/spec/{metaprogramming → gorillib/metaprogramming}/class_attribute_spec.rb +3 -3
- data/spec/{metaprogramming → gorillib/metaprogramming}/delegation_spec.rb +3 -3
- data/spec/{metaprogramming → gorillib/metaprogramming}/singleton_class_spec.rb +3 -3
- data/spec/gorillib/model/record/defaults_spec.rb +108 -0
- data/spec/gorillib/model/record/factories_spec.rb +321 -0
- data/spec/gorillib/model/record/overlay_spec.rb +46 -0
- data/spec/gorillib/model/serialization_spec.rb +48 -0
- data/spec/gorillib/model_spec.rb +281 -0
- data/spec/{numeric → gorillib/numeric}/clamp_spec.rb +2 -2
- data/spec/{object → gorillib/object}/blank_spec.rb +2 -2
- data/spec/{object → gorillib/object}/try_dup_spec.rb +2 -2
- data/spec/{object → gorillib/object}/try_spec.rb +3 -2
- data/spec/gorillib/pathname_spec.rb +114 -0
- data/spec/{string → gorillib/string}/constantize_spec.rb +2 -2
- data/spec/{string → gorillib/string}/human_spec.rb +2 -2
- data/spec/{string → gorillib/string}/inflections_spec.rb +4 -3
- data/spec/{string → gorillib/string}/inflector_test_cases.rb +0 -0
- data/spec/{string → gorillib/string}/truncate_spec.rb +4 -10
- data/spec/gorillib/type/extended_spec.rb +120 -0
- data/spec/gorillib/utils/capture_output_spec.rb +71 -0
- data/spec/spec_helper.rb +8 -11
- data/spec/support/gorillib_test_helpers.rb +66 -0
- data/spec/support/hashlike_fuzzing_helper.rb +31 -33
- data/spec/support/hashlike_helper.rb +3 -3
- data/spec/support/model_test_helpers.rb +81 -0
- data/spec/support/shared_examples/included_module.rb +20 -0
- metadata +177 -158
- data/lib/gorillib/array/average.rb +0 -13
- data/lib/gorillib/array/sorted_median.rb +0 -11
- data/lib/gorillib/array/sorted_percentile.rb +0 -11
- data/lib/gorillib/array/sorted_sample.rb +0 -12
- data/lib/gorillib/dsl_object.rb +0 -64
- data/lib/gorillib/hash/indifferent_access.rb +0 -207
- data/lib/gorillib/hash/tree_merge.rb +0 -4
- data/lib/gorillib/hashlike/tree_merge.rb +0 -49
- data/lib/gorillib/metaprogramming/cattr_accessor.rb +0 -79
- data/lib/gorillib/metaprogramming/mattr_accessor.rb +0 -61
- data/lib/gorillib/receiver/active_model_shim.rb +0 -32
- data/lib/gorillib/receiver/acts_as_hash.rb +0 -195
- data/lib/gorillib/receiver/acts_as_loadable.rb +0 -42
- data/lib/gorillib/receiver/locale/en.yml +0 -27
- data/lib/gorillib/receiver/tree_diff.rb +0 -74
- data/lib/gorillib/receiver/validations.rb +0 -30
- data/lib/gorillib/receiver.rb +0 -402
- data/lib/gorillib/receiver_model.rb +0 -21
- data/lib/gorillib/struct/acts_as_hash.rb +0 -108
- data/notes/fancy_hashes_and_receivers.textile +0 -120
- data/notes/hash_rdocs.textile +0 -97
- data/spec/array/average_spec.rb +0 -24
- data/spec/array/sorted_median_spec.rb +0 -18
- data/spec/array/sorted_percentile_spec.rb +0 -24
- data/spec/array/sorted_sample_spec.rb +0 -28
- data/spec/dsl_object_spec.rb +0 -99
- data/spec/hash/indifferent_access_spec.rb +0 -391
- data/spec/metaprogramming/cattr_accessor_spec.rb +0 -43
- data/spec/metaprogramming/mattr_accessor_spec.rb +0 -45
- data/spec/receiver/acts_as_hash_spec.rb +0 -295
- data/spec/receiver_spec.rb +0 -551
- data/spec/struct/acts_as_hash_fuzz_spec.rb +0 -71
- data/spec/struct/acts_as_hash_spec.rb +0 -422
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
module Gorillib::Test
|
|
2
|
+
def self.cluster(name=nil, attrs={}, &block)
|
|
3
|
+
@example_cluster ||= Cluster.new(attrs.merge(:name => name))
|
|
4
|
+
@example_cluster.instance_exec(&block) if block
|
|
5
|
+
@example_cluster
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class IronfanBuilder
|
|
9
|
+
include Gorillib::FancyBuilder
|
|
10
|
+
field :name, Symbol
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
class ComputeBuilder < IronfanBuilder; end
|
|
14
|
+
|
|
15
|
+
class Organization < IronfanBuilder ; end
|
|
16
|
+
class Provider < IronfanBuilder ; end
|
|
17
|
+
class Cluster < ComputeBuilder ; end
|
|
18
|
+
class Facet < ComputeBuilder ; end
|
|
19
|
+
class Server < ComputeBuilder ; end
|
|
20
|
+
class Volume < IronfanBuilder ; end
|
|
21
|
+
class Cloud < IronfanBuilder ; end
|
|
22
|
+
class SecurityGroup < IronfanBuilder ; end
|
|
23
|
+
class Component < IronfanBuilder ; end
|
|
24
|
+
class Aspect < IronfanBuilder ; end
|
|
25
|
+
class Machine < IronfanBuilder ; end
|
|
26
|
+
class ChefNode < IronfanBuilder ; def save() ; end ; end
|
|
27
|
+
class ChefClient < IronfanBuilder ; def save() ; end ; end
|
|
28
|
+
class ChefRole < IronfanBuilder ; def save() ; end ; end
|
|
29
|
+
|
|
30
|
+
module Ironfan
|
|
31
|
+
class << self
|
|
32
|
+
attr_reader :dry_run
|
|
33
|
+
attr_reader :config
|
|
34
|
+
end
|
|
35
|
+
@dry_run = false
|
|
36
|
+
@config = {}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class ComputeBuilder < IronfanBuilder
|
|
41
|
+
field :environment, Symbol
|
|
42
|
+
collection :clouds, Cloud
|
|
43
|
+
collection :volumes, Volume
|
|
44
|
+
collection :components, Component
|
|
45
|
+
|
|
46
|
+
def run_list() ; end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
class Cluster < ComputeBuilder
|
|
50
|
+
collection :facets, Facet
|
|
51
|
+
belongs_to :organization, Organization
|
|
52
|
+
|
|
53
|
+
def servers() organization.servers.where(:cluster_name => self.name) ; end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
module ComputeBuilder::Deprecated
|
|
57
|
+
def bogosity() ; end
|
|
58
|
+
def bogus?() ; end
|
|
59
|
+
def raid_group() ; end
|
|
60
|
+
def root_volume() ; end
|
|
61
|
+
def role() ; end
|
|
62
|
+
def recipe() ; end
|
|
63
|
+
def role_implication() ; end
|
|
64
|
+
end
|
|
65
|
+
module Cluster::Deprecated
|
|
66
|
+
attr_accessor :chef_roles
|
|
67
|
+
def find_facet(facet_name)
|
|
68
|
+
facets.fetch(facet_name){ raise("Facet '#{facet_name}' is not defined in cluster '#{self.name}'") }
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
class Facet < ComputeBuilder
|
|
73
|
+
belongs_to :cluster, Cluster
|
|
74
|
+
collection :servers, Server
|
|
75
|
+
field :instances, Integer, :doc => 'number of servers to instantiate for this machine'
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
class Server < ComputeBuilder
|
|
79
|
+
belongs_to :cluster, Cluster
|
|
80
|
+
belongs_to :facet, Facet
|
|
81
|
+
member :machine, Machine
|
|
82
|
+
member :chef_node, ChefNode
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
class Volume < IronfanBuilder
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
class Cloud < IronfanBuilder
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
class Component < IronfanBuilder
|
|
92
|
+
field :discovers, Array, :of => :whatever, :doc => 'components this one discovers. Can be used to intelligently generate security groups, add client components, etc'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class SecurityGroup < IronfanBuilder
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
class Universe < IronfanBuilder
|
|
99
|
+
collection :organizations, Organization
|
|
100
|
+
collection :providers, Provider
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
class Organization < IronfanBuilder
|
|
104
|
+
collection :chef_nodes, ChefNode
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
class Provider < IronfanBuilder
|
|
108
|
+
collection :limbo_servers, Server
|
|
109
|
+
collection :clusters, Cluster
|
|
110
|
+
collection :machines, Machine
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
cluster(:yellowhat) do
|
|
114
|
+
environment :prod
|
|
115
|
+
|
|
116
|
+
facet(:webnode) do
|
|
117
|
+
instances 12
|
|
118
|
+
volume(:logs) do
|
|
119
|
+
end
|
|
120
|
+
server(:a)
|
|
121
|
+
|
|
122
|
+
servers # <Gorillib::Collection { :a => <Server name=:a ... > } >
|
|
123
|
+
server(:a) # <Server name=:a ... > } >
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
facet(:dbnode) do
|
|
127
|
+
environment nil
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
facet(:esnode) do
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class Place
|
|
2
|
+
include Gorillib::Record
|
|
3
|
+
# fields can be simple...
|
|
4
|
+
field :name, String
|
|
5
|
+
field :country_id, String, :doc => 'Country code (2-letter alpha) containing the place'
|
|
6
|
+
# ... or complext
|
|
7
|
+
field :geo, GeoCoordinates, :doc => 'geographic location of the place'
|
|
8
|
+
end
|
|
9
|
+
class GeoCoordinates
|
|
10
|
+
include Gorillib::Record
|
|
11
|
+
field :latitude, Float, :doc => 'latitude in decimal degrees; negative numbers are south of the equator'
|
|
12
|
+
field :longitude, Float, :doc => 'longitude in decimal degrees; negative numbers are west of Greenwich'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# It's simple to instantiate complex nested data structures
|
|
16
|
+
lunch_spot = Place.receive({ :name => "Torchy's Tacos", :country_id => "us",
|
|
17
|
+
:geo => { :latitude => "30.295", :longitude => "-97.745" }})
|
data/gorillib.gemspec
CHANGED
|
@@ -5,50 +5,58 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "gorillib"
|
|
8
|
-
s.version = "0.
|
|
8
|
+
s.version = "0.4.0pre"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Infochimps"]
|
|
12
|
-
s.date = "2012-
|
|
12
|
+
s.date = "2012-08-16"
|
|
13
13
|
s.description = "Gorillib: infochimps lightweight subset of ruby convenience methods"
|
|
14
14
|
s.email = "coders@infochimps.org"
|
|
15
15
|
s.extra_rdoc_files = [
|
|
16
|
-
"LICENSE.
|
|
16
|
+
"LICENSE.md",
|
|
17
17
|
"README.md"
|
|
18
18
|
]
|
|
19
19
|
s.files = [
|
|
20
20
|
".gitignore",
|
|
21
21
|
".rspec",
|
|
22
|
-
"
|
|
22
|
+
".yardopts",
|
|
23
|
+
"CHANGELOG.md",
|
|
23
24
|
"Gemfile",
|
|
24
|
-
"
|
|
25
|
+
"Guardfile",
|
|
26
|
+
"LICENSE.md",
|
|
25
27
|
"README.md",
|
|
26
28
|
"Rakefile",
|
|
29
|
+
"TODO.md",
|
|
27
30
|
"VERSION",
|
|
31
|
+
"examples/builder/ironfan.rb",
|
|
32
|
+
"examples/model/simple.rb",
|
|
28
33
|
"gorillib.gemspec",
|
|
34
|
+
"lib/alt/kernel/call_stack.rb",
|
|
29
35
|
"lib/gorillib.rb",
|
|
30
|
-
"lib/gorillib/array/average.rb",
|
|
31
36
|
"lib/gorillib/array/compact_blank.rb",
|
|
32
37
|
"lib/gorillib/array/deep_compact.rb",
|
|
33
38
|
"lib/gorillib/array/extract_options.rb",
|
|
34
39
|
"lib/gorillib/array/random.rb",
|
|
35
|
-
"lib/gorillib/array/
|
|
36
|
-
"lib/gorillib/array/sorted_percentile.rb",
|
|
37
|
-
"lib/gorillib/array/sorted_sample.rb",
|
|
40
|
+
"lib/gorillib/array/wrap.rb",
|
|
38
41
|
"lib/gorillib/base.rb",
|
|
39
|
-
"lib/gorillib/
|
|
42
|
+
"lib/gorillib/builder.rb",
|
|
43
|
+
"lib/gorillib/builder/field.rb",
|
|
44
|
+
"lib/gorillib/collection.rb",
|
|
45
|
+
"lib/gorillib/collection/has_collection.rb",
|
|
46
|
+
"lib/gorillib/configurable.rb",
|
|
40
47
|
"lib/gorillib/datetime/parse.rb",
|
|
41
|
-
"lib/gorillib/
|
|
48
|
+
"lib/gorillib/datetime/to_flat.rb",
|
|
42
49
|
"lib/gorillib/enumerable/sum.rb",
|
|
50
|
+
"lib/gorillib/exception/confidence.rb",
|
|
51
|
+
"lib/gorillib/exception/raisers.rb",
|
|
43
52
|
"lib/gorillib/hash/compact.rb",
|
|
44
53
|
"lib/gorillib/hash/deep_compact.rb",
|
|
45
54
|
"lib/gorillib/hash/deep_dup.rb",
|
|
46
55
|
"lib/gorillib/hash/deep_merge.rb",
|
|
47
|
-
"lib/gorillib/hash/indifferent_access.rb",
|
|
48
56
|
"lib/gorillib/hash/keys.rb",
|
|
57
|
+
"lib/gorillib/hash/mash.rb",
|
|
49
58
|
"lib/gorillib/hash/reverse_merge.rb",
|
|
50
59
|
"lib/gorillib/hash/slice.rb",
|
|
51
|
-
"lib/gorillib/hash/tree_merge.rb",
|
|
52
60
|
"lib/gorillib/hash/zip.rb",
|
|
53
61
|
"lib/gorillib/hashlike.rb",
|
|
54
62
|
"lib/gorillib/hashlike/compact.rb",
|
|
@@ -60,81 +68,94 @@ Gem::Specification.new do |s|
|
|
|
60
68
|
"lib/gorillib/hashlike/keys.rb",
|
|
61
69
|
"lib/gorillib/hashlike/reverse_merge.rb",
|
|
62
70
|
"lib/gorillib/hashlike/slice.rb",
|
|
63
|
-
"lib/gorillib/
|
|
71
|
+
"lib/gorillib/io/system_helpers.rb",
|
|
64
72
|
"lib/gorillib/logger/log.rb",
|
|
65
73
|
"lib/gorillib/metaprogramming/aliasing.rb",
|
|
66
|
-
"lib/gorillib/metaprogramming/cattr_accessor.rb",
|
|
67
74
|
"lib/gorillib/metaprogramming/class_attribute.rb",
|
|
75
|
+
"lib/gorillib/metaprogramming/concern.rb",
|
|
68
76
|
"lib/gorillib/metaprogramming/delegation.rb",
|
|
69
|
-
"lib/gorillib/metaprogramming/mattr_accessor.rb",
|
|
70
77
|
"lib/gorillib/metaprogramming/remove_method.rb",
|
|
71
78
|
"lib/gorillib/metaprogramming/singleton_class.rb",
|
|
79
|
+
"lib/gorillib/model.rb",
|
|
80
|
+
"lib/gorillib/model/active_model_conversion.rb",
|
|
81
|
+
"lib/gorillib/model/active_model_naming.rb",
|
|
82
|
+
"lib/gorillib/model/active_model_shim.rb",
|
|
83
|
+
"lib/gorillib/model/base.rb",
|
|
84
|
+
"lib/gorillib/model/defaults.rb",
|
|
85
|
+
"lib/gorillib/model/errors.rb",
|
|
86
|
+
"lib/gorillib/model/factories.rb",
|
|
87
|
+
"lib/gorillib/model/field.rb",
|
|
88
|
+
"lib/gorillib/model/named_schema.rb",
|
|
89
|
+
"lib/gorillib/model/overlay.rb",
|
|
90
|
+
"lib/gorillib/model/record_schema.rb",
|
|
91
|
+
"lib/gorillib/model/serialization.rb",
|
|
92
|
+
"lib/gorillib/model/validate.rb",
|
|
72
93
|
"lib/gorillib/numeric/clamp.rb",
|
|
73
94
|
"lib/gorillib/object/blank.rb",
|
|
74
95
|
"lib/gorillib/object/try.rb",
|
|
75
96
|
"lib/gorillib/object/try_dup.rb",
|
|
76
|
-
"lib/gorillib/
|
|
77
|
-
"lib/gorillib/
|
|
78
|
-
"lib/gorillib/receiver/acts_as_hash.rb",
|
|
79
|
-
"lib/gorillib/receiver/acts_as_loadable.rb",
|
|
80
|
-
"lib/gorillib/receiver/locale/en.yml",
|
|
81
|
-
"lib/gorillib/receiver/tree_diff.rb",
|
|
82
|
-
"lib/gorillib/receiver/validations.rb",
|
|
83
|
-
"lib/gorillib/receiver_model.rb",
|
|
84
|
-
"lib/gorillib/serialization.rb",
|
|
97
|
+
"lib/gorillib/pathname.rb",
|
|
98
|
+
"lib/gorillib/serialization/to_wire.rb",
|
|
85
99
|
"lib/gorillib/some.rb",
|
|
86
100
|
"lib/gorillib/string/constantize.rb",
|
|
87
101
|
"lib/gorillib/string/human.rb",
|
|
88
102
|
"lib/gorillib/string/inflections.rb",
|
|
103
|
+
"lib/gorillib/string/inflector.rb",
|
|
104
|
+
"lib/gorillib/string/simple_inflector.rb",
|
|
89
105
|
"lib/gorillib/string/truncate.rb",
|
|
90
|
-
"lib/gorillib/
|
|
91
|
-
"lib/gorillib/
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"spec/
|
|
96
|
-
"spec/
|
|
97
|
-
"spec/
|
|
98
|
-
"spec/array/
|
|
99
|
-
"spec/array/
|
|
100
|
-
"spec/
|
|
101
|
-
"spec/
|
|
102
|
-
"spec/
|
|
103
|
-
"spec/
|
|
104
|
-
"spec/
|
|
105
|
-
"spec/
|
|
106
|
-
"spec/
|
|
107
|
-
"spec/hash/
|
|
108
|
-
"spec/hash/
|
|
109
|
-
"spec/hash/
|
|
110
|
-
"spec/hash/
|
|
111
|
-
"spec/hash/
|
|
112
|
-
"spec/
|
|
113
|
-
"spec/
|
|
114
|
-
"spec/hashlike/
|
|
115
|
-
"spec/hashlike/
|
|
116
|
-
"spec/
|
|
117
|
-
"spec/
|
|
118
|
-
"spec/
|
|
119
|
-
"spec/
|
|
120
|
-
"spec/metaprogramming/
|
|
121
|
-
"spec/metaprogramming/
|
|
122
|
-
"spec/metaprogramming/
|
|
123
|
-
"spec/metaprogramming/singleton_class_spec.rb",
|
|
124
|
-
"spec/
|
|
125
|
-
"spec/
|
|
126
|
-
"spec/
|
|
127
|
-
"spec/
|
|
128
|
-
"spec/
|
|
129
|
-
"spec/
|
|
106
|
+
"lib/gorillib/type/extended.rb",
|
|
107
|
+
"lib/gorillib/utils/capture_output.rb",
|
|
108
|
+
"lib/gorillib/utils/console.rb",
|
|
109
|
+
"lib/gorillib/utils/nuke_constants.rb",
|
|
110
|
+
"lib/gorillib/utils/stub_module.rb",
|
|
111
|
+
"spec/examples/builder/ironfan_spec.rb",
|
|
112
|
+
"spec/extlib/hash_spec.rb",
|
|
113
|
+
"spec/extlib/mash_spec.rb",
|
|
114
|
+
"spec/gorillib/array/compact_blank_spec.rb",
|
|
115
|
+
"spec/gorillib/array/extract_options_spec.rb",
|
|
116
|
+
"spec/gorillib/builder_spec.rb",
|
|
117
|
+
"spec/gorillib/collection_spec.rb",
|
|
118
|
+
"spec/gorillib/configurable_spec.rb",
|
|
119
|
+
"spec/gorillib/datetime/parse_spec.rb",
|
|
120
|
+
"spec/gorillib/datetime/to_flat_spec.rb",
|
|
121
|
+
"spec/gorillib/enumerable/sum_spec.rb",
|
|
122
|
+
"spec/gorillib/exception/raisers_spec.rb",
|
|
123
|
+
"spec/gorillib/hash/compact_spec.rb",
|
|
124
|
+
"spec/gorillib/hash/deep_compact_spec.rb",
|
|
125
|
+
"spec/gorillib/hash/deep_merge_spec.rb",
|
|
126
|
+
"spec/gorillib/hash/keys_spec.rb",
|
|
127
|
+
"spec/gorillib/hash/reverse_merge_spec.rb",
|
|
128
|
+
"spec/gorillib/hash/slice_spec.rb",
|
|
129
|
+
"spec/gorillib/hash/zip_spec.rb",
|
|
130
|
+
"spec/gorillib/hashlike/behave_same_as_hash_spec.rb",
|
|
131
|
+
"spec/gorillib/hashlike/deep_hash_spec.rb",
|
|
132
|
+
"spec/gorillib/hashlike/hashlike_behavior_spec.rb",
|
|
133
|
+
"spec/gorillib/hashlike/hashlike_via_accessors_spec.rb",
|
|
134
|
+
"spec/gorillib/hashlike_spec.rb",
|
|
135
|
+
"spec/gorillib/logger/log_spec.rb",
|
|
136
|
+
"spec/gorillib/metaprogramming/aliasing_spec.rb",
|
|
137
|
+
"spec/gorillib/metaprogramming/class_attribute_spec.rb",
|
|
138
|
+
"spec/gorillib/metaprogramming/delegation_spec.rb",
|
|
139
|
+
"spec/gorillib/metaprogramming/singleton_class_spec.rb",
|
|
140
|
+
"spec/gorillib/model/record/defaults_spec.rb",
|
|
141
|
+
"spec/gorillib/model/record/factories_spec.rb",
|
|
142
|
+
"spec/gorillib/model/record/overlay_spec.rb",
|
|
143
|
+
"spec/gorillib/model/serialization_spec.rb",
|
|
144
|
+
"spec/gorillib/model_spec.rb",
|
|
145
|
+
"spec/gorillib/numeric/clamp_spec.rb",
|
|
146
|
+
"spec/gorillib/object/blank_spec.rb",
|
|
147
|
+
"spec/gorillib/object/try_dup_spec.rb",
|
|
148
|
+
"spec/gorillib/object/try_spec.rb",
|
|
149
|
+
"spec/gorillib/pathname_spec.rb",
|
|
150
|
+
"spec/gorillib/string/constantize_spec.rb",
|
|
151
|
+
"spec/gorillib/string/human_spec.rb",
|
|
152
|
+
"spec/gorillib/string/inflections_spec.rb",
|
|
153
|
+
"spec/gorillib/string/inflector_test_cases.rb",
|
|
154
|
+
"spec/gorillib/string/truncate_spec.rb",
|
|
155
|
+
"spec/gorillib/type/extended_spec.rb",
|
|
156
|
+
"spec/gorillib/utils/capture_output_spec.rb",
|
|
130
157
|
"spec/spec_helper.rb",
|
|
131
|
-
"spec/
|
|
132
|
-
"spec/string/human_spec.rb",
|
|
133
|
-
"spec/string/inflections_spec.rb",
|
|
134
|
-
"spec/string/inflector_test_cases.rb",
|
|
135
|
-
"spec/string/truncate_spec.rb",
|
|
136
|
-
"spec/struct/acts_as_hash_fuzz_spec.rb",
|
|
137
|
-
"spec/struct/acts_as_hash_spec.rb",
|
|
158
|
+
"spec/support/gorillib_test_helpers.rb",
|
|
138
159
|
"spec/support/hashlike_fuzzing_helper.rb",
|
|
139
160
|
"spec/support/hashlike_helper.rb",
|
|
140
161
|
"spec/support/hashlike_struct_helper.rb",
|
|
@@ -143,43 +164,42 @@ Gem::Specification.new do |s|
|
|
|
143
164
|
"spec/support/matchers/be_array_eql.rb",
|
|
144
165
|
"spec/support/matchers/be_hash_eql.rb",
|
|
145
166
|
"spec/support/matchers/enumerate_method.rb",
|
|
146
|
-
"spec/support/matchers/evaluate_to_true.rb"
|
|
167
|
+
"spec/support/matchers/evaluate_to_true.rb",
|
|
168
|
+
"spec/support/model_test_helpers.rb",
|
|
169
|
+
"spec/support/shared_examples/included_module.rb"
|
|
147
170
|
]
|
|
148
171
|
s.homepage = "http://infochimps.com/labs"
|
|
149
172
|
s.licenses = ["MIT"]
|
|
150
173
|
s.require_paths = ["lib"]
|
|
151
174
|
s.rubygems_version = "1.8.15"
|
|
152
175
|
s.summary = "include only what you need. No dependencies, no creep"
|
|
153
|
-
s.test_files = ["spec/
|
|
176
|
+
s.test_files = ["spec/examples/builder/ironfan_spec.rb", "spec/extlib/hash_spec.rb", "spec/extlib/mash_spec.rb", "spec/gorillib/array/compact_blank_spec.rb", "spec/gorillib/array/extract_options_spec.rb", "spec/gorillib/builder_spec.rb", "spec/gorillib/collection_spec.rb", "spec/gorillib/configurable_spec.rb", "spec/gorillib/datetime/parse_spec.rb", "spec/gorillib/datetime/to_flat_spec.rb", "spec/gorillib/enumerable/sum_spec.rb", "spec/gorillib/exception/raisers_spec.rb", "spec/gorillib/hash/compact_spec.rb", "spec/gorillib/hash/deep_compact_spec.rb", "spec/gorillib/hash/deep_merge_spec.rb", "spec/gorillib/hash/keys_spec.rb", "spec/gorillib/hash/reverse_merge_spec.rb", "spec/gorillib/hash/slice_spec.rb", "spec/gorillib/hash/zip_spec.rb", "spec/gorillib/hashlike/behave_same_as_hash_spec.rb", "spec/gorillib/hashlike/deep_hash_spec.rb", "spec/gorillib/hashlike/hashlike_behavior_spec.rb", "spec/gorillib/hashlike/hashlike_via_accessors_spec.rb", "spec/gorillib/hashlike_spec.rb", "spec/gorillib/logger/log_spec.rb", "spec/gorillib/metaprogramming/aliasing_spec.rb", "spec/gorillib/metaprogramming/class_attribute_spec.rb", "spec/gorillib/metaprogramming/delegation_spec.rb", "spec/gorillib/metaprogramming/singleton_class_spec.rb", "spec/gorillib/model/record/defaults_spec.rb", "spec/gorillib/model/record/factories_spec.rb", "spec/gorillib/model/record/overlay_spec.rb", "spec/gorillib/model/serialization_spec.rb", "spec/gorillib/model_spec.rb", "spec/gorillib/numeric/clamp_spec.rb", "spec/gorillib/object/blank_spec.rb", "spec/gorillib/object/try_dup_spec.rb", "spec/gorillib/object/try_spec.rb", "spec/gorillib/pathname_spec.rb", "spec/gorillib/string/constantize_spec.rb", "spec/gorillib/string/human_spec.rb", "spec/gorillib/string/inflections_spec.rb", "spec/gorillib/string/inflector_test_cases.rb", "spec/gorillib/string/truncate_spec.rb", "spec/gorillib/type/extended_spec.rb", "spec/gorillib/utils/capture_output_spec.rb", "spec/spec_helper.rb", "spec/support/gorillib_test_helpers.rb", "spec/support/hashlike_fuzzing_helper.rb", "spec/support/hashlike_helper.rb", "spec/support/hashlike_struct_helper.rb", "spec/support/hashlike_via_delegation.rb", "spec/support/kcode_test_helper.rb", "spec/support/matchers/be_array_eql.rb", "spec/support/matchers/be_hash_eql.rb", "spec/support/matchers/enumerate_method.rb", "spec/support/matchers/evaluate_to_true.rb", "spec/support/model_test_helpers.rb", "spec/support/shared_examples/included_module.rb"]
|
|
154
177
|
|
|
155
178
|
if s.respond_to? :specification_version then
|
|
156
179
|
s.specification_version = 3
|
|
157
180
|
|
|
158
181
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
182
|
+
s.add_runtime_dependency(%q<multi_json>, ["~> 1.1"])
|
|
159
183
|
s.add_runtime_dependency(%q<json>, [">= 0"])
|
|
184
|
+
s.add_runtime_dependency(%q<configliere>, [">= 0.4.13"])
|
|
160
185
|
s.add_development_dependency(%q<bundler>, ["~> 1"])
|
|
186
|
+
s.add_development_dependency(%q<pry>, [">= 0"])
|
|
161
187
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6"])
|
|
162
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.5"])
|
|
163
|
-
s.add_development_dependency(%q<yard>, ["~> 0.6"])
|
|
164
|
-
s.add_development_dependency(%q<cucumber>, ["~> 1"])
|
|
165
|
-
s.add_development_dependency(%q<aruba>, ["~> 0.4"])
|
|
166
188
|
else
|
|
189
|
+
s.add_dependency(%q<multi_json>, ["~> 1.1"])
|
|
167
190
|
s.add_dependency(%q<json>, [">= 0"])
|
|
191
|
+
s.add_dependency(%q<configliere>, [">= 0.4.13"])
|
|
168
192
|
s.add_dependency(%q<bundler>, ["~> 1"])
|
|
193
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
|
169
194
|
s.add_dependency(%q<jeweler>, ["~> 1.6"])
|
|
170
|
-
s.add_dependency(%q<rspec>, ["~> 2.5"])
|
|
171
|
-
s.add_dependency(%q<yard>, ["~> 0.6"])
|
|
172
|
-
s.add_dependency(%q<cucumber>, ["~> 1"])
|
|
173
|
-
s.add_dependency(%q<aruba>, ["~> 0.4"])
|
|
174
195
|
end
|
|
175
196
|
else
|
|
197
|
+
s.add_dependency(%q<multi_json>, ["~> 1.1"])
|
|
176
198
|
s.add_dependency(%q<json>, [">= 0"])
|
|
199
|
+
s.add_dependency(%q<configliere>, [">= 0.4.13"])
|
|
177
200
|
s.add_dependency(%q<bundler>, ["~> 1"])
|
|
201
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
|
178
202
|
s.add_dependency(%q<jeweler>, ["~> 1.6"])
|
|
179
|
-
s.add_dependency(%q<rspec>, ["~> 2.5"])
|
|
180
|
-
s.add_dependency(%q<yard>, ["~> 0.6"])
|
|
181
|
-
s.add_dependency(%q<cucumber>, ["~> 1"])
|
|
182
|
-
s.add_dependency(%q<aruba>, ["~> 0.4"])
|
|
183
203
|
end
|
|
184
204
|
end
|
|
185
205
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module Kernel
|
|
2
|
+
|
|
3
|
+
alias_method :pp_callstack, :caller
|
|
4
|
+
alias_method :pp_call_stack, :caller
|
|
5
|
+
|
|
6
|
+
# Parse a caller string and break it into its components,
|
|
7
|
+
# returning an array composed of:
|
|
8
|
+
#
|
|
9
|
+
# * file (String)
|
|
10
|
+
# * lineno (Integer)
|
|
11
|
+
# * method (Symbol)
|
|
12
|
+
#
|
|
13
|
+
# For example, from irb
|
|
14
|
+
#
|
|
15
|
+
# call_stack(1)
|
|
16
|
+
#
|
|
17
|
+
# _produces_ ...
|
|
18
|
+
#
|
|
19
|
+
# [["(irb)", 2, :irb_binding],
|
|
20
|
+
# ["/usr/lib/ruby/1.8/irb/workspace.rb", 52, :irb_binding],
|
|
21
|
+
# ["/usr/lib/ruby/1.8/irb/workspace.rb", 52, nil]]
|
|
22
|
+
#
|
|
23
|
+
# Note: If the user decides to redefine caller() to output data
|
|
24
|
+
# in a different format, _prior_ to requiring this, then the
|
|
25
|
+
# results will be indeterminate.
|
|
26
|
+
#
|
|
27
|
+
# CREDIT: Trans
|
|
28
|
+
|
|
29
|
+
def call_stack(level = 1)
|
|
30
|
+
call_str_array = pp_call_stack(level)
|
|
31
|
+
stack = []
|
|
32
|
+
call_str_array.each{ |call_str|
|
|
33
|
+
file, lineno, method = call_str.split(':')
|
|
34
|
+
if method =~ /in `(.*)'/ then
|
|
35
|
+
method = $1.intern()
|
|
36
|
+
end
|
|
37
|
+
stack << [file, lineno.to_i, method]
|
|
38
|
+
}
|
|
39
|
+
stack
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
alias_method :callstack, :call_stack
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class Binding
|
|
48
|
+
|
|
49
|
+
# Returns the call stack, in array format.
|
|
50
|
+
def call_stack(level=1)
|
|
51
|
+
eval( "callstack( #{level} )" )
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
alias_method :callstack, :call_stack
|
|
55
|
+
end
|
|
56
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
class Array
|
|
2
|
+
# Wraps its argument in an array unless it is already an array (or array-like).
|
|
3
|
+
#
|
|
4
|
+
# Specifically:
|
|
5
|
+
#
|
|
6
|
+
# * If the argument is +nil+ an empty list is returned.
|
|
7
|
+
# * Otherwise, if the argument responds to +to_ary+ it is invoked, and its result returned.
|
|
8
|
+
# * Otherwise, returns an array with the argument as its single element.
|
|
9
|
+
#
|
|
10
|
+
# @example nil: an empty list
|
|
11
|
+
# Array.wrap(nil) # => []
|
|
12
|
+
# @example an array: itself
|
|
13
|
+
# Array.wrap([1, 2, 3]) # => [1, 2, 3]
|
|
14
|
+
# @example an atom: array of length 1
|
|
15
|
+
# Array.wrap(0) # => [0]
|
|
16
|
+
#
|
|
17
|
+
# This method is similar in purpose to `Kernel#Array`, but there are some differences:
|
|
18
|
+
#
|
|
19
|
+
# * If the argument responds to +to_ary+ the method is invoked. `Kernel#Array`
|
|
20
|
+
# moves on to try +to_a+ if the returned value is +nil+, but `Array.wrap` returns
|
|
21
|
+
# such a +nil+ right away.
|
|
22
|
+
# * If the returned value from +to_ary+ is neither +nil+ nor an +Array+ object, `Kernel#Array`
|
|
23
|
+
# raises an exception, while `Array.wrap` does not, it just returns the value.
|
|
24
|
+
# * It does not call +to_a+ on the argument, though special-cases +nil+ to return an empty array.
|
|
25
|
+
#
|
|
26
|
+
# The last point is particularly worth comparing for some enumerables:
|
|
27
|
+
#
|
|
28
|
+
# @example It does not molest hashes
|
|
29
|
+
# Array(:foo => :bar) # => [[:foo, :bar]]
|
|
30
|
+
# Array.wrap(:foo => :bar) # => [{:foo => :bar}]
|
|
31
|
+
#
|
|
32
|
+
# @example It does not do insane things to strings
|
|
33
|
+
# Array("foo\nbar") # => ["foo\n", "bar"], in Ruby 1.8
|
|
34
|
+
# Array.wrap("foo\nbar") # => ["foo\nbar"]
|
|
35
|
+
#
|
|
36
|
+
# There's also a related idiom that uses the splat operator:
|
|
37
|
+
#
|
|
38
|
+
# [*object]
|
|
39
|
+
#
|
|
40
|
+
# which returns `[nil]` for +nil+, and calls to `Array(object)` otherwise.
|
|
41
|
+
#
|
|
42
|
+
# Thus, in this case the behavior is different for +nil+, and the differences with
|
|
43
|
+
# `Kernel#Array` explained above apply to the rest of +object+s.
|
|
44
|
+
def self.wrap(object)
|
|
45
|
+
if object.nil?
|
|
46
|
+
[]
|
|
47
|
+
elsif object.respond_to?(:to_ary)
|
|
48
|
+
object.to_ary || [object]
|
|
49
|
+
else
|
|
50
|
+
[object]
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
data/lib/gorillib/base.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require 'gorillib/object/blank'
|
|
2
|
+
require 'gorillib/object/try'
|
|
2
3
|
require 'gorillib/array/extract_options'
|
|
4
|
+
require 'gorillib/array/compact_blank'
|
|
3
5
|
require 'gorillib/hash/reverse_merge'
|
|
4
6
|
require 'gorillib/hash/compact'
|
|
7
|
+
require 'gorillib/hash/keys'
|
|
5
8
|
require 'gorillib/metaprogramming/class_attribute'
|
|
6
|
-
require 'gorillib/metaprogramming/cattr_accessor'
|
|
7
|
-
require 'gorillib/hash/deep_compact'
|
|
8
|
-
require 'gorillib/array/deep_compact'
|