raxe 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -55,6 +55,4 @@ end
55
55
 
56
56
  $: << File.join( File.dirname( __FILE__ ) , "lib" )
57
57
  require "raxe"
58
- Raxe::Tasks.new do |raxe|
59
-
60
- end # raxe
58
+ Raxe::Tasks.new( Raxe.new )
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
data/lib/raxe.rb CHANGED
@@ -1,68 +1,55 @@
1
+ require "raxe/installer"
2
+ require "raxe/generator"
1
3
  require "raxe/tasks"
2
4
 
3
- # main function lives in here
5
+ # Raxe class
4
6
  class Raxe
7
+ attr_reader :paths, :setup_flag
5
8
 
6
- @@output_path = File.join( Dir.pwd , "raxe/src" )
9
+ def initialize
10
+ # Step 1: Checks for a conf file to load
11
+ @paths = {}
12
+ p_check_conf
13
+
14
+ # Step 2: Setup the components
15
+ @installer = Raxe::Installer.new( self )
16
+ @generator = Raxe::Generator.new( self )
17
+ end # initialize
7
18
 
8
- def self.out_path
9
- return @@output_path
10
- end # self.out_path
19
+ def generate( generator_data )
20
+ @generator.generate( generator_data )
21
+ end # generate
11
22
 
12
- def self.out_path=( path )
13
- @@output_path = path
14
- end # self.out_path
23
+ def install( installer_data = :install )
24
+ install_data = {
25
+ :req => installer_data ,
26
+ :callback => lambda { p_check_conf }
27
+ } # install_data
28
+ @installer.install( install_data )
29
+ end # install
15
30
 
16
- def self.generate( package, file )
17
- # Step 1 : Generating files
18
- original = self.gen(package, file)
19
- spec = self.gen(package + "spec", file + "Spec")
20
- data = self.gen(package + "data", file + "Data")
21
-
22
- # Step 1.5: Generating content
23
- original_content = "import #{package}data.#{file.capitalize}Data;\n"
24
- original_content += "class #{file.capitalize} { \n"
25
- original_content += "\tprivate var #{file}data : #{file.capitalize}Data; \n"
26
- original_content += "\t public function new () { } // new \n"
27
- original_content += "} // #{file.capitalize}"
28
- # Step 2: Writing content
29
- self.append2file( original, original_content)
30
-
31
- spec_content = "import #{package}data.#{file.capitalize}Data;\n"
32
- spec_content += "import #{package}.#{file.capitalize};\n"
33
- spec_content += "class #{file.capitalize}Spec extends haxespec.FuryTestCase { \n"
34
- spec_content += "\t public override function setup () { } // setup \n"
35
- spec_content += "\t public override function tearDown () { } // tearDown \n"
36
- spec_content += "} // #{file.capitalize}Spec"
37
- self.append2file( spec, spec_content )
38
-
39
- data_content = "typedef #{file.capitalize}Data = { \n"
40
- data_content += "} // #{file.capitalize}Data "
41
- self.append2file( data, data_content )
42
- return 0
43
- end # self.generate
31
+ def destroy( destroyer_data )
32
+ # Raxe::Destroyer.destroy( destroy_data )
33
+ end # destroy
44
34
 
45
- private
46
- def self.append2file( file, content )
47
- File.open( file, "a+" ) do |f|
48
- f.puts content
49
- end # File.open
50
- end # self.writefile
35
+ def build( builder_data )
36
+ # Raxe::Builder.build( builder_data )
37
+ end # build
51
38
 
52
- def self.gen( package, file )
53
- path = File.join( self.out_path , package )
54
- Dir.chdir( self.out_path )
55
- Dir.mkdir( path ) unless FileTest.exists?( path )
56
- Dir.chdir( path )
57
- if FileTest.exists?( file.capitalize + ".hx" )
58
- puts "Error: the package + file combo you've specified already exists!"
59
- return
60
- end # FileTest.exists?
61
- File.open( file.capitalize + ".hx", "w+" ) do |f|
62
- f.puts "package #{package};"
63
- end # File.open
64
- return File.join( path, file.capitalize + ".hx" )
65
- end # self.gen
39
+ private
40
+ def p_check_conf
41
+ conf_path = File.join( Dir.pwd, ".raxeconf" )
42
+ if FileTest.exists?( conf_path )
43
+ File.open( conf_path, "r" ) do |f|
44
+ while line = f.gets
45
+ item = line.split( "!!!" )
46
+ @paths[item[0]] = item[1].strip
47
+ end # while
48
+ end # File.open
49
+ @setup_flag = true
50
+ else # if file exists
51
+ @setup_flag = false
52
+ @paths = {}
53
+ end # if file exists
54
+ end # p_check_conf
66
55
  end # Raxe
