hs 0.1.1
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 +15 -0
- data/README.md +4 -0
- data/lib/hs.rb +18 -0
- data/lib/project/base.rb +93 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OTIyMTg4NjQzZjAxMzBkNzRlYzU5NDIyNTM1MGU2NzBlYjU1OGQwYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NWQ5YThmNjBjNGRmM2EyYjVmYmE5ZGI0OWU4YTE4ZWU0YzEwNTZiYw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NWI5YTUyNDg3ODllOTU5ODkyZjk0ZjIwYTkyZDM1OGY5ZjkxOWNkOTI2OGRh
|
10
|
+
NTVkMTFlOGMyM2UyN2RmNzYyNDExNjI1M2IxNzNjNDE0NWE4NTIyNDEyNjQ4
|
11
|
+
MjlmNmMxOWZmNTRlMzVhYmFhNTM4ZTc4ZDlhN2RhZThiNjc4ZDA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MDg4MTFiOWU1ODY4MWRkNGZlMjA2YWNkMDBiZmY3MTY1MzVhYjMzOGNhNTUw
|
14
|
+
ZDBhMjIwMGM5MTljNjA3MWQwYmEwYjJjYjM3Yzg0NGMyNDkwMTZkNDFhOTVk
|
15
|
+
YjQ1N2RiMDUzMjBkY2MzYjgwMjc5M2RmMTBkM2I4NjhmNWYzNDM=
|
data/README.md
ADDED
data/lib/hs.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'motion-cocoapods'
|
3
|
+
require 'bubble-wrap/core'
|
4
|
+
require 'sugarcube-anonymous'
|
5
|
+
require 'sugarcube-legacy'
|
6
|
+
require 'sugarcube-numbers'
|
7
|
+
|
8
|
+
unless defined?(Motion::Project::Config)
|
9
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
10
|
+
end
|
11
|
+
|
12
|
+
lib_dir_path = File.dirname(File.expand_path(__FILE__))
|
13
|
+
Motion::Project::App.setup do |app|
|
14
|
+
app.files.unshift(Dir.glob(File.join(lib_dir_path, "project/**/*.rb")))
|
15
|
+
|
16
|
+
app.pods ||= Motion::Project::CocoaPods.new(app)
|
17
|
+
app.pods.pod 'Reachability'
|
18
|
+
end
|
data/lib/project/base.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
module HS
|
2
|
+
class Base
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
# ROTATION HELPERS
|
7
|
+
def landscape_left?
|
8
|
+
Device.interface_orientation == :landscape_left
|
9
|
+
end
|
10
|
+
|
11
|
+
def landscape_right?
|
12
|
+
Device.interface_orientation == :landscape_right
|
13
|
+
end
|
14
|
+
|
15
|
+
def right_side_up?
|
16
|
+
Device.interface_orientation == :portrait
|
17
|
+
end
|
18
|
+
|
19
|
+
def upside_down?
|
20
|
+
Device.interface_orientation == :portrait_upside_down
|
21
|
+
end
|
22
|
+
|
23
|
+
def landscape?
|
24
|
+
landscape_left? || landscape_right?
|
25
|
+
end
|
26
|
+
|
27
|
+
def portrait?
|
28
|
+
right_side_up?
|
29
|
+
end
|
30
|
+
|
31
|
+
def rotation_width(orientation = Device.interface_orientation)
|
32
|
+
Device.screen.width_for_orientation(orientation)
|
33
|
+
end
|
34
|
+
|
35
|
+
def rotation_height(orientation = Device.interface_orientation)
|
36
|
+
Device.screen.height_for_orientation(orientation)
|
37
|
+
end
|
38
|
+
|
39
|
+
def rotation_transform
|
40
|
+
transform = 0.degrees
|
41
|
+
if landscape_left?
|
42
|
+
transform = 270.degrees
|
43
|
+
elsif landscape_right?
|
44
|
+
transform = 90.degrees
|
45
|
+
end
|
46
|
+
|
47
|
+
CGAffineTransformMakeRotation(transform)
|
48
|
+
end
|
49
|
+
|
50
|
+
def orientation
|
51
|
+
if landscape_left?(Device.interface_orientation)
|
52
|
+
UIInterfaceOrientationLandscapeLeft
|
53
|
+
elsif landscape_right?(Device.interface_orientation)
|
54
|
+
UIInterfaceOrientationLandscapeRight
|
55
|
+
else
|
56
|
+
UIInterfaceOrientationPortrait
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# INTERNET HELPERS
|
61
|
+
def reachable?
|
62
|
+
Reachability.reachabilityForInternetConnection.isReachable
|
63
|
+
end
|
64
|
+
|
65
|
+
# MISC HELPERS
|
66
|
+
def keyboard_height
|
67
|
+
Device.ipad? ? 264 : 216
|
68
|
+
end
|
69
|
+
|
70
|
+
def aspect_height_from(old_height, old_width:old_width, width:width)
|
71
|
+
old_height.to_f / old_width.to_f * width
|
72
|
+
end
|
73
|
+
|
74
|
+
def aspect_size_from(old_height, old_width:old_width, width:width)
|
75
|
+
height = old_height.to_f / old_width.to_f * width
|
76
|
+
[width, height]
|
77
|
+
end
|
78
|
+
|
79
|
+
def app_inactive?
|
80
|
+
App.shared.applicationState != UIApplicationStateActive
|
81
|
+
end
|
82
|
+
|
83
|
+
def ios_7?
|
84
|
+
Device.ios_version.to_i >= 7
|
85
|
+
end
|
86
|
+
|
87
|
+
def ios_6?
|
88
|
+
Device.ios_version.to_i >= 6
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Holger Sindbaek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-31 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: sugarcube
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bubble-wrap
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: motion-cocoapods
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.3.7
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.3.7
|
69
|
+
description: Generic helpers I tend to use in a lot of different apps
|
70
|
+
email:
|
71
|
+
- HolgerSindbaek@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- README.md
|
77
|
+
- lib/hs.rb
|
78
|
+
- lib/project/base.rb
|
79
|
+
homepage: https://github.com/holgersindbaek/HS
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.1.8
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Generic helpers I tend to use in a lot of different apps
|
103
|
+
test_files: []
|