code_online 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
+ SHA256:
3
+ metadata.gz: 2132b6ea493a4fac956ab3c3c9e106e650ae60f172787d6b95fd983a60b3abc0
4
+ data.tar.gz: e58e6f1e23c8ec36582bc798b06d08268df59cc7d219510701167a5ae522c1e6
5
+ SHA512:
6
+ metadata.gz: c83f7b6d405be4bb76e857003b0aeb0da4bc75091c13e5b70049f6a5020a6dd585188132e48284de67572a9291d88ab57ecc6bd05f2519ea5ec5ab2e80a571cd
7
+ data.tar.gz: 179bc5169b2528f5dc6a4f3d0ae95578e9697545d3748fb2406b489d7ba0137bfcdf6d79300906f7d638b53a288c81e738777025fe72dcdffd9f143e95c2068b
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,2 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-10-30
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders 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, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at kevin@vinhas.fr. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in code_online.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "standard", "~> 1.3"
data/Gemfile.lock ADDED
@@ -0,0 +1,83 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ code_online (0.1.0)
5
+ watir
6
+ webdrivers
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ childprocess (4.1.0)
13
+ diff-lcs (1.5.0)
14
+ json (2.6.2)
15
+ nokogiri (1.13.9-arm64-darwin)
16
+ racc (~> 1.4)
17
+ parallel (1.22.1)
18
+ parser (3.1.2.1)
19
+ ast (~> 2.4.1)
20
+ racc (1.6.0)
21
+ rainbow (3.1.1)
22
+ rake (13.0.6)
23
+ regexp_parser (2.6.0)
24
+ rexml (3.2.5)
25
+ rspec (3.12.0)
26
+ rspec-core (~> 3.12.0)
27
+ rspec-expectations (~> 3.12.0)
28
+ rspec-mocks (~> 3.12.0)
29
+ rspec-core (3.12.0)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-expectations (3.12.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.12.0)
34
+ rspec-mocks (3.12.0)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.12.0)
37
+ rspec-support (3.12.0)
38
+ rubocop (1.35.1)
39
+ json (~> 2.3)
40
+ parallel (~> 1.10)
41
+ parser (>= 3.1.2.1)
42
+ rainbow (>= 2.2.2, < 4.0)
43
+ regexp_parser (>= 1.8, < 3.0)
44
+ rexml (>= 3.2.5, < 4.0)
45
+ rubocop-ast (>= 1.20.1, < 2.0)
46
+ ruby-progressbar (~> 1.7)
47
+ unicode-display_width (>= 1.4.0, < 3.0)
48
+ rubocop-ast (1.23.0)
49
+ parser (>= 3.1.1.0)
50
+ rubocop-performance (1.14.3)
51
+ rubocop (>= 1.7.0, < 2.0)
52
+ rubocop-ast (>= 0.4.0)
53
+ ruby-progressbar (1.11.0)
54
+ rubyzip (2.3.2)
55
+ selenium-webdriver (4.5.0)
56
+ childprocess (>= 0.5, < 5.0)
57
+ rexml (~> 3.2, >= 3.2.5)
58
+ rubyzip (>= 1.2.2, < 3.0)
59
+ websocket (~> 1.0)
60
+ standard (1.16.1)
61
+ rubocop (= 1.35.1)
62
+ rubocop-performance (= 1.14.3)
63
+ unicode-display_width (2.3.0)
64
+ watir (7.1.0)
65
+ regexp_parser (>= 1.2, < 3)
66
+ selenium-webdriver (~> 4.0)
67
+ webdrivers (5.2.0)
68
+ nokogiri (~> 1.6)
69
+ rubyzip (>= 1.3.0)
70
+ selenium-webdriver (~> 4.0)
71
+ websocket (1.2.9)
72
+
73
+ PLATFORMS
74
+ arm64-darwin-21
75
+
76
+ DEPENDENCIES
77
+ code_online!
78
+ rake (~> 13.0)
79
+ rspec (~> 3.0)
80
+ standard (~> 1.3)
81
+
82
+ BUNDLED WITH
83
+ 2.3.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Vin0uz
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,55 @@
1
+
2
+ # CodeOnline
3
+
4
+ A simple browser-based API to GS1 codeonline platform.
5
+
6
+ Instead of manually create all your eans, using codeonline.fr webpage,
7
+ you can now do it with a couple of line of code.
8
+
9
+ #### ⚠️ Warning ⚠️
10
+ This gem isn't related to GS1 teams, so it's by definition quite fragile.
11
+
12
+
13
+ ## Installation
14
+
15
+ To use it in Rails, add this line to your application's Gemfile
16
+
17
+ ```ruby
18
+ gem "code_online"
19
+ ```
20
+
21
+ To use it in a usual ruby environment, you can simply
22
+ ```ruby
23
+ gem install "code_online"
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ```ruby
29
+ require "code_online"
30
+
31
+ client = CodeOnline::Client.new(email: "youremail@foo.bar", password: "unbreakable-password")
32
+ > "Connected to codeonline ✅"
33
+ ean = client.create_ean(product_name: "My Cool product", weight: "50")
34
+ > "3701492718516"
35
+ ```
36
+
37
+
38
+ ## How it works ?
39
+
40
+ It's simply copying what you'd do if you were going to the web interface.
41
+
42
+ _This makes it quite fragile because the web page can change anyday.._
43
+
44
+
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
49
+
50
+
51
+ ## Contributing
52
+
53
+ Contributions are always welcome! Feel free to open issues or pull requests 🙏
54
+
55
+ _If you notice any security issue, please reach outbefore opening a public issue_
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[spec standard]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "code_online"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,56 @@
1
+ module CodeOnline
2
+ class Client
3
+ HOMEPAGE_URL = "https://codeonline.fr/dashboard/list".freeze
4
+ LOGIN_URL = "https://codeonline.fr/login".freeze
5
+
6
+ def initialize(email:, password:)
7
+ @browser = ::Watir::Browser.new(:chrome, headless: true)
8
+
9
+ login(email: email, password: password)
10
+ end
11
+
12
+ def create_ean(product_name:, weight:)
13
+ browser.goto(HOMEPAGE_URL)
14
+ browser.button(id: "button-basic").click
15
+ browser.link(visible_text: "Créer un GTIN").click
16
+
17
+ browser.radio(id: "choice_0").select
18
+ browser.button(visible_text: "J'ai compris").click
19
+
20
+ browser.span(visible_text: "Équipements de Marquage Sportif").click
21
+ browser.text_field(id: "brand").set("Grinta")
22
+ browser.text_field(id: "product-name-item-value-0").set(product_name)
23
+ browser.text_field(id: "net-content-item-input-0").set(weight)
24
+ browser.select(class: "net-content-item-unit").select("Gramme")
25
+ browser.button(visible_text: "Suivant").click
26
+ browser.button(visible_text: "Terminer et afficher la fiche produit").click
27
+
28
+ browser.span(class: "gtixnValue").text
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :browser
34
+
35
+ def login(email:, password:)
36
+ browser.goto(HOMEPAGE_URL)
37
+
38
+ if browser.url == LOGIN_URL
39
+ browser.button(visible_text: "Se connecter").click
40
+ browser.text_field(id: "Email").set(email)
41
+ browser.button(id: "connexion_button").click
42
+
43
+ browser.wait_until { |b| b.text_field(id: "password-field").exists? }
44
+ browser.text_field(id: "password-field").set(password)
45
+ browser.button(id: "SubmitPassword").click
46
+ browser.wait_until { |b| b.url == HOMEPAGE_URL }
47
+ end
48
+
49
+ if browser.url != HOMEPAGE_URL
50
+ raise "Connexion to CodeOnline didn't go well!"
51
+ else
52
+ puts "Connected to codeonline ✅"
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CodeOnline
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "code_online/version"
4
+ require_relative "code_online/client"
5
+
6
+ require "watir"
7
+ require "webdrivers"
8
+
9
+ module CodeOnline
10
+ class Error < StandardError; end
11
+ # Your code goes here...
12
+ end
@@ -0,0 +1,4 @@
1
+ module CodeOnline
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: code_online
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vin0uz
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-12-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: watir
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: webdrivers
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ - kevin@vinhas.fr
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rspec"
49
+ - ".standard.yml"
50
+ - CHANGELOG.md
51
+ - CODE_OF_CONDUCT.md
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - bin/console
58
+ - bin/setup
59
+ - lib/code_online.rb
60
+ - lib/code_online/client.rb
61
+ - lib/code_online/version.rb
62
+ - sig/code_online.rbs
63
+ homepage: https://github.com/Vin0uz/code_online
64
+ licenses:
65
+ - MIT
66
+ metadata:
67
+ homepage_uri: https://github.com/Vin0uz/code_online
68
+ source_code_uri: https://github.com/Vin0uz/code_online
69
+ changelog_uri: https://github.com/Vin0uz/code_online/blob/main/CHANGELOG.md
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 2.6.0
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubygems_version: 3.3.3
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: A simple and automated bot over interface of GS1' codeonline website.
89
+ test_files: []