shop 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTUxZjYwODM5NjMwNGY2OGJhMzZiNTFlMTI1YzRmYjQ1ZTc5N2QwZQ==
4
+ NDUzOTc4MzA4NGE0Zjc5NTJkNTM4Mjk1Y2I4YjZlZDdhNjU3NzIxZg==
5
5
  data.tar.gz: !binary |-
6
- YmRjNjJmNzU0YWI5NzA3ODk2MTlkMWQ2NzI0NWYwNTRkYmExYWJhYg==
6
+ NjE5ZjE0MmNkZWZjNTE0N2ExODQ1OWQyMDBkZGNiNzIyYzMzNTJkYw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OWE3ZTIxYjIxNzZmZmFlZjg2Y2E4NzgyMmQxOTdhZmEwNTFmNzYzYTc4ZjFk
10
- NmQ3MThkOGE4MTNlZjg0ZDU2NmJhNDE0YTQ0YTNkODQwMzVmNDkwYWEzOWM0
11
- MmYxNzk2NTg2NDUzOWY3M2U0ZDBmOThkZDZjZDQxZDkyN2RhNGE=
9
+ NTFlZjc0Y2EzZjhkMGQ2MDAwYmIxM2MzNDQ0MDlkNWQzNDBiM2YzOGVkZjcx
10
+ ZGY2ZGZiZjY0YjNiOGJkZjFjYjNkMzE4Mjg3YjQyNzllNzBhYTliZmI3YmE2
11
+ ODk5MzI3ODliNWU3YWE5NjdiZTI3M2JlYTBiNmJkNTFhN2ExYmQ=
12
12
  data.tar.gz: !binary |-
13
- ZDFhMzVhMjEzMTRjMDVmZWVmNWRlNzlmOWNkOGNhZTNiMDc1ZmI0OTNhY2U4
14
- NDUwZGZlNTVlMDc1ZGE3MTgyZTc3NjgzYjY3MjBjYWU0ZDJhYjVmMThlMjEx
15
- YWQ2MmZjM2YxMjkxY2Y0MjkzODM3NDFmNDI5MGMyZmVlMmE4ZWM=
13
+ ZTMyYzY4MTQyNGZjMmMzYmQyODM3YmZkNzEwYzNlM2NhZDM3NGU2OGI4NTkz
14
+ ZGZmNTBjMGU1ZTU1Y2I5OGQ0MjEzMTAzMmY1NzlhODJjNzVkYzEzNDEwNGQx
15
+ OTk1OTllMWQ4NWRlZWY3MGM4NTFhY2E2NTdmYzRlNDgzZjAzZjg=
@@ -1,6 +1,12 @@
1
1
  # Shop changelog
2
+
2
3
  ## Head
3
4
 
5
+ ## 0.1.9
6
+ - Change template system to use `<%= %>` instead of `{{}}`
7
+ - Creates the database in the `install` task
8
+ - Fuck yeah autocompletion
9
+
4
10
  ## 0.1.8
5
11
  - By default the clean task clean the cache
6
12
  - Add a `template` section to the configuration file so you can use custom templates
@@ -1,17 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shop (0.1.8)
4
+ shop (0.1.9)
5
5
  highline (~> 1.6.19)
6
+ mysql2
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
9
10
  specs:
11
+ diff-lcs (1.2.4)
10
12
  highline (1.6.19)
13
+ mysql2 (0.3.13)
14
+ rspec (2.14.1)
15
+ rspec-core (~> 2.14.0)
16
+ rspec-expectations (~> 2.14.0)
17
+ rspec-mocks (~> 2.14.0)
18
+ rspec-core (2.14.5)
19
+ rspec-expectations (2.14.3)
20
+ diff-lcs (>= 1.1.3, < 2.0)
21
+ rspec-mocks (2.14.3)
11
22
 
12
23
  PLATFORMS
13
24
  ruby
14
25
 
15
26
  DEPENDENCIES
27
+ rspec
16
28
  shop!
17
- highline (~> 1.6.19)
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
- # Shop
1
+ # Shop [![Build Status](https://secure.travis-ci.org/romainberger/shop.png)](http://travis-ci.org/romainberger/shop)
2
2
 
