multi_mappable 0.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 085ec8b6c42883b155a22969b050c710f62bdd18
4
+ data.tar.gz: ad66eedfd9084a44743c4830c5c84eb017fd75cb
5
+ SHA512:
6
+ metadata.gz: 016a9ba2fc760316cf423777e42a002e962864b11a463e7ac425a6351ef425d6af162a7afdfc0cc7e6e1e22bf807e28348db380fda2c0d6239d44ae91fc85b5d
7
+ data.tar.gz: 62401430b3c9af9383f07bce44207ed1a67bf71e847a76a7419e7f2e37d4e306766d5542cd4cf834e724ea4c12613cf0f18309c27ce3488ca9e58af46cdd3f95
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .ruby-version
19
+ .tm_properties
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in multi_mappable.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 UCI, OIT
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # MultiMappable
2
+
3
+ Ruby gem mixing Virtus and ROXML to produce objects that can map between attributes and XML.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'multi_mappable'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install multi_mappable
18
+
19
+ ## Usage
20
+
21
+ ````ruby
22
+ class Person
23
+ include MultiMappable
24
+
25
+ element name: :name, type: String
26
+ element name: :address, type: String
27
+ end
28
+
29
+ class Contact
30
+ include MultiMappable
31
+
32
+ element name: :people, type: Array[Person], opts: { as: [Person] }
33
+ end
34
+
35
+ > p = Person.new
36
+ > p.name = "Zot"
37
+ > p.address = "UCI"
38
+ > c = Contact.new(people: [p])
39
+ > c.to_s
40
+
41
+ # Produces
42
+ <contact>
43
+ <person>
44
+ <name>Zot</name>
45
+ <address>UCI</address>
46
+ </person>
47
+ </contact>
48
+ ````
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it ( https://github.com/ucirvine/multi_mappable/fork )
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'MultiMappable'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ Bundler::GemHelper.install_tasks
18
+
19
+ require 'rspec/core/rake_task'
20
+
21
+ RSpec::Core::RakeTask.new(:spec)
22
+
23
+ task default: :spec
24
+
@@ -0,0 +1,5 @@
1
+ require "multi_mappable/version"
2
+ require "multi_mappable/multi_mappable"
3
+
4
+ module MultiMappable
5
+ end
@@ -0,0 +1,29 @@
1
+ require 'roxml'
2
+ require 'virtus'
3
+
4
+ module MultiMappable
5
+ module ClassMethods
6
+ def post_element(post_element = nil)
7
+ return(@post_element || {}) unless post_element.present?
8
+ @post_element = post_element
9
+ end
10
+
11
+ def element(args)
12
+ opts = args.fetch(:opts, {})
13
+ attribute args[:name], args[:type]
14
+ xml_accessor args[:name], opts.merge(post_element)
15
+ end
16
+ end
17
+
18
+ def self.included(base)
19
+ base.class_eval do
20
+ include ROXML
21
+ include Virtus.model
22
+ end
23
+ base.extend(ClassMethods)
24
+ end
25
+
26
+ def to_s
27
+ to_xml.to_s
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module MultiMappable
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'multi_mappable/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "multi_mappable"
8
+ spec.version = MultiMappable::VERSION
9
+ spec.authors = ["Jose Hales-Garcia"]
10
+ spec.email = ["jose.halesgarcia@uci.edu"]
11
+ spec.summary = %q{Map attributes and XML.}
12
+ spec.description = %q{Mix Virtus and ROXML to produce objects that can map between attributes and XML.}
13
+ spec.homepage = "https://github.com/ucirvine/multi_mappable"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(spec)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "virtus"
22
+ spec.add_dependency "roxml"
23
+ spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency "debugger"
27
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe MultiMappable do
4
+ let(:name) { "Zot" }
5
+ let(:address) { "UCI" }
6
+ let(:obj) { Contact.new(people: [Person.new(name: name, address: address)]) }
7
+
8
+ subject { obj.to_s.split.join }
9
+ it "converts attributes to XML" do
10
+ expect(subject).to eq(%{<contact><person><name>#{name}</name><address>#{address}</address></person></contact>})
11
+ end
12
+ end
13
+
14
+ class Person
15
+ include MultiMappable
16
+
17
+ element name: :name, type: String
18
+ element name: :address, type: String
19
+ end
20
+
21
+ class Contact
22
+ include MultiMappable
23
+
24
+ element name: :people, type: Array[Person], opts: { as: [Person] }
25
+ end
@@ -0,0 +1,24 @@
1
+ require 'multi_mappable'
2
+ require 'rspec/autorun'
3
+
4
+ # Requires supporting ruby files with custom matchers and macros, etc,
5
+ # in spec/support/ and its subdirectories.
6
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
7
+
8
+ # This file was generated by the `rspec --init` command. Conventionally, all
9
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
10
+ # Require this file using `require "spec_helper"` to ensure that it is only
11
+ # loaded once.
12
+ #
13
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
14
+ RSpec.configure do |config|
15
+ config.treat_symbols_as_metadata_keys_with_true_values = true
16
+ config.run_all_when_everything_filtered = true
17
+ config.filter_run :focus
18
+
19
+ # Run specs in random order to surface order dependencies. If you find an
20
+ # order dependency and want to debug it, you can fix the order by providing
21
+ # the seed, which is printed after each run.
22
+ # --seed 1234
23
+ config.order = 'random'
24
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: multi_mappable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jose Hales-Garcia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: virtus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: roxml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: debugger
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Mix Virtus and ROXML to produce objects that can map between attributes
98
+ and XML.
99
+ email:
100
+ - jose.halesgarcia@uci.edu
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - lib/multi_mappable.rb
111
+ - lib/multi_mappable/multi_mappable.rb
112
+ - lib/multi_mappable/version.rb
113
+ - multi_mappable.gemspec
114
+ - spec/multi_mappable_spec.rb
115
+ - spec/spec_helper.rb
116
+ homepage: https://github.com/ucirvine/multi_mappable
117
+ licenses:
118
+ - MIT
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.0.3
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Map attributes and XML.
140
+ test_files:
141
+ - spec/multi_mappable_spec.rb
142
+ - spec/spec_helper.rb