besturder 0.2.2 → 0.3.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/besturder +11 -1
  3. data/lib/besturder.rb +59 -48
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3544dd14f2a9944ee021b23829bb85535f1172a
4
- data.tar.gz: edf28da6f39a0390f5affa31c2afa2de809ab69f
3
+ metadata.gz: 780eb6027f2b18193d7352218dec9f648b271f0d
4
+ data.tar.gz: 1e54848e9d62a795cbe30454ebb6bebc5c7a6f7c
5
5
  SHA512:
6
- metadata.gz: 686d77cd6d0c47549ea30dc8fda19bc186c491a7af5a863a08a3a328b21e0f696640dc4aa641ff300cb11e81cf60e1d5ceb67b5838d74ce21268926e6606682a
7
- data.tar.gz: c4d6495df939e3f1971863cd46571b42bdc5c59e51919f42e1799dfb713a387ff8f96f2810b39b5f4cd950d12e6bedbef1123ea49191dce453b8f295c7607fa4
6
+ metadata.gz: 9bc5953b89253308869b54eab97f34b22f35b4c543e3532bc0f6851a05f3de30c47c09911d367e9a43a62147664428ff940dfe7b05b00dce4648b4b871e6eb09
7
+ data.tar.gz: 230eda5ccaef3f150785ccab13f197663b24e9164ecb2f90c3dd7e5665c3d7a002c38037a8da277f78e0580d0797ae9aa8bc35d4972945bf359d38a26d087e11
@@ -2,4 +2,14 @@
2
2
 
3
3
  require "besturder"
4
4
 
5
- Besturder.new
5
+ besturder = Besturder.new
6
+
7
+ besturder.main if ARGV[0].nil?
8
+
9
+ unless ARGV[0].nil?
10
+ case ARGV[0]
11
+ when '--install'
12
+ besturder.singleinstall ARGV[1] unless ARGV[1].nil?
13
+
14
+ end
15
+ end
@@ -1,53 +1,64 @@
1
1
  require "open-uri"
2
2
  require "json"
3
- $jsonfile = "package.json"
4
- $packs = JSON.parse(File.read("#{File.expand_path(File.dirname(__FILE__))}/packs.json"))
3
+ $JSONFILE = "package.json"
4
+ $PACKS = JSON.parse(File.read("#{File.expand_path(File.dirname(__FILE__))}/packs.json"))
5
5
  def download(key)
6
- unless File.exists? $packs[key]["dir"]
7
- puts "Installing #{key}..."
8
- File.open($packs[key]["dir"], "w") do |file|
9
- opena = open($packs[key]['url']).read
10
- opena.lines.each do |line|
11
- file << line
12
- end
13
- end
14
- puts "The #{key} dependency has been installed"
15
- else
16
- puts "The dependency #{key} is already installed"
17
- end
6
+ unless File.exists? $PACKS[key]["dir"]
7
+ puts "Installing #{key}..."
8
+ File.open($PACKS[key]["dir"], "w") do |file|
9
+ opena = open($PACKS[key]['url']).read
10
+ opena.lines.each do |line|
11
+ file << line
12
+ end
13
+ end
14
+ puts "The #{key} dependency has been installed"
15
+ else
16
+ puts "The dependency #{key} is already installed"
17
+ end
18
18
  end
19
19
  class Besturder
20
- def initialize
21
- if File.exist? $jsonfile then
22
- json = JSON.parse File.read $jsonfile
23
- dependencies = json["dependencies"]
24
- if dependencies.size != 0 then
25
- Dir.mkdir "js" unless Dir.exist? "js"
26
- Dir.mkdir "css" unless Dir.exist? "css"
27
- dependencies.downcase.each do |value|
28
- download(value) if $packs.keys.include? value
29
- puts "The dependency #{value} doesn't exist" unless $packs.keys.include? value
30
- end
31
- else
32
- puts "You don't have dependencies in your #{$jsonfile}"
33
- end
34
- else
35
- print "the file #{$jsonfile} doesn't exist, do you want create it?[Y/N] "
36
- s_n = gets.chomp
37
- if s_n.upcase == "Y" then
38
- print "\tWrite the dependencies (separated by commas and without spaces): "
39
- dependencia = gets.chomp
40
- dependencia = dependencia.split(",")
41
- dependencia.each { |a| a.downcase! }
42
- json = {name:name,version:version,dependencies:dependencia}
43
- json = JSON.pretty_generate json
44
- file = File.open("#{$jsonfile}", "w") do |b|
45
- b << json
46
- end
47
- puts "File created without errors!"
48
- else
49
- exit
50
- end
51
- end
52
- end
53
- end
20
+ def main
21
+ if File.exist? $JSONFILE then
22
+ json = JSON.parse File.read $JSONFILE
23
+ dependencies = json["dependencies"]
24
+ if dependencies.size != 0 then
25
+ Dir.mkdir "js" unless Dir.exist? "js"
26
+ Dir.mkdir "css" unless Dir.exist? "css"
27
+ dependencies.downcase.each do |value|
28
+ download(value) if $PACKS.keys.include? value
29
+ puts "The dependency #{value} doesn't exist" unless $PACKS.keys.include? value
30
+ end
31
+ else
32
+ puts "You don't have dependencies in your #{$JSONFILE}"
33
+ end
34
+ else
35
+ print "the file #{$JSONFILE} doesn't exist, do you want create it?[Y/N] "
36
+ s_n = gets.chomp
37
+ if s_n.upcase == "Y" then
38
+ print "\tWrite the dependencies (separated by commas and without spaces): "
39
+ dependencia = gets.chomp
40
+ dependencia = dependencia.split(",")
41
+ dependencia.each { |a| a.downcase! }
42
+ json = {name:name,version:version,dependencies:dependencia}
43
+ json = JSON.pretty_generate json
44
+ file = File.open("#{$JSONFILE}", "w") do |b|
45
+ b << json
46
+ end
47
+ puts "File created without errors!"
48
+ else
49
+ exit
50
+ end
51
+ end
52
+ end
53
+ def singleinstall(key)
54
+ dir = $PACKS[key]["dir"]
55
+ unless File.exists? dir
56
+ dir = dir.split '/'
57
+ dir0 = dir[0]
58
+ Dir.mkdir dir0 unless Dir.exist? dir0
59
+ download(key)
60
+ else
61
+ puts "The dependency #{key} is already installed"
62
+ end
63
+ end
64
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: besturder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daviz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-28 00:00:00.000000000 Z
11
+ date: 2015-12-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Besturder is a simple package manager for HTML5
14
14
  email: roman.daco.st@gmail.com