geo-core 0.0.4
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/Gemfile.lock +45 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/geo-core-0.0.2.gem +0 -0
- data/geo-core-0.0.3.gem +0 -0
- data/geo-core.gemspec +19 -0
- data/lib/domain/item_orcamento.rb +19 -0
- data/lib/domain/material.rb +3 -0
- data/lib/domain/orcamento.rb +22 -0
- data/lib/domain_helper.rb +5 -0
- data/lib/geo-core.rb +6 -0
- data/lib/geo-core/version.rb +5 -0
- data/lib/mongoid.yml +12 -0
- data/lib/service/orcamento_service.rb +38 -0
- metadata +75 -0
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
ZenTest (4.8.3)
|
5
|
+
activemodel (3.2.11)
|
6
|
+
activesupport (= 3.2.11)
|
7
|
+
builder (~> 3.0.0)
|
8
|
+
activesupport (3.2.11)
|
9
|
+
i18n (~> 0.6)
|
10
|
+
multi_json (~> 1.0)
|
11
|
+
autotest (4.4.6)
|
12
|
+
ZenTest (>= 4.4.1)
|
13
|
+
builder (3.0.4)
|
14
|
+
diff-lcs (1.1.3)
|
15
|
+
i18n (0.6.1)
|
16
|
+
mongoid (3.0.17)
|
17
|
+
activemodel (~> 3.1)
|
18
|
+
moped (~> 1.2)
|
19
|
+
origin (~> 1.0)
|
20
|
+
tzinfo (~> 0.3.22)
|
21
|
+
moped (1.3.2)
|
22
|
+
multi_json (1.5.0)
|
23
|
+
origin (1.0.11)
|
24
|
+
rspec (2.12.0)
|
25
|
+
rspec-core (~> 2.12.0)
|
26
|
+
rspec-expectations (~> 2.12.0)
|
27
|
+
rspec-mocks (~> 2.12.0)
|
28
|
+
rspec-core (2.12.2)
|
29
|
+
rspec-expectations (2.12.1)
|
30
|
+
diff-lcs (~> 1.1.3)
|
31
|
+
rspec-mocks (2.12.1)
|
32
|
+
rspec-nc (0.0.4)
|
33
|
+
rspec (~> 2.9)
|
34
|
+
terminal-notifier (~> 1.4.2)
|
35
|
+
terminal-notifier (1.4.2)
|
36
|
+
tzinfo (0.3.35)
|
37
|
+
|
38
|
+
PLATFORMS
|
39
|
+
ruby
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
autotest
|
43
|
+
mongoid
|
44
|
+
rspec
|
45
|
+
rspec-nc
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Marco Rojo
|
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,29 @@
|
|
1
|
+
# Geo::Core
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'geo-core'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install geo-core
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/geo-core-0.0.2.gem
ADDED
Binary file
|
data/geo-core-0.0.3.gem
ADDED
Binary file
|
data/geo-core.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'geo-core/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "geo-core"
|
8
|
+
gem.version = Geo::Core::VERSION
|
9
|
+
gem.authors = ["Marco Rojo"]
|
10
|
+
gem.email = ["mrmarcondes@gmail.com"]
|
11
|
+
gem.description = %q{Apenas um teste}
|
12
|
+
gem.summary = %q{Apenas um teste}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.add_dependency "mongoid"
|
16
|
+
|
17
|
+
gem.files = Dir['lib/**/*.rb'] + Dir['lib/*.yml'] + Dir['*.*']
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative '../geo-core.rb'
|
2
|
+
|
3
|
+
module Geo
|
4
|
+
module Core
|
5
|
+
class ItemOrcamento
|
6
|
+
include Mongoid::Document
|
7
|
+
store_in collection: "itens_orcamento"
|
8
|
+
|
9
|
+
belongs_to :orcamento, class_name: "Geo::Core::Orcamento"
|
10
|
+
|
11
|
+
field :codigo_material
|
12
|
+
field :quantidade
|
13
|
+
|
14
|
+
validates :codigo_material, :quantidade, presence: true
|
15
|
+
validates :quantidade, :numericality => true
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../geo-core.rb'
|
2
|
+
|
3
|
+
module Geo
|
4
|
+
module Core
|
5
|
+
class Orcamento
|
6
|
+
include Mongoid::Document
|
7
|
+
store_in collection: "orcamentos"
|
8
|
+
|
9
|
+
field :cliente
|
10
|
+
field :descricao
|
11
|
+
|
12
|
+
has_many :itens, class_name: 'Geo::Core::ItemOrcamento'
|
13
|
+
|
14
|
+
validates :cliente, :descricao, presence: true
|
15
|
+
|
16
|
+
#necessario por conta do form.fields_for do rails
|
17
|
+
def itens_attributes=(attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/geo-core.rb
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
require 'mongoid'
|
2
|
+
current_path = File.expand_path File.dirname(__FILE__)
|
3
|
+
Mongoid.load!(current_path << "/mongoid.yml", :development)
|
4
|
+
Dir['./lib/domain/*.rb'].each {|file| require file }
|
5
|
+
Dir['./lib/service/*.rb'].each {|file| require file }
|
6
|
+
Dir['./lib/*.rb'].each {|file| require file }
|
data/lib/mongoid.yml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative '../domain/orcamento.rb'
|
2
|
+
require_relative '../domain/item_orcamento.rb'
|
3
|
+
|
4
|
+
module Geo
|
5
|
+
module Service
|
6
|
+
class Orcamento
|
7
|
+
def self.novo
|
8
|
+
return Geo::Core::Orcamento.new
|
9
|
+
end
|
10
|
+
|
11
|
+
#FIXME fazer tratamento de errors
|
12
|
+
def self.salvar(params)
|
13
|
+
begin
|
14
|
+
orcamento = Geo::Core::Orcamento.new params
|
15
|
+
raise orcamento.errors unless orcamento.valid?
|
16
|
+
orcamento.save
|
17
|
+
criar_itens_para orcamento, params[:itens_attributes]
|
18
|
+
return orcamento
|
19
|
+
rescue
|
20
|
+
raise ""
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def self.criar_itens_para(orcamento, param)
|
26
|
+
itens = Array.new
|
27
|
+
param.each do |chave, valor|
|
28
|
+
item = Geo::Core::ItemOrcamento.new valor
|
29
|
+
itens.push item if item.valid?
|
30
|
+
end
|
31
|
+
orcamento.itens.push itens
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: geo-core
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Marco Rojo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: mongoid
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Apenas um teste
|
31
|
+
email:
|
32
|
+
- mrmarcondes@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- lib/domain/item_orcamento.rb
|
38
|
+
- lib/domain/material.rb
|
39
|
+
- lib/domain/orcamento.rb
|
40
|
+
- lib/domain_helper.rb
|
41
|
+
- lib/geo-core/version.rb
|
42
|
+
- lib/geo-core.rb
|
43
|
+
- lib/service/orcamento_service.rb
|
44
|
+
- lib/mongoid.yml
|
45
|
+
- Gemfile.lock
|
46
|
+
- geo-core-0.0.2.gem
|
47
|
+
- geo-core-0.0.3.gem
|
48
|
+
- geo-core.gemspec
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
homepage: ''
|
52
|
+
licenses: []
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.8.24
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Apenas um teste
|
75
|
+
test_files: []
|