67
-
68
-
data/raxe.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "raxe"
8
- s.version = "0.0.0"
8
+ s.version = "0.0.1"
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"]
12
- s.date = "2012-07-10"
12
+ s.date = "2012-07-12"
13
13
  s.description = "Written as a ruby gem, raxe is a series of macros for writing simpler haxe code for javascript compilation"
14
14
  s.email = "foxnewsnetwork@gmail.com"
15
15
  s.executables = ["raxe"]
@@ -28,7 +28,9 @@ Gem::Specification.new do |s|
28
28
  "bin/raxe",
29
29
  "lib/raxe.rb",
30
30
  "raxe.gemspec",
31
- "spec/raxe_spec.rb",
31
+ "spec/generator/raxe_generator_spec.rb",
32
+ "spec/installer/raxe_installer_spec.rb",
33
+ "spec/raxe_object_spec.rb",
32
34
  "test/helper.rb",
33
35
  "test/test_raxe.rb"
34
36
  ]
@@ -0,0 +1,51 @@
1
+ require "raxe"
2
+
3
+ describe Raxe do
4
+ describe Raxe::Generator do
5
+ before(:each) do
6
+ @raxe = Raxe.new
7
+ @raxe.install
8
+ @generator = Raxe::Generator.new( @raxe )
9
+ end # before each
10
+ after(:each) do
11
+ @raxe.install(:uninstall)
12
+ end # after each
13
+ describe "generating packages" do
14
+ before(:each) do
15
+ @packname = "lolcat"
16
+ @expected = [ '','data','spec'].map do | x |
17
+ File.join( @raxe.paths['source'] , @packname + x )
18
+ end # expected
19
+ end # before each
20
+ after(:each) do
21
+ @generator.kill_packages( @packname )
22
+ end # after each
23
+ it "should allow for successful package creation" do
24
+ @generator.make_packages( @packname )
25
+ @expected.each do | folder |
26
+ FileTest.exists?( folder ).should be_true
27
+ end # expected
28
+ end # it
29
+ end # generating packages
30
+ describe "generating files into packages" do
31
+ before(:each) do
32
+ @packname = "happycat"
33
+ @filename = "faggot"
34
+ @expected = ["", "data", "spec"].map do | x |
35
+ File.join(@raxe.paths['source'], File.join(@packname + x, @filename.capitalize + x.capitalize + ".hx" ) )
36
+ end # expected
37
+ @generator.make_packages( @packname )
38
+ end # before each
39
+ after(:each) do
40
+ @generator.kill_files( @packname, @filename )
41
+ @generator.kill_packages( @packname )
42
+ end # after each
43
+ it "should allow for successful file creation" do
44
+ @generator.make_files( @packname, @filename )
45
+ @expected.each do | file |
46
+ FileTest.exists?( file ).should be_true
47
+ end # expected each
48
+ end # it
49
+ end # generating files
50
+ end # Raxe::Generator
51
+ end # Raxe
@@ -0,0 +1,122 @@
1
+ require "raxe"
2
+
3
+ describe Raxe do
4
+ describe Raxe::Installer do
5
+ describe "conf file deletion" do
6
+ before(:each) do
7
+ Raxe::Installer.make_conf_file
8
+ end # before each
9
+ after(:each) do
10
+ File.delete( ".raxeconf" ) if FileTest.exists?( ".raxeconf" )
11
+ end # after each
12
+ it "should kill the conf file" do
13
+ Raxe::Installer.kill_conf_file
14
+ FileTest.exists?( ".raxeconf" ).should be_false
15
+ end # it
16
+ end # conf file deletion
17
+ describe "conf file creation" do
18
+ before(:each) do
19
+ @defaults = {
20
+ "root" => "raxe" ,
21
+ "output" => "raxe/out" ,
22
+ "source" => "raxe/src",
23
+ "tests" => "raxe/tests"
24
+ } # defaults
25
+ @filename = File.join( Dir.pwd, ".raxeconf" )
26
+ end # before each
27
+ after(:each) do
28
+ File.delete( @filename ) if FileTest.exists?( @filename )
29
+ end # after each
30
+ it "should have the proper defaults" do
31
+ Raxe::Installer.make_conf_file
32
+ FileTest.exists?( @filename ).should be_true
33
+ File.open( @filename, "r" ) do |f|
34
+ while line = f.gets
35
+ item = line.split("!!!")
36
+ @defaults[item[0]].should eq( item[1].strip )
37
+ end # while
38
+ end # File.open
39
+ end # it
40
+ end # conf file creation
41
+ describe "folder uninstallation" do
42
+ before(:each) do
43
+ @root = File.join( Dir.pwd, 'raxe' )
44
+ @trunk = ['out','src','tests']
45
+ @expected= { :folders => @trunk.map { |x| File.join( @root, x ) }, :files => [File.join( @root, 'build.hxml' )] }
46
+
47
+ @raxe = Raxe.new
48
+ @installer = Raxe::Installer.new( @raxe )
49
+ @raxe.install
50
+ end # before each
51
+ after(:each) do
52
+ @expected[:folders].each do | folder |
53
+ Dir.delete( folder ) if Dir.exists? folder
54
+ end # each folder
55
+ @expected[:files].each do | file |
56
+ File.delete( file ) if FileTest.exists? file
57
+ end # each file
58
+ Dir.delete( @root ) if Dir.exists? @root
59
+ end # after each
60
+ it "should delete everything" do
61
+ @raxe.install(:uninstall)
62
+ @expected[:folders].each do |folder|
63
+ FileTest.exists?( folder ).should be_false
64
+ end # each folder
65
+ @expected[:files].each do |file|
66
+ FileTest.exists?( file ).should be_false
67
+ end # each file
68
+ end # it
69
+ end # folder uninstallation
70
+ describe "folder installation" do
71
+ describe "pure naked" do
72
+ before( :each ) do
73
+ @root = File.join( Dir.pwd, 'raxe' )
74
+ @trunk = ['out','src','tests']
75
+ @expected= { :folders => @trunk.map { |x| File.join( @root, x ) }, :files => [File.join( @root, 'build.hxml' )] }
76
+ end # before each
77
+ after( :each ) do
78
+ @expected[:folders].each do | folder |
79
+ Dir.delete( folder ) if Dir.exists? folder
80
+ end # each folder
81
+ @expected[:files].each do | file |
82
+ File.delete( file ) if FileTest.exists? file
83
+ end # each file
84
+ Dir.delete( @root ) if Dir.exists? @root
85
+ end # after
86
+ it "should create all the expected files and folders" do
87
+ Raxe::Installer.make_content
88
+ @expected.each do | type, items |
89
+ items.each do |item|
90
+ FileTest.exists?( item ).should be_true
91
+ end # each item
92
+ end # expected each
93
+ end # it
94
+ end # pure naked
95
+ describe "some stuff exists" do
96
+ before( :each ) do
97
+ @root = File.join( Dir.pwd, 'raxe' )
98
+ @trunk = ['out','src','tests']
99
+ @expected= { :folders => @trunk.map { |x| File.join( @root, x ) }, :files => [File.join( @root, 'build.hxml' )] }
100
+ Raxe::Installer.make_content
101
+ end # before each
102
+ after( :each ) do
103
+ @expected[:folders].each do | folder |
104
+ Dir.delete( folder ) if Dir.exists? folder
105
+ end # each folder
106
+ @expected[:files].each do | file |
107
+ File.delete( file ) if FileTest.exists? file
108
+ end # each file
109
+ Dir.delete( @root ) if Dir.exists? @root
110
+ end # after
111
+ it "should skip the ones that don't need creating and do only what is needed" do
112
+ Raxe::Installer.make_content
113
+ @expected.each do | type, items |
114
+ items.each do |item|
115
+ FileTest.exists?( item ).should be_true
116
+ end # each item
117
+ end # expected each
118
+ end # it
119
+ end # some stuff exists
120
+ end # folder installation
121
+ end # Raxe::Installer
122
+ end # Raxe
@@ -0,0 +1,124 @@
1
+ require "raxe"
2
+
3
+ describe Raxe do
4
+ describe "initialization" do
5
+ describe "naked" do
6
+ before(:each) do
7
+ @raxe = Raxe.new
8
+ end # before each
9
+ it "should have a blank path" do
10
+ @raxe.paths.should be_empty
11
+ end # it
12
+ it "should not be properly setup" do
13
+ @raxe.setup_flag.should be_false
14
+ end # it
15
+ end # naked
16
+ describe "has conf" do
17
+ before(:each) do
18
+ @filename = File.join( Dir.pwd, ".raxeconf" )
19
+ @junk = {
20
+ "root" => "raxe" ,
21
+ "output" => "raxe/out" ,
22
+ "source" => "raxe/src",
23
+ "tests" => "raxe/tests"
24
+ } # junk
25
+ File.open( @filename, "w+" ) do |f|
26
+ @junk.each do |key, val|
27
+ f.puts key + "!!!" + val
28
+ end # junk each
29
+ end # File.open
30
+ @raxe = Raxe.new
31
+ end # before each
32
+ after(:each) do
33
+ File.delete( @filename )
34
+ end # after each
35
+ it "should be properly setup" do
36
+ @raxe.setup_flag.should be_true
37
+ end # it
38
+ it "should have the correct paths" do
39
+ @junk.each do |key, val|
40
+ @raxe.paths[key].should eq(val)
41
+ end # junk.each
42
+ end # it
43
+ end # has conf
44
+ end # initialization
45
+ describe "installation" do
46
+ before(:each) do
47
+ @raxe = Raxe.new
48
+ @expected = {
49
+ "root" => "raxe" ,
50
+ "output" => "raxe/out" ,
51
+ "source" => "raxe/src",
52
+ "tests" => "raxe/tests"
53
+ } # expected
54
+ end # before each
55
+ after(:each) do
56
+ @raxe.install( :uninstall )
57
+ end # after each
58
+ it "should modify the flags and whatnot after a successful installation" do
59
+ @raxe.install
60
+ @raxe.setup_flag.should be_true
61
+ @raxe.paths.each do | type, location |
62
+ @expected[type].should eq( location )
63
+ end # paths.each
64
+ end # it
65
+ end # installation
66
+ describe "uninstallation" do
67
+ before(:each) do
68
+ @raxe = Raxe.new
69
+ @raxe.install
70
+ end # before each
71
+ it "should have reset the proper flags and paths" do
72
+ @raxe.install( :uninstall )
73
+ @raxe.setup_flag.should be_false
74
+ @raxe.paths.should be_empty
75
+ end # it
76
+ end # uninstallation
77
+ describe "generation" do
78
+ before(:each) do
79
+ @raxe = Raxe.new
80
+ @raxe.install
81
+ @packname = "faggot"
82
+ @filename = "trevor"
83
+ @expected = {
84
+ :file => ['','data','spec'].map { | x | File.join(File.join(@raxe.paths['source'], @packname + x), @filename.capitalize + x.capitalize + ".hx" ) } ,
85
+ :folder => ['','data','spec'].map { | x | File.join( @raxe.paths['source'], @packname + x ) }
86
+ } # expected
87
+ end # before each
88
+ after(:each) do
89
+ @raxe.generate( :req => :ungenerate, :package => @packname, :file => @filename )
90
+ @raxe.install(:uninstall)
91
+ end # after each
92
+ it "should successfully create the desried package" do
93
+ @raxe.generate( :req => :generate , :package => @packname , :file => @filename )
94
+ @expected[:file].each do | file |
95
+ FileTest.exists?( file ).should be_true
96
+ end # expected
97
+ @expected[:folder].each do | folder |
98
+ Dir.exists?( folder ).should be_true
99
+ end # expected
100
+ end # it
101
+ end # generation
102
+ describe "ungeneration" do
103
+ before( :each ) do
104
+ @raxe = Raxe.new
105
+ @raxe.install
106
+ @packname = "faggot"
107
+ @filename = "trevor"
108
+ @expected = {
109
+ :file => ['','data','spec'].map { | x | File.join(File.join(@raxe.paths['source'], @packname + x), @filename.capitalize + x.capitalize + ".hx" ) } ,
110
+ :folder => ['','data','spec'].map { | x | File.join( @raxe.paths['source'], @packname + x ) }
111
+ } # expected
112
+ @raxe.generate( :req => :generate , :package => @packname , :file => @filename )
113
+ end # before each
114
+ it "should destroy all the unnecessary crap" do
115
+ @raxe.generate( :req => :ungenerate, :package => @packname, :file => @filename )
116
+ @expected[:file].each do | file |
117
+ FileTest.exists?( file ).should be_false
118
+ end # expected
119
+ @expected[:folder].each do |folder|
120
+ Dir.exists?( folder ).should be_false
121
+ end # expected
122
+ end # it
123
+ end # ungeneration
124
+ end # Raxe
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.0
4
+ version: 0.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-10 00:00:00.000000000Z
12
+ date: 2012-07-12 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
16
- requirement: &75301690 !ruby/object:Gem::Requirement
16
+ requirement: &71419420 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.5.8
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *75301690
24
+ version_requirements: *71419420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: shoulda
27
- requirement: &75300650 !ruby/object:Gem::Requirement
27
+ requirement: &71413670 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *75300650
35
+ version_requirements: *71413670
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdoc
38
- requirement: &75299950 !ruby/object:Gem::Requirement
38
+ requirement: &71412120 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.12'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *75299950
46
+ version_requirements: *71412120
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &75299060 !ruby/object:Gem::Requirement
49
+ requirement: &71410650 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *75299060
57
+ version_requirements: *71410650
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &75298350 !ruby/object:Gem::Requirement
60
+ requirement: &71401530 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.8.4
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *75298350
68
+ version_requirements: *71401530
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &75297760 !ruby/object:Gem::Requirement
71
+ requirement: &71399750 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - =
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 2.11.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *75297760
79
+ version_requirements: *71399750
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: colorize
82
- requirement: &75296410 !ruby/object:Gem::Requirement
82
+ requirement: &71395950 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *75296410
90
+ version_requirements: *71395950
91
91
  description: Written as a ruby gem, raxe is a series of macros for writing simpler
92
92
  haxe code for javascript compilation
93
93
  email: foxnewsnetwork@gmail.com
@@ -108,7 +108,9 @@ files:
108
108
  - bin/raxe
109
109
  - lib/raxe.rb
110
110
  - raxe.gemspec
111
- - spec/raxe_spec.rb
111
+ - spec/generator/raxe_generator_spec.rb
112
+ - spec/installer/raxe_installer_spec.rb
113
+ - spec/raxe_object_spec.rb
112
114
  - test/helper.rb
113
115
  - test/test_raxe.rb
114
116
  homepage: http://github.com/foxnewsnetwork/raxe
@@ -126,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
128
  version: '0'
127
129
  segments:
128
130
  - 0
129
- hash: -7642339
131
+ hash: 183230721
130
132
  required_rubygems_version: !ruby/object:Gem::Requirement
131
133
  none: false
132
134
  requirements:
data/spec/raxe_spec.rb DELETED
@@ -1,34 +0,0 @@
1
- require "raxe"
2
-
3
- describe Raxe do
4
- describe "directory access" do
5
- describe "basic functionality" do
6
- it "should have a proper output path" do
7
- Raxe.out_path.should_not be_nil
8
- end # it
9
- it "should have the default output path set to javascripts/raxe" do
10
- Raxe.out_path.should eq( File.join( Dir.pwd, "raxe/src" ) )
11
- end # it
12
- it "should allow for changing the output directory" do
13
- Raxe.out_path = File.dirname( __FILE__ )
14
- Raxe.out_path.should eq File.dirname( __FILE__ )
15
- end # it
16
- end # basic functionality
17
- end # making directories
18
- describe "package generation" do
19
- before(:each) do
20
- @package = "package"
21
- @file = "file"
22
- Raxe.out_path = File.join( Dir.pwd, "raxe/src" )
23
- end # before
24
- it "should generate the package directory, files, and associated items" do
25
- Raxe.generate( @package, @file )
26
- package_path = File.join(Raxe.out_path , @package )
27
- file_path = File.join( Raxe.out_path, @package, @file.capitalize + ".hx" )
28
- ["", "spec","data"].each do |type|
29
- FileTest.exists?( package_path + type ).should be_true
30
- FileTest.exists?( file_path ).should be_true
31
- end # each type
32
- end # it
33
- end # package generation
34
- end # Raxe