collection_base 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 +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +3 -0
- data/Gemfile +8 -0
- data/LICENSE +21 -0
- data/README.md +39 -0
- data/Rakefile +21 -0
- data/bin/console +16 -0
- data/bin/setup +16 -0
- data/collection_base.gemspec +28 -0
- data/lib/collection_base/base.rb +79 -0
- data/lib/collection_base/version.rb +3 -0
- data/lib/collection_base.rb +6 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6778ebea100442761ed9f019e126b1360616e15f
|
4
|
+
data.tar.gz: 0cf1a29e7dbaa24feb85e38a789904a29f669552
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21c5dcb507b78ceff6b30d4d9d2918c56af8f1034594cc06f388e608388daa04dac0ea72162adadfa6039ecbff4bc48be4a6a5d6cf0acdc75f43dc5afe4a8992
|
7
|
+
data.tar.gz: 39136b80237335184bbcbbac5cc2cb932a31147d4d65e5b3f9f737a38d0a92410c4c89b33a6e8af686682b5166c5e183ea42badb65e4a7d87aa11a6d32513973
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Cenit, LLC
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# CollectionBase
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/collection_base`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'collection_base'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install collection_base
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/collection_base/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new
|
7
|
+
|
8
|
+
task :default do
|
9
|
+
Rake::Task[:spec].invoke
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'Run specs'
|
13
|
+
RSpec::Core::RakeTask.new do |t|
|
14
|
+
t.pattern = './spec/**/*_spec.rb'
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Generate code coverage'
|
18
|
+
RSpec::Core::RakeTask.new(:coverage) do |t|
|
19
|
+
t.rcov = true
|
20
|
+
t.rcov_opts = ['--exclude', '/gems/,spec']
|
21
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'console' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('collection_base', 'console')
|
data/bin/setup
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'setup' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('collection_base', 'setup')
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'collection_base/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.name = 'collection_base'
|
9
|
+
s.version = CollectionBase::VERSION
|
10
|
+
s.summary = 'Collection base for develop Collection in Cenithub'
|
11
|
+
s.description = 'Collection base for develop Collection in Cenithub'
|
12
|
+
s.required_ruby_version = '>= 2.0.0'
|
13
|
+
|
14
|
+
s.authors = ['Asnioby Hernandez Lopez', 'Miguel Sancho']
|
15
|
+
s.email = ['asnioby@gmail.com', 'sanchojaf@gmail.com']
|
16
|
+
s.homepage = 'http://www.cenitsaas.com'
|
17
|
+
s.license = "MIT"
|
18
|
+
|
19
|
+
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
s.bindir = 'bin'
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
|
24
|
+
s.add_development_dependency "bundler", "~> 1.9"
|
25
|
+
s.add_development_dependency "rake", "~> 10.0"
|
26
|
+
|
27
|
+
s.requirements << 'none'
|
28
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module CollectionBase
|
2
|
+
class Base
|
3
|
+
|
4
|
+
attr_accessor :base_path
|
5
|
+
|
6
|
+
def initialize (base_path)
|
7
|
+
@base_path = base_path
|
8
|
+
end
|
9
|
+
|
10
|
+
def process_model(object)
|
11
|
+
result = []
|
12
|
+
files = load_json(object).to_a
|
13
|
+
files.collect do |file|
|
14
|
+
result << JSON.parse(open_json(file))
|
15
|
+
end
|
16
|
+
result
|
17
|
+
end
|
18
|
+
|
19
|
+
def process_libraries
|
20
|
+
results = []
|
21
|
+
lib_index = @base_path + '/libraries/index.json'
|
22
|
+
libraries = JSON.parse(open_json(lib_index)).to_a
|
23
|
+
libraries.collect do |lib|
|
24
|
+
schemas = []
|
25
|
+
files = load_libraries(lib["file"]).to_a
|
26
|
+
files.collect do |file|
|
27
|
+
hash = {"uri" => File.basename(file),
|
28
|
+
"schema" => open_json(file).to_s,
|
29
|
+
"library" => {
|
30
|
+
"_reference" => true,
|
31
|
+
"name" => lib["name"]
|
32
|
+
}
|
33
|
+
}
|
34
|
+
schemas << hash
|
35
|
+
end
|
36
|
+
results << {"name" => lib["name"], "schemas" => schemas}
|
37
|
+
end
|
38
|
+
results
|
39
|
+
end
|
40
|
+
|
41
|
+
def shared_base
|
42
|
+
JSON.parse(open_head)
|
43
|
+
end
|
44
|
+
|
45
|
+
def sample_data(file)
|
46
|
+
JSON.parse(open_sample(file))
|
47
|
+
end
|
48
|
+
|
49
|
+
def open_json(file)
|
50
|
+
File.open(file, mode: "r:utf-8").read
|
51
|
+
rescue => e
|
52
|
+
e.message
|
53
|
+
end
|
54
|
+
|
55
|
+
def open_head
|
56
|
+
File.open(@base_path + '/index.json', mode: "r:utf-8").read
|
57
|
+
rescue => e
|
58
|
+
e.message
|
59
|
+
end
|
60
|
+
|
61
|
+
def open_sample(model)
|
62
|
+
File.open(@base_path + "/support/sample/#{model}.json", mode: "r:utf-8").read
|
63
|
+
rescue => e
|
64
|
+
e.message
|
65
|
+
end
|
66
|
+
|
67
|
+
def load_json(object)
|
68
|
+
Dir.glob("#{@base_path}/#{object}/*.json")
|
69
|
+
rescue => e
|
70
|
+
e.message
|
71
|
+
end
|
72
|
+
|
73
|
+
def load_libraries(lib)
|
74
|
+
Dir.glob("#{@base_path}/libraries/#{lib}/*.json")
|
75
|
+
rescue => e
|
76
|
+
e.message
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: collection_base
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Asnioby Hernandez Lopez
|
8
|
+
- Miguel Sancho
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-05-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.9'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.9'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
description: Collection base for develop Collection in Cenithub
|
43
|
+
email:
|
44
|
+
- asnioby@gmail.com
|
45
|
+
- sanchojaf@gmail.com
|
46
|
+
executables:
|
47
|
+
- console
|
48
|
+
- setup
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- ".gitignore"
|
53
|
+
- ".travis.yml"
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- bin/console
|
59
|
+
- bin/setup
|
60
|
+
- collection_base.gemspec
|
61
|
+
- lib/collection_base.rb
|
62
|
+
- lib/collection_base/base.rb
|
63
|
+
- lib/collection_base/version.rb
|
64
|
+
homepage: http://www.cenitsaas.com
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 2.0.0
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements:
|
83
|
+
- none
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.2.2
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Collection base for develop Collection in Cenithub
|
89
|
+
test_files: []
|