veda-apps 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +70 -0
- data/README.md +62 -0
- data/Rakefile +44 -0
- data/bin/veda +49 -0
- data/features/step_definitions/veda_steps.rb +6 -0
- data/features/support/env.rb +15 -0
- data/features/veda.feature +8 -0
- data/lib/.DS_Store +0 -0
- data/lib/Qr.rb +60 -0
- data/lib/VedaQRScanner/UIViewControllerExtension.swift +72 -0
- data/lib/VedaQRScanner/VedaQR.storyboard +73 -0
- data/lib/VedaQRScanner/VedaQRScannerViewController.swift +134 -0
- data/lib/veda/.DS_Store +0 -0
- data/lib/veda/version.rb +3 -0
- data/lib/veda.rb +4 -0
- data/test/default_test.rb +14 -0
- data/test/test_helper.rb +9 -0
- data/veda.gemspec +23 -0
- data/veda.rdoc +5 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 87e42f0fc256241626ef457153bd8e02e16d1736
|
4
|
+
data.tar.gz: 1972ae16977f507f06a777bd51dac103f87add3f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64121feca242ae3372a83acd9732a57a3c1309c33d33491cb09b274bd8be19ef03bbd822dee946d053b1e2b3f3d2ede09c37b3641ea2b88542e5eae60af94420
|
7
|
+
data.tar.gz: 4e163a10435492bd1465abdc736a6c9757842c44579b126e3b41589a9926a3af534a4f3ae96bf675684f0889361fd6fd5aad0e297c6565a96512253657b57e27
|
data/.DS_Store
ADDED
Binary file
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
veda (0.0.1)
|
5
|
+
gli (= 2.17.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
aruba (0.14.3)
|
11
|
+
childprocess (~> 0.8.0)
|
12
|
+
contracts (~> 0.9)
|
13
|
+
cucumber (>= 1.3.19)
|
14
|
+
ffi (~> 1.9.10)
|
15
|
+
rspec-expectations (>= 2.99)
|
16
|
+
thor (~> 0.19)
|
17
|
+
backports (3.11.0)
|
18
|
+
builder (3.2.3)
|
19
|
+
childprocess (0.8.0)
|
20
|
+
ffi (~> 1.0, >= 1.0.11)
|
21
|
+
coderay (1.1.1)
|
22
|
+
contracts (0.16.0)
|
23
|
+
cucumber (3.1.0)
|
24
|
+
builder (>= 2.1.2)
|
25
|
+
cucumber-core (~> 3.1.0)
|
26
|
+
cucumber-expressions (~> 5.0.4)
|
27
|
+
cucumber-wire (~> 0.0.1)
|
28
|
+
diff-lcs (~> 1.3)
|
29
|
+
gherkin (~> 5.0)
|
30
|
+
multi_json (>= 1.7.5, < 2.0)
|
31
|
+
multi_test (>= 0.1.2)
|
32
|
+
cucumber-core (3.1.0)
|
33
|
+
backports (>= 3.8.0)
|
34
|
+
cucumber-tag_expressions (~> 1.1.0)
|
35
|
+
gherkin (>= 5.0.0)
|
36
|
+
cucumber-expressions (5.0.7)
|
37
|
+
cucumber-tag_expressions (1.1.1)
|
38
|
+
cucumber-wire (0.0.1)
|
39
|
+
diff-lcs (1.3)
|
40
|
+
ffi (1.9.18)
|
41
|
+
gherkin (5.0.0)
|
42
|
+
gli (2.17.1)
|
43
|
+
method_source (0.8.2)
|
44
|
+
multi_json (1.13.1)
|
45
|
+
multi_test (0.1.2)
|
46
|
+
pry (0.10.4)
|
47
|
+
coderay (~> 1.1.0)
|
48
|
+
method_source (~> 0.8.1)
|
49
|
+
slop (~> 3.4)
|
50
|
+
rake (12.3.0)
|
51
|
+
rdoc (6.0.1)
|
52
|
+
rspec-expectations (3.7.0)
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
+
rspec-support (~> 3.7.0)
|
55
|
+
rspec-support (3.7.0)
|
56
|
+
slop (3.6.0)
|
57
|
+
thor (0.20.0)
|
58
|
+
|
59
|
+
PLATFORMS
|
60
|
+
ruby
|
61
|
+
|
62
|
+
DEPENDENCIES
|
63
|
+
aruba
|
64
|
+
pry
|
65
|
+
rake
|
66
|
+
rdoc
|
67
|
+
veda!
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
1.14.4
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Veda Ios modules generators
|
2
|
+
###### There are many times when we write same thing in different app. Like qr scanner, search etc. This is an attempt to automate the redundant task. Using command line we can generate specific task without writing all the codes. All codes generated can be customized according to your needs and are well tested. currently All codes are generated for Swift.
|
3
|
+
|
4
|
+
|
5
|
+
### QR scanner
|
6
|
+
|
7
|
+
**step 1:**
|
8
|
+
|
9
|
+
generate qr module with command line.
|
10
|
+
|
11
|
+
syntax: `veda generate --qr path_to_viewcontroller`
|
12
|
+
|
13
|
+
example:
|
14
|
+
|
15
|
+
`veda generate --qr /Users/shishirsapkota/Library/Autosave\ Information/qrTest/qrTest/ViewController.swift`
|
16
|
+
|
17
|
+
This will generate three files in the folder containing the viewcontroller.swift.
|
18
|
+
|
19
|
+
**step 2:**
|
20
|
+
|
21
|
+
Add files to your xcode project.
|
22
|
+
|
23
|
+
![alt text](https://lh3.googleusercontent.com/yfMZKNaGzODzaQRtyGwUPJpRrhohbxheezgS04VRUeHvq3j9OgPrHnIDC_wNQTnSpv-S03OEPISFTEEVjl6WDmx3l-bMwmi0xNTYMgR-jgvHpy4sYRxBDUsl1SiNLPFJzDgz6ZUX9GaDQpwNLSqjXq5wFTE_O4TNgha_tHr1XI3eJu39wt5EX4HMWWKefzDKaOSac5OtEGUwZ_-LTju2J-3zMyD4q2tnbQ_uv853CCUWjqjcLOQ-6zsJYH9pJkf75yNsWV9We0-9kNKwCbPrEX6x-rdPux35dNTKmz5eC6czJo8ONgsmI2trfSxTN9ZCLIJ1YJP94RwdKlY-MtWpFdjZuqA3QGzB5rFIB98NkRqHx0hKk9UxP7QBYxeWl13O-Dd_RZJSNPn4gYXfav6SJbqvwd9HUv8uKCpCGAtn0QaK9YUZ6U9qHlBPTKfd74CmHB0aY-KQ4kc99a6h-SGMH72ARlkTe83__qgQyphwuPcU6rRn36ScNSxxwGkLZzzWwNkM8t7X1Fh7OGeN9WQ1E5oNxPzzwmJiP5S8e6ep6Rm2ISA7nb8qcHdyBLEj1QIcDAaIPYaxEuHfXVOMb2HtFXjrMVNP2BUVLzTPbWk=w340-h475-no)
|
24
|
+
|
25
|
+
Add three files generated.
|
26
|
+
|
27
|
+
![alt text](https://lh3.googleusercontent.com/agRabsGqRD6tvA4ckMgOBwIF2AAaw7kfrV2nzv7EYwjXOuIvHdw0ZMYO3tVf1Ol2Y_dwvH9yKUAUZh3SaomDYXU4NhzLQnLu8VVpNtbV7efi-WPh4i-bG-msE4JPXU4DnvK-eKs20g_VuRuipM-XToabuCd40AqNAPqJkJmPZBIzeab___ZWJJ2V6mpj6f3LmtjERmmjZPLJ_hYRoVE_ig0U85HzktAnEQP-ruMKwvizBzUDqEL9zSohWL7ws9BiV91pN9qGKddgbwAbV-4a6nCpE7ZaDh3j8VI9SopbrwyDKBNp4_FP0YqCsH6EBYnSHcNFaajVDWn65_DHYwOkpzWPLCIeVs70k19iRhVl8fzjzKfz2BIEn0y2ZDKDkCZC8JjAUeC0l18jy71NfQb8g-pBso6DQzn1eGFRhIrUyEMlVG4V6TRYdx8Tc_K6wKpz-CEVeyXoTwzlylN8gr9BD6u0qICj0YQFH_wkMqIoJcxtmy2N9spt0K4zZojyeA0PwKQYrLqOsI5RGGncFCsOVAtDmq2KtNnTfhExfgceA770VzAG77cZ8HQVH_slQCa-GW4YKmpycEoNggmBr4Ms2mpiaNs0YFL7ni7AEzw=w262-h102-no)
|
28
|
+
|
29
|
+
|
30
|
+
**At the End of Your viewcontroller, extension where function to open the qr scanner is Automatically added.**
|
31
|
+
|
32
|
+
```swift
|
33
|
+
extension ViewController {
|
34
|
+
func scan() {
|
35
|
+
self.openVedaQRScanner(source: self) { (viewcontroller, string) in
|
36
|
+
let qrString = string
|
37
|
+
print(qrString)
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
func openVedaQRScanner(source: UIViewController, completion: @escaping (VedaQRScannerViewController, String)->()) {
|
42
|
+
if let vc = UIStoryboard(name: "VedaQR", bundle: nil).instantiateInitialViewController() as? VedaQRScannerViewController {
|
43
|
+
vc.onObtained = completion
|
44
|
+
source.present(vc, animated: true, completion: nil)
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
```
|
50
|
+
|
51
|
+
**step3**:
|
52
|
+
|
53
|
+
create an outlet and open qrscanner
|
54
|
+
|
55
|
+
```swift
|
56
|
+
@IBAction func openQr(_ sender: UIButton) {
|
57
|
+
self.scan()
|
58
|
+
}
|
59
|
+
```
|
60
|
+
|
61
|
+
|
62
|
+
Enjoy.
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rubygems/package_task'
|
4
|
+
require 'rdoc/task'
|
5
|
+
require 'cucumber'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
Rake::RDocTask.new do |rd|
|
8
|
+
rd.main = "README.rdoc"
|
9
|
+
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
10
|
+
rd.title = 'Your application title'
|
11
|
+
end
|
12
|
+
|
13
|
+
spec = eval(File.read('veda.gemspec'))
|
14
|
+
|
15
|
+
Gem::PackageTask.new(spec) do |pkg|
|
16
|
+
end
|
17
|
+
CUKE_RESULTS = 'results.html'
|
18
|
+
CLEAN << CUKE_RESULTS
|
19
|
+
desc 'Run features'
|
20
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
21
|
+
opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
|
22
|
+
opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
|
23
|
+
t.cucumber_opts = opts
|
24
|
+
t.fork = false
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Run features tagged as work-in-progress (@wip)'
|
28
|
+
Cucumber::Rake::Task.new('features:wip') do |t|
|
29
|
+
tag_opts = ' --tags ~@pending'
|
30
|
+
tag_opts = ' --tags @wip'
|
31
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
|
32
|
+
t.fork = false
|
33
|
+
end
|
34
|
+
|
35
|
+
task :cucumber => :features
|
36
|
+
task 'cucumber:wip' => 'features:wip'
|
37
|
+
task :wip => 'features:wip'
|
38
|
+
require 'rake/testtask'
|
39
|
+
Rake::TestTask.new do |t|
|
40
|
+
t.libs << "test"
|
41
|
+
t.test_files = FileList['test/*_test.rb']
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => [:test,:features]
|
data/bin/veda
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'gli'
|
3
|
+
begin # XXX: Remove this begin/rescue before distributing your app
|
4
|
+
require 'veda'
|
5
|
+
require 'QR'
|
6
|
+
|
7
|
+
rescue LoadError
|
8
|
+
STDERR.puts "In development, you need to use `bundle exec bin/veda` to run your app"
|
9
|
+
STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"
|
10
|
+
STDERR.puts "Feel free to remove this message from bin/veda now"
|
11
|
+
exit 64
|
12
|
+
end
|
13
|
+
|
14
|
+
include GLI::App
|
15
|
+
# inclu
|
16
|
+
|
17
|
+
command :generate do |c|
|
18
|
+
c.desc 'Generate'
|
19
|
+
c.switch :qr
|
20
|
+
|
21
|
+
c.action do |global_options,options,args|
|
22
|
+
|
23
|
+
if options[:qr]
|
24
|
+
puts 'generate qr'
|
25
|
+
path = args.first
|
26
|
+
# raise 'cant help at this time'
|
27
|
+
raise 'File name not given' if path.nil?
|
28
|
+
raise "#{path}. File does not exist." unless File.file?(path)
|
29
|
+
generate_qr path
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
on_error do |exception|
|
37
|
+
# puts 'error occured'
|
38
|
+
true
|
39
|
+
end
|
40
|
+
|
41
|
+
def generate_qr path
|
42
|
+
qr = QR::Qr.new
|
43
|
+
qr.generate_qr path
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
exit run(ARGV)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
|
3
|
+
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
4
|
+
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
|
5
|
+
|
6
|
+
Before do
|
7
|
+
# Using "announce" causes massive warnings on 1.9.2
|
8
|
+
@puts = true
|
9
|
+
@original_rubylib = ENV['RUBYLIB']
|
10
|
+
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
After do
|
14
|
+
ENV['RUBYLIB'] = @original_rubylib
|
15
|
+
end
|
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/Qr.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
module QR
|
2
|
+
class Qr
|
3
|
+
require 'fileutils'
|
4
|
+
def generate_qr path
|
5
|
+
qr_storyboard_path = root + '/lib/VedaQRScanner/VedaQr.storyboard'
|
6
|
+
qr_viewcontroller_path = root + '/lib/VedaQRScanner/VedaQRScannerViewController.swift'
|
7
|
+
viewcontroller_extension_path = root + '/lib/VedaQRScanner/UIViewControllerExtension.swift'
|
8
|
+
|
9
|
+
dest_folder = dest_folder_path path
|
10
|
+
copy qr_storyboard_path, dest_folder
|
11
|
+
copy qr_viewcontroller_path, dest_folder
|
12
|
+
copy viewcontroller_extension_path, dest_folder
|
13
|
+
viewcontroller_name = viewcontroller_name path
|
14
|
+
write((extension viewcontroller_name), path)
|
15
|
+
puts "successfully generated qr scanner in path: #{dest_folder}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def write extension, path
|
19
|
+
f = File.open(path, 'a')
|
20
|
+
f.write(extension)
|
21
|
+
f.close
|
22
|
+
end
|
23
|
+
|
24
|
+
def copy src_path, dest_path
|
25
|
+
FileUtils.cp(src_path, dest_path)
|
26
|
+
end
|
27
|
+
|
28
|
+
def root
|
29
|
+
File.expand_path '../..', __FILE__
|
30
|
+
end
|
31
|
+
|
32
|
+
def dest_folder_path path
|
33
|
+
dest_folder = path.split('/').reverse.drop(1).reverse.join('/')
|
34
|
+
end
|
35
|
+
|
36
|
+
def viewcontroller_name path
|
37
|
+
path.split('/').reverse.first.split('.').first
|
38
|
+
end
|
39
|
+
|
40
|
+
def extension name
|
41
|
+
extension = <<-EOS
|
42
|
+
extension #{name} {
|
43
|
+
func scan() {
|
44
|
+
self.openVedaQRScanner(source: self) { (viewcontroller, string) in
|
45
|
+
let qrString = string
|
46
|
+
print(qrString)
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
func openVedaQRScanner(source: UIViewController, completion: @escaping (VedaQRScannerViewController, String)->()) {
|
51
|
+
if let vc = UIStoryboard(name: "VedaQR", bundle: nil).instantiateInitialViewController() as? VedaQRScannerViewController {
|
52
|
+
vc.onObtained = completion
|
53
|
+
source.present(vc, animated: true, completion: nil)
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
EOS
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
// Created by shishir sapkota on 1/17/18.
|
2
|
+
// Copyright © 2018 ccr. All rights reserved.
|
3
|
+
//
|
4
|
+
|
5
|
+
import UIKit
|
6
|
+
|
7
|
+
// MARK: Alerts
|
8
|
+
|
9
|
+
extension UIViewController {
|
10
|
+
|
11
|
+
func confirmationAlert(title: String, message: String, confirmTitle: String, style: UIAlertActionStyle = .destructive, confirmAction: @escaping () -> Void) {
|
12
|
+
let deleteActionSheetController = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
13
|
+
let deleteAction = UIAlertAction(title: confirmTitle, style: style) {
|
14
|
+
action -> Void in
|
15
|
+
confirmAction()
|
16
|
+
}
|
17
|
+
|
18
|
+
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { action -> Void in
|
19
|
+
}
|
20
|
+
deleteActionSheetController.addAction(deleteAction)
|
21
|
+
deleteActionSheetController.addAction(cancelAction)
|
22
|
+
self.present(deleteActionSheetController, animated: true, completion: nil)
|
23
|
+
}
|
24
|
+
|
25
|
+
func alert(message: String?, title: String? = "error", okAction: (()->())? = nil) {
|
26
|
+
let alertController = getAlert(message: message, title: title)
|
27
|
+
alertController.addAction(title: "Ok", handler: okAction)
|
28
|
+
self.present(alertController, animated: true, completion: nil)
|
29
|
+
}
|
30
|
+
|
31
|
+
func alertWithOkCancel(message: String?, title: String? = "error", okTitle: String? = "Ok", style: UIAlertControllerStyle? = .alert, cancelTitle: String? = "Cancel", OkStyle: UIAlertActionStyle = .default, cancelStyle: UIAlertActionStyle = .default, okAction: (()->())? = nil, cancelAction: (()->())? = nil) {
|
32
|
+
let alertController = getAlert(message: message, title: title, style: style)
|
33
|
+
alertController.addAction(title: okTitle,style: OkStyle, handler: okAction)
|
34
|
+
alertController.addAction(title: cancelTitle, style: cancelStyle, handler: cancelAction)
|
35
|
+
self.present(alertController, animated: true, completion: nil)
|
36
|
+
}
|
37
|
+
|
38
|
+
private func getAlert(message: String?, title: String?, style: UIAlertControllerStyle? = .alert) -> UIAlertController {
|
39
|
+
return UIAlertController(title: title, message: message, preferredStyle: style ?? .alert)
|
40
|
+
}
|
41
|
+
|
42
|
+
func present(_ alert: UIAlertController, asActionsheetInSourceView sourceView: Any) {
|
43
|
+
if UI_USER_INTERFACE_IDIOM() == .pad {
|
44
|
+
alert.modalPresentationStyle = .popover
|
45
|
+
if let presenter = alert.popoverPresentationController {
|
46
|
+
if sourceView is UIBarButtonItem {
|
47
|
+
presenter.barButtonItem = sourceView as? UIBarButtonItem
|
48
|
+
}else if sourceView is UIView {
|
49
|
+
let view = sourceView as! UIView
|
50
|
+
presenter.sourceView = view
|
51
|
+
presenter.sourceRect = view.bounds
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
self.present(alert, animated: true, completion: nil)
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
extension UIAlertController {
|
61
|
+
func addAction(title: String?, style: UIAlertActionStyle = .default, handler: (()->())? = nil) {
|
62
|
+
let action = UIAlertAction(title: title, style: style, handler: {_ in
|
63
|
+
handler?()
|
64
|
+
})
|
65
|
+
self.addAction(action)
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
struct Associate {
|
70
|
+
static var hud: UInt8 = 0
|
71
|
+
static var empty: UInt8 = 0
|
72
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="nmi-tm-f5L">
|
3
|
+
<device id="retina4_7" orientation="portrait">
|
4
|
+
<adaptation id="fullscreen"/>
|
5
|
+
</device>
|
6
|
+
<dependencies>
|
7
|
+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
|
8
|
+
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
|
9
|
+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
10
|
+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
11
|
+
</dependencies>
|
12
|
+
<customFonts key="customFonts">
|
13
|
+
<array key="Montserrat-Light.otf">
|
14
|
+
<string>Montserrat-Light</string>
|
15
|
+
</array>
|
16
|
+
</customFonts>
|
17
|
+
<scenes>
|
18
|
+
<!--QR Scanner-->
|
19
|
+
<scene sceneID="5E8-S9-meX">
|
20
|
+
<objects>
|
21
|
+
<viewController storyboardIdentifier="QRCodeScannerViewController" title="QR Scanner" id="nmi-tm-f5L" customClass="VedaQRScannerViewController" customModule="QrText" customModuleProvider="target" sceneMemberID="viewController">
|
22
|
+
<view key="view" contentMode="scaleToFill" id="gUG-tk-vvb">
|
23
|
+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
24
|
+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
25
|
+
<subviews>
|
26
|
+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No QR Code Detected" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PKj-yY-jHf">
|
27
|
+
<rect key="frame" x="0.0" y="637" width="375" height="30"/>
|
28
|
+
<color key="backgroundColor" white="0.33333333333333331" alpha="0.49532350352112675" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
29
|
+
<constraints>
|
30
|
+
<constraint firstAttribute="height" constant="30" id="ngR-F2-HkS"/>
|
31
|
+
</constraints>
|
32
|
+
<fontDescription key="fontDescription" name="Montserrat-Light" family="Montserrat" pointSize="15"/>
|
33
|
+
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
34
|
+
<nil key="highlightedColor"/>
|
35
|
+
</label>
|
36
|
+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pay-bH-qQH">
|
37
|
+
<rect key="frame" x="316" y="30" width="44" height="44"/>
|
38
|
+
<constraints>
|
39
|
+
<constraint firstAttribute="width" secondItem="pay-bH-qQH" secondAttribute="height" multiplier="1:1" id="G0d-yl-9B9"/>
|
40
|
+
<constraint firstAttribute="width" constant="44" id="joF-Ir-Ny9"/>
|
41
|
+
</constraints>
|
42
|
+
<color key="tintColor" red="0.37647058820000001" green="0.69019607839999997" blue="0.33333333329999998" alpha="1" colorSpace="calibratedRGB"/>
|
43
|
+
<state key="normal" image="cross"/>
|
44
|
+
<connections>
|
45
|
+
<action selector="close:" destination="nmi-tm-f5L" eventType="touchUpInside" id="h4b-Wl-cwS"/>
|
46
|
+
</connections>
|
47
|
+
</button>
|
48
|
+
</subviews>
|
49
|
+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
50
|
+
<constraints>
|
51
|
+
<constraint firstItem="79Q-8r-vF8" firstAttribute="trailing" secondItem="PKj-yY-jHf" secondAttribute="trailing" id="28M-XW-WHG"/>
|
52
|
+
<constraint firstItem="pay-bH-qQH" firstAttribute="top" secondItem="79Q-8r-vF8" secondAttribute="top" constant="10" id="CtP-nS-g7b"/>
|
53
|
+
<constraint firstItem="79Q-8r-vF8" firstAttribute="bottom" secondItem="PKj-yY-jHf" secondAttribute="bottom" id="XbB-3i-LLY"/>
|
54
|
+
<constraint firstItem="79Q-8r-vF8" firstAttribute="trailing" secondItem="pay-bH-qQH" secondAttribute="trailing" constant="15" id="slv-zp-aKh"/>
|
55
|
+
<constraint firstItem="PKj-yY-jHf" firstAttribute="leading" secondItem="79Q-8r-vF8" secondAttribute="leading" id="tsS-C7-ljE"/>
|
56
|
+
</constraints>
|
57
|
+
<viewLayoutGuide key="safeArea" id="79Q-8r-vF8"/>
|
58
|
+
</view>
|
59
|
+
<navigationItem key="navigationItem" id="YoB-Nz-6mb"/>
|
60
|
+
<connections>
|
61
|
+
<outlet property="closeButton" destination="pay-bH-qQH" id="MAd-2c-Ap4"/>
|
62
|
+
<outlet property="messageLabel" destination="PKj-yY-jHf" id="MSs-Pz-xHS"/>
|
63
|
+
</connections>
|
64
|
+
</viewController>
|
65
|
+
<placeholder placeholderIdentifier="IBFirstResponder" id="EM6-Ir-349" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
66
|
+
</objects>
|
67
|
+
<point key="canvasLocation" x="188" y="217"/>
|
68
|
+
</scene>
|
69
|
+
</scenes>
|
70
|
+
<resources>
|
71
|
+
<image name="cross" width="22" height="22"/>
|
72
|
+
</resources>
|
73
|
+
</document>
|
@@ -0,0 +1,134 @@
|
|
1
|
+
// Created by shishir sapkota on 1/17/18.
|
2
|
+
// Copyright © 2018 ccr. All rights reserved.
|
3
|
+
//
|
4
|
+
// QRCodeScannerViewController.swift
|
5
|
+
// Created by Iccr
|
6
|
+
// https://github.com/Iccr
|
7
|
+
|
8
|
+
import UIKit
|
9
|
+
import AVFoundation
|
10
|
+
|
11
|
+
class VedaQRScannerViewController: UIViewController {
|
12
|
+
// Mark:- Properties
|
13
|
+
var captureSession: AVCaptureSession?
|
14
|
+
var videoPreviewLayer: AVCaptureVideoPreviewLayer?
|
15
|
+
var qrCodeFrameView: UIView?
|
16
|
+
var onObtained: ((VedaQRScannerViewController, String) -> ())?
|
17
|
+
|
18
|
+
// Mark:- Outlets
|
19
|
+
@IBOutlet weak var closeButton: UIButton!
|
20
|
+
@IBOutlet weak var messageLabel: UILabel!
|
21
|
+
|
22
|
+
// Mark:- Life cycle
|
23
|
+
override func viewDidLoad() {
|
24
|
+
super.viewDidLoad()
|
25
|
+
}
|
26
|
+
|
27
|
+
override func viewWillAppear(_ animated: Bool) {
|
28
|
+
super.viewWillAppear(animated)
|
29
|
+
checkPermission()
|
30
|
+
}
|
31
|
+
|
32
|
+
// Mark:- @IBActions
|
33
|
+
@IBAction func close(_ sender: Any?) {
|
34
|
+
self.captureSession?.stopRunning()
|
35
|
+
self.dismiss(animated: true, completion: nil)
|
36
|
+
}
|
37
|
+
|
38
|
+
// Mark:- Other functions
|
39
|
+
private func checkPermission() {
|
40
|
+
PermissionHelper.isAllowedToRecordVideo { (isAllowed) in
|
41
|
+
if isAllowed {
|
42
|
+
self.openQr()
|
43
|
+
}else {
|
44
|
+
self.alertWithOkCancel(message: "Camera access denied. Do you want to change the permission from settings?", okAction: {
|
45
|
+
let url = URL(string: UIApplicationOpenSettingsURLString)!
|
46
|
+
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
47
|
+
}, cancelAction: {
|
48
|
+
self.close(nil)
|
49
|
+
})
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
private func openQr() {
|
55
|
+
if self.setupAvCapture() {
|
56
|
+
setupOutput()
|
57
|
+
setupVideoLayer()
|
58
|
+
captureSession?.startRunning()
|
59
|
+
setupQRCodeFrameView()
|
60
|
+
self.view.bringSubview(toFront: messageLabel)
|
61
|
+
self.view.bringSubview(toFront: closeButton)
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
func setupAvCapture() -> Bool {
|
66
|
+
let captureDevice = AVCaptureDevice.default(for: AVMediaType.video)
|
67
|
+
do {
|
68
|
+
// Get an instance of the AVCaptureDeviceInput class using the previous device object.
|
69
|
+
guard let captureDevice = captureDevice else {return false}
|
70
|
+
let input = try AVCaptureDeviceInput(device: captureDevice)
|
71
|
+
captureSession = AVCaptureSession()
|
72
|
+
// Set the input device on the capture session.
|
73
|
+
captureSession?.addInput(input)
|
74
|
+
return true
|
75
|
+
} catch {
|
76
|
+
// If any error occurs, simply print it out and don't continue any more.
|
77
|
+
print(error)
|
78
|
+
return false
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
func setupOutput() {
|
83
|
+
// Initialize a AVCaptureMetadataOutput object and set it as the output device to the capture session.
|
84
|
+
let captureMetadataOutput = AVCaptureMetadataOutput()
|
85
|
+
captureMetadataOutput.setMetadataObjectsDelegate(self, queue: DispatchQueue.main)
|
86
|
+
captureSession?.addOutput(captureMetadataOutput)
|
87
|
+
captureMetadataOutput.metadataObjectTypes = [AVMetadataObject.ObjectType.qr]
|
88
|
+
}
|
89
|
+
|
90
|
+
func setupVideoLayer() {
|
91
|
+
videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession!)
|
92
|
+
videoPreviewLayer?.videoGravity = AVLayerVideoGravity.resizeAspectFill
|
93
|
+
videoPreviewLayer?.frame = view.layer.bounds
|
94
|
+
view.layer.addSublayer(videoPreviewLayer!)
|
95
|
+
}
|
96
|
+
|
97
|
+
func setupQRCodeFrameView() {
|
98
|
+
// Initialize QR Code Frame to highlight the QR code
|
99
|
+
qrCodeFrameView = UIView()
|
100
|
+
qrCodeFrameView!.layer.borderColor = UIColor.green.cgColor
|
101
|
+
qrCodeFrameView!.layer.borderWidth = 2
|
102
|
+
view.addSubview(qrCodeFrameView!)
|
103
|
+
view.bringSubview(toFront: qrCodeFrameView!)
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
extension VedaQRScannerViewController: AVCaptureMetadataOutputObjectsDelegate {
|
108
|
+
func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) {
|
109
|
+
if metadataObjects.count == 0 {
|
110
|
+
qrCodeFrameView?.frame = CGRect.zero
|
111
|
+
messageLabel.text = "noQR"
|
112
|
+
return
|
113
|
+
}
|
114
|
+
// Get the metadata object.
|
115
|
+
let metadataObj = metadataObjects[0] as! AVMetadataMachineReadableCodeObject
|
116
|
+
if metadataObj.type == AVMetadataObject.ObjectType.qr {
|
117
|
+
let qrCodeObject = videoPreviewLayer?.transformedMetadataObject(for: metadataObj)
|
118
|
+
qrCodeFrameView?.frame = qrCodeObject!.bounds
|
119
|
+
if metadataObj.stringValue != nil {
|
120
|
+
messageLabel.text = metadataObj.stringValue
|
121
|
+
self.captureSession?.stopRunning()
|
122
|
+
self.dismiss(animated: true, completion: nil)
|
123
|
+
self.onObtained?(self, metadataObj.stringValue!)
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
struct PermissionHelper {
|
130
|
+
static func isAllowedToRecordVideo(completion: @escaping (Bool) -> ()) {
|
131
|
+
let status = AVCaptureDevice.authorizationStatus(for: AVMediaType.video)
|
132
|
+
completion(status != .denied && status != .restricted)
|
133
|
+
}
|
134
|
+
}
|
data/lib/veda/.DS_Store
ADDED
Binary file
|
data/lib/veda/version.rb
ADDED
data/lib/veda.rb
ADDED
data/test/test_helper.rb
ADDED
data/veda.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Ensure we require the local version and not one we might have installed already
|
2
|
+
require File.join([File.dirname(__FILE__),'lib','veda','version.rb'])
|
3
|
+
spec = Gem::Specification.new do |s|
|
4
|
+
s.name = 'veda-apps'
|
5
|
+
s.version = Veda::VERSION
|
6
|
+
s.author = 'Shishir sapkota'
|
7
|
+
s.email = 'sis.ccr@gmail.com'
|
8
|
+
s.homepage = 'https://github.com/Iccr'
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.summary = 'Automate the Ios Tasks'
|
11
|
+
s.files = `git ls-files`.split("
|
12
|
+
")
|
13
|
+
s.require_paths << 'lib'
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.extra_rdoc_files = ['veda.rdoc']
|
16
|
+
s.rdoc_options << '--title' << 'veda' << '--main' << 'README.rdoc' << '-ri'
|
17
|
+
s.bindir = 'bin'
|
18
|
+
s.executables << 'veda'
|
19
|
+
s.add_development_dependency('rake')
|
20
|
+
s.add_development_dependency('rdoc')
|
21
|
+
s.add_development_dependency('aruba')
|
22
|
+
s.add_runtime_dependency('gli','2.17.1')
|
23
|
+
end
|
data/veda.rdoc
ADDED
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: veda-apps
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shishir sapkota
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
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: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aruba
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: gli
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.17.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.17.1
|
69
|
+
description:
|
70
|
+
email: sis.ccr@gmail.com
|
71
|
+
executables:
|
72
|
+
- veda
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files:
|
75
|
+
- veda.rdoc
|
76
|
+
files:
|
77
|
+
- ".DS_Store"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/veda
|
83
|
+
- features/step_definitions/veda_steps.rb
|
84
|
+
- features/support/env.rb
|
85
|
+
- features/veda.feature
|
86
|
+
- lib/.DS_Store
|
87
|
+
- lib/Qr.rb
|
88
|
+
- lib/VedaQRScanner/UIViewControllerExtension.swift
|
89
|
+
- lib/VedaQRScanner/VedaQR.storyboard
|
90
|
+
- lib/VedaQRScanner/VedaQRScannerViewController.swift
|
91
|
+
- lib/veda.rb
|
92
|
+
- lib/veda/.DS_Store
|
93
|
+
- lib/veda/version.rb
|
94
|
+
- test/default_test.rb
|
95
|
+
- test/test_helper.rb
|
96
|
+
- veda.gemspec
|
97
|
+
- veda.rdoc
|
98
|
+
homepage: https://github.com/Iccr
|
99
|
+
licenses: []
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options:
|
103
|
+
- "--title"
|
104
|
+
- veda
|
105
|
+
- "--main"
|
106
|
+
- README.rdoc
|
107
|
+
- "-ri"
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.5.1
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Automate the Ios Tasks
|
127
|
+
test_files: []
|