jinx 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
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,14 @@
1
+ .DS_Store
2
+ *~
3
+ *.pdf
4
+ .project
5
+ .loadpath
6
+ .yardoc
7
+ *.gem
8
+ *.tar*
9
+ **/ext/bin
10
+ **/classes
11
+ /doc/api
12
+ **log
13
+ /test/results
14
+
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --backtrace
2
+ --format Fuubar
3
+ --color
@@ -0,0 +1 @@
1
+ -o doc/api --private --protected --name-tag 'quirk:Technology idiosyncracy' - History.md LEGAL LICENSE
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+ gemspec
3
+
4
+ group :development do
5
+ gem 'jinx', :path => File.dirname(__FILE__)
6
+ end
@@ -0,0 +1,27 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jinx (2.1.1)
5
+ bundler
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.1.3)
11
+ rake (0.9.2.2)
12
+ rspec (2.9.0)
13
+ rspec-core (~> 2.9.0)
14
+ rspec-expectations (~> 2.9.0)
15
+ rspec-mocks (~> 2.9.0)
16
+ rspec-core (2.9.0)
17
+ rspec-expectations (2.9.1)
18
+ diff-lcs (~> 1.1.3)
19
+ rspec-mocks (2.9.0)
20
+
21
+ PLATFORMS
22
+ java
23
+
24
+ DEPENDENCIES
25
+ jinx!
26
+ rake
27
+ rspec (>= 2.6)
@@ -0,0 +1,6 @@
1
+ This history lists major release themes. See the GitHub commits (https://github.com/jinx/core)
2
+ for change details.
3
+
4
+ 2.1.1 / 2012-04-13
5
+ ------------------
6
+ * Initial public release spun off from caruby/core.
data/LEGAL ADDED
@@ -0,0 +1,5 @@
1
+ LEGAL NOTICE INFORMATION
2
+ ------------------------
3
+
4
+ All the files in this distribution are covered under either the MIT
5
+ license (see the file LICENSE).
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Oregon Health & Science University
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ JINX: JRuby Java introspector
2
+ =============================
3
+
4
+ **Home**: [http://github.com/jinx/core](http://github.com/jinx/core)
5
+ **Git**: [http://github.com/jinx/core](http://github.com/jinx/core)
6
+ **Author**: OHSU Knight Cancer Institute
7
+ **Copyright**: 2012
8
+ **License**: MIT License
9
+
10
+ Synopsis
11
+ --------
12
+
13
+ Jinx introspects a Java application domain package.
14
+
15
+ Feature List
16
+ ------------
17
+
18
+ 1. Introspects Java properties.
19
+
20
+ 2. Annotates the introspected object model with additional meta-data.
21
+
22
+ 2. Manages object dependencies.
23
+
24
+ 3. Enforces inverse association integrity.
25
+
26
+ 4. Adds property defaults.
27
+
28
+ 5. Validates object completeness.
29
+
30
+ Installing
31
+ ----------
32
+ Jinx is installed as a JRuby gem:
33
+
34
+ [sudo] jgem install jinx
35
+
36
+ Usage
37
+ -----
38
+ See the [example](http://github.com/jinx/core/tree/master/examples/family) for a sample usage pattern.
39
+
40
+ Copyright
41
+ ---------
42
+
43
+ Jinx © 2012 by [Oregon Health & Science University](http://www.ohsu.edu/xd/health/services/cancer/index.cfm).
44
+ Jinx is licensed under the MIT license. Please see the LICENSE and LEGAL files for more information.
@@ -0,0 +1,41 @@
1
+ require 'fileutils'
2
+ require File.dirname(__FILE__) + '/lib/jinx/version'
3
+
4
+ # the gem name
5
+ GEM = 'jinx'
6
+ GEM_VERSION = Jinx::VERSION
7
+
8
+ WINDOWS = (Config::CONFIG['host_os'] =~ /mingw|win32|cygwin/ ? true : false) rescue false
9
+ SUDO = WINDOWS ? '' : 'sudo'
10
+
11
+ desc 'Default: run the tests'
12
+ task :default => :test
13
+
14
+ desc 'Builds the gem'
15
+ task :gem do
16
+ sh "jgem build #{GEM}.gemspec"
17
+ end
18
+
19
+ desc 'Installs the gem'
20
+ task :install => :gem do
21
+ sh "#{SUDO} jgem install #{GEM}-#{GEM_VERSION}.gem"
22
+ end
23
+
24
+ desc 'Documents the API'
25
+ task :doc do
26
+ FileUtils.rm_rf 'doc/api'
27
+ sh 'yardoc'
28
+ end
29
+
30
+ desc 'Runs the spec tests'
31
+ task :spec do
32
+ Dir['spec/**/*_spec.rb'].each { |f| sh "rspec #{f}" rescue nil }
33
+ end
34
+
35
+ desc 'Runs the unit tests'
36
+ task :unit do
37
+ Dir['test/**/*_test.rb'].each { |f| sh "jruby #{f}" rescue nil }
38
+ end
39
+
40
+ desc 'Runs all tests'
41
+ task :test => [:spec, :unit]
@@ -0,0 +1,10 @@
1
+ Jinx Family Example
2
+ ===================
3
+
4
+ This directory contains a simple Jinx usage example. The associations are as follows:
5
+
6
+ * 1 Household : N Persons (bidirectonal independent)
7
+
8
+ * 1 Household : 1 Address (unidirectional dependent)
9
+
10
+ * 1-2 Parents : N Children (bidirectonal dependent)
@@ -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}/family.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,68 @@
1
+ package family;
2
+
3
+ public class Address
4
+ {
5
+ private String street1;
6
+
7
+ private String street2;
8
+
9
+ private String city;
10
+
11
+ private String state;
12
+
13
+ private String postalCode;
14
+
15
+ public Address()
16
+ {
17
+ }
18
+
19
+ public String getStreet1()
20
+ {
21
+ return street1;
22
+ }
23
+
24
+ public void setStreet1(String value)
25
+ {
26
+ this.street1 = value;
27
+ }
28
+
29
+ public String getStreet2()
30
+ {
31
+ return street2;
32
+ }
33
+
34
+ public void setStreet2(String value)
35
+ {
36
+ this.street2 = value;
37
+ }
38
+
39
+ public String getCity()
40
+ {
41
+ return city;
42
+ }
43
+
44
+ public void setCity(String value)
45
+ {
46
+ this.city = value;
47
+ }
48
+
49
+ public String getState()
50
+ {
51
+ return state;
52
+ }
53
+
54
+ public void setState(String value)
55
+ {
56
+ this.state = value;
57
+ }
58
+
59
+ public String getPostalCode()
60
+ {
61
+ return postalCode;
62
+ }
63
+
64
+ public void setPostalCode(String value)
65
+ {
66
+ this.postalCode = value;
67
+ }
68
+ }
@@ -0,0 +1,24 @@
1
+ package family;
2
+
3
+ import java.util.Collection;
4
+ import java.util.ArrayList;
5
+
6
+ public class Child extends Person
7
+ {
8
+ private Collection<Parent> parents;
9
+
10
+ public Child()
11
+ {
12
+ parents = new ArrayList<Parent>();
13
+ }
14
+
15
+ public Collection<Parent> getParents()
16
+ {
17
+ return parents;
18
+ }
19
+
20
+ public void setParents(Collection<Parent> parents)
21
+ {
22
+ this.parents = parents;
23
+ }
24
+ }
@@ -0,0 +1,26 @@
1
+ package family;
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,36 @@
1
+ package family;
2
+
3
+ import java.util.Collection;
4
+ import java.util.HashSet;
5
+
6
+ public class Household extends DomainObject
7
+ {
8
+ private Address address;
9
+
10
+ private Collection<Person> members;
11
+
12
+ public Household()
13
+ {
14
+ members = new HashSet<Person>();
15
+ }
16
+
17
+ public Address getAddress()
18
+ {
19
+ return address;
20
+ }
21
+
22
+ public void setAddress(Address address)
23
+ {
24
+ this.address = address;
25
+ }
26
+
27
+ public Collection<Person> getMembers()
28
+ {
29
+ return members;
30
+ }
31
+
32
+ public void setMembers(Collection<Person> members)
33
+ {
34
+ this.members = members;
35
+ }
36
+ }
@@ -0,0 +1,48 @@
1
+ package family;
2
+
3
+ import java.util.Collection;
4
+ import java.util.ArrayList;
5
+
6
+ public class Parent extends Person
7
+ {
8
+ private Parent spouse;
9
+
10
+ private String ssn;
11
+
12
+ private Collection<Child> children;
13
+
14
+ public Parent()
15
+ {
16
+ children = new ArrayList<Child>();
17
+ }
18
+
19
+ public String getSSN()
20
+ {
21
+ return ssn;
22
+ }
23
+
24
+ public void setSSN(String value)
25
+ {
26
+ this.ssn = value;
27
+ }
28
+
29
+ public Parent getSpouse()
30
+ {
31
+ return spouse;
32
+ }
33
+
34
+ public void setSpouse(Parent spouse)
35
+ {
36
+ this.spouse = spouse;
37
+ }
38
+
39
+ public Collection<Child> getChildren()
40
+ {
41
+ return children;
42
+ }
43
+
44
+ public void setChildren(Collection<Child> children)
45
+ {
46
+ this.children = children;
47
+ }
48
+ }
@@ -0,0 +1,42 @@
1
+ package family;
2
+
3
+ import java.util.Date;
4
+
5
+ public class Person extends DomainObject
6
+ {
7
+ private String name;
8
+
9
+ private Date birthDate;
10
+
11
+ private Household household;
12
+
13
+ public String getName()
14
+ {
15
+ return name;
16
+ }
17
+
18
+ public void setName(String value)
19
+ {
20
+ this.name = value;
21
+ }
22
+
23
+ public Date getBirthDate()
24
+ {
25
+ return birthDate;
26
+ }
27
+
28
+ public void setBirthDate(Date date)
29
+ {
30
+ this.birthDate = date;
31
+ }
32
+
33
+ public Household getHousehold()
34
+ {
35
+ return household;
36
+ }
37
+
38
+ public void setHousehold(Household household)
39
+ {
40
+ this.household = household;
41
+ }
42
+ }