flexquery_datastore 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5396d1a1fc23ca413a7edf78df7cdf48fe00866b
4
+ data.tar.gz: 3fe7a9a0b538a2ab0ce24fb8acb23cc1818bf124
5
+ SHA512:
6
+ metadata.gz: 03b28ff426e62bebe050ac523f247563c9b502ef55de7f3c2e75194a0056230769beefbdd9ec6b36f0d63a7a015804e75c3f52fbc1fa4cdb21879b654ac36631
7
+ data.tar.gz: 5a7411d80b99e0a62afe23afb955448e60240da566964553bc095aebcb8e00bf7c410503bcb05dd971a5f0a2c5fb6f027d832ceaf5456fb6648351a321d9693d
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in flexquery_datastore.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Eli Shkurkin
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,92 @@
1
+ # FlexqueryDatastore
2
+
3
+ A Ruby Gem to interface with a FlexQuery DataStore instance.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'flexquery_datastore'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install flexquery_datastore
20
+
21
+ ## Usage
22
+
23
+ This gem is for the DataStore product offered by [FlexQuery](flexquery.com). It provides an ORM mapping on top of the DataStore database.
24
+
25
+ [DataMapper](http://datamapper.org/) was used as the ORM library. You can use [DataMapper query methods](http://datamapper.org/docs/find.html) on all objects created by this gem.
26
+
27
+ ### Up and Running
28
+ To get up and running you need to set an environment variable that your application can read with your postgres url.
29
+
30
+ ```ruby
31
+ DATASTORE_POSTGRES_URL=postgres://username:password@localhost/exampledb
32
+ ```
33
+ Optionally, you can set DataMapper to log all sql queries generated.
34
+ ```ruby
35
+ LOG_DATASTORE_QUERIES=true
36
+ ```
37
+ ### Available Classes and Associations
38
+ The following are the classes and associations available in this gem. All have been namespaced with DataStore::
39
+
40
+ ```ruby
41
+ # primary key rp8inventoryitems.desc1
42
+ DataStore::Product
43
+ product = DataStore::Product.first
44
+ product.variants
45
+ product.vendor
46
+ product.cateogry
47
+
48
+ # primary key rp8inventoryitems.itemsid
49
+ DataStore::Variant
50
+ variant = DataStore::Variant.first
51
+ variant.stocks
52
+ variant.product
53
+ variant.vendor
54
+ variant.category
55
+
56
+ # primary key rp8inventorydepartments.dcs
57
+ DataStore::Category
58
+ category = DataStore::Category.first
59
+ category.variants
60
+ category.products
61
+
62
+ # composite primary key rp8inventoryqtys.itemsid, rp8inventoryqtys.storeno
63
+ DataStore::Stock
64
+ stock = DataStore::Stock.first
65
+ stock.variant
66
+ stock.store
67
+
68
+ # primary key stores.storeno
69
+ DataStore::Store
70
+ store = DataStore::Store.first
71
+ store.stocks
72
+
73
+ # primary key rp8inventoryvendors.vendorcode
74
+ DataStore::Vendor
75
+ vendor = DataStore::Vendor.first
76
+ vendor.variants
77
+ vendor.products
78
+ ```
79
+
80
+ ## Development
81
+
82
+ 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.
83
+
84
+ 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).
85
+
86
+ ## Contributing
87
+
88
+ 1. Fork it ( https://github.com/[my-github-username]/flexquery_datastore/fork )
89
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
90
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
91
+ 4. Push to the branch (`git push origin my-new-feature`)
92
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ desc "Open an irb session with flexquery_datastore loaded in"
4
+ task :console do
5
+ sh "irb -rubygems -I lib -r flexquery_datastore.rb"
6
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "flexquery_datastore"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'flexquery_datastore/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "flexquery_datastore"
8
+ spec.version = FlexqueryDatastore::VERSION
9
+ spec.authors = ["Eli Shkurkin"]
10
+ spec.email = ["eshkurkin@gmail.com"]
11
+
12
+ spec.summary = %q{A Ruby Gem to interface with a FlexQuery DataStore instance.}
13
+ spec.description = %q{This gem is for the DataStore product offered by FlexQuery (flexquery.com).
14
+ It provides an ORM layer on top of the DataStore database.}
15
+ spec.homepage = "https://github.com/azaleasf/flexquery_datastore"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.8"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.3.0"
26
+
27
+ spec.add_runtime_dependency "data_mapper", "~> 1.2.0"
28
+ spec.add_runtime_dependency "dm-postgres-adapter", "~> 1.2.0"
29
+ end
@@ -0,0 +1,6 @@
1
+ require "flexquery_datastore/version"
2
+ require "data_mapper"
3
+
4
+ DataMapper::Logger.new($stdout, :debug) if ENV['LOG_DATASTORE_QUERIES']
5
+ DataMapper.setup(:default, ENV['DATASTORE_POSTGRES_URL'])
6
+ Dir[File.dirname(__FILE__) + '/flexquery_datastore/models/*.rb'].each {|file| require file }
@@ -0,0 +1,24 @@
1
+ module DataStore
2
+ class Category
3
+ include DataMapper::Resource
4
+ storage_names[:default] = "rp8inventorydepartments"
5
+ property :dcs, String, field: "dcs", key: true
6
+
7
+ has n, :variants, child_key: [:dcs]
8
+
9
+ property :dept, String, field: "dept"
10
+ property :class, String, field: "class"
11
+ property :subclass, String, field: "subclass"
12
+ property :dcsname, String, field: "dcsname"
13
+ property :deptname, String, field: "deptname"
14
+ property :classname, String, field: "classname"
15
+ property :subclassname, String, field: "subclassname"
16
+ property :puredcs, String, field: "puredcs"
17
+
18
+ def products
19
+ products = self.variants.uniq { |variant| variant.desc1 }
20
+ product_ids = products.map { |product| product.desc1 }
21
+ DataStore::Product.all(desc1: product_ids)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ module DataStore
2
+ class Product
3
+ include DataMapper::Resource
4
+ storage_names[:default] = "rp8inventoryitems"
5
+ property :desc1, String, field: "desc1", key: true
6
+
7
+ has n, :variants, child_key: [:desc1]
8
+ belongs_to :vendor, child_key: [:vendorcode]
9
+ belongs_to :category, child_key: [:dcs]
10
+
11
+ property :dcs, String, field: "dcs"
12
+ property :vendorcode, String, field: "vendorcode"
13
+ property :desc1, String, field: "desc1"
14
+ property :desc2, String, field: "desc2"
15
+ property :alu, String, field: "alu"
16
+ property :season, String, field: "udf0"
17
+ property :year, String, field: "udf1"
18
+ property :core, String, field: "udf2"
19
+ property :udf3, String, field: "udf3"
20
+ property :stylesid, Integer, field: "stylesid"
21
+ end
22
+ end
@@ -0,0 +1,16 @@
1
+ module DataStore
2
+ class Stock
3
+ include DataMapper::Resource
4
+ storage_names[:default] = "rp8inventoryqtys"
5
+ property :itemsid, Integer, field: "itemsid", key: true
6
+ property :storeno, Integer, field: "storeno", key: true
7
+
8
+ belongs_to :variant, child_key: [:itemsid]
9
+ belongs_to :store, child_key: [:storeno]
10
+
11
+ property :onhand, Integer, field: "onhand"
12
+ property :onorder, Integer, field: "onorder"
13
+ property :received, Integer, field: "received"
14
+ property :sold, Integer, field: "sold"
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ module DataStore
2
+ class Store
3
+ include DataMapper::Resource
4
+ storage_names[:default] = "stores"
5
+ property :storeno, Integer, field: "storeno", key: true
6
+
7
+ has n, :stocks, child_key: [:storeno]
8
+
9
+ property :storecode, Integer, field: "storecode"
10
+ property :name, String, field: "storename"
11
+ end
12
+ end
@@ -0,0 +1,42 @@
1
+ module DataStore
2
+ class Variant
3
+ include DataMapper::Resource
4
+ storage_names[:default] = "rp8inventoryitems"
5
+ property :itemsid, Integer, field: "itemsid", key: true
6
+
7
+ has n, :stocks, child_key: [:itemsid]
8
+ belongs_to :product, child_key: [:desc1]
9
+ belongs_to :vendor, child_key: [:vendorcode]
10
+ belongs_to :category, child_key: [:dcs]
11
+
12
+ property :desc1, String, field: "desc1"
13
+ property :attr, String, field: "attr"
14
+ property :size, String, field: "size"
15
+ property :lrecvd, DateTime, field: "lrecvd"
16
+ property :lsoldd, DateTime, field: "lsoldd"
17
+ property :frecvd, DateTime, field: "frecvd"
18
+ property :lmrkdnd, DateTime, field: "lmrkdnd"
19
+ property :price, Integer, field: "price"
20
+ property :cost, Float, field: "cost"
21
+ property :margin, Float, field: "mgn"
22
+ property :marginprc, Integer, field: "mgnprc"
23
+ property :coeff, Float, field: "coeff"
24
+ property :taxprc, Float, field: "taxprc"
25
+ property :tax, Float, field: "tax"
26
+ property :ordcost, Float, field: "ordcost"
27
+ property :formerprice, Integer, field: "frmrprc"
28
+ property :pricewtx, Float, field: "prcwtx"
29
+ property :marginwtx, Float, field: "mrgwtx"
30
+ property :formerpricewtx, Float, field: "frmrprcwtx"
31
+ property :printtags, Boolean, field: "printtags"
32
+ property :mkupprc, String, field: "mkupprc"
33
+ property :itemnum, Integer, field: "itemnum"
34
+ property :itemsid, Integer, field: "itemsid"
35
+ property :noninventory, Boolean, field: "noninventory"
36
+ property :committed, Boolean, field: "committed"
37
+ property :doclastedit, DateTime, field: "doclastedit"
38
+ property :salediscpercent, Float, field: "salediscpercent"
39
+ property :saledisc, Integer, field: "saledisc"
40
+ property :totaltax, Float, field: "totaltax"
41
+ end
42
+ end
@@ -0,0 +1,17 @@
1
+ module DataStore
2
+ class Vendor
3
+ include DataMapper::Resource
4
+ storage_names[:default] = "rp8inventoryvendors"
5
+ property :vendorcode, String, field: "vendorcode", key: true
6
+
7
+ has n, :variants, child_key: [:vendorcode]
8
+
9
+ property :name, String, field: "company"
10
+
11
+ def products
12
+ products = self.variants.uniq { |variant| variant.desc1 }
13
+ product_ids = products.map { |product| product.desc1 }
14
+ DataStore::Product.all(desc1: product_ids)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module FlexqueryDatastore
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flexquery_datastore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Eli Shkurkin
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.3.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.3.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: data_mapper
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.2.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: dm-postgres-adapter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.2.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.2.0
83
+ description: |-
84
+ This gem is for the DataStore product offered by FlexQuery (flexquery.com).
85
+ It provides an ORM layer on top of the DataStore database.
86
+ email:
87
+ - eshkurkin@gmail.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".rspec"
94
+ - ".travis.yml"
95
+ - CODE_OF_CONDUCT.md
96
+ - Gemfile
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - bin/console
101
+ - bin/setup
102
+ - flexquery_datastore.gemspec
103
+ - lib/flexquery_datastore.rb
104
+ - lib/flexquery_datastore/models/Category.rb
105
+ - lib/flexquery_datastore/models/Product.rb
106
+ - lib/flexquery_datastore/models/Stock.rb
107
+ - lib/flexquery_datastore/models/Store.rb
108
+ - lib/flexquery_datastore/models/Variant.rb
109
+ - lib/flexquery_datastore/models/Vendor.rb
110
+ - lib/flexquery_datastore/version.rb
111
+ homepage: https://github.com/azaleasf/flexquery_datastore
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.4.6
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: A Ruby Gem to interface with a FlexQuery DataStore instance.
135
+ test_files: []