omnis 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omnis.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'rspec'
8
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Piotr Zolnierek
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.
@@ -0,0 +1,29 @@
1
+ # Omnis
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'omnis'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install omnis
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
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ Dir["**/*.rake"].each {|ext| load ext}
4
+
5
+ task :default => [:'spec:unit', :'spec:acceptance']
@@ -0,0 +1,5 @@
1
+ require "omnis/version"
2
+
3
+ module Omnis
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Omnis
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omnis/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "omnis"
8
+ gem.version = Omnis::VERSION
9
+ gem.authors = ["Piotr Zolnierek"]
10
+ gem.email = ["pz@anixe.pl"]
11
+ gem.description = %q{Helps a read-only ORM kind-of}
12
+ gem.summary = %q{see above}
13
+ gem.homepage = "http://github.com/pzol/omnis"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.add_development_dependency 'rspec', '>=2.9.0'
20
+ gem.add_development_dependency 'guard'
21
+ gem.add_development_dependency 'guard-rspec'
22
+ gem.add_development_dependency 'guard-bundler'
23
+ gem.add_development_dependency 'growl'
24
+ gem.add_development_dependency 'activesupport'
25
+ gem.add_development_dependency 'rake'
26
+ end
@@ -0,0 +1,49 @@
1
+ class BookingQuery
2
+ include Omnis::MongoQuery
3
+
4
+ collection Mongo::Connection.new['bms']['bookings']
5
+
6
+ def parse_date(value)
7
+ case result = Time.parse(value) rescue Chronic.parse(value, :guess => false)
8
+ when Time; Between.new(m, result.getlocal.beginning_of_day..result.getlocal.end_of_day)
9
+ when Chronic::Span; Between.new(m, result)
10
+ else nil
11
+ end
12
+ end
13
+
14
+ param :contract, Matches
15
+ param :date_from {|value| parse_date(value) }
16
+ param :date_to {|value| parse_date(value) }
17
+
18
+ fields %w[ref_anixe ref_customer status passengers date_status_modified date_from date_to description product contract agency services]
19
+ end
20
+
21
+ class BookingTransformer
22
+ include Omnis::DataTransformer
23
+
24
+ def extract_passenger(doc)
25
+ ->doc { Maybe(doc)['passengers'].map {|v| v.first.values.slice(1..2).join(' ') }.or('Unknown').fetch.to_s }
26
+ end
27
+
28
+ property :ref_anixe, "ref_anixe"
29
+ property :ref_customer, "ref_customer"
30
+ property :status, "status"
31
+ property :passenger, extract_passenger(doc)
32
+ property :date "date_status_modified", :default => Time.at(0), :format => ->v { v.to_s(:date) }
33
+ property :description, "description"
34
+ property :product, "product"
35
+ property :contract, "contract"
36
+ property :agency, "agency"
37
+ property :date_from, "services.0.date_from", :default => "n/a", :format => ->v { v.to_s(:date) }
38
+ property :date_to, "services.0.date_to", :default => "n/a", :format => ->v { v.to_s(:date) }
39
+
40
+ def to_object(doc)
41
+ OpenStruct.new(doc)
42
+ end
43
+ end
44
+
45
+ present BookingQuery.new(params), Foo.new(NestedHashExtractor.new)
46
+
47
+ def present(query, transformer)
48
+ query.call(transformer)
49
+ end
@@ -0,0 +1,26 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ SPEC_SUITES = [
4
+ { :id => :unit,
5
+ :title => 'unit',
6
+ :files => %w(spec/**/*_spec.rb) },
7
+
8
+ { :id => :acceptance,
9
+ :title => 'acceptance',
10
+ :files => %w(spec_acceptance/acceptance/**/*_spec.rb),
11
+ :opts => '-I spec_acceptance' },
12
+ ]
13
+
14
+
15
+ namespace :spec do
16
+ SPEC_SUITES.each do |suite|
17
+ desc "Run #{suite[:title]} tests"
18
+ RSpec::Core::RakeTask.new(suite[:id]) do |t|
19
+ spec_files = []
20
+ suite[:files].each { |glob| spec_files += Dir[glob] } if suite[:files]
21
+ t.pattern = spec_files
22
+
23
+ t.rspec_opts = suite[:opts] if suite.has_key? :opts
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ require 'bundler/setup'
2
+ Bundler.require :test
3
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omnis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Piotr Zolnierek
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.9.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.9.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: guard
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: guard-rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: guard-bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: growl
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: activesupport
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rake
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: Helps a read-only ORM kind-of
127
+ email:
128
+ - pz@anixe.pl
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - Gemfile
135
+ - LICENSE.txt
136
+ - README.md
137
+ - Rakefile
138
+ - lib/omnis.rb
139
+ - lib/omnis/version.rb
140
+ - omnis.gemspec
141
+ - readme.rb
142
+ - spec/spec.rake
143
+ - spec/spec_helper.rb
144
+ homepage: http://github.com/pzol/omnis
145
+ licenses: []
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ! '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 1.8.23
165
+ signing_key:
166
+ specification_version: 3
167
+ summary: see above
168
+ test_files:
169
+ - spec/spec.rake
170
+ - spec/spec_helper.rb