raxe 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -1,7 +1,8 @@
1
- require "raxe/installer"
2
- require "raxe/generator"
3
- require "raxe/tasks"
4
- require "raxe/commands"
1
+ here = File.dirname __FILE__
2
+ require "#{here}/raxe/installer"
3
+ require "#{here}/raxe/generator"
4
+ require "#{here}/raxe/tasks"
5
+ require "#{here}/raxe/commands"
5
6
 
6
7
  # Raxe class
7
8
  class Raxe
@@ -0,0 +1,7 @@
1
+ #require "raxe"
2
+
3
+ class Raxe
4
+ class Builder
5
+
6
+ end # Builder
7
+ end # Raxe
@@ -0,0 +1,54 @@
1
+ # require "raxe"
2
+
3
+ class Raxe
4
+ class Commands
5
+ def initialize( raxe )
6
+ @raxe = raxe
7
+ end # initialize
8
+
9
+ def command( command_data )
10
+ if command_data.nil? || command_data.empty?
11
+ display_help
12
+ else
13
+ case command_data[0]
14
+ when "install", "uninstall"
15
+ c = command_data[0] == "uninstall" ? :uninstall : nil
16
+ @raxe.install(c)
17
+ when "generate", "ungenerate"
18
+ c = command_data[0] == "generate" ? :generate : :ungenerate
19
+ p = command_data[1]
20
+ f = command_data[2]
21
+ if p.nil? || f.nil?
22
+ display_error
23
+ return -1
24
+ else
25
+ @raxe.generate( :req => c, :package => p, :file => f )
26
+ end # if bad cmds
27
+ when "routes"
28
+ if @raxe.setup_flag
29
+ puts @raxe.paths
30
+ else
31
+ puts "Raxe has not been installed yet. Consider installing before using"
32
+ end # if installed
33
+ else
34
+ display_help
35
+ end # case command_data
36
+ end # if null command
37
+ return 0
38
+ end # commands
39
+
40
+ def display_help
41
+ puts "Usage : raxe [command] [arguments]"
42
+ puts "Commands : "
43
+ puts " install # installs the raxe application into the current workspace"
44
+ puts " uninstall # removes the raxe application if there is one in the current workspace"
45
+ puts " generate [package] [file] # generates a standard raxe package"
46
+ puts " ungenerate [package] [file] # removes the named package if it exists"
47
+ puts " routes # shows the current haxe pathing"
48
+ end # display_help
49
+
50
+ def display_error
51
+ puts "Bad usage, you're probably missing some parameters or put in too many."
52
+ end # display_error
53
+ end # Commands
54
+ end # Raxe
@@ -0,0 +1,7 @@
1
+ # require "raxe"
2
+
3
+ class Raxe
4
+ class Destroyer
5
+
6
+ end # Destroyer
7
+ end # Raxe
@@ -0,0 +1,133 @@
1
+ # require "raxe"
2
+
3
+ class Raxe
4
+ class Generator
5
+
6
+ def initialize( raxe )
7
+ @raxe = raxe
8
+ end # initialize
9
+
10
+ def generate(generate_data)
11
+ case generate_data[:req]
12
+ when :generate
13
+ make_packages( generate_data[:package] )
14
+ make_files( generate_data[:package], generate_data[:file] )
15
+ when :ungenerate
16
+ kill_files( generate_data[:package], generate_data[:file] )
17
+ kill_packages( generate_data[:package] )
18
+ end # case req
19
+ end # generate
20
+
21
+ def kill_files( package, file )
22
+ # Step 1 : Check existence
23
+ flags = p_check_file_existence( package, file )
24
+
25
+ # Step 2 : Remove the ones who exist
26
+ flags.each do | path, status |
27
+ if status
28
+ File.delete( path )
29
+ puts " Deleted file " + path
30
+ else # status
31
+ puts " File " + path + " does not exist"
32
+ end # status
33
+ end # flags.each
34
+ end # kill_files
35
+
36
+ def make_files( package, file )
37
+ # Step 1 : Check existence
38
+ flags = p_check_file_existence( package, file )
39
+
40
+ # Step 1.5 : Generate file content
41
+ contents = p_generate_file_content( package, file )
42
+
43
+ # Step 2: Make the ones who do not exist
44
+ flags.each do | path, status |
45
+ if status
46
+ puts " File " + path + " already exists..."
47
+ else # status
48
+ File.open( path, "w+" ) do |f|
49
+ f.puts contents[path]
50
+ end # File.open
51
+ puts " Created file " + path
52
+ end # if status
53
+ end # flags each
54
+ end # make_files
55
+
56
+ def kill_packages( who )
57
+ # Step 1: Check existence
58
+ flags = p_check_package_existence( who )
59
+
60
+ # Step 2: Kill the ones who exist (if dir is empty)
61
+ flags.each do |path, status|
62
+ if status
63
+ if Dir.entries( path ).length < 3
64
+ Dir.delete( path )
65
+ puts " Deleted directory " + path
66
+ else # has stuff
67
+ puts " Directory " + path + " cannot be delete because it has stuff in it"
68
+ end # if
69
+ else # status
70
+ puts " Directory " + path + " does not exist"
71
+ end # status
72
+ end # flags.each
73
+ end # kill_packages
74
+
75
+ def make_packages( who )
76
+ # Step 1: Check existence
77
+ flags = p_check_package_existence( who )
78
+
79
+ # Step 2: Create the ones who do not exist
80
+ flags.each do | path, status |
81
+ if status
82
+ puts " Directory " + path + " already exists"
83
+ else # status
84
+ Dir.mkdir( path )
85
+ puts " Created directory " + path
86
+ end # status
87
+ end # flags each
88
+ end # make_package
89
+
90
+ private
91
+ def p_generate_file_content( package, file )
92
+ original_content = "import #{package}data.#{file.capitalize}Data;\n"
93
+ original_content += "class #{file.capitalize} { \n"
94
+ original_content += "\tprivate var #{file}data : #{file.capitalize}Data; \n"
95
+ original_content += "\t public function new () { } // new \n"
96
+ original_content += "} // #{file.capitalize}"
97
+
98
+ spec_content = "import #{package}data.#{file.capitalize}Data;\n"
99
+ spec_content += "import #{package}.#{file.capitalize};\n"
100
+ spec_content += "class #{file.capitalize}Spec extends haxespec.FuryTestCase { \n"
101
+ spec_content += "\t public override function setup () { } // setup \n"
102
+ spec_content += "\t public override function tearDown () { } // tearDown \n"
103
+ spec_content += "} // #{file.capitalize}Spec"
104
+
105
+ data_content = "typedef #{file.capitalize}Data = { \n"
106
+ data_content += "} // #{file.capitalize}Data "
107
+
108
+ paths = ['','data','spec'].map { | x | File.join(File.join( @raxe.paths['source'], package + x ), file.capitalize + x.capitalize + ".hx" ) }
109
+ return {
110
+ paths[0] => original_content ,
111
+ paths[1] => spec_content ,
112
+ paths[2] => data_content
113
+ } # return
114
+ end # generate_file_content
115
+
116
+ def p_check_package_existence( package )
117
+ p_check_existence( ['','data','spec'].map { | x | package + x } )
118
+ end # p_check_package_existence
119
+
120
+ def p_check_file_existence( package, file )
121
+ p_check_existence( ['', 'data','spec'].map { | x | File.join( package + x, file.capitalize + x.capitalize + ".hx" ) } )
122
+ end # p_check_file_existence
123
+
124
+ def p_check_existence( expected )
125
+ flags = {}
126
+ expected.each do | folder |
127
+ path = File.join( @raxe.paths['source'], folder )
128
+ flags[path] = FileTest.exists?( path )
129
+ end # expected
130
+ return flags
131
+ end # p_check_existence
132
+ end # Generator
133
+ end # Raxe
@@ -0,0 +1,111 @@
1
+ require "rake"
2
+ # require "raxe"
3
+
4
+ class Raxe
5
+ class Installer
6
+
7
+ def initialize( raxe )
8
+ @raxe = raxe
9
+ end # initialize
10
+
11
+ def self.get_haxe
12
+ # TODO: figure out a better way of doing this... seriously...
13
+ # FIXME: Actually test this method lol
14
+ begin
15
+ puts " Let's see if you have haxe installed..."
16
+ sh "which haxe"
17
+ puts " Great! It looks like haXe has already been installed."
18
+ rescue
19
+ puts " Grabbing the tar ball from haxe.org..."
20
+ sh "wget http://haxe.org/file/hxinst-linux.tgz"
21
+ puts " Extracting the tar ball..."
22
+ sh "tar -xvf hxinst-linux.tgz"
23
+ puts " Changing permission to run the installer executable"
24
+ sh "chmod 755 hxinst-linux"
25
+ puts " Running the executable"
26
+ sh "./hxinst-linux"
27
+ puts " Cleaning up"
28
+ sh "rm hxinst-linux"
29
+ sh "rm hxinst-linux.tgz"
30
+ puts " Finished installing haxe"
31
+ end # begin-rescue
32
+ end # check_haxe
33
+
34
+ def install( install_data )
35
+ case install_data[:req]
36
+ when :install
37
+ Installer.make_conf_file
38
+ Installer.make_content
39
+ when :uninstall
40
+ Installer.kill_conf_file
41
+ kill_content
42
+ end # case req
43
+ install_data[:callback].call
44
+ end # self.install
45
+
46
+ def self.kill_conf_file
47
+ filename = File.join( Dir.pwd, ".raxeconf" )
48
+ File.delete( filename ) if FileTest.exists? filename
49
+ end # self.kill_conf_file
50
+
51
+ def self.make_conf_file
52
+ configurations = {
53
+ "root" => "raxe" ,
54
+ "output" => "raxe/out" ,
55
+ "source" => "raxe/src",
56
+ "tests" => "raxe/tests"
57
+ } # configuration
58
+ File.open( File.join( Dir.pwd, ".raxeconf" ), "w+" ) do |f|
59
+ configurations.each do |key, val|
60
+ f.puts key + "!!!" + val
61
+ end # configurations.each
62
+ end # File.open
63
+ end # self.raxe_conf
64
+
65
+ def kill_content
66
+ kill_recursively = lambda do |dir|
67
+ begin
68
+ Dir.delete( dir ) unless Dir.entries( dir ).length > 2
69
+ rescue
70
+ dir.foreach do |item|
71
+ File.delete( item ) if File.file? item
72
+ kill_recursively.call( item ) if Dir.directory? item && item != "." && item != ".."
73
+ end # dir.foreach
74
+ end # begin-rescue
75
+ end # kill_recursively
76
+ @raxe.paths.each do |type, location|
77
+ next if type == "root"
78
+ kill_recursively.call( location )
79
+ end # @raxe.paths
80
+ File.delete( File.join( @raxe.paths['root'], "build.hxml" ) ) if FileTest.exists? File.join( @raxe.paths['root'], "build.hxml" )
81
+ puts " Deleted build.hxml"
82
+ Dir.delete( @raxe.paths["root"] ) if Dir.entries( @raxe.paths["root"] ).length < 3
83
+ end # kill_content
84
+
85
+ def self.make_content
86
+ root_dir = "raxe"
87
+ unless FileTest.exists? root_dir
88
+ Dir.mkdir root_dir
89
+ puts " Created directory " + root_dir
90
+ else
91
+ puts " Directory " + root_dir + " already exists. Skiping to next step."
92
+ end # exists
93
+ [ "src", "out", "tests" ].each do |f|
94
+ folder = File.join( root_dir , f )
95
+ unless FileTest.exists? folder
96
+ Dir.mkdir folder
97
+ puts " Created directory " + folder
98
+ else
99
+ puts " Directory " + folder + " already exists. Skipping to next step."
100
+ end # exists
101
+ end # each
102
+ File.open( File.join( root_dir, "build.hxml" ), "w+" ) do |f|
103
+ f.puts "# haXe output instructions go here. Uncommented whatever you need"
104
+ f.puts "# -js out/raxe.js"
105
+ f.puts "# -main raxetest.RaxeFire"
106
+ end # File.open
107
+ puts " Wrote build.hxml"
108
+ puts " Done!"
109
+ end # self.install
110
+ end # Installer
111
+ end # Raxe
@@ -0,0 +1,45 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+
4
+
5
+ class Rake::Application
6
+ attr_accessor :raxe_tasks
7
+ def raxe
8
+ return raxe_tasks.raxe
9
+ end # raxe
10
+ end # Rake::Application
11
+
12
+ class Raxe
13
+ class Tasks< ::Rake::TaskLib
14
+ attr_accessor:raxe, :raxe_builder
15
+
16
+ def initialize( raxe )
17
+ @raxe = raxe
18
+ Rake.application.raxe_tasks = self
19
+ define_tasks()
20
+ end # initialize
21
+
22
+ private
23
+ def define_tasks()
24
+ require "raxe/installer"
25
+ namespace :raxe do
26
+ desc "cleans out the testing environment; useful only in testing"
27
+ task :clean_tests do
28
+ sh "rm raxe -r"
29
+ end # clean
30
+
31
+ desc "gets and installs haXe if it isn't found (only works on Linux)"
32
+ task :gethaxe do
33
+ Raxe::Installer.get_haxe
34
+ end # gethaxe
35
+
36
+ desc "installs raxe into the current project"
37
+ task :install => [:gethaxe]
38
+ task :install do
39
+ @raxe.install
40
+ end # install
41
+ end # raxe
42
+ end # define_tasks
43
+ end # Tasks
44
+ end # Raxe
45
+
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "raxe"
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Yuki Nagato", "Madotsuki"]
@@ -27,6 +27,12 @@ Gem::Specification.new do |s|
27
27
  "VERSION",
