rawbotz 0.1.2
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 +12 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +9 -0
- data/README.md +185 -0
- data/Rakefile +29 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config.ru +9 -0
- data/exe/debug/test_mail +15 -0
- data/exe/rawbotz +39 -0
- data/exe/rawbotz_import_links +74 -0
- data/exe/rawbotz_maintenance.sh +57 -0
- data/exe/rawbotz_process_order +86 -0
- data/exe/rawbotz_process_order_queue +80 -0
- data/exe/rawbotz_stock_update +84 -0
- data/exe/rawbotz_update_local_products +48 -0
- data/exe/rawbotz_update_remote_products +160 -0
- data/lib/rawbotz/app.rb +84 -0
- data/lib/rawbotz/cli/order_result_table.rb +57 -0
- data/lib/rawbotz/datapolate.rb +42 -0
- data/lib/rawbotz/helpers/flash_helper.rb +13 -0
- data/lib/rawbotz/helpers/icon_helper.rb +40 -0
- data/lib/rawbotz/helpers/resource_link_helper.rb +45 -0
- data/lib/rawbotz/local_shop.rb +12 -0
- data/lib/rawbotz/mail_template.rb +29 -0
- data/lib/rawbotz/option_parser.rb +37 -0
- data/lib/rawbotz/order_processor.rb +92 -0
- data/lib/rawbotz/product_updater.rb +89 -0
- data/lib/rawbotz/public/Chart.min.js +14 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/HELP-US-OUT.txt +7 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/css/font-awesome.css +2086 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/css/font-awesome.min.css +4 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/fonts/FontAwesome.otf +0 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/fonts/fontawesome-webfont.eot +0 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/fonts/fontawesome-webfont.svg +655 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/fonts/fontawesome-webfont.woff +0 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/fonts/fontawesome-webfont.woff2 +0 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/less/animated.less +34 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/less/bordered-pulled.less +25 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/less/core.less +12 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/less/fixed-width.less +6 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/less/font-awesome.less +17 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/less/icons.less +697 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/less/larger.less +13 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/less/list.less +19 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/less/mixins.less +26 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/less/path.less +15 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/less/rotated-flipped.less +20 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/less/stacked.less +20 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/less/variables.less +708 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/scss/_animated.scss +34 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/scss/_bordered-pulled.scss +25 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/scss/_core.scss +12 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/scss/_fixed-width.scss +6 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/scss/_icons.scss +697 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/scss/_larger.scss +13 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/scss/_list.scss +19 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/scss/_mixins.scss +26 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/scss/_path.scss +15 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/scss/_rotated-flipped.scss +20 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/scss/_stacked.scss +20 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/scss/_variables.scss +708 -0
- data/lib/rawbotz/public/font-awesome-4.5.0/scss/font-awesome.scss +17 -0
- data/lib/rawbotz/public/jquery-2.2.0.min.js +4 -0
- data/lib/rawbotz/public/jui/external/jquery/jquery.js +9789 -0
- data/lib/rawbotz/public/jui/images/ui-icons_444444_256x240.png +0 -0
- data/lib/rawbotz/public/jui/images/ui-icons_555555_256x240.png +0 -0
- data/lib/rawbotz/public/jui/images/ui-icons_777620_256x240.png +0 -0
- data/lib/rawbotz/public/jui/images/ui-icons_777777_256x240.png +0 -0
- data/lib/rawbotz/public/jui/images/ui-icons_cc0000_256x240.png +0 -0
- data/lib/rawbotz/public/jui/images/ui-icons_ffffff_256x240.png +0 -0
- data/lib/rawbotz/public/jui/index.html +513 -0
- data/lib/rawbotz/public/jui/jquery-ui.css +1225 -0
- data/lib/rawbotz/public/jui/jquery-ui.js +16617 -0
- data/lib/rawbotz/public/jui/jquery-ui.min.css +7 -0
- data/lib/rawbotz/public/jui/jquery-ui.min.js +13 -0
- data/lib/rawbotz/public/jui/jquery-ui.structure.css +833 -0
- data/lib/rawbotz/public/jui/jquery-ui.structure.min.css +5 -0
- data/lib/rawbotz/public/jui/jquery-ui.theme.css +410 -0
- data/lib/rawbotz/public/jui/jquery-ui.theme.min.css +5 -0
- data/lib/rawbotz/public/pure-min.css +11 -0
- data/lib/rawbotz/public/rawbotz.css +60 -0
- data/lib/rawbotz/public/rawbotz.js +96 -0
- data/lib/rawbotz/public/rawbotz_ajax_product_link.js +64 -0
- data/lib/rawbotz/remote_shop.rb +21 -0
- data/lib/rawbotz/routes/non_remote_orders.rb +45 -0
- data/lib/rawbotz/routes/orders.rb +76 -0
- data/lib/rawbotz/routes/product_links.rb +68 -0
- data/lib/rawbotz/routes/products.rb +104 -0
- data/lib/rawbotz/routes/remote_shop.rb +37 -0
- data/lib/rawbotz/routes/suppliers.rb +36 -0
- data/lib/rawbotz/routes.rb +9 -0
- data/lib/rawbotz/version.rb +3 -0
- data/lib/rawbotz/views/_hide_unhide_button.haml +11 -0
- data/lib/rawbotz/views/_menu.haml +20 -0
- data/lib/rawbotz/views/index.haml +1 -0
- data/lib/rawbotz/views/layout.haml +55 -0
- data/lib/rawbotz/views/maintenance/menu.haml +25 -0
- data/lib/rawbotz/views/maintenance.haml +150 -0
- data/lib/rawbotz/views/order/_head.haml +24 -0
- data/lib/rawbotz/views/order/_item_table.haml +44 -0
- data/lib/rawbotz/views/order/new.haml +22 -0
- data/lib/rawbotz/views/order/non_remote.haml +42 -0
- data/lib/rawbotz/views/order/packlist.haml +14 -0
- data/lib/rawbotz/views/order/view.haml +79 -0
- data/lib/rawbotz/views/orders/index.haml +40 -0
- data/lib/rawbotz/views/orders/menu.haml +24 -0
- data/lib/rawbotz/views/orders/non_remotes.haml +8 -0
- data/lib/rawbotz/views/product/_stock_sales_plot.haml +60 -0
- data/lib/rawbotz/views/product/link_to.haml +29 -0
- data/lib/rawbotz/views/product/view.haml +64 -0
- data/lib/rawbotz/views/products/_link_table.haml +38 -0
- data/lib/rawbotz/views/products/index.haml +36 -0
- data/lib/rawbotz/views/products/link_wizard.haml +48 -0
- data/lib/rawbotz/views/products/links.haml +65 -0
- data/lib/rawbotz/views/products/menu.haml +27 -0
- data/lib/rawbotz/views/products/table.haml +20 -0
- data/lib/rawbotz/views/products/table_with_linking.haml +30 -0
- data/lib/rawbotz/views/remote_cart/index.haml +30 -0
- data/lib/rawbotz/views/remote_order/view.haml +35 -0
- data/lib/rawbotz/views/remote_orders/index.haml +20 -0
- data/lib/rawbotz/views/remote_product/view.haml +90 -0
- data/lib/rawbotz/views/remote_products/_table.haml +15 -0
- data/lib/rawbotz/views/remote_products/index.haml +30 -0
- data/lib/rawbotz/views/supplier/view.haml +63 -0
- data/lib/rawbotz/views/suppliers/index.haml +13 -0
- data/lib/rawbotz/views/thin_layout.haml +32 -0
- data/lib/rawbotz/views/widgets/_ajax_link.haml +5 -0
- data/lib/rawbotz/views/widgets/_link.haml +6 -0
- data/lib/rawbotz/views/widgets/_link_line.haml +15 -0
- data/lib/rawbotz.rb +77 -0
- data/rawbotz.gemspec +33 -0
- metadata +327 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 81bcca5d73862da12d5eb4ed197377f0866bae8c
|
|
4
|
+
data.tar.gz: 903e12e32aade0a32acc87310d820b574e6edf0e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 081bc679e520975b5df4541200295bf9925798cacbad4246582b998c539a3bb1a3cc8a561bd6d36ce8b6e58955405094eb613fb82492de5229313fd4077888a7
|
|
7
|
+
data.tar.gz: c20fd92925a37221f111e5156ef9f9db0da466e4469f0002869a1422e8eed9924bfbe4dd23cc5d06f9052f7716e2cddc7264ce537ecf8652087499a8ee3dab7a
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
+
|
|
8
|
+
We are committed to making participation in this project a harassment-free
|
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
+
|
|
13
|
+
Examples of unacceptable behavior by participants include:
|
|
14
|
+
|
|
15
|
+
* The use of sexualized language or imagery
|
|
16
|
+
* Personal attacks
|
|
17
|
+
* Trolling or insulting/derogatory comments
|
|
18
|
+
* Public or private harassment
|
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
|
20
|
+
addresses, without explicit permission
|
|
21
|
+
* Other unethical or unprofessional conduct
|
|
22
|
+
|
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
+
threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
+
Conduct may be permanently removed from the project team.
|
|
33
|
+
|
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
+
when an individual is representing the project or its community.
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
+
reported by contacting a project maintainer at felix.wolfsteller@gmail.com. All
|
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
+
incident.
|
|
43
|
+
|
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
+
version 1.3.0, available at
|
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
+
|
|
48
|
+
[homepage]: http://contributor-covenant.org
|
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Uncomment these for local development
|
|
4
|
+
#gem 'magento_remote', path: "../magento_remote"
|
|
5
|
+
#gem 'rawgento_models', path: "../rawgento_models"
|
|
6
|
+
#gem 'rawgento_db', path: "../rawgento_db"
|
|
7
|
+
|
|
8
|
+
# Specify your gem's dependencies in rawbotz.gemspec
|
|
9
|
+
gemspec
|
data/README.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Rawbotz
|
|
2
|
+
|
|
3
|
+
Rawbotz provides a Web-Interface to do certain management tasks for a particular Magento Web-Shop (RawLiving Germany).
|
|
4
|
+
|
|
5
|
+
In this shop, products are supplied by different suppliers, of which one offers a magento-shop itself.
|
|
6
|
+
|
|
7
|
+
Rawbotz couples the `rawgento_db`, `rawgento_models` and `magento_remote` gems to make it easy to order items from this particular other shop and provides further functionality, e.g. accessing stock and sales history information.
|
|
8
|
+
|
|
9
|
+
Note that this git repository includes software components whose Copyright and License differ from the other parts.
|
|
10
|
+
|
|
11
|
+
These are
|
|
12
|
+
- Font Awesome (http://fontawesome.io/) in `lib/rawbotz/public/font-awesome-4.5.0`
|
|
13
|
+
- Pure CSS (http://purecss.io) in `lib/rawbotz/public/pure-min.css`
|
|
14
|
+
- Chart.JS (http://chartjs.org) in `lib/rawbotz/public/Chart.min.js`
|
|
15
|
+
- jquery and jquery-ui (http://jquery.com, http://jqueryui.com) in `lib/rawbotz/public/jquery-2.2.0.min.js` and `lib/rawbotz/public/jui`
|
|
16
|
+
|
|
17
|
+
The copyright and license information is contained in the respective file headers. All other files are Copyright 2016 Felix Wolfsteller and licensed under the AGPLv3 (or any later).
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
While bundling rawbotz up and installing it as a gem should be possible, it is strongly advised to install it via git.
|
|
22
|
+
|
|
23
|
+
Note that the dependencies should be handled with bundler if you are not running a development setup.
|
|
24
|
+
|
|
25
|
+
Anyway, the application is so specific to RawLiving Germanys needs that you probably want to get in contact first.
|
|
26
|
+
|
|
27
|
+
## Assumptions
|
|
28
|
+
|
|
29
|
+
- supplier attribute
|
|
30
|
+
- shelve attribute
|
|
31
|
+
- packsize attribute
|
|
32
|
+
- Ubuntu 14.04 installation, using rvm in an unprivileged users home.
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
Until `rawgento_models`, `rawgento_db` and `magento_remote` (gems by same author) have settled, please adjust the `Gemfile` and checkout these gems in the parent folder.
|
|
37
|
+
|
|
38
|
+
### Configuration
|
|
39
|
+
|
|
40
|
+
Rawbotz combines the configuration files of `rawgento_db`, `rawgento_models` and `magento_remote` in a single file (default: `rawbotz.conf`). In theory, the components configure themselves using their respective default configuration file paths.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
#### Unified appraoch
|
|
44
|
+
|
|
45
|
+
Create a `rawbotz.conf` YAML-file with the unified keys needed. Note that you can pass the path to this configuration file to the various executables in `exe/`.
|
|
46
|
+
|
|
47
|
+
# Rawbotz own database
|
|
48
|
+
default: &default
|
|
49
|
+
adapter: sqlite3
|
|
50
|
+
database: /home/rawbotz/database.sqlite
|
|
51
|
+
encoding: utf8
|
|
52
|
+
pool: 5
|
|
53
|
+
timeout: 5000
|
|
54
|
+
|
|
55
|
+
development:
|
|
56
|
+
<<: *default
|
|
57
|
+
test:
|
|
58
|
+
<<: *default
|
|
59
|
+
database: db/rawgento_test.db
|
|
60
|
+
|
|
61
|
+
# Local Magento MySQL database
|
|
62
|
+
host: 127.0.0.1
|
|
63
|
+
port: 3306
|
|
64
|
+
database: magento_shop_dbname
|
|
65
|
+
username: magento_db_username
|
|
66
|
+
password: magento_db_password
|
|
67
|
+
# Attributes needed
|
|
68
|
+
attribute_ids:
|
|
69
|
+
name: 11
|
|
70
|
+
supplier_name: 666
|
|
71
|
+
shelve_nr: 42
|
|
72
|
+
packsize: 1337
|
|
73
|
+
|
|
74
|
+
# Remote Magento Web Interface (for our mech)
|
|
75
|
+
remote_shop:
|
|
76
|
+
base_uri: https://magentoshop.remote
|
|
77
|
+
user: mylogin@email.address
|
|
78
|
+
pass: whatnottobenamed
|
|
79
|
+
|
|
80
|
+
supplier_name: MagentoShop Remote
|
|
81
|
+
|
|
82
|
+
local_shop:
|
|
83
|
+
base_uri: https://magentoshop.mine
|
|
84
|
+
|
|
85
|
+
mail:
|
|
86
|
+
to: your@email.address
|
|
87
|
+
from: senders@email.address
|
|
88
|
+
host: email.address
|
|
89
|
+
user: senders@email.user
|
|
90
|
+
pass: senders.email.password
|
|
91
|
+
port: 587
|
|
92
|
+
|
|
93
|
+
Then, tell RawbotzApp to eat your config via `exe/rawbotz -c rawbotz.conf`.
|
|
94
|
+
To have fun directly with rack instead use the environment variable `RAWBOTZ_CONFIG`, like in `RAWBOTZ_CONFIG=/home/rawbotz/rawbotz.conf rackup`.
|
|
95
|
+
|
|
96
|
+
#### Reference to the configurable required components
|
|
97
|
+
|
|
98
|
+
Look in the corresponding gems to check how their configuration has to be done:
|
|
99
|
+
|
|
100
|
+
* [rawgento_db s rawgento_db-config.yml](https://github.com/rawliving-germany/rawgento_db)
|
|
101
|
+
* [rawgento_models s db/config.yml](https://github.com/rawliving-germany/rawgento_models)
|
|
102
|
+
* [magento_remotes config](https://github.com/fwolfst/magento_remote)
|
|
103
|
+
|
|
104
|
+
##### In Quick
|
|
105
|
+
|
|
106
|
+
Configure your database in db/config.yml (Rails style, `rawgento_models`).
|
|
107
|
+
|
|
108
|
+
Configure your magento mysql-connection in rawgento_db-config.yml (`rawgento_db`):
|
|
109
|
+
host: myshop.shop
|
|
110
|
+
port: 3306
|
|
111
|
+
database: magento_myshop
|
|
112
|
+
username: magento_myshop_dbuser
|
|
113
|
+
password: magento_myshop_dbpassword
|
|
114
|
+
|
|
115
|
+
Finally, configure the remote shops credentials (`magento_remote`)
|
|
116
|
+
|
|
117
|
+
## Setup
|
|
118
|
+
|
|
119
|
+
Note that a script with basic support for maintenance-tasks is underway (exe/rawbotz_maintenance.sh).
|
|
120
|
+
|
|
121
|
+
#### Setup the database
|
|
122
|
+
|
|
123
|
+
Run `rake db:setup` (if `db/schema.rb` is present) or `rake db:migrate` to setup the database.
|
|
124
|
+
Unfortunately, there is no way to pass in the config file, so for now you have to create `db/config.yml` (which can be nearly the same as `rawbotz.conf`) temporarily.
|
|
125
|
+
|
|
126
|
+
#### Populate the database with local and remote products
|
|
127
|
+
|
|
128
|
+
E.g. with `bundle exec exe/rawbotz_update_local_products -c rawbotz.conf` .
|
|
129
|
+
This will query your magento MySQL database and create 'local' products, expect the command to run a while (minutes).
|
|
130
|
+
|
|
131
|
+
E.g. with `bundle exec exe/rawbotz_update_remote_products -c rawbotz.conf`
|
|
132
|
+
This will query the remote magento shop (scraping it via html GET requests) and create 'remote' products, expect the command to run a while longer (more minutes). You might need to adapt parameters, depending on the remote shop. `bundle exec exe/rawbotz_update_remote_products --help` gives you a hint on how to optimize your settings.
|
|
133
|
+
|
|
134
|
+
#### Setup mailing
|
|
135
|
+
|
|
136
|
+
Mails are sent via pony.
|
|
137
|
+
|
|
138
|
+
Create following `rawbotz.conf` section:
|
|
139
|
+
|
|
140
|
+
mail:
|
|
141
|
+
to: your@email.address
|
|
142
|
+
from: senders@email.address
|
|
143
|
+
host: email.address
|
|
144
|
+
user: senders@email.user
|
|
145
|
+
pass: senders.email.password
|
|
146
|
+
port: 587
|
|
147
|
+
|
|
148
|
+
. Multiple receipients can be addressed like this:
|
|
149
|
+
|
|
150
|
+
mail:
|
|
151
|
+
to:
|
|
152
|
+
- your@email.address
|
|
153
|
+
- colleagues@mail.address
|
|
154
|
+
.
|
|
155
|
+
|
|
156
|
+
### Deployment or web-app startup
|
|
157
|
+
|
|
158
|
+
You can run `(bundle exec) exe/rawbotz`, `rackup` or put rawbotz behind a phusion passenger.
|
|
159
|
+
There is a `-c` option to pass in a config file.
|
|
160
|
+
|
|
161
|
+
As usual, for `rackup` you can specify port (`-p`) and host (`-o`) parameters. The path to config file has to be exposed as RAWBOTZ_CONFIG env var.
|
|
162
|
+
|
|
163
|
+
### Stock History Update via cron
|
|
164
|
+
|
|
165
|
+
Assuming an Ubuntu Server Setup, run `crontab -e` and add following line to fetch stock values every day at 03:00 am.
|
|
166
|
+
|
|
167
|
+
### Other tools included
|
|
168
|
+
|
|
169
|
+
#### rawbotz_update_local_products
|
|
170
|
+
|
|
171
|
+
Updates Products from magento MySQL database. See `--help` for more information.
|
|
172
|
+
|
|
173
|
+
## Development
|
|
174
|
+
|
|
175
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec rawbotz` to use the gem in this directory, ignoring other installed copies of this gem.
|
|
176
|
+
|
|
177
|
+
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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
178
|
+
|
|
179
|
+
You can `bundle console` to jump into a pre-setup irb, then call `RawgentoModels::establish_connection "rawbotz.conf"` to setup the database connection and deal with real world data.
|
|
180
|
+
|
|
181
|
+
## Contributing
|
|
182
|
+
|
|
183
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rawbotz. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
184
|
+
|
|
185
|
+
Feel free to get in contact with me.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require 'rawgento_models'
|
|
3
|
+
|
|
4
|
+
require 'rake/testtask'
|
|
5
|
+
|
|
6
|
+
task :default => :spec
|
|
7
|
+
|
|
8
|
+
RawgentoModels.load_tasks
|
|
9
|
+
|
|
10
|
+
# TODO Setup the environment by calling something like RawgentoModels::establish_connection "rawbotz.conf"` and reading the rest of the config file
|
|
11
|
+
|
|
12
|
+
# These tasks should be solveable either via a rake task or via single executables
|
|
13
|
+
|
|
14
|
+
# initial load
|
|
15
|
+
|
|
16
|
+
# remote scrape
|
|
17
|
+
|
|
18
|
+
# local load and update
|
|
19
|
+
|
|
20
|
+
# stock update
|
|
21
|
+
|
|
22
|
+
Rake::TestTask.new do |t|
|
|
23
|
+
t.pattern = "test/*test.rb"
|
|
24
|
+
end
|
|
25
|
+
#Rake::TestTask.new do |t|
|
|
26
|
+
# t.libs << "test"
|
|
27
|
+
# t.test_files = FileList['test/*test.rb']
|
|
28
|
+
# t.verbose = true
|
|
29
|
+
#end
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "rawbotz"
|
|
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
data/config.ru
ADDED
data/exe/debug/test_mail
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "rawbotz"
|
|
4
|
+
require 'rawbotz/option_parser'
|
|
5
|
+
|
|
6
|
+
optparse = Rawbotz::OptionParser.new do |opts, options|
|
|
7
|
+
opts.banner = "Usage: #{$PROGRAM_NAME} [OPTIONS] ORDER_ID"
|
|
8
|
+
opts.separator ""
|
|
9
|
+
end
|
|
10
|
+
optparse.parse!
|
|
11
|
+
options = optparse.options
|
|
12
|
+
|
|
13
|
+
mail = Rawbotz::mail("rawbotz test mail", "Success.\nHere the body.")
|
|
14
|
+
|
|
15
|
+
exit 0
|
data/exe/rawbotz
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "rawbotz"
|
|
4
|
+
require 'optparse'
|
|
5
|
+
|
|
6
|
+
options = {}
|
|
7
|
+
program_name = File.basename __FILE__
|
|
8
|
+
$program_name = program_name
|
|
9
|
+
|
|
10
|
+
optparse = OptionParser.new do |opts|
|
|
11
|
+
opts.banner = "Usage: #{program_name} [OPTIONS]"
|
|
12
|
+
opts.separator ""
|
|
13
|
+
|
|
14
|
+
opts.separator "Single rawbotz configuration file"
|
|
15
|
+
opts.on("-c", "--config FILE", 'file path to rawgento-db YAML config file.') do |c|
|
|
16
|
+
if !File.exist? c
|
|
17
|
+
STDERR.puts "Cannot load conf file #{c}"
|
|
18
|
+
exit 2
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Rawbotz.conf_file_path = c
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
opts.separator ""
|
|
25
|
+
opts.separator "General"
|
|
26
|
+
opts.on_tail('--version', 'Show version.') do
|
|
27
|
+
puts "#{program_name} #{Rawbotz::VERSION}"
|
|
28
|
+
exit 0
|
|
29
|
+
end
|
|
30
|
+
opts.on('-h', '--help', 'Show this help.') do
|
|
31
|
+
puts opts
|
|
32
|
+
exit 0
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
optparse.parse!
|
|
36
|
+
|
|
37
|
+
require "rawbotz/app"
|
|
38
|
+
|
|
39
|
+
RawbotzApp.run!
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "rawbotz"
|
|
4
|
+
require "rawbotz/option_parser"
|
|
5
|
+
|
|
6
|
+
require 'csv'
|
|
7
|
+
|
|
8
|
+
program_name = File.basename __FILE__
|
|
9
|
+
|
|
10
|
+
optparse = Rawbotz::OptionParser.new do |opts, options|
|
|
11
|
+
opts.banner = "Usage: #{program_name} [OPTIONS] <CSVFILE>"
|
|
12
|
+
opts.separator ""
|
|
13
|
+
|
|
14
|
+
opts.on("-d", "--dry-run", "Simulate, do not actually write to db") do |d|
|
|
15
|
+
options[:dry_run] = d
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
optparse.parse!
|
|
19
|
+
|
|
20
|
+
logger = Logger.new(STDOUT)
|
|
21
|
+
logger.level = optparse.options[:verbose] ? Logger::DEBUG : Logger::INFO
|
|
22
|
+
|
|
23
|
+
logger.debug "#{program_name} #{Rawbotz::VERSION}"
|
|
24
|
+
|
|
25
|
+
if ARGV.length != 1
|
|
26
|
+
STDERR.puts "Need to supply an argument!"
|
|
27
|
+
STDERR.puts optparse.banner
|
|
28
|
+
exit 2
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
logger.info("Read csv input file #{ARGV[0]}")
|
|
32
|
+
|
|
33
|
+
if optparse.options[:dry_run]
|
|
34
|
+
logger.info("In dry-run-mode, will not actually write to database.")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
begin
|
|
38
|
+
CSV.foreach(ARGV[0]) do |line|
|
|
39
|
+
local_pid = line[0]
|
|
40
|
+
remote_pid = line[1]
|
|
41
|
+
|
|
42
|
+
local_product = RawgentoModels::LocalProduct.find_by(product_id: local_pid)
|
|
43
|
+
remote_product = RawgentoModels::RemoteProduct.find_by(product_id: remote_pid)
|
|
44
|
+
|
|
45
|
+
if local_product.nil?
|
|
46
|
+
logger.error "Local Product with product-id #{local_pid} could not be found"
|
|
47
|
+
next
|
|
48
|
+
elsif remote_product.nil?
|
|
49
|
+
logger.error "Remote Product with product-id #{remote_pid} could not be found"
|
|
50
|
+
next
|
|
51
|
+
end
|
|
52
|
+
if local_product.remote_product == remote_product
|
|
53
|
+
logger.info "Link #{local_pid} -> #{remote_pid} already present"
|
|
54
|
+
next
|
|
55
|
+
end
|
|
56
|
+
if !options[:dry_run]
|
|
57
|
+
local_product.remote_product = remote_product
|
|
58
|
+
local_product.save
|
|
59
|
+
end
|
|
60
|
+
logger.info "Linked #{local_pid} -> #{remote_pid}"
|
|
61
|
+
logger.debug "Linked #{local_product.name} -> #{remote_product.name}"
|
|
62
|
+
end
|
|
63
|
+
rescue Exception => e
|
|
64
|
+
logger.error "Could not read csv input file"
|
|
65
|
+
logger.error e.inspect
|
|
66
|
+
logger.error e.backtrace
|
|
67
|
+
exit 1
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
if optparse.options[:dry_run]
|
|
71
|
+
logger.info("In dry-run-mode, did not actually write to database.")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
exit 0
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Part of rawbotz, (c) Felix Wolfsteller 2016
|
|
4
|
+
# Licensed under the GPLv3
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
command -v dialog >/dev/null 2>&1 || {
|
|
9
|
+
echo >&2 "The program 'dialog' seems not to be installed, exiting."
|
|
10
|
+
exit 1
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
PROGRESS_WIDTH=60
|
|
14
|
+
PROGRESS_HEIGHT=30
|
|
15
|
+
|
|
16
|
+
RAWBOTZ_CONF="rawbotz.conf"
|
|
17
|
+
|
|
18
|
+
menu_selection=$(mktemp /tmp/rawbotz_maintenance.XXXXXX)
|
|
19
|
+
|
|
20
|
+
dialog --menu "Rawbotz Menu" 18 30 8 \
|
|
21
|
+
1 "Start rawbotz on port 9711" \
|
|
22
|
+
2 "Update local magento products" \
|
|
23
|
+
3 "Look for new remote products" \
|
|
24
|
+
4 "Save current stock data" \
|
|
25
|
+
5 "Trigger Order queue processing" \
|
|
26
|
+
2> tmp
|
|
27
|
+
|
|
28
|
+
if [ "$?" = 0 ]
|
|
29
|
+
then
|
|
30
|
+
_ret=$(cat tmp)
|
|
31
|
+
rm tmp
|
|
32
|
+
if [ "$_ret" = "1" ]
|
|
33
|
+
then
|
|
34
|
+
echo "starting rawbotz"
|
|
35
|
+
./start_rb.sh
|
|
36
|
+
elif [ "$_ret" = "2" ]
|
|
37
|
+
then
|
|
38
|
+
bundle exec rawbotz_update_local_products -v -c "$RAWBOTZ_CONF" | sed -e 's/.* -- : //' | dialog --progressbox "Update local magento products" $PROGRESS_HEIGHT $PROGRESS_WIDTH
|
|
39
|
+
elif [ "$_ret" = "3" ]
|
|
40
|
+
then
|
|
41
|
+
# program "unbuffer?"
|
|
42
|
+
bundle exec rawbotz_update_remote_products -c "$RAWBOTZ_CONF" -n -w 0 | stdbuf -oL -eL sed -e 's/.* -- : //' | dialog --progressbox "Updating Remote Products" $PROGRESS_HEIGHT $PROGRESS_WIDTH
|
|
43
|
+
elif [ "$_ret" = "4" ]
|
|
44
|
+
then
|
|
45
|
+
rawbotz_stock_update -v -c "$RAWBOTZ_CONF" | dialog --progressbox "Saving current stock data" $PROGRESS_HEIGHT $PROGRESS_WIDTH
|
|
46
|
+
elif [ "$_ret" = "5" ]
|
|
47
|
+
then
|
|
48
|
+
rawbotz_process_order_queue -v -c "$RAWBOTZ_CONF" | dialog --progressbox "Processing Order Queue" $PROGRESS_HEIGHT $PROGRESS_WIDTH
|
|
49
|
+
else
|
|
50
|
+
echo "Bad choice."
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
rm "$menu_selection"
|
|
56
|
+
|
|
57
|
+
exit 0
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'date'
|
|
4
|
+
|
|
5
|
+
require "rawbotz"
|
|
6
|
+
require 'rawbotz/option_parser'
|
|
7
|
+
|
|
8
|
+
optparse = Rawbotz::OptionParser.new do |opts, options|
|
|
9
|
+
opts.banner = "Usage: #{$PROGRAM_NAME} [OPTIONS] ORDER_ID"
|
|
10
|
+
opts.separator ""
|
|
11
|
+
|
|
12
|
+
opts.on("-m", "--[no]-mail", "Send mail with result") do |m|
|
|
13
|
+
options[:mail] = true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
opts.on("-f", "--force", "Force order even if state is not queued") do |m|
|
|
17
|
+
options[:force] = true
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
optparse.parse!
|
|
21
|
+
|
|
22
|
+
options = optparse.options
|
|
23
|
+
Rawbotz::configure_logger options
|
|
24
|
+
|
|
25
|
+
include RawgentoModels
|
|
26
|
+
|
|
27
|
+
def main options
|
|
28
|
+
Rawbotz::logger.debug "#{$PROGRAM_NAME} #{Rawbotz::VERSION}"
|
|
29
|
+
|
|
30
|
+
if ARGV.length != 1
|
|
31
|
+
Rawbotz::logger.error("Need an argument (order_id)")
|
|
32
|
+
exit 4
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
Rawbotz::logger.info("Starting order")
|
|
36
|
+
|
|
37
|
+
order = RawgentoModels::Order.find(ARGV[0].to_i)
|
|
38
|
+
if !order.present?
|
|
39
|
+
Rawbotz::logger.error("No Order with #{ARGV[0].to_i} found.")
|
|
40
|
+
exit 5
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
Rawbotz::logger.info("#{order.order_items.length} items in Order")
|
|
44
|
+
if order.state != :new
|
|
45
|
+
Rawbotz::logger.warn("Order in state #{order.state}!")
|
|
46
|
+
if !options[:force]
|
|
47
|
+
Rawbotz::logger.warn("Run with -f,--force flag to ignore")
|
|
48
|
+
exit 6
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
order.update(state: :processing)
|
|
53
|
+
|
|
54
|
+
order_processor = Rawbotz::OrderProcessor.new(order, Rawbotz::logger)
|
|
55
|
+
|
|
56
|
+
order_processor.process!
|
|
57
|
+
|
|
58
|
+
Rawbotz::logger.info("Finished order")
|
|
59
|
+
|
|
60
|
+
order.update(state: :ordered)
|
|
61
|
+
|
|
62
|
+
if options[:mail]
|
|
63
|
+
settings = YAML::load_file(Rawbotz::conf_file_path)["mail"]
|
|
64
|
+
pony_via_options = { address: settings["host"],
|
|
65
|
+
user_name: settings["user"],
|
|
66
|
+
port: settings["port"].to_i,
|
|
67
|
+
authentication: :login,
|
|
68
|
+
password: settings["pass"]}
|
|
69
|
+
Rawbotz::logger.info("Attempting mail send to #{settings['to']}")
|
|
70
|
+
Pony.mail({
|
|
71
|
+
to: settings["to"],
|
|
72
|
+
from: settings["from"],
|
|
73
|
+
subject: "test",
|
|
74
|
+
body: "great",
|
|
75
|
+
via: :smtp,
|
|
76
|
+
via_options: pony_via_options
|
|
77
|
+
})
|
|
78
|
+
else
|
|
79
|
+
Rawbotz::logger.info("Not sending mail (invoke with -m to do so)")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
diff = order_processor.check_against_cart
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
main options
|
|
86
|
+
exit 0
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'date'
|
|
4
|
+
|
|
5
|
+
require 'terminal-table'
|
|
6
|
+
|
|
7
|
+
require "rawbotz"
|
|
8
|
+
require 'rawbotz/option_parser'
|
|
9
|
+
require 'rawbotz/cli/order_result_table'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
optparse = Rawbotz::OptionParser.new do |opts, options|
|
|
13
|
+
opts.banner = "Usage: #{$PROGRAM_NAME} [OPTIONS] ORDER_ID"
|
|
14
|
+
opts.separator ""
|
|
15
|
+
|
|
16
|
+
opts.on("-m", "--[no-]mail", "Send mail with result") do |m|
|
|
17
|
+
options[:mail] = m
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
optparse.parse!
|
|
21
|
+
options = optparse.options
|
|
22
|
+
|
|
23
|
+
include RawgentoModels
|
|
24
|
+
|
|
25
|
+
def main options
|
|
26
|
+
logger = Logger.new(STDOUT)
|
|
27
|
+
logger.level = options[:verbose] ? Logger::DEBUG : Logger::INFO
|
|
28
|
+
|
|
29
|
+
logger.debug "#{$PROGRAM_NAME} #{Rawbotz::VERSION}"
|
|
30
|
+
|
|
31
|
+
logger.info("Checking queue")
|
|
32
|
+
|
|
33
|
+
queue = RawgentoModels::Order.queued
|
|
34
|
+
logger.info("-> #{queue.count} orders to process")
|
|
35
|
+
|
|
36
|
+
if queue.count == 0
|
|
37
|
+
logger.info("Nothing to do, exiting.")
|
|
38
|
+
exit 0
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
order = queue.first
|
|
42
|
+
|
|
43
|
+
logger.info("#{order.order_items.length} items in Order")
|
|
44
|
+
|
|
45
|
+
if order.state != "queued"
|
|
46
|
+
logger.warn("Order in state #{order.state}!")
|
|
47
|
+
end
|
|
48
|
+
order.update(state: :processing)
|
|
49
|
+
|
|
50
|
+
logger.info ("#{order.order_items.processible.count} products to order.")
|
|
51
|
+
|
|
52
|
+
mech = Rawbotz.new_mech
|
|
53
|
+
mech.login
|
|
54
|
+
|
|
55
|
+
order_processor = Rawbotz::OrderProcessor.new(order, logger)
|
|
56
|
+
order_processor.process!
|
|
57
|
+
|
|
58
|
+
order.update(state: :ordered)
|
|
59
|
+
|
|
60
|
+
logger.info("Finished order")
|
|
61
|
+
|
|
62
|
+
logger.info("Checking current cart")
|
|
63
|
+
diffs = order_processor.check_against_cart
|
|
64
|
+
|
|
65
|
+
# Option to put to stdout
|
|
66
|
+
diff_table = Rawbotz::CLI::OrderResultTable.tables diffs
|
|
67
|
+
puts diff_table
|
|
68
|
+
|
|
69
|
+
if options[:mail]
|
|
70
|
+
logger.debug("Sending mail")
|
|
71
|
+
mail = Rawbotz::mail("rawbotz order finished",
|
|
72
|
+
"Finished Order nr #{order.id}. Result: [tbd]\n\n#{diff_table}")
|
|
73
|
+
logger.debug("Mail sent: #{mail}")
|
|
74
|
+
else
|
|
75
|
+
logger.debug("not sending mail")
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
main options
|
|
80
|
+
exit 0
|