pingo 0.0.1.1

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
+ SHA1:
3
+ metadata.gz: afa4de1631b672bc9d7c464d8657f5ba61efb4ec
4
+ data.tar.gz: dfc79d9bf173e7c1dd04677a5e248db43bf1153d
5
+ SHA512:
6
+ metadata.gz: ede9c4ca309e4c58c217c14dad3622ff0a1bacbe0d08769ad99462cb73ab6a16c19f28fa2fb85c0294fe46f90dce0ac43802009b6ec53bee038eb99b6bb1c0db
7
+ data.tar.gz: c102e515cfa93ce1560ae5553cfd3655716dd19861e4f72092c61a9edfc30d3e7e88efd10b0699aa4639eb285d966483d8e29d43c304f58bfadadc9b4afe7b14
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pingo.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Kyuden
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Pingo
2
+
3
+ Pingo provide a scatterbrain with a `pingo` command of sounding your iphone.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'pingo'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install pingo
18
+
19
+ ## Usage
20
+
21
+ Set APPLE_ID and APPLE_PASSWORD in environment variables.
22
+
23
+ ```bash
24
+ # Set it in .zshrc, .bashrc etc...
25
+ echo "export APPLE_ID=your_apple_id" >> ~/.zshrc
26
+ echo "export APPLE_PASSWORD=your_apple_password" >> ~/.zshrc
27
+ source ~/.zshrc
28
+ ```
29
+
30
+ Execute `pingo` command with iphone model name
31
+
32
+ ```bash
33
+ pingo your_iphone_model_name
34
+ ```
35
+
36
+ Example:
37
+
38
+ ```
39
+ # when iphone 5s
40
+ pingo 5s
41
+ ```
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it ( https://github.com/[my-github-username]/pingo/fork )
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
data/bin/pingo ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pingo'
4
+
5
+ Pingo::CLI.start
@@ -0,0 +1,16 @@
1
+ require 'thor'
2
+
3
+ module Pingo
4
+ class CLI < Thor
5
+ desc "IPHONE_MODEL(ex 5, 5s)", "sound iphone"
6
+ def pingo(device_name)
7
+ Pingo.run(device_name)
8
+ end
9
+
10
+ private
11
+
12
+ def method_missing(device_name)
13
+ pingo(device_name.to_s)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module Pingo
2
+ VERSION = "0.0.1.1"
3
+ end
data/lib/pingo.rb ADDED
@@ -0,0 +1,87 @@
1
+ require "pingo/version"
2
+ require "pingo/cli/sound"
3
+ require "json"
4
+ require "typhoeus"
5
+
6
+ module Pingo
7
+ class Pingo
8
+ INIT_CLIENT = 'initClient'
9
+ PLAY_SOUND = 'playSound'
10
+
11
+ def initialize(device_name)
12
+ @device_name = device_name
13
+ @username = ENV['APPLE_ID']
14
+ @password = ENV['APPLE_PASSWORD']
15
+ end
16
+
17
+ def self.run(device_name)
18
+ new(device_name).instance_eval do
19
+ @partition = get_partition
20
+ @device_id = get_device_id
21
+ play_sound
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def get_partition
28
+ post(INIT_CLIENT).headers['X-Apple-MMe-Host']
29
+ end
30
+
31
+ def get_device_id
32
+ parse_device_id(post(INIT_CLIENT))
33
+ end
34
+
35
+ def parse_device_id(data)
36
+ JSON.parse(data.body)['content'].each { |params| return params["id"] if match_device?(params) }
37
+ end
38
+
39
+ def match_device?(params)
40
+ params['location'] && params['deviceDisplayName'] =~ /#{@device_name}$/
41
+ end
42
+
43
+ def play_sound
44
+ post(PLAY_SOUND, generate_body)
45
+ end
46
+
47
+ def generate_body
48
+ JSON.generate(play_sound_body)
49
+ end
50
+
51
+ def play_sound_body
52
+ {
53
+ clientContext: {
54
+ appName: 'FindMyiPhone',
55
+ appVersion: '2.0.2',
56
+ shouldLocate: false,
57
+ },
58
+ device: @device_id,
59
+ subject: "Pingo"
60
+ }
61
+ end
62
+
63
+ def post(mode, body=nil)
64
+ Typhoeus::Request.post(uri(mode), userpwd: "#{@username}:#{@password}", headers: post_headers, followlocation: true, verbose: true, maxredirs: 1, body: body)
65
+ end
66
+
67
+ def post_headers
68
+ {
69
+ 'Content-Type' => 'application/json; charset=utf-8',
70
+ 'X-Apple-Find-Api-Ver' => '2.0',
71
+ 'X-Apple-Authscheme' => 'UserIdGuest',
72
+ 'X-Apple-Realm-Support' => '1.0',
73
+ 'Accept-Language' => 'en-us',
74
+ 'userAgent' => 'Pingo',
75
+ 'Connection' => 'keep-alive'
76
+ }
77
+ end
78
+
79
+ def uri(mode)
80
+ @partition ? "https://#{@partition}/#{base_uri}/#{mode}" : "https://fmipmobile.icloud.com/#{base_uri}/#{mode}"
81
+ end
82
+
83
+ def base_uri
84
+ "fmipservice/device/#{@username}"
85
+ end
86
+ end
87
+ end
data/pingo.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pingo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pingo"
8
+ spec.version = Pingo::VERSION
9
+ spec.authors = ["Kyuden"]
10
+ spec.email = ["msmsms.um@gmail.com"]
11
+ spec.summary = %q{Write a short summary. Required.}
12
+ spec.description = %q{Write a longer description. Optional.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "typhoeus"
22
+ spec.add_runtime_dependency "thor"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pingo do
4
+ it 'has a version number' do
5
+ expect(Pingo::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'pingo'
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pingo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Kyuden
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: typhoeus
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: thor
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Write a longer description. Optional.
84
+ email:
85
+ - msmsms.um@gmail.com
86
+ executables:
87
+ - pingo
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/pingo
99
+ - lib/pingo.rb
100
+ - lib/pingo/cli/sound.rb
101
+ - lib/pingo/version.rb
102
+ - pingo.gemspec
103
+ - spec/pingo_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: ''
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.2.2
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Write a short summary. Required.
129
+ test_files:
130
+ - spec/pingo_spec.rb
131
+ - spec/spec_helper.rb