28
28
  "bin/raxe",
29
29
  "lib/raxe.rb",
30
+ "lib/raxe/builder.rb",
31
+ "lib/raxe/commands.rb",
32
+ "lib/raxe/destroyer.rb",
33
+ "lib/raxe/generator.rb",
34
+ "lib/raxe/installer.rb",
35
+ "lib/raxe/tasks.rb",
30
36
  "raxe.gemspec",
31
37
  "spec/commands/raxe_command_spec.rb",
32
38
  "spec/generator/raxe_generator_spec.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raxe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2012-07-13 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: colorize
17
- requirement: &72381090 !ruby/object:Gem::Requirement
17
+ requirement: &71497360 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - =
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.5.8
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *72381090
25
+ version_requirements: *71497360
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: shoulda
28
- requirement: &72380690 !ruby/object:Gem::Requirement
28
+ requirement: &71496950 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *72380690
36
+ version_requirements: *71496950
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rdoc
39
- requirement: &72380250 !ruby/object:Gem::Requirement
39
+ requirement: &71496350 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '3.12'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *72380250
47
+ version_requirements: *71496350
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: bundler
50
- requirement: &72379780 !ruby/object:Gem::Requirement
50
+ requirement: &71495710 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 1.0.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *72379780
58
+ version_requirements: *71495710
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: jeweler
61
- requirement: &72379370 !ruby/object:Gem::Requirement
61
+ requirement: &71495050 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 1.8.4
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *72379370
69
+ version_requirements: *71495050
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec
72
- requirement: &72378960 !ruby/object:Gem::Requirement
72
+ requirement: &71493510 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - =
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 2.11.0
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *72378960
80
+ version_requirements: *71493510
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: colorize
83
- requirement: &72377610 !ruby/object:Gem::Requirement
83
+ requirement: &71351730 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,7 +88,7 @@ dependencies:
88
88
  version: '0'
89
89
  type: :runtime
90
90
  prerelease: false
91
- version_requirements: *72377610
91
+ version_requirements: *71351730
92
92
  description: Written as a ruby gem, raxe is a series of macros for writing simpler
93
93
  haxe code for javascript compilation
94
94
  email: foxnewsnetwork@gmail.com
@@ -108,6 +108,12 @@ files:
108
108
  - VERSION
109
109
  - bin/raxe
110
110
  - lib/raxe.rb
111
+ - lib/raxe/builder.rb
112
+ - lib/raxe/commands.rb
113
+ - lib/raxe/destroyer.rb
114
+ - lib/raxe/generator.rb
115
+ - lib/raxe/installer.rb
116
+ - lib/raxe/tasks.rb
111
117
  - raxe.gemspec
112
118
  - spec/commands/raxe_command_spec.rb
113
119
  - spec/generator/raxe_generator_spec.rb
@@ -130,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
136
  version: '0'
131
137
  segments:
132
138
  - 0
133
- hash: -500945297
139
+ hash: -632048269
134
140
  required_rubygems_version: !ruby/object:Gem::Requirement
135
141
  none: false
136
142
  requirements: