npgproject 0.0.3

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: 92c5b084d14bbc22e0741b7d86c03ae1902996c3
4
+ data.tar.gz: 8f0f3d387451a6d8679b709646474d7680cc3e88
5
+ SHA512:
6
+ metadata.gz: 0c5620338c93154eeb26a6032d780167feb307988bcfd5544c826d80953e6f158cd8bb7c20b0f682957b9243b4bd893508a0a2b8649ba23beb9ab4f8b2b2519f
7
+ data.tar.gz: 4cf8db3219d778b85029731b822da79b3b27cbd70fe5affabbd273f482dcea64d79f3d767de16be63a93ab2ebc1f5b27a5476dcfb426e34a67f781e2d857d452
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in project.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TODO: Write your name
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,31 @@
1
+ # Project
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'project'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install project
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/project/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,3 @@
1
+ module Project
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,136 @@
1
+ require "npg/project/version"
2
+ require 'shellwords'
3
+ require 'iniparse'
4
+ require 'FileUtils'
5
+ require 'zlib'
6
+ module NPG
7
+ class Directory
8
+ def [](*a)
9
+ File.join @path, *a
10
+ end
11
+ end
12
+ class PGHandle < Directory
13
+ def initialize(path)
14
+ @path = path
15
+ unless FileTest.directory?(path)
16
+ if FileTest.file?(path)
17
+ raise Errno::EEXIST, path
18
+ end
19
+ Dir.mkdir path
20
+ end
21
+ end
22
+
23
+
24
+ end
25
+ class Project < Directory
26
+ attr_accessor :path
27
+ def initialize(path = nil)
28
+ self.path = path
29
+ end
30
+
31
+ def path=(val)
32
+ val = File.expand_path val
33
+ if FileTest.directory?(val)
34
+ @path = val
35
+ elsif FileTest.file?(val)
36
+ @path = File.dirname(val)
37
+ else
38
+ raise Error::ENOENT, val
39
+ end
40
+ end
41
+
42
+ def executable
43
+ File.join(self.path, "Game.exe")
44
+ end
45
+
46
+ def handle
47
+ PGHandle.new File.join self.path, ".npg"
48
+ end
49
+
50
+ def run(opt = {})
51
+ opt = {
52
+ exe: executable,
53
+ cmdline: nil,
54
+ console: false,
55
+ debug: false,
56
+ }.update(opt)
57
+ npg = handle
58
+ if code = opt[:code]
59
+
60
+ FileUtils.cp self["Game.exe"], npg["Game.exe"]
61
+ open npg["Game.ini"], 'w' do |f|
62
+ f.write\
63
+ %{[Game]
64
+ Scripts=npgldr
65
+ RTP=#{ini["Game"]["RTP"]}
66
+ RTP1=#{ini["Game"]["RTP1"]}
67
+ RTP2=#{ini["Game"]["RTP2"]}
68
+ RTP3=#{ini["Game"]["RTP3"]}
69
+ Title=#{ini["Game"]["Title"]}
70
+ Library=../#{ini["Game"]["Library"]}
71
+ }
72
+ end
73
+ realcode = [LDRHeader, %{
74
+ NPG::StartupPath = Dir.getwd
75
+ NPG::Path = #{path.inspect}
76
+ NPG::RGSSScripts = #{ini["Game"]["Scripts"].inspect}
77
+ }, code].join("\n\n")
78
+ x = [[0, "npgldr", Zlib::Deflate.deflate(realcode)]]
79
+ open npg["npgldr"], 'w' do |f| Marshal.dump(x, f) end
80
+ opt.update exe: npg["Game.exe"]
81
+ end
82
+
83
+
84
+
85
+ File.delete npg["error.txt"] if FileTest.file?(npg["error.txt"])
86
+ cmdline = Shellwords.shelljoin([opt[:exe], opt[:cmdline],
87
+ opt[:console] ? "console" : nil,
88
+ opt[:debug] ? "debug": nil,
89
+ opt[:debug] ? "test": nil,
90
+ ].compact.map{|x|
91
+ Shellwords.escape(x)
92
+ })
93
+ system cmdline
94
+ if FileTest.file?(npg["error.txt"])
95
+ raise File.read(npg["error.txt"])
96
+ end
97
+ end
98
+
99
+ LDRHeader = %{
100
+ module NPG
101
+ class << self
102
+ def rgss_run
103
+ begin
104
+ Dir.chdir NPG::Path
105
+ $RGSS_SCRIPTS = open(NPG::RGSSScripts, "rb") do |f| Marshal.load(f) end
106
+ $RGSS_SCRIPTS.each_with_index{|x, i|
107
+ x[3] = Zlib::Inflate.inflate(x[2])
108
+ }
109
+ type = (defined? msgbox) ? "{%04d}" : "Section%03d"
110
+ $RGSS_SCRIPTS.each_with_index{|x, i|
111
+
112
+ eval x[3], TOPLEVEL_BINDING, type % (i+1), 1
113
+ }
114
+ rescue Object
115
+ x = $!.backtrace.unshift($!.to_s).join("\n")
116
+ open(".npg/error.txt", "w") do |f|
117
+ f.write x
118
+ f.write "\n"
119
+ end
120
+ end
121
+ end
122
+ end
123
+ end
124
+ }
125
+
126
+ def config_file
127
+ File.join(self.path, "Game.ini")
128
+ end
129
+
130
+ def ini
131
+ a = IniParse.parse File.read config_file
132
+ end
133
+ end
134
+
135
+ end
136
+
data/project.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'npg/project/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "npgproject"
8
+ spec.version = Project::VERSION
9
+ spec.authors = ["Seiran"]
10
+ spec.email = ["pochy2008@qq.com"]
11
+ spec.summary = %q{NeoPlayground Project}
12
+ spec.description = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").map{|x|
17
+ x.sub(/lib\//){"lib/npg/"}
18
+ }
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_dependency "iniparse"
26
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: npgproject
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Seiran
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: iniparse
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: ''
56
+ email:
57
+ - pochy2008@qq.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/npg/project.rb
68
+ - lib/npg/project/version.rb
69
+ - project.gemspec
70
+ homepage: ''
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.0.14
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: NeoPlayground Project
94
+ test_files: []