nu 0.1.10 → 0.1.11

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.
data/bin/nu CHANGED
@@ -1,6 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.expand_path('../../lib/cli', __FILE__)
4
- require File.expand_path('../../lib/loader', __FILE__)
3
+ require 'nu'
5
4
 
6
- Nu::CLI.start
5
+ begin
6
+ Nu::CLI.start
7
+ rescue Interrupt
8
+ puts 'quitting'
9
+ exit 1
10
+ end
data/lib/nu.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'nu/cli'
2
+ require 'nu/loader'
3
+ require 'nu/config'
4
+
5
+ #other fancy stuff
data/lib/nu/cli.rb ADDED
@@ -0,0 +1,56 @@
1
+ require 'FileUtils'
2
+ require 'thor'
3
+ require 'yaml'
4
+
5
+ module Nu
6
+ class CLI < Thor
7
+ include Thor::Actions
8
+
9
+
10
+ def initialize(*)
11
+ super
12
+ @config_file = ".nu/options.yaml"
13
+ end
14
+
15
+ desc "install GEMNAME", "installs a gem in the 'pwd'"
16
+ method_options :location => :string
17
+
18
+ def install(name)
19
+ ensure_default_config
20
+
21
+ loc = get_location
22
+ cl = options['location']
23
+ loc = cl unless cl.nil?
24
+
25
+ Nu::Loader.load name, loc
26
+ end
27
+
28
+ desc "lib FOLDER", "where do you want to store the gems"
29
+ def lib(folder)
30
+ File.delete @config_file if File.exist? @config_file
31
+ add_file @config_file
32
+ content = YAML::dump( { 'lib' => folder })
33
+ append_file @config_file, content
34
+ end
35
+
36
+ def self.source_root
37
+ File.dirname(__FILE__)
38
+ end
39
+
40
+ private
41
+ def ensure_default_config
42
+ if File.exist? @config_file
43
+ return
44
+ end
45
+ add_file @config_file
46
+ content = YAML::dump( {'lib'=>'lib'} )
47
+ append_file @config_file, content
48
+ end
49
+
50
+ def get_location
51
+ content = YAML.load_file @config_file
52
+ content['lib']
53
+ end
54
+
55
+ end
56
+ end
data/lib/nu/config.rb ADDED
@@ -0,0 +1,37 @@
1
+ require 'yaml'
2
+ require 'thor'
3
+ require 'FileUtils'
4
+
5
+ module Nu
6
+ #class Config < Thor::Group
7
+ #include Thor::Actions
8
+
9
+ #@config_file = ".nu/options.yaml"
10
+
11
+ #def self.get_config
12
+ # unless File.exists? @config_file
13
+ # FileUtils.touch @config_file
14
+ # append_file @config_file, YAML::dump({})
15
+ # end
16
+ # cd = YAML.load_file @config_file
17
+ # cd = ask_about_libdir cd
18
+ #
19
+ # save_file cd
20
+ # cd
21
+ #end
22
+
23
+ #def self.ask_about_libdir(config)
24
+ # if config['lib'].nil?
25
+ # loc = ask "Where do you want me to copy things to?"
26
+ # config = {'lib'=>loc}
27
+ # end
28
+ # config
29
+ #end
30
+
31
+ #def self.save_file(config)
32
+ # File.open(@config_file, 'w') do |out|
33
+ # YAML.dump( config, out)
34
+ # end
35
+ #end
36
+ #end
37
+ end
@@ -1,24 +1,24 @@
1
- require 'FileUtils'
1
+ require 'rubygems'
2
2
 
3
3
  module Nu
4
- class CLI
4
+ class Loader
5
5
 
6
- def self.start
7
-
6
+ def self.load(name)
7
+ load(name, 'lib')
8
+ end
9
+ def self.load(name, location)
8
10
  #improve the crap out of this
9
- action = ARGV[0]
10
- @gem_to_copy = ARGV[1]
11
+ @gem_to_copy = name
12
+ @location = location
11
13
 
12
14
 
13
- l = Nu::Loader.new
14
- if !l.available? @gem_to_copy
15
+ if !Gem.available? @gem_to_copy
15
16
  puts "Gem unavailable - please install it"
