creact 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b79e6bfab5327ae896ff07756678d0f90c3b3e1c
4
- data.tar.gz: 4439f42f524b21abad0cb5403c60b15b6a8c479a
3
+ metadata.gz: c87bceda693baa933514e2e3e5b39fcce6a7ab2f
4
+ data.tar.gz: 97b2c1b45f7fe8fe6e8cc809015f87488927d447
5
5
  SHA512:
6
- metadata.gz: cff7d059bbe6528aeb99869f395082a6baac9fc892529e2d16a56af2e5c0c29f3f8f6991a0bec87c921f415a25187ecb802f4e6d477642038d9d747c65e376eb
7
- data.tar.gz: 0570540162eedae105d445b71aa13478aa9791f053d48c4e5e6b0427e8e218c3b478933e57e0bcb07689d26e49c04b43ca59b2b51fdbb6fb5f8b40ac19b24936
6
+ metadata.gz: 1879dd81095462bf6dafb7082ede33a872aa37a728cb4a625cb1a4ca7db16c1a4e43f92e11118e1366b7b328b5eaa10a6a52a6f23bb9a940c940b8046f9838ec
7
+ data.tar.gz: 7f337051b04b0c475e5bd422f5cc3c4179f5c33a03223e6b4df1a47dffc6fd50691577b86deddeca6027d4552c13e28efc1c9540a4d391ce8abdb3e129f780f2
@@ -29,6 +29,9 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "bundler", "~> 1.11"
30
30
  spec.add_development_dependency "rake", "~> 11.0"
31
31
  spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "guard-shell"
33
+ spec.add_development_dependency "pry-rescue"
34
+ spec.add_development_dependency "pry-byebug"
32
35
  spec.add_dependency 'opal'
33
36
  spec.add_dependency 'jquery'
34
37
  spec.add_dependency 'opal-jquery'
@@ -3,24 +3,21 @@ module Creact
3
3
  extend self
4
4
  def get_absolute_path(file)
5
5
  location = File.dirname(__FILE__)
6
- puts "#{location}/files/#{file}"
7
6
  "#{location}/files/#{file}"
8
7
  end
9
8
 
10
9
  def create_dirs
11
- dirs = ['views', 'js']
12
- puts 'Creating the following dirs: ' + dirs.join(' ')
13
- FileUtils.makedirs dirs
10
+ @dirs = ['views', 'js']
11
+ puts 'Creating the following dirs: ' + @dirs.join(' ')
12
+ FileUtils.makedirs @dirs
14
13
  end
15
14
 
16
15
  def create_views(template=:mote)
16
+ # TODO: Add support for other template languages
17
17
  puts 'Creating view files...'
18
- # TODO: Refactor into a case statement:
19
- if template == :mote
20
- @view_files = ['layout.mote', 'home.mote']
21
- end
22
- files = @view_files.map { |file| get_absolute_path(file) }
23
- FileUtils.cp(files, 'views')
18
+ files = ['layout.mote', 'home.mote']
19
+ @view_files = files.map { |file| get_absolute_path(file) }
20
+ FileUtils.cp(@view_files, 'views')
24
21
  end
25
22
 
26
23
  def create_js(template=:mote)
@@ -29,59 +26,35 @@ module Creact
29
26
  FileUtils.cp(@js_files, 'js')
30
27
  end
31
28
 
32
- # # def create_react_module
33
- # # # TODO: Do I need this anymore?
34
- # # FileUtils.cp(get_absolute_path('react_helpers.rb'), '.')
35
- # # end
36
-
37
- def creact_react_entry_point
38
- FileUtils.cp(get_absolute_path('react.rb'), 'js')
29
+ def delete_dirs
30
+ FileUtils.rm_rf 'views'
31
+ FileUtils.rm_rf 'js'
39
32
  end
40
33
 
41
- # def check_dir_empty(dir)
42
- # (Dir.entries(dir) - %w{ . .. }).empty?
43
- # end
44
- #
45
- # def delete_files
46
- # @js_files = ['js/jquery.js', 'js/react.rb']
47
- # @view_files = ['views/layout.mote', 'views/home.mote']
48
- # puts "Destructive operation: 'yes' to continue"
49
- # confirm = gets.strip
50
- #
51
- # if confirm == 'yes'
52
- # puts 'Deleting...'
53
- # puts @view_files
54
- # FileUtils.rm @view_files
55
- # puts @js_files
56
- # FileUtils.rm @js_files
57
- # puts 'React entry point'
58
- # FileUtils.rm 'js/react.rb'
59
- # # puts 'React helper module'
60
- # # FileUtils.rm 'react_helpers.rb'
61
- #
62
- # if check_dir_empty('views')
63
- # puts 'Deleting directory: views...'
64
- # FileUtils.rm_rf 'views'
65
- # end
66
- #
67
- # if check_dir_empty('js')
68
- # puts 'Deleting directory: js...'
69
- # FileUtils.rm_rf 'js'
70
- # puts 'Done'
71
- # end
72
- # else
73
- # puts 'Aborted.'
74
- # end
75
- # end
76
- #
77
34
  def run_generator
35
+ existing_files = []
36
+ files_to_create = [
37
+ 'views/layout.mote',
38
+ 'views/home.mote',
39
+ 'js/react.rb',
40
+ 'js/jquery.js'
41
+ ]
42
+ files_to_create.each do |file|
43
+ if File.exists? file
44
+ existing_files << file
45
+ end
46
+ end
47
+ if not existing_files.empty?
48
+ raise IOError, "Move or rename the following files to use this generator: #{existing_files}"
49
+ end
50
+
78
51
  puts 'Running generator'
79
- # Dir.chdir Dir.pwd
80
52
  create_dirs
81
53
  create_views
54
+ @view_files.map { |file| puts file }
82
55
  create_js
83
- # create_react_module
84
- creact_react_entry_point
56
+ @js_files.map { |file| puts file }
57
+ puts 'Done!'
85
58
  end
86
59
  end
87
60
  end
@@ -1,3 +1,3 @@
1
1
  module Creact
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: creact
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Bush
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-16 00:00:00.000000000 Z
11
+ date: 2016-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,48 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-shell
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: pry-rescue
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
+ - !ruby/object:Gem::Dependency
84
+ name: pry-byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: opal
57
99
  requirement: !ruby/object:Gem::Requirement
@@ -164,7 +206,6 @@ files:
164
206
  - lib/creact/files/jquery.js
165
207
  - lib/creact/files/layout.mote
166
208
  - lib/creact/files/react.rb
167
- - lib/creact/files/react_helpers.rb
168
209
  - lib/creact/version.rb
169
210
  - react_helpers.rb
170
211
  homepage: https://github.com/disavowd/creact
@@ -1,11 +0,0 @@
1
- require 'opal'
2
-
3
- module ReactHelpers
4
- def loader
5
- opal = Opal::Server.new {|s|
6
- s.append_path 'js'
7
- s.main = 'app'
8
- }
9
- opal_boot_code = Opal::Processor.load_asset_code(opal.sprockets, 'react')
10
- end
11
- end