turksatkablo_cli 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/README.md +9 -4
- data/bin/turksatkablo +6 -8
- data/lib/init/poltergeist.rb +0 -4
- data/lib/turksatkablo_cli.rb +0 -2
- data/lib/turksatkablo_cli/online_operations/agent.rb +1 -1
- data/lib/turksatkablo_cli/online_operations/auth.rb +0 -1
- data/lib/turksatkablo_cli/online_operations/cli.rb +1 -1
- data/lib/turksatkablo_cli/online_operations/enums.rb +2 -0
- data/lib/turksatkablo_cli/online_operations/helpers.rb +26 -6
- data/lib/turksatkablo_cli/online_operations/version.rb +1 -1
- data/spec/helper_spec.rb +23 -0
- data/spec/spec_helper.rb +24 -0
- data/turksatkablo_cli.gemspec +2 -2
- metadata +20 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b19ab32c3aae669255dfdf8167dfd170b2c615f0
|
4
|
+
data.tar.gz: 7b6fa7332994494a2a18dfa0516d66dcd93e7e55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 706d9059ccddc262168fae94f222897c680112daefde5d868a00e7ad37dd3c14b2fca65491e957f4d602c1b38b67dfbe6e2e4cd4a74900073fe17d769b8c9f75
|
7
|
+
data.tar.gz: c7bfac791558500ea4f8039949ee0e2554e4ef131d5d38066d806da93aaf12c80f0a119192342db31a85c912f48edb454d87407a0d0af638a2605c1fcaaf213c
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ A command-line interface for the Turksat Kablo Online Islemler - https://online.
|
|
11
11
|
|
12
12
|
## Setup
|
13
13
|
|
14
|
-
turksatkablo_cli is built with Ruby, so you'll need a working Ruby 2.
|
14
|
+
turksatkablo_cli is built with Ruby, so you'll need a working Ruby 2.2.0>= environment to use it. You can find Ruby installation instructions [here](https://www.ruby-lang.org/en/installation/).
|
15
15
|
|
16
16
|
|
17
17
|
1. Install via rubygems
|
@@ -41,14 +41,19 @@ turksatkablo musterino # Müşteri no - kısa kodu mn
|
|
41
41
|
turksatkablo ozet # Hizmetler genel durum - kısa kodu o
|
42
42
|
```
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
+ 0.1.4 – Fix retry_authenticate and authenticated? methods
|
44
|
+
## Changelog
|
45
|
+
+ 0.2.0 – Add `RSpec` and `environment` tests, required `ruby` version updated (2.2.0 >=), `nokogiri` version updated (has a known critical severity security vulnerability in version range < 1.8.1)
|
46
|
+
+ 0.1.4 – Fix retry_authenticate and authenticated? methods (login details could not be saved after the retry_authenticate method)
|
47
47
|
+ 0.1.3 – Modernize multiple classes, add `ozet`, `hizmetler`, `musterino`, `kampanya`, `anlikborc` commands
|
48
48
|
+ 0.1.2 – Modernize Agent and Auth classes, ability to save user's encrypted login details, add `kota` command.
|
49
49
|
+ 0.1.1 – Build app skeleton, implement basic authentication
|
50
50
|
+ 0.1.0 - Initial version.
|
51
51
|
|
52
|
+
### Development
|
53
|
+
```bash
|
54
|
+
bundle exec rspec -fd spec
|
55
|
+
```
|
56
|
+
|
52
57
|
### Contributing
|
53
58
|
|
54
59
|
turksatkablo_cli is open source, and contributions are very welcome!
|
data/bin/turksatkablo
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
## encoding: utf-8
|
3
3
|
|
4
|
-
if RUBY_VERSION < '2.1.0'
|
5
|
-
abort "turksatkablo_cli requires Ruby 2.1.0 or higher"
|
6
|
-
end
|
7
|
-
|
8
4
|
lib_dir = File.expand_path("../../lib", __FILE__)
|
9
5
|
$LOAD_PATH.unshift lib_dir if File.directory?(lib_dir)
|
10
6
|
|
7
|
+
require 'turksatkablo_cli/online_operations/helpers'
|
8
|
+
require 'turksatkablo_cli/online_operations/enums'
|
9
|
+
|
10
|
+
TurksatkabloCli::OnlineOperations::Helpers.check_ruby_version
|
11
|
+
TurksatkabloCli::OnlineOperations::Helpers.check_is_installed?("phantomjs", TurksatkabloCli::OnlineOperations::Enums::PHANTOM_JS_REQUIRED)
|
12
|
+
|
11
13
|
require 'turksatkablo_cli'
|
12
14
|
|
13
15
|
# catch control-c and exit
|
@@ -20,11 +22,7 @@ end
|
|
20
22
|
at_exit{
|
21
23
|
# cleanup temp files
|
22
24
|
# close open connections
|
23
|
-
begin
|
24
25
|
Capybara.current_session.driver.quit
|
25
|
-
rescue Exception => e
|
26
|
-
abort "turksatkablo_cli requires phantomjs https://github.com/rokumatsumoto/turksatkablo_cli#setup"
|
27
|
-
end
|
28
26
|
}
|
29
27
|
|
30
28
|
TurksatkabloCli.main
|
data/lib/init/poltergeist.rb
CHANGED
@@ -5,11 +5,7 @@ require 'capybara/poltergeist'
|
|
5
5
|
# See more options at https://github.com/teampoltergeist/poltergeist#customization
|
6
6
|
options = { js_errors: false, phantomjs_options: ['--load-images=no', '--ignore-ssl-errors=yes'] }
|
7
7
|
Capybara.register_driver :poltergeist do |app|
|
8
|
-
begin
|
9
8
|
Capybara::Poltergeist::Driver.new(app, options)
|
10
|
-
rescue Exception => e
|
11
|
-
abort "turksatkablo_cli requires phantomjs https://github.com/rokumatsumoto/turksatkablo_cli#setup"
|
12
|
-
end
|
13
9
|
end
|
14
10
|
|
15
11
|
# Configure Capybara to use Poltergeist as the driver
|
data/lib/turksatkablo_cli.rb
CHANGED
@@ -5,7 +5,7 @@ module TurksatkabloCli
|
|
5
5
|
class Agent
|
6
6
|
include Helpers
|
7
7
|
attr_accessor :login_choose, :username, :password, :radio_btn_value,
|
8
|
-
:fail_login_attempt, :session, :has_logged_in
|
8
|
+
:fail_login_attempt, :session, :has_logged_in
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@session = Capybara::Session.new(:poltergeist)
|
@@ -28,7 +28,7 @@ module TurksatkabloCli
|
|
28
28
|
desc "kota", "Kalan kota - kısa kodu k"
|
29
29
|
def kota
|
30
30
|
if agent.authenticated?
|
31
|
-
|
31
|
+
@session.find(:css, "div.circle-container div.toplam p").all("span, sub").map(&:text).each { |val| puts val }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
map "k" => "kota"
|
@@ -22,6 +22,8 @@ module TurksatkabloCli
|
|
22
22
|
define :KAMPANYA_ADI, "KAMPANYA ADI"
|
23
23
|
define :TAAHHUT_BAS_TRH, "TAAHHÜT BAŞLANGIÇ TARİHİ"
|
24
24
|
define :TAAHHUT_BIT_TRH, "TAAHHÜT BİTİŞ TARİHİ"
|
25
|
+
|
26
|
+
define :PHANTOM_JS_REQUIRED, "turksatkablo_cli requires phantomjs https://github.com/rokumatsumoto/turksatkablo_cli#setup"
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -1,16 +1,10 @@
|
|
1
1
|
require 'open3'
|
2
2
|
require 'net/ping'
|
3
3
|
|
4
|
-
|
5
4
|
module TurksatkabloCli
|
6
5
|
module OnlineOperations
|
7
6
|
module Helpers
|
8
7
|
|
9
|
-
def run(*commands)
|
10
|
-
stdin, stdout, stderr, w = Open3.popen3(*commands)
|
11
|
-
[stdout.gets(nil), stderr.gets(nil), w.value]
|
12
|
-
end
|
13
|
-
|
14
8
|
def internet_connection?
|
15
9
|
begin
|
16
10
|
Net::Ping::External.new("8.8.8.8").ping?
|
@@ -41,6 +35,32 @@ module TurksatkabloCli
|
|
41
35
|
puts "\n"
|
42
36
|
end
|
43
37
|
|
38
|
+
def self.check_ruby_version(ruby_version = RUBY_VERSION)
|
39
|
+
if ruby_version < '2.2.0'
|
40
|
+
abort "turksatkablo_cli requires Ruby 2.2.0 or higher"
|
41
|
+
else
|
42
|
+
ruby_version
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.check_is_installed?(command, err_msg)
|
47
|
+
if which(command)
|
48
|
+
true
|
49
|
+
else
|
50
|
+
abort(err_msg)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.which(command)
|
55
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
56
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
57
|
+
exts.each { |ext|
|
58
|
+
exe = File.join(path, "#{command}#{ext}")
|
59
|
+
return exe if File.executable?(exe) && !File.directory?(exe)
|
60
|
+
}
|
61
|
+
end
|
62
|
+
return nil
|
63
|
+
end
|
44
64
|
|
45
65
|
end
|
46
66
|
end
|
data/spec/helper_spec.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
RSpec.describe "environment" do
|
2
|
+
|
3
|
+
it "ruby version is >= 2.2.0" do
|
4
|
+
expect(TurksatkabloCli::OnlineOperations::Helpers.check_ruby_version("2.4.2")).to be >= "2.1.0"
|
5
|
+
end
|
6
|
+
|
7
|
+
it "ruby version is < 2.2.0" do
|
8
|
+
expect { TurksatkabloCli::OnlineOperations::Helpers.check_ruby_version("2.1.0") }.to raise_error(SystemExit)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "phantomjs needs to be in path" do
|
12
|
+
expect(TurksatkabloCli::OnlineOperations::Helpers.check_is_installed?("phantomjs", TurksatkabloCli::OnlineOperations::Enums::PHANTOM_JS_REQUIRED)).to be_truthy
|
13
|
+
end
|
14
|
+
|
15
|
+
it "ruby is in path" do
|
16
|
+
expect(TurksatkabloCli::OnlineOperations::Helpers.which("ruby")).to be_instance_of(String)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "phantom_jsx is not in path" do
|
20
|
+
expect { TurksatkabloCli::OnlineOperations::Helpers.check_is_installed?("phantom_jsx", "phantom_jsx is not in path") }.to raise_error(SystemExit)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require 'rspec'
|
7
|
+
require 'turksatkablo_cli/online_operations/helpers'
|
8
|
+
require 'turksatkablo_cli/online_operations/enums'
|
9
|
+
|
10
|
+
module SpecHelper
|
11
|
+
end
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.expect_with :rspec do |expectations|
|
15
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
16
|
+
end
|
17
|
+
|
18
|
+
config.mock_with :rspec do |mocks|
|
19
|
+
mocks.verify_partial_doubles = true
|
20
|
+
end
|
21
|
+
|
22
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
23
|
+
config.include(SpecHelper)
|
24
|
+
end
|
data/turksatkablo_cli.gemspec
CHANGED
@@ -27,16 +27,16 @@ Gem::Specification.new do |spec|
|
|
27
27
|
# f.match(%r{^(test|spec|features)/})
|
28
28
|
# end
|
29
29
|
|
30
|
-
spec.required_ruby_version = '>= 2.
|
30
|
+
spec.required_ruby_version = '>= 2.2.0'
|
31
31
|
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
32
32
|
spec.files = `git ls-files`.split("\n")
|
33
33
|
spec.require_paths = ["lib"]
|
34
34
|
spec.add_development_dependency "bundler", "~> 1.16"
|
35
35
|
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
36
37
|
|
37
38
|
spec.add_runtime_dependency "thor", '~> 0.20.0'
|
38
39
|
spec.add_runtime_dependency 'highline', '~> 1.7', '>= 1.7.8'
|
39
|
-
spec.add_runtime_dependency 'nokogiri', '1.7.1'
|
40
40
|
spec.add_runtime_dependency 'rack', '1.6.8'
|
41
41
|
spec.add_runtime_dependency 'rack-test', '0.7.0'
|
42
42
|
spec.add_runtime_dependency 'net-ping', '~> 2.0', '>= 2.0.2'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turksatkablo_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samet Gunaydin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
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.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.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: thor
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,20 +86,6 @@ dependencies:
|
|
72
86
|
- - ">="
|
73
87
|
- !ruby/object:Gem::Version
|
74
88
|
version: 1.7.8
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: nokogiri
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - '='
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: 1.7.1
|
82
|
-
type: :runtime
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - '='
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: 1.7.1
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: rack
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,6 +219,7 @@ extensions: []
|
|
219
219
|
extra_rdoc_files: []
|
220
220
|
files:
|
221
221
|
- ".gitignore"
|
222
|
+
- ".rspec"
|
222
223
|
- CODE_OF_CONDUCT.md
|
223
224
|
- Gemfile
|
224
225
|
- LICENSE.txt
|
@@ -237,6 +238,8 @@ files:
|
|
237
238
|
- lib/turksatkablo_cli/online_operations/enums.rb
|
238
239
|
- lib/turksatkablo_cli/online_operations/helpers.rb
|
239
240
|
- lib/turksatkablo_cli/online_operations/version.rb
|
241
|
+
- spec/helper_spec.rb
|
242
|
+
- spec/spec_helper.rb
|
240
243
|
- turksatkablo_cli.gemspec
|
241
244
|
homepage: https://github.com/rokumatsumoto/turksatkablo_cli
|
242
245
|
licenses:
|
@@ -251,7 +254,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
254
|
requirements:
|
252
255
|
- - ">="
|
253
256
|
- !ruby/object:Gem::Version
|
254
|
-
version: 2.
|
257
|
+
version: 2.2.0
|
255
258
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
259
|
requirements:
|
257
260
|
- - ">="
|