16
17
  return
17
18
  else
18
19
  puts "Found Gem"
19
20
  end
20
21
  #TODO: better error handling flow control for above
21
-
22
22
 
23
23
 
24
24
  start_here = get_copy_from()
@@ -28,40 +28,43 @@ module Nu
28
28
  puts "Copy To: #{to}"
29
29
 
30
30
  FileUtils.copy_entry start_here, to
31
- #files = get_files()
32
- #files.each do |file|
33
- #someone please show me how to do this better
34
- # from = File.expand_path(file, start_here+"/..")
35
- #puts "copy #{from} #{to}"
36
- #FileUtils.copy(from, to)
37
- #end
31
+ end
32
+
33
+ def self.get_libdir(name)
34
+ g = get_gemspec name
35
+ l = Gem.searcher.lib_dirs_for g
36
+ #scrub and return?
37
+ l
38
38
  end
39
39
 
40
+ def self.get_gemspec(name)
41
+ gems = Gem.source_index.find_name name
42
+ return gems.last if gems.length > 0
43
+ end
44
+
40
45
  def self.get_copy_from
41
- l = Nu::Loader.new
42
- libdir = l.get_libdir @gem_to_copy
46
+ libdir = get_libdir @gem_to_copy
43
47
  #puts File.expand_path libdir
44
48
  #try Dir.glob("{bin,lib}/**/*")
45
49
  libdir.gsub '{lib}','lib'
46
50
  end
47
51
 
48
52
  def self.get_files
49
- l = Nu::Loader.new
50
- spec = l.get_gemspec @gem_to_copy
53
+ spec = get_gemspec @gem_to_copy
51
54
  files = spec.lib_files #get full path
52
55
  files
53
56
  end
54
57
 
55
58
  def self.get_copy_to
56
- l = Nu::Loader.new
57
- spec = l.get_gemspec @gem_to_copy
59
+ spec = get_gemspec @gem_to_copy
58
60
  #to be used in copying
59
61
  name = spec.full_name
60
- to = Dir.pwd + "/lib/#{name}"
62
+ to = Dir.pwd + "/#{@location}/#{name}"
61
63
  if Dir[to] == [] #may need a smarter guy here
62
64
  FileUtils.mkpath to
63
65
  end
64
66
  to
65
67
  end
68
+
66
69
  end
67
- end
70
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 10
10
- version: 0.1.10
9
+ - 11
10
+ version: 0.1.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dru Sellers
@@ -19,8 +19,23 @@ cert_chain: []
19
19
 
20
20
  date: 2010-07-16 00:00:00 -05:00
21
21
  default_executable:
22
- dependencies: []
23
-
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ name: thor
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ hash: 59
32
+ segments:
33
+ - 0
34
+ - 13
35
+ - 8
36
+ version: 0.13.8
37
+ type: :runtime
38
+ version_requirements: *id001
24
39
  description: Nu manages an application's dependencies through its entire life, across many machines, systematically and repeatably
25
40
  email:
26
41
  - nu-net@googlegroups.com
@@ -32,8 +47,10 @@ extra_rdoc_files: []
32
47
 
33
48
  files:
34
49
  - bin/nu
35
- - lib/cli.rb
36
- - lib/loader.rb
50
+ - lib/nu/cli.rb
51
+ - lib/nu/config.rb
52
+ - lib/nu/loader.rb
53
+ - lib/nu.rb
37
54
  has_rdoc: true
38
55
  homepage: http://groups.google.com/group/nu-net
39
56
  licenses: []
data/lib/loader.rb DELETED
@@ -1,22 +0,0 @@
1
- require 'rubygems'
2
-
3
- module Nu
4
- class Loader
5
-
6
- def get_libdir(name)
7
- g = get_gemspec name
8
- l = Gem.searcher.lib_dirs_for g
9
- #scrub and return?
10
- l
11
- end
12
-
13
- def get_gemspec(name)
14
- gems = Gem.source_index.find_name name
15
- return gems.last if gems.length > 0
16
- end
17
-
18
- def available? (name)
19
- Gem.available? name
20
- end
21
- end
22
- end