motion-pixate-observer 0.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.
- data/README.md +57 -0
- data/bin/pixate_server +29 -0
- data/lib/Socket/Socket-Prefix.pch +7 -0
- data/lib/Socket/Socket.h +14 -0
- data/lib/Socket/libSocket.a +0 -0
- data/lib/motion-pixate-observer.rb +9 -0
- data/lib/project/pixate_style_watch.rb +29 -0
- metadata +55 -0
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Motion::Pixate::Observer
|
2
|
+
|
3
|
+
This gem provides a function that you changes css files, apply changes into your application that uses Pixate Framework immediately.
|
4
|
+
|
5
|
+
You do not need rebuild your application and any operations.
|
6
|
+
Only update your css files.
|
7
|
+
|
8
|
+
この gem は、CSS ファイルを変更すると即座に Pixate Framework を利用したアプリに変更内容を適用するという機能を提供します。
|
9
|
+
|
10
|
+
CSS ファイルを変更するたびにアプリをビルドし直す必要も、アプリ上での操作も一切必要ありません。CSS ファイルをエディタで編集し保存するだけです。
|
11
|
+
|
12
|
+
## Requirements
|
13
|
+
|
14
|
+
- RubyMotion 1.0 or greater (see http://www.rubymotion.com).
|
15
|
+
- Pixate Framework 1.0 or greater (see http://www.pixate.com/).
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
```
|
20
|
+
$ gem install motion-pixate-observer
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
- Add require `motion-pixate-observer` to your `Rakefile`
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'rubygems'
|
29
|
+
require 'motion-pixate-observer'
|
30
|
+
```
|
31
|
+
|
32
|
+
- include `Motion::Pixate::Observer` in Main Controller. Call `startObserving` in `viewDidLoad`.
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
class MainViewController < UIViewController
|
36
|
+
include Motion::Pixate::Observer # include Motion::Pixate::Observer in Main Controller
|
37
|
+
|
38
|
+
def viewDidLoad
|
39
|
+
super
|
40
|
+
|
41
|
+
startObserving # start searching and communicate with server
|
42
|
+
|
43
|
+
....
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
- First, you have to start server. Depends on MacRuby when start server.
|
48
|
+
|
49
|
+
|
50
|
+
```
|
51
|
+
$ ./pixate_server css_file_path
|
52
|
+
```
|
53
|
+
|
54
|
+
After started server, run your RubyMotion application.
|
55
|
+
|
56
|
+
- update css files, apply changes immediately.
|
57
|
+
|
data/bin/pixate_server
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/local/bin/macruby
|
2
|
+
framework "Cocoa"
|
3
|
+
require "socket"
|
4
|
+
|
5
|
+
cssfile = ARGV[0] || ""
|
6
|
+
unless File.exists?(cssfile)
|
7
|
+
warn "USAGE : #{$0} css_file_path"
|
8
|
+
exit
|
9
|
+
end
|
10
|
+
|
11
|
+
SERVER_PORT = 8000
|
12
|
+
SERVER_NAME = "Pixate CSS Notifier"
|
13
|
+
|
14
|
+
netservice = NSNetService.alloc.initWithDomain("", type: "_pixate._tcp", name: SERVER_NAME, port: SERVER_PORT)
|
15
|
+
netservice.publish
|
16
|
+
|
17
|
+
serv = TCPServer.open("", SERVER_PORT)
|
18
|
+
fd = open(cssfile, "r")
|
19
|
+
gcdq = Dispatch::Queue.new('pixate')
|
20
|
+
mask = Dispatch::Source::VNODE_WRITE | Dispatch::Source::VNODE_EXTEND
|
21
|
+
|
22
|
+
while true
|
23
|
+
Thread.start(serv.accept) do |sock|
|
24
|
+
source ||= Dispatch::Source.new(Dispatch::Source::VNODE, fd, mask, gcdq) do
|
25
|
+
fd.rewind
|
26
|
+
sock.write(fd.read)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/Socket/Socket.h
ADDED
Binary file
|
@@ -0,0 +1,9 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
lib_dir_path = File.dirname(File.expand_path(__FILE__))
|
6
|
+
Motion::Project::App.setup do |app|
|
7
|
+
app.files.concat(Dir.glob(File.join(lib_dir_path, "project/**/*.rb")))
|
8
|
+
app.vendor_project(File.join(lib_dir_path, "Socket"), :static)
|
9
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Motion; module Pixate; module Observer
|
2
|
+
def startObserving
|
3
|
+
@netServiceBrowser = NSNetServiceBrowser.alloc.init
|
4
|
+
@netServiceBrowser.delegate = self
|
5
|
+
@netServiceBrowser.searchForServicesOfType("_pixate._tcp", inDomain: "")
|
6
|
+
end
|
7
|
+
|
8
|
+
def netServiceBrowser(netServiceBrowser,
|
9
|
+
didFindService: service,
|
10
|
+
moreComing: moreComing)
|
11
|
+
@netServiceBrowser.stop
|
12
|
+
|
13
|
+
service = NSNetService.alloc.initWithDomain(service.domain, type: service.type, name: service.name)
|
14
|
+
service.delegate = self
|
15
|
+
service.resolveWithTimeout(5.0)
|
16
|
+
end
|
17
|
+
|
18
|
+
def netServiceDidResolveAddress(service)
|
19
|
+
service.stop
|
20
|
+
|
21
|
+
socket = Socket.alloc.initWithHost(service.hostName, Port: service.port)
|
22
|
+
socket.delegate = self
|
23
|
+
socket.startReceivingData
|
24
|
+
end
|
25
|
+
|
26
|
+
def socketDidReceive(string)
|
27
|
+
style(string)
|
28
|
+
end
|
29
|
+
end; end; end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-pixate-observer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Watson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-24 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: This gem provides a function that you changes css files, apply changes
|
15
|
+
into your application that uses Pixate Framework immediately.
|
16
|
+
email:
|
17
|
+
- watson1978@gmail.com
|
18
|
+
executables:
|
19
|
+
- pixate_server
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- README.md
|
24
|
+
- lib/motion-pixate-observer.rb
|
25
|
+
- lib/project/pixate_style_watch.rb
|
26
|
+
- lib/Socket/libSocket.a
|
27
|
+
- lib/Socket/Socket-Prefix.pch
|
28
|
+
- lib/Socket/Socket.h
|
29
|
+
- bin/pixate_server
|
30
|
+
homepage: https://github.com/Watson1978/motion-pixate-observer
|
31
|
+
licenses: []
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.8.23
|
51
|
+
signing_key:
|
52
|
+
specification_version: 3
|
53
|
+
summary: This gem provides a function that you changes css files, apply changes into
|
54
|
+
your application that uses Pixate Framework immediately.
|
55
|
+
test_files: []
|