jinx 2.1.1

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.
Files changed (149) hide show
  1. data/.gitignore +14 -0
  2. data/.rspec +3 -0
  3. data/.yardopts +1 -0
  4. data/Gemfile +6 -0
  5. data/Gemfile.lock +27 -0
  6. data/History.md +6 -0
  7. data/LEGAL +5 -0
  8. data/LICENSE +22 -0
  9. data/README.md +44 -0
  10. data/Rakefile +41 -0
  11. data/examples/family/README.md +10 -0
  12. data/examples/family/ext/build.xml +35 -0
  13. data/examples/family/ext/src/family/Address.java +68 -0
  14. data/examples/family/ext/src/family/Child.java +24 -0
  15. data/examples/family/ext/src/family/DomainObject.java +26 -0
  16. data/examples/family/ext/src/family/Household.java +36 -0
  17. data/examples/family/ext/src/family/Parent.java +48 -0
  18. data/examples/family/ext/src/family/Person.java +42 -0
  19. data/examples/family/lib/family.rb +15 -0
  20. data/examples/family/lib/family/address.rb +6 -0
  21. data/examples/family/lib/family/domain_object.rb +6 -0
  22. data/examples/family/lib/family/household.rb +6 -0
  23. data/examples/family/lib/family/parent.rb +16 -0
  24. data/examples/family/lib/family/person.rb +6 -0
  25. data/examples/model/README.md +25 -0
  26. data/examples/model/ext/build.xml +35 -0
  27. data/examples/model/ext/src/domain/Child.java +192 -0
  28. data/examples/model/ext/src/domain/Dependent.java +29 -0
  29. data/examples/model/ext/src/domain/DomainObject.java +26 -0
  30. data/examples/model/ext/src/domain/Independent.java +83 -0
  31. data/examples/model/ext/src/domain/Parent.java +129 -0
  32. data/examples/model/ext/src/domain/Person.java +14 -0
  33. data/examples/model/lib/model.rb +13 -0
  34. data/examples/model/lib/model/child.rb +13 -0
  35. data/examples/model/lib/model/domain_object.rb +6 -0
  36. data/examples/model/lib/model/independent.rb +11 -0
  37. data/examples/model/lib/model/parent.rb +17 -0
  38. data/jinx.gemspec +22 -0
  39. data/lib/jinx.rb +3 -0
  40. data/lib/jinx/active_support/README.txt +2 -0
  41. data/lib/jinx/active_support/core_ext/string.rb +7 -0
  42. data/lib/jinx/active_support/core_ext/string/inflections.rb +167 -0
  43. data/lib/jinx/active_support/inflections.rb +55 -0
  44. data/lib/jinx/active_support/inflector.rb +398 -0
  45. data/lib/jinx/cli/application.rb +36 -0
  46. data/lib/jinx/cli/command.rb +214 -0
  47. data/lib/jinx/helpers/array.rb +108 -0
  48. data/lib/jinx/helpers/boolean.rb +42 -0
  49. data/lib/jinx/helpers/case_insensitive_hash.rb +39 -0
  50. data/lib/jinx/helpers/class.rb +149 -0
  51. data/lib/jinx/helpers/collection.rb +33 -0
  52. data/lib/jinx/helpers/collections.rb +11 -0
  53. data/lib/jinx/helpers/collector.rb +20 -0
  54. data/lib/jinx/helpers/conditional_enumerator.rb +21 -0
  55. data/lib/jinx/helpers/enumerable.rb +242 -0
  56. data/lib/jinx/helpers/enumerate.rb +35 -0
  57. data/lib/jinx/helpers/error.rb +15 -0
  58. data/lib/jinx/helpers/file_separator.rb +65 -0
  59. data/lib/jinx/helpers/filter.rb +52 -0
  60. data/lib/jinx/helpers/flattener.rb +38 -0
  61. data/lib/jinx/helpers/hash.rb +12 -0
  62. data/lib/jinx/helpers/hashable.rb +502 -0
  63. data/lib/jinx/helpers/inflector.rb +36 -0
  64. data/lib/jinx/helpers/key_transformer_hash.rb +43 -0
  65. data/lib/jinx/helpers/lazy_hash.rb +44 -0
  66. data/lib/jinx/helpers/log.rb +106 -0
  67. data/lib/jinx/helpers/math.rb +12 -0
  68. data/lib/jinx/helpers/merge.rb +60 -0
  69. data/lib/jinx/helpers/module.rb +18 -0
  70. data/lib/jinx/helpers/multi_enumerator.rb +31 -0
  71. data/lib/jinx/helpers/options.rb +92 -0
  72. data/lib/jinx/helpers/os.rb +19 -0
  73. data/lib/jinx/helpers/partial_order.rb +37 -0
  74. data/lib/jinx/helpers/pretty_print.rb +207 -0
  75. data/lib/jinx/helpers/set.rb +8 -0
  76. data/lib/jinx/helpers/stopwatch.rb +76 -0
  77. data/lib/jinx/helpers/transformer.rb +24 -0
  78. data/lib/jinx/helpers/transitive_closure.rb +55 -0
  79. data/lib/jinx/helpers/uniquifier.rb +50 -0
  80. data/lib/jinx/helpers/validation.rb +33 -0
  81. data/lib/jinx/helpers/visitor.rb +370 -0
  82. data/lib/jinx/import/class_path_modifier.rb +77 -0
  83. data/lib/jinx/import/java.rb +337 -0
  84. data/lib/jinx/importer.rb +240 -0
  85. data/lib/jinx/metadata.rb +155 -0
  86. data/lib/jinx/metadata/attribute_enumerator.rb +73 -0
  87. data/lib/jinx/metadata/dependency.rb +244 -0
  88. data/lib/jinx/metadata/id_alias.rb +23 -0
  89. data/lib/jinx/metadata/introspector.rb +179 -0
  90. data/lib/jinx/metadata/inverse.rb +170 -0
  91. data/lib/jinx/metadata/java_property.rb +169 -0
  92. data/lib/jinx/metadata/propertied.rb +500 -0
  93. data/lib/jinx/metadata/property.rb +401 -0
  94. data/lib/jinx/metadata/property_characteristics.rb +114 -0
  95. data/lib/jinx/resource.rb +862 -0
  96. data/lib/jinx/resource/copy_visitor.rb +36 -0
  97. data/lib/jinx/resource/inversible.rb +90 -0
  98. data/lib/jinx/resource/match_visitor.rb +180 -0
  99. data/lib/jinx/resource/matcher.rb +20 -0
  100. data/lib/jinx/resource/merge_visitor.rb +73 -0
  101. data/lib/jinx/resource/mergeable.rb +185 -0
  102. data/lib/jinx/resource/reference_enumerator.rb +49 -0
  103. data/lib/jinx/resource/reference_path_visitor.rb +38 -0
  104. data/lib/jinx/resource/reference_visitor.rb +55 -0
  105. data/lib/jinx/resource/unique.rb +35 -0
  106. data/lib/jinx/version.rb +3 -0
  107. data/spec/defaults_spec.rb +30 -0
  108. data/spec/definitions/model/alias/child.rb +5 -0
  109. data/spec/definitions/model/base/child.rb +5 -0
  110. data/spec/definitions/model/base/domain_object.rb +5 -0
  111. data/spec/definitions/model/base/independent.rb +5 -0
  112. data/spec/definitions/model/defaults/child.rb +5 -0
  113. data/spec/definitions/model/dependency/child.rb +5 -0
  114. data/spec/definitions/model/dependency/parent.rb +6 -0
  115. data/spec/definitions/model/inverse/child.rb +5 -0
  116. data/spec/definitions/model/inverse/independent.rb +5 -0
  117. data/spec/definitions/model/inverse/parent.rb +5 -0
  118. data/spec/definitions/model/mandatory/child.rb +6 -0
  119. data/spec/dependency_spec.rb +47 -0
  120. data/spec/family_spec.rb +64 -0
  121. data/spec/inverse_spec.rb +53 -0
  122. data/spec/mandatory_spec.rb +43 -0
  123. data/spec/metadata_spec.rb +68 -0
  124. data/spec/resource_spec.rb +30 -0
  125. data/spec/spec_helper.rb +3 -0
  126. data/spec/support/model.rb +19 -0
  127. data/test/fixtures/line_separator/cr_line_sep.txt +1 -0
  128. data/test/fixtures/line_separator/crlf_line_sep.txt +3 -0
  129. data/test/fixtures/line_separator/lf_line_sep.txt +3 -0
  130. data/test/fixtures/mixed/ext/build.xml +35 -0
  131. data/test/fixtures/mixed/ext/src/mixed/Case/Example.java +5 -0
  132. data/test/helper.rb +7 -0
  133. data/test/lib/jinx/command_test.rb +41 -0
  134. data/test/lib/jinx/helpers/boolean_test.rb +27 -0
  135. data/test/lib/jinx/helpers/class_test.rb +60 -0
  136. data/test/lib/jinx/helpers/collections_test.rb +402 -0
  137. data/test/lib/jinx/helpers/file_separator_test.rb +29 -0
  138. data/test/lib/jinx/helpers/inflector_test.rb +11 -0
  139. data/test/lib/jinx/helpers/lazy_hash_test.rb +32 -0
  140. data/test/lib/jinx/helpers/module_test.rb +24 -0
  141. data/test/lib/jinx/helpers/options_test.rb +66 -0
  142. data/test/lib/jinx/helpers/partial_order_test.rb +41 -0
  143. data/test/lib/jinx/helpers/pretty_print_test.rb +83 -0
  144. data/test/lib/jinx/helpers/stopwatch_test.rb +16 -0
  145. data/test/lib/jinx/helpers/transitive_closure_test.rb +80 -0
  146. data/test/lib/jinx/helpers/visitor_test.rb +288 -0
  147. data/test/lib/jinx/import/java_test.rb +78 -0
  148. data/test/lib/jinx/import/mixed_case_test.rb +16 -0
  149. metadata +272 -0