3
3
  CLI for easier [PrestaShop](http://www.prestashop.com/en/) development. Actually it's just for the lazy people.
4
4
 
5
5
  I always use Rakefiles and Makefiles for lots of tasks. With this gem you can use these tasks without having to create any *akefiles. For more infos about how and why see: [Introducing Shop](http://romainberger.com/2013/09/29/introducing-shop/).
6
6
 
7
+ Shop has been developed to work with PrestaShop 1.5 and 1.4 (support for 1.6 will be added once it's realeased).
8
+
7
9
  ## Installation
8
10
 
9
11
  gem install shop
@@ -29,7 +31,7 @@ Download the latest stable version of PrestaShop in the current directory or in
29
31
 
30
32
  ### Installation
31
33
 
32
- Since 1.5.4 [PrestaShop provides a CLI](http://doc.prestashop.com/display/PS15/Installing+PrestaShop+using+the+command+line) to install your PrestaShop. You can try to remember every arguments, or just use the Shop task and stay relatively sane (no offense to the PrestaShop developers but... come on).
34
+ Since 1.5.4 [PrestaShop provides a CLI](http://doc.prestashop.com/display/PS15/Installing+PrestaShop+using+the+command+line) to install your PrestaShop. You can try to remember every arguments, or just use the Shop task and stay relatively sane (no offense to the PrestaShop developers but... come on). The task will create the database if needed.
33
35
 
34
36
  # php install/cli.php --name=Romain --lol=whyamitypingallthis
35
37
  # nope
@@ -73,8 +75,6 @@ You can generate new pages for PrestaShop easily with the `controller` command.
73
75
  # example:
74
76
  shop controller CustomPage
75
77
 
76
- This task is adapted to work on PrestaShop 1.5 and 1.4.
77
-
78
78
  ### Modules
79
79
 
80
80
  **The modules related tasks will need the Shop project to be [initialized](https://github.com/romainberger/shop)**
@@ -162,6 +162,14 @@ You can edit this file with the command
162
162
 
163
163
  It will open the config file in your `$EDITOR`. It's YAML so it shouldn't be scary.
164
164
 
165
+ ## Custom templates
166
+
167
+ Some tasks generates files, using templates located in [/templates](https://github.com/romainberger/shop/tree/master/templates). You can override these files to use custom ones. See the [template readme for more infos](https://github.com/romainberger/shop/tree/master/templates).
168
+
169
+ ## Autocompletion
170
+
171
+ To enable autocompletion with Shop, [see the doc](https://github.com/romainberger/shop/tree/master/completion)
172
+
165
173
  ## Compatibility
166
174
 
167
175
  Shop has been developed and tested on osx. It may not work on platforms other than *nix, particularly the `new` command that uses the unix `unzip` command. I plan on working on rewriting this part with only Ruby so it could work everywhere. I'm not going to try it on Windows so feel free to open issues (or even better, contribute) if you notice something not working as expected.
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
 
2
2
  # Helper functions
3
3
 
4
+ task :default => :test
5
+
4
6
  def name
5
7
  @name ||= Dir['*.gemspec'].first.split('.').first
6
8
  end
@@ -25,3 +27,7 @@ task :inst => [:build, :install]
25
27
  task :publish do
26
28
  system "gem push #{name}-#{version}.gem"
27
29
  end
30
+
31
+ task :test do
32
+ system "bundle exec rspec test"
33
+ end
@@ -5,6 +5,7 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
5
5
  require 'fileutils'
6
6
  require 'open-uri'
7
7
  require 'yaml'
8
+ require 'mysql2'
8
9
 
9
10
  require 'highline/import'
10
11
 
@@ -15,5 +16,5 @@ require 'shop/platform'
15
16
  require 'shop/shopconfig'
16
17
 
17
18
  module Shop
18
- VERSION = '0.1.8'
19
+ VERSION = '0.1.9'
19
20
  end
@@ -46,7 +46,7 @@ module Shop
46
46
  return init(major) if command == 'init'
47
47
  return install if command == 'install'
48
48
  return shopModule(major, minor, extra) if command == 'module'
49
- return override(major, major, extra) if command == 'override'
49
+ return override(major, minor, extra) if command == 'override'
50
50
  return controller(major) if command == 'controller'
51
51
  return clean(major) if command == 'clean'
52
52
  return jshint(major) if command == 'jshint'
@@ -55,6 +55,7 @@ module Shop
55
55
  return version if command == "-v"
56
56
  return version if command == "--version"
57
57
  return help if command == 'help'
58
+ return complete(major) if command == 'cmplt'
58
59
 
59
60
  puts "\n#{red("Error")}: Command not found"
60
61
  return help
@@ -65,11 +66,12 @@ module Shop
65
66
  def newProject(path)
66
67
  unless path.nil?
67
68
  FileUtils.mkpath(path)
69
+ puts "Creating new PrestaShop project in ./#{path}"
68
70
  else
69
71
  path = "./"
72
+ puts "Creating new PrestaShop project"
70
73
  end
71
74
 
72
- puts "Please wait..."
73
75
  print "Downloading the framework... "
74
76
  url = 'https://github.com/PrestaShop/PrestaShop/archive/master.zip'
75
77
  open("master.zip", "wb") do |f|
@@ -147,8 +149,18 @@ module Shop
147
149
  command << "--email=#{entry[:email]} "
148
150
  command << "--newsletter=0"
149
151
 
152
+ # Creates the database if it doesn't exist
153
+ client = Mysql2::Client.new(
154
+ :host => entry[:db_server],
155
+ :username => entry[:db_user],
156
+ :password => entry[:db_password]
157
+ )
158
+ puts "Creating the database..."
159
+ client.query("CREATE DATABASE IF NOT EXISTS `#{entry[:db_name]}`")
160
+ client.close()
161
+
150
162
  # run the php script
151
- puts "Installing Prestashop please wait... "
163
+ puts "Installing Prestashop please wait..."
152
164
  system command
153
165
  done
154
166
  end
@@ -195,7 +207,7 @@ module Shop
195
207
  exit
196
208
  else
197
209
  puts " #{green("create")} #{filepath}"
198
- File.open(filepath, "w") do; end
210
+ File.open(filepath, "w")
199
211
  end
200
212
  elsif major == 'css'
201
213
  theme
@@ -211,7 +223,7 @@ module Shop
211
223
  exit
212
224
  elsif
213
225
  puts " #{green("create")} #{filepath}"
214
- File.open(filepath, "w") do; end
226
+ File.open(filepath, "w")
215
227
  end
216
228
  else
217
229
  # create a module
@@ -254,6 +266,7 @@ module Shop
254
266
  # Creates an override for controllers and classes
255
267
  def override(major, minor, extra)
256
268
  name = minor.capitalize
269
+
257
270
  if major == 'controller'
258
271
  # controller
259
272
  if !extra.nil? && extra == 'admin'
@@ -266,7 +279,6 @@ module Shop
266
279
  filename = "#{name}.php"
267
280
  path = "override/controllers/#{side}/#{filename}"
268
281
 
269
-
270
282
  elsif major == 'class'
271
283
  # class
272
284
  filename = "#{name}.php"
@@ -350,7 +362,7 @@ module Shop
350
362
 
351
363
  files.each do |f|
352
364
  puts " #{green("create")} #{f}"
353
- File.open(f, "w") do; end
365
+ File.open(f, "w")
354
366
  end
355
367
 
356
368
  clean("class")
@@ -379,7 +391,7 @@ module Shop
379
391
  if File.exists?(index)
380
392
  File.delete(index)
381
393
  end
382
- File.open(index, "w") do; end
394
+ File.open(index, "w")
383
395
  # the file needs to be chmod'ed to 666
384
396
  File.chmod(0666, index)
385
397
  end
@@ -387,7 +399,6 @@ module Shop
387
399
  done
388
400
  end
389
401
 
390
-
391
402
  # Run jshint
392
403
  def jshint(major)
393
404
  theme
@@ -480,6 +491,26 @@ module Shop
480
491
  }.gsub(/^ {10}/, '')
481
492
  puts text
482
493
  end
494
+
495
+ # Method for the autocompletion
496
+ def complete(word)
497
+ complete = %{
498
+ new
499
+ init
500
+ install
501
+ module
502
+ module template
503
+ override
504
+ override controller
505
+ override class
506
+ controller
507
+ clean
508
+ clean class
509
+ jshint
510
+ makefile
511
+ }
512
+ puts complete
513
+ end
483
514
  end
484
515
  end
485
516
  end
@@ -40,7 +40,7 @@ module Shop
40
40
  content = File.read(file)
41
41
 
42
42
  datas.each do |k, v|
43
- k = "{{#{k}}}"
43
+ k = "<%= #{k} %>"
44
44
  content = content.gsub(k, v)
45
45
  end
46
46
  return content
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'shop'
16
- s.version = '0.1.8'
17
- s.date = '2013-09-29'
16
+ s.version = '0.1.9'
17
+ s.date = '2013-10-02'
18
18
  s.rubyforge_project = 'shop'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -51,9 +51,11 @@ Gem::Specification.new do |s|
51
51
  ## List your runtime dependencies here. Runtime dependencies are those
52
52
  ## that are needed for an end user to actually USE your code.
53
53
  s.add_dependency('highline', "~> 1.6.19")
54
+ s.add_dependency('mysql2')
54
55
 
55
56
  ## List your development dependencies here. Development dependencies are
56
57
  ## those that are only needed during development
58
+ s.add_development_dependency('rspec')
57
59
 
58
60
  ## Leave this section as-is. It will be automatically generated from the
59
61
  ## contents of your Git repository via the gemspec task. DO NOT REMOVE
@@ -10,5 +10,5 @@ clean-class:
10
10
 
11
11
  clean-cache:
12
12
  @printf "Cleaning cache..."
13
- -@rm themes/{{theme}}/cache/*.css themes/{{theme}}/cache/*.js 2>/dev/null || true
13
+ -@rm themes/<%= theme %>/cache/*.css themes/<%= theme %>/cache/*.js 2>/dev/null || true
14
14
  @echo " ${CHECK}"
@@ -1,18 +1,18 @@
1
1
  <?php
2
2
 
3
- class {{controller_name}}Core extends FrontController {
3
+ class <%= controller_name %>Core extends FrontController {
4
4
 
5
5
  public function setMedia() {
6
6
  parent::setMedia();
7
7
 
8
- Tools::addCSS(_THEME_CSS_DIR_.'{{name}}.css');
9
- Tools::addJS(_THEME_JS_DIR_.'{{name}}.js');
8
+ Tools::addCSS(_THEME_CSS_DIR_.'<%= name %>.css');
9
+ Tools::addJS(_THEME_JS_DIR_.'<%= name %>.js');
10
10
  }
11
11
 
12
12
  public function displayContent() {
13
13
  parent::displayContent();
14
14
 
15
- self::$smarty->display(_PS_THEME_DIR_.'{{name}}.tpl');
15
+ self::$smarty->display(_PS_THEME_DIR_.'<%= name %>.tpl');
16
16
  }
17
17
 
18
18
  }
@@ -1,12 +1,12 @@
1
1
  <?php
2
2
 
3
- class {{controller_name}}Core extends FrontController {
3
+ class <%= controller_name %>Core extends FrontController {
4
4
 
5
5
  public function setMedia() {
6
6
  parent::setMedia();
7
7
 
8
- $this->addCSS(_THEME_CSS_DIR_.'{{name}}.css');
9
- $this->addJS(_THEME_JS_DIR_.'{{name}}.js');
8
+ $this->addCSS(_THEME_CSS_DIR_.'<%= name %>.css');
9
+ $this->addJS(_THEME_JS_DIR_.'<%= name %>.js');
10
10
  }
11
11
 
12
12
  /**
@@ -16,7 +16,7 @@ class {{controller_name}}Core extends FrontController {
16
16
  public function initContent() {
17
17
  parent::initContent();
18
18
 
19
- $this->setTemplate(_PS_THEME_DIR_.'{{name}}.tpl');
19
+ $this->setTemplate(_PS_THEME_DIR_.'<%= name %>.tpl');
20
20
  }
21
21
 
22
22
  }
@@ -1,12 +1,12 @@
1
1
  <?php
2
2
 
3
- class {{name_capitalize}} extends Module {
3
+ class <%= name_capitalize %> extends Module {
4
4
 
5
5
  public function __construct() {
6
- $this->name = '{{name}}';
7
- $this->tab = '{{tab}}';
6
+ $this->name = '<%= name %>';
7
+ $this->tab = '<%= tab %>';
8
8
  $this->version = 0.1;
9
- $this->author = '{{author}}';
9
+ $this->author = '<%= author %>';
10
10
 
11
11
  parent::__construct();
12
12
 
@@ -1,4 +1,4 @@
1
1
  <?php
2
2
 
3
3
  require(dirname(__FILE__).'/config/config.inc.php');
4
- ControllerFactory::getController('{{controller_name}}')->run();
4
+ ControllerFactory::getController('<%= controller_name %>')->run();
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain Berger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-29 00:00:00.000000000 Z
11
+ date: 2013-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.6.19
27
+ - !ruby/object:Gem::Dependency
28
+ name: mysql2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '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'
27
55
  description: ! "CLI for the lazy people working on PrestaShop so you don't\n have
28
56
  to type."
29
57
  email: romain@romainberger.com