haxe-cli-proxy 0.2.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 271fa9c268f8c9efa545b80629b66f5d41f3888a
4
+ data.tar.gz: 04ef5267e6527d7cdffcda3b86819bba17e50c43
5
+ SHA512:
6
+ metadata.gz: 244e385f1764b1c508891f29ebd6fd4ec89c442b8466d71dfce3384f7f19a19694122e493cd65930ca4b1b60d2cfbb065c8168b9f8fd5ac3145b7ee2291e8b89
7
+ data.tar.gz: 05bb7397acb0031c23f1544e6e3ebbaed434119497cb996ef16ea7d59df2a2a9f424701d0836feb846c8a554b43aa30ef8fc903f3a6be3651cccd46578f024ce
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /_builds/
2
+ /_projects/
3
+ /_steps/
4
+ /.idea/
5
+ /*.iml
6
+ /.bundle/
7
+ /Gemfile.lock
8
+ /coverage/
9
+ /vendor/
10
+ /pkg/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ -r spec_helper.rb
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in haxe_cli_proxy.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 kenta.motoyanagi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # HaxeCliProxy
2
+
3
+ [![wercker status](https://app.wercker.com/status/1e5c4fa372db4a6ca4a0b3c1d78624c3/s/master "wercker status")](https://app.wercker.com/project/bykey/1e5c4fa372db4a6ca4a0b3c1d78624c3)
4
+ [![Code Climate](https://codeclimate.com/github/k-motoyan/haxe_cli_proxy/badges/gpa.svg)](https://codeclimate.com/github/k-motoyan/haxe_cli_proxy)
5
+ [![Test Coverage](https://codeclimate.com/github/k-motoyan/haxe_cli_proxy/badges/coverage.svg)](https://codeclimate.com/github/k-motoyan/haxe_cli_proxy/coverage)
6
+
7
+ HaxeCliProxy is haxe command line client for ruby.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'haxe-cli-proxy'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install haxe-cli-proxy
24
+
25
+ ## License
26
+
27
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
28
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "haxe_cli_proxy"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'haxe/cli/proxy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'haxe-cli-proxy'
8
+ spec.version = ::Haxe::Cli::Proxy::VERSION
9
+ spec.authors = ['k-motoyan']
10
+ spec.email = ['k-motoyan888@gmail.com']
11
+
12
+ spec.summary = %q{Haxe command line client.}
13
+ spec.homepage = 'https://github.com/k-motoyan/haxe-cli-proxy'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.executables = []
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.10'
21
+ spec.add_development_dependency 'rake', '~> 10.0'
22
+ spec.add_development_dependency 'rspec'
23
+ spec.add_development_dependency 'simplecov'
24
+ spec.add_development_dependency 'codeclimate-test-reporter'
25
+ end
@@ -0,0 +1,100 @@
1
+ module Haxe
2
+ module Cli
3
+ module Proxy
4
+ module Command
5
+ require 'open3'
6
+
7
+ class << self
8
+ HAXE = ::Haxe::Cli::Proxy::Constants::HAXE
9
+
10
+ ##
11
+ # Check whether command `haxe` exists.
12
+ #
13
+ # @return [boolean]
14
+ ##
15
+ def exists?
16
+ if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/
17
+ system "where #{HAXE} > nul"
18
+ else
19
+ system "hash #{HAXE} 2> /dev/null"
20
+ end
21
+ end
22
+
23
+ ##
24
+ # Execute command `haxe -help`
25
+ #
26
+ # @return [::Haxe::Cli::Command::Result] `haxe -help` command results.
27
+ ##
28
+ def help
29
+ help = ::Haxe::Cli::Proxy::Constants::OPTION_HELP
30
+ execute "#{HAXE} #{help}"
31
+ end
32
+
33
+ ##
34
+ # Execute command `haxe -lib [lib_name]:[version]`
35
+ #
36
+ # @param [String] lib_name haxe library name.
37
+ # @param [String|nil] version haxe library version.
38
+ # @return [::Haxe::Cli::Command::Result] `haxe -lib` command results.
39
+ ##
40
+ def lib(lib_name, version=nil)
41
+ lib = ::Haxe::Cli::Proxy::Constants::OPTION_LIB
42
+ lib_name << ":#{version}" unless version.nil?
43
+ execute "#{HAXE} #{lib} #{lib_name}"
44
+ end
45
+
46
+ ##
47
+ # Execute command `haxe -xml [file]`
48
+ #
49
+ # @param [String] file haxe library name.
50
+ # @return [::Haxe::Cli::Command::Result] `haxe -lib` command results.
51
+ ##
52
+ def xml(file)
53
+ xml = ::Haxe::Cli::Proxy::Constants::OPTION_XML
54
+ execute "#{HAXE} #{xml} #{file}"
55
+ end
56
+
57
+ ##
58
+ # Execute haxe compile command.
59
+ #
60
+ # @param [Hash] options compile options.
61
+ # if uses hxml, give option parameter such as...
62
+ # {
63
+ # hxml: [hxml file name]
64
+ # }
65
+ # if not uses hxml, give option parameter such as...
66
+ # {
67
+ # main: [main class name],
68
+ # target: [compile target],
69
+ # output: [output directory or file],
70
+ # lib: [using haxe libraries with array],
71
+ # compile_flag: [compile flags with array],
72
+ # debug: [debug mode flag with boolean],
73
+ # verbose: [verbose mode flag with boolean],
74
+ # dce: [dead code elimination option]
75
+ # }
76
+ # @return [::Haxe::Cli::Command::Result] haxe compile command results.
77
+ ##
78
+ def compile(options)
79
+ builder = ::Haxe::Cli::Proxy::CompileOption::Builder.new(options)
80
+ execute "#{HAXE} #{builder}"
81
+ end
82
+
83
+ private
84
+
85
+ def execute(command)
86
+ Result.new Open3.capture3(command)
87
+ end
88
+ end
89
+
90
+ class Result
91
+ attr_reader :stdout, :stderr, :status
92
+
93
+ def initialize(open3_captured)
94
+ @stdout, @stderr, @status = open3_captured
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,73 @@
1
+ module Haxe
2
+ module Cli
3
+ module Proxy
4
+ module CompileOption
5
+ class Builder
6
+ def initialize(options)
7
+ @opts = options
8
+ end
9
+
10
+ def to_s
11
+ if compile_by_hxml?
12
+ @opts[:hxml]
13
+ else
14
+ build_options
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def compile_by_hxml?
21
+ @opts.key?(:hxml)
22
+ end
23
+
24
+ def build_options
25
+ opts = ''
26
+ targets = ::Haxe::Cli::Proxy::Constants::TARGETS
27
+ ded_code_options = ::Haxe::Cli::Proxy::Constants::DED_CODE_OPTIONS
28
+ main = ::Haxe::Cli::Proxy::Constants::COMPILE_MAIN
29
+ lib = ::Haxe::Cli::Proxy::Constants::COMPILE_LIB
30
+ flag = ::Haxe::Cli::Proxy::Constants::COMPILE_FLAG
31
+ dce = ::Haxe::Cli::Proxy::Constants::COMPILE_DEC
32
+ verbose = ::Haxe::Cli::Proxy::Constants::COMPILE_VERBOSE
33
+ debug = ::Haxe::Cli::Proxy::Constants::COMPILE_DEBUG
34
+
35
+ unless %i(main target output).any? { |k| !@opts[k].nil? }
36
+ raise ::Haxe::Cli::Proxy::Error::NotExistsCompileRequiredKeys.new
37
+ end
38
+
39
+ unless targets.key?(@opts[:target])
40
+ raise ::Haxe::Cli::Proxy::Error::UnknownCompileTarget.new
41
+ end
42
+
43
+ opts << "#{main} #{@opts[:main]} #{targets[@opts[:target]]} #{@opts[:output]}"
44
+
45
+ if !@opts[:lib].nil? && @opts[:lib].is_a?(Array)
46
+ opts << " #{lib} "
47
+ opts << @opts[:lib].join(' ')
48
+ end
49
+
50
+ if !@opts[:compile_flag].nil? && @opts[:compile_flag].is_a?(Array)
51
+ opts << " #{flag} "
52
+ opts << @opts[:compile_flag].join(' ')
53
+ end
54
+
55
+ if !@opts[:debug].nil? && @opts[:debug]
56
+ opts << " #{debug}"
57
+ end
58
+
59
+ if !@opts[:verbose].nil? && @opts[:verbose]
60
+ opts << " #{verbose}"
61
+ end
62
+
63
+ if !@opts[:dce].nil? && ded_code_options.include?(@opts[:dce])
64
+ opts << " #{dce} #{@opts[:dce]}"
65
+ end
66
+
67
+ opts
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,46 @@
1
+ module Haxe
2
+ module Cli
3
+ module Proxy
4
+ module Constants
5
+ HAXE = 'haxe'
6
+
7
+ COMPILE_MAIN = '-main'
8
+ COMPILE_DEC = '-dce'
9
+ COMPILE_LIB = '-lib'
10
+ COMPILE_FLAG = '-D'
11
+ COMPILE_VERBOSE = '-v'
12
+ COMPILE_DEBUG = '-debug'
13
+
14
+ TARGET_JS = 'js'
15
+ TARGET_SWF = 'swf'
16
+ TARGET_AS3 = 'as3'
17
+ TARGET_NEKO = 'neko'
18
+ TARGET_PHP = 'php'
19
+ TARGET_CPP = 'cpp'
20
+ TARGET_CS = 'c#'
21
+ TARGET_JAVA = 'java'
22
+ TARGET_PYTHON = 'python'
23
+ TARGETS = {
24
+ TARGET_JS => '-js',
25
+ TARGET_SWF => '-swf',
26
+ TARGET_AS3 => '-as3',
27
+ TARGET_NEKO => '-neko',
28
+ TARGET_PHP => '-php',
29
+ TARGET_CPP => '-cpp',
30
+ TARGET_CS => '-cs',
31
+ TARGET_JAVA => '-java',
32
+ TARGET_PYTHON => '-python'
33
+ }
34
+
35
+ DED_CODE_STANDARD = 'std'
36
+ DED_CODE_FULL = 'full'
37
+ DED_CODE_NO = 'no'
38
+ DED_CODE_OPTIONS = [ DED_CODE_STANDARD, DED_CODE_FULL, DED_CODE_NO ]
39
+
40
+ OPTION_XML = '-xml'
41
+ OPTION_HELP = '-help'
42
+ OPTION_LIB = '-lib'
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,28 @@
1
+ module Haxe
2
+ module Cli
3
+ module Proxy
4
+ module Error
5
+ class HaxeCliProxyError < StandardError
6
+ end
7
+
8
+ class CommandNotExistsError < HaxeCliProxyError
9
+ def initialize
10
+ super 'Command `haxe` was not found. please install haxe.'
11
+ end
12
+ end
13
+
14
+ class NotExistsCompileRequiredKeys < HaxeCliProxyError
15
+ def initialize
16
+ super 'Compile option required "main", "target" and "output".'
17
+ end
18
+ end
19
+
20
+ class UnknownCompileTarget < HaxeCliProxyError
21
+ def initialize
22
+ super 'Unknown compile target.'
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ module Haxe
2
+ module Cli
3
+ module Proxy
4
+ VERSION = '0.2.0'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ require 'haxe/cli/proxy/version'
2
+ require 'haxe/cli/proxy/constants'
3
+ require 'haxe/cli/proxy/error'
4
+ require 'haxe/cli/proxy/command'
5
+ require 'haxe/cli/proxy/compile_option'
6
+
7
+ module Haxe
8
+ module Cli
9
+ module Proxy
10
+ raise Error::CommandNotExistsError.new unless Command.exists?
11
+ end
12
+ end
13
+ end
data/wercker.yml ADDED
@@ -0,0 +1,24 @@
1
+ box: ruby:2.2.2
2
+ build:
3
+ steps:
4
+ - script:
5
+ name: install dependences packages
6
+ code: sudo apt-get -y install wget
7
+ - script:
8
+ name: export haxe envaironments
9
+ code: |
10
+ export HAXE_DL_URL=http://haxe.org/website-content/downloads/3.2.0/downloads/haxe-3.2.0-linux64.tar.gz
11
+ export HAXE_PATH=$WERCKER_CACHE_DIR/haxe
12
+ export HAXE_STD_PATH=$HAXE_PATH/std
13
+ export PATH=$HAXE_PATH:$PATH
14
+ - script:
15
+ name: install haxe
16
+ code: |
17
+ if [ ! -e $HAXE_PATH ]; then
18
+ mkdir -p $HAXE_PATH
19
+ wget -O - $HAXE_DL_URL | tar xzf - --strip=1 -C $HAXE_PATH
20
+ fi
21
+ - bundle-install
22
+ - script:
23
+ name: rspec
24
+ code: bundle exec rspec
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: haxe-cli-proxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - k-motoyan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-12 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: rspec
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: simplecov
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: codeclimate-test-reporter
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:
84
+ email:
85
+ - k-motoyan888@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
98
+ - haxe_cli_proxy.gemspec
99
+ - lib/haxe-cli-proxy.rb
100
+ - lib/haxe/cli/proxy/command.rb
101
+ - lib/haxe/cli/proxy/compile_option.rb
102
+ - lib/haxe/cli/proxy/constants.rb
103
+ - lib/haxe/cli/proxy/error.rb
104
+ - lib/haxe/cli/proxy/version.rb
105
+ - wercker.yml
106
+ homepage: https://github.com/k-motoyan/haxe-cli-proxy
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.5
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Haxe command line client.
130
+ test_files: []