@@ -0,0 +1,15 @@
1
+ # Add the Java jar file to the Java path.
2
+ require File.dirname(__FILE__) + '/../ext/bin/family.jar'
3
+
4
+ # The Jinx Model example application domain module.
5
+ module Family
6
+ include Jinx::Resource
7
+
8
+ extend Jinx::Importer
9
+
10
+ # The Java package name.
11
+ packages 'family'
12
+
13
+ # The JRuby mix-ins are in the model subdirectory.
14
+ definitions File.dirname(__FILE__) + '/family'
15
+ end
@@ -0,0 +1,6 @@
1
+ module Family
2
+ class Address
3
+ # The postal code is aliased as zip.
4
+ property :postal_code, :alias => :zip
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Family
2
+ class DomainObject
3
+ # The identifier property is the primary key.
4
+ property :identifier, :primary_key
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Family
2
+ class Household
3
+ # The household owns its address.
4
+ property :address, :dependent
5
+ end
6
+ end
@@ -0,0 +1,16 @@
1
+ module Family
2
+ class Parent
3
+ # The SSN is a secondary key
4
+ property :ssn, :secondary_key
5
+
6
+ # A parent owns children.
7
+ property :children, :dependent
8
+
9
+ # The spouse is an independent reference. The spouse is an idempotent inverse,
10
+ # i.e. parent = parent.spouse.spouse.
11
+ property :spouse, :inverse => :spouse
12
+
13
+ # The household is an independent reference with inverse members.
14
+ property :household, :inverse => :members
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ module Family
2
+ class Person
3
+ # The household is an independent reference with inverse members.
4
+ property :household, :inverse => :members
5
+ end
6
+ end
@@ -0,0 +1,25 @@
1
+ Jinx Model Example
2
+ ===================
3
+
4
+ This directory contains a generic Jinx usage example which exercises most of the meta-data possibilities.
5
+ The associations are as follows:
6
+
7
+ * Parent is-a Person
8
+
9
+ * Child is-a Person
10
+
11
+ * 1 Parent : N Children (bidirectonal dependent)
12
+
13
+ * 1 Parent : 1 spouse Parent (bidirectonal independent)
14
+
15
+ * 1 Person : 1 Dependent (unidirectonal dependent)
16
+
17
+ * 1 Independent : N People (bidirectional independent)
18
+
19
+ * M Children : N friend Children (bidirectional self-referential typed independent)
20
+
21
+ * M Independents : N other Independents (bidirectional self-referential untyped independent)
22
+
23
+ * 1-2 Parents : N Children (bidirectonal dependent)
24
+
25
+ Every object has an identifier and a name. Child has all supported primitive property types.
@@ -0,0 +1,35 @@
1
+ <?xml version ="1.0"?>
2
+
3
+ <project name="import Jinx test fixture" default="jar">
4
+
5
+ <!--build locations -->
6
+ <property name="base.dir" value="." />
7
+ <property name="source.dir" value="src" />
8
+ <property name="target.dir" value="classes" />
9
+ <property name="bin.dir" value="bin" />
10
+
11
+ <target name="init">
12
+ <tstamp />
13
+ <mkdir dir="${target.dir}" />
14
+ <mkdir dir="${bin.dir}" />
15
+ </target>
16
+
17
+ <!-- Compile all files in the source directory -->
18
+ <target name="compile" depends="init">
19
+ <javac destdir="${target.dir}" includes="**/*.*" includeAntRuntime="false">
20
+ <src path="${source.dir}" />
21
+ <compilerarg value="-Xlint:unchecked"/>
22
+ </javac>
23
+ </target>
24
+
25
+ <target name="jar" depends="compile">
26
+ <jar destfile="${bin.dir}/model.jar" basedir="${target.dir}" includes="**/*.*" />
27
+ </target>
28
+
29
+ <!-- Remove build directories -->
30
+ <target name="clean">
31
+ <delete dir="${bin.dir}" />
32
+ <delete dir="${target.dir}" />
33
+ </target>
34
+
35
+ </project>
@@ -0,0 +1,192 @@
1
+ package domain;
2
+
3
+ import java.util.Collection;
4
+ import java.util.ArrayList;
5
+
6
+ public class Child extends DomainObject implements Person
7
+ {
8
+ /**
9
+ * A string property.
10
+ */
11
+ private String name;
12
+
13
+ /**
14
+ * A boolean property.
15
+ */
16
+ private Jinx::Boolean flag;
17
+
18
+ /**
19
+ * An integer property.
20
+ */
21
+ private Integer cardinal;
22
+
23
+ /**
24
+ * A decimal property.
25
+ */
26
+ private Double decimal;
27
+
28
+ /**
29
+ * This child's parent.
30
+ * <p>
31
+ * This property exercises a reference from a dependent to its owner.
32
+ * </p>
33
+ */
34
+ private Parent parent;
35
+
36
+ /**
37
+ * This child's siblings.
38
+ * <p>
39
+ * This property exercises a 1:M self-reference.
40
+ * </p>
41
+ */
42
+ private Collection<Child> friends;
43
+
44
+ /**
45
+ * This child's independent reference.
46
+ * <p>
47
+ * This property exercises a reference to an independent object.
48
+ * </p>
49
+ */
50
+ private Independent indy;
51
+
52
+ /**
53
+ * This child's uni-directional dependent reference.
54
+ * <p>
55
+ * This property exercises a reference to a uni-directional dependent object.
56
+ * </p>
57
+ */
58
+ private Dependent dependent;
59
+
60
+ public Child()
61
+ {
62
+ friends = new ArrayList<Child>();
63
+ }
64
+
65
+ /**
66
+ * @return the name
67
+ */
68
+ public String getName()
69
+ {
70
+ return name;
71
+ }
72
+
73
+ /**
74
+ * @param name the name to set
75
+ */
76
+ public void setName(String name)
77
+ {
78
+ this.name = name;
79
+ }
80
+
81
+ /**
82
+ * @return the flag
83
+ */
84
+ public Jinx::Boolean getFlag()
85
+ {
86
+ return flag;
87
+ }
88
+
89
+ /**
90
+ * @param flag the flag to set
91
+ */
92
+ public void setFlag(Jinx::Boolean flag)
93
+ {
94
+ this.flag = flag;
95
+ }
96
+
97
+ /**
98
+ * @return the decimal
99
+ */
100
+ public Double getDecimal()
101
+ {
102
+ return decimal;
103
+ }
104
+
105
+ /**
106
+ * @param decimal the decimal to set
107
+ */
108
+ public void setDecimal(Double decimal)
109
+ {
110
+ this.decimal = decimal;
111
+ }
112
+
113
+ /**
114
+ * @return the cardinal
115
+ */
116
+ public Integer getCardinal()
117
+ {
118
+ return cardinal;
119
+ }
120
+
121
+ /**
122
+ * @param cardinal the cardinal to set
123
+ */
124
+ public void setCardinal(Integer cardinal)
125
+ {
126
+ this.cardinal = cardinal;
127
+ }
128
+
129
+ /**
130
+ * @return the parent
131
+ */
132
+ public Parent getParent()
133
+ {
134
+ return parent;
135
+ }
136
+
137
+ /**
138
+ * @param parent the parent to set
139
+ */
140
+ public void setParent(Parent parent)
141
+ {
142
+ this.parent = parent;
143
+ }
144
+
145
+ /**
146
+ * @return the child independent reference
147
+ */
148
+ public Independent getIndy()
149
+ {
150
+ return indy;
151
+ }
152
+
153
+ /**
154
+ * @param indy the child independent reference to set
155
+ */
156
+ public void setIndy(Independent indy)
157
+ {
158
+ this.indy = indy;
159
+ }
160
+
161
+ /**
162
+ * @return the friends
163
+ */
164
+ public Collection<Child> getFriends()
165
+ {
166
+ return friends;
167
+ }
168
+
169
+ /**
170
+ * @param friends the friends to set
171
+ */
172
+ public void setFriends(Collection<Child> friends)
173
+ {
174
+ this.friends = friends;
175
+ }
176
+
177
+ /**
178
+ * @return the dependent
179
+ */
180
+ public Dependent getDependent()
181
+ {
182
+ return dependent;
183
+ }
184
+
185
+ /**
186
+ * @param dependent the dependent to set
187
+ */
188
+ public void setDependent(Dependent dependent)
189
+ {
190
+ this.dependent = dependent;
191
+ }
192
+ }
@@ -0,0 +1,29 @@
1
+ package domain;
2
+
3
+ public class Dependent extends DomainObject
4
+ {
5
+ /**
6
+ * A string property.
7
+ */
8
+ private String name;
9
+
10
+ public Dependent()
11
+ {
12
+ }
13
+
14
+ /**
15
+ * @return the name
16
+ */
17
+ public String getName()
18
+ {
19
+ return name;
20
+ }
21
+
22
+ /**
23
+ * @param name the name to set
24
+ */
25
+ public void setName(String name)
26
+ {
27
+ this.name = name;
28
+ }
29
+ }
@@ -0,0 +1,26 @@
1
+ package domain;
2
+
3
+ public abstract class DomainObject
4
+ {
5
+ private Long identifier;
6
+
7
+ public DomainObject()
8
+ {
9
+ }
10
+
11
+ /**
12
+ * @return the database identifier
13
+ */
14
+ public Long getIdentifier()
15
+ {
16
+ return identifier;
17
+ }
18
+
19
+ /**
20
+ * @param id the id to set
21
+ */
22
+ public void setIdentifier(Long id)
23
+ {
24
+ this.identifier = id;
25
+ }
26
+ }
@@ -0,0 +1,83 @@
1
+ package domain;
2
+
3
+ import java.util.Collection;
4
+ import java.util.ArrayList;
5
+ import java.util.HashSet;
6
+
7
+ public class Independent extends DomainObject
8
+ {
9
+ /**
10
+ * A string property.
11
+ */
12
+ private String name;
13
+
14
+ /**
15
+ * The people which reference this object.
16
+ * <p>
17
+ * This property exercises a heterogenous 1:M reference.
18
+ * </p>
19
+ */
20
+ private Collection<Person> people;
21
+
22
+ /**
23
+ * The other independents.
24
+ * <p>
25
+ * This property exercises an unparameterized M:N independent reference.
26
+ * </p>
27
+ */
28
+ private Collection others;
29
+
30
+ public Independent()
31
+ {
32
+ people = new HashSet<Person>();
33
+ others = new ArrayList();
34
+ }
35
+
36
+ /**
37
+ * @return the name
38
+ */
39
+ public String getName()
40
+ {
41
+ return name;
42
+ }
43
+
44
+ /**
45
+ * @param name the name to set
46
+ */
47
+ public void setName(String name)
48
+ {
49
+ this.name = name;
50
+ }
51
+
52
+ /**
53
+ * @return the others
54
+ */
55
+ public Collection<Person> getPeople()
56
+ {
57
+ return people;
58
+ }
59
+
60
+ /**
61
+ * @param others the others to set
62
+ */
63
+ public void setPeople(Collection<Person> people)
64
+ {
65
+ this.people = people;
66
+ }
67
+
68
+ /**
69
+ * @return the others
70
+ */
71
+ public Collection getOthers()
72
+ {
73
+ return others;
74
+ }
75
+
76
+ /**
77
+ * @param others the others to set
78
+ */
79
+ public void setOthers(Collection others)
80
+ {
81
+ this.others = others;
82
+ }
83
+ }