pupu 0.0.4.pre → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -18,3 +18,11 @@
18
18
 
19
19
  = Version 0.0.4
20
20
  * Added Rails example app
21
+ * pupu reinstall & pupu install --force
22
+ * Added Pupu.framework
23
+ * Added Pupu.logger
24
+ * Added Pupu.environment & Pupu.environment?
25
+ * Added --ruby & --no-ruby options to the generator
26
+
27
+ = Version 0.0.5
28
+ * Added if option to javascript/stylesheet, so you can use styleshett "ie", if: "lt IE 8"
data/bin/pupu CHANGED
@@ -16,8 +16,9 @@ require "pupu/cli"
16
16
  def usage
17
17
  <<-HELP
18
18
  === Usage ===
19
- pupu install [pupu]
19
+ pupu install [pupu] [-f|--force]
20
20
  pupu uninstall [pupu]
21
+ pupu reinstall [pupu]
21
22
  pupu update [pupu|all]
22
23
  pupu list
23
24
  pupu check
@@ -34,6 +35,8 @@ begin
34
35
  Pupu::CLI.new(ARGV).install
35
36
  when "uninstall", "remove"
36
37
  Pupu::CLI.new(ARGV).uninstall
38
+ when "reinstall"
39
+ Pupu::CLI.new(ARGV, force: true).install
37
40
  when "update"
38
41
  Pupu::CLI.new(ARGV).update
39
42
  when "list" # list all pupus
@@ -3,6 +3,16 @@
3
3
  require "pupu"
4
4
  require "pupu/helpers"
5
5
 
6
+ Pupu.framework = :merb
7
+
8
+ def Pupu.environment
9
+ Merb.environment
10
+ end
11
+
12
+ def Pupu.logger
13
+ Merb.logger
14
+ end
15
+
6
16
  Merb::BootLoader.before_app_loads do
7
17
  Pupu.root = Merb.root
8
18
  Pupu.media_root = File.join(Merb.root, "public")
@@ -3,6 +3,16 @@
3
3
  require "pupu"
4
4
  require "pupu/helpers"
5
5
 
6
+ Pupu.framework = :rails
7
+
8
+ def Pupu.environment
9
+ Rails.environment
10
+ end
11
+
12
+ def Pupu.logger
13
+ Rails.logger
14
+ end
15
+
6
16
  Pupu.root = Rails.root
7
17
  Pupu.media_root = File.join(Rails.root, "public")
8
18
  ActionView::Base.send(:include, Pupu::Helpers)
@@ -3,6 +3,16 @@
3
3
  require "pupu"
4
4
  require "pupu/helpers"
5
5
 
6
+ Pupu.framework = :rango
7
+
8
+ def Pupu.environment
9
+ Rango.environment
10
+ end
11
+
12
+ def Pupu.logger
13
+ Rango.logger
14
+ end
15
+
6
16
  Rango.after_boot(:register_pupu) do
7
17
  Pupu.root = Rango.root
8
18
  #Pupu.media_prefix = Project.settings.media_prefix
@@ -9,7 +9,7 @@ require "pupu/pupu"
9
9
  require "pupu/github"
10
10
 
11
11
  # copyied from merb.thor, this part is actually my code as well :)
12
- module ColorfulMessages
12
+ module Kernel
13
13
  # red
14
14
  def error(*messages)
15
15
  puts messages.map { |msg| "\033[1;31m#{msg}\033[0m" }
@@ -40,10 +40,9 @@ end
40
40
 
41
41
  module Pupu
42
42
  class CLI
43
- include ColorfulMessages
44
- attr_reader :args
45
- def initialize(args)
46
- @args = args
43
+ attr_reader :args, :options
44
+ def initialize(args, options = Hash.new)
45
+ @args, @options = args, options
47
46
  self.detect
48
47
  self.load_config
49
48
  self.parse_argv
@@ -88,8 +87,9 @@ module Pupu
88
87
  def install
89
88
  self.args.each do |pupu|
90
89
  begin
91
- GitHub.install(pupu)
92
- rescue PluginIsAlreadyInstalled
90
+ GitHub.install(pupu, options)
91
+ rescue PluginIsAlreadyInstalled => e
92
+ puts e.backtrace.join("\n- ")
93
93
  info "Plugin #{pupu} is already installed, skipping"
94
94
  end
95
95
  end
@@ -51,15 +51,22 @@ module Pupu
51
51
  def javascript(basename, params = Hash.new)
52
52
  path = @pupu.javascript(basename).url
53
53
  tag = "<script src='#{path}' type='text/javascript'></script>"
54
+ if params[:if]
55
+ tag = "<!--[if #{params[:if]}]>" + tag + "<![endif]-->"
56
+ end
54
57
  @files.push(path)
55
58
  @output.push(tag)
56
59
  end
57
60
 
58
61
  def stylesheet(basename, params = Hash.new)
59
62
  path = @pupu.stylesheet(basename).url
63
+ condition = params.delete(:if)
60
64
  default = {media: 'screen', rel: 'stylesheet', type: 'text/css'}
61
65
  params = default.merge(params)
62
66
  tag = "<link href='#{path}' #{params.to_html_attrs} />"
67
+ if condition
68
+ tag = "<!--[if #{condition}]>" + tag + "<![endif]-->"
69
+ end
63
70
  @files.push(path)
64
71
  @output.push(tag)
65
72
  end
@@ -21,13 +21,14 @@ module Pupu
21
21
  class << self
22
22
  include ShellExtensions
23
23
  # GitHub.install("autocompleter")
24
- # GitHub.install("botanicus/autocompleter")
25
- def install(repo)
24
+ # GitHub.install("botanicus/autocompleter", force: true)
25
+ def install(repo, options = Hash.new)
26
26
  user, repo = repo.split("/") if repo.match(%r{/})
27
27
  user = ENV["USER"] unless user
28
28
  url = "git://github.com/#{user}/pupu-#{repo}.git"
29
- self.install_files(repo, url)
30
- self.install_dependencies(@pupu)
29
+ info "Installing #{repo}"
30
+ self.install_files(repo, url, options)
31
+ self.install_dependencies(@pupu, options)
31
32
  # TODO: git commit [files] -m "Added pupu #{repo} from #{url}"
32
33
  end
33
34
 
@@ -73,17 +74,22 @@ module Pupu
73
74
  end
74
75
  end
75
76
 
76
- def install_dependencies(pupu)
77
+ def install_dependencies(pupu, options = Hash.new)
77
78
  dsl = DSL.new(pupu)
78
79
  dsl.instance_eval(File.read(pupu.file("config.rb").path))
79
80
  dsl.get_dependencies.each do |dependency|
80
- self.install(dependency.name.to_s) # FIXME: "user/repo"
81
+ info "Installing dependency #{dependency}"
82
+ self.install(dependency.name.to_s, options) # FIXME: "user/repo"
81
83
  end
82
84
  end
83
85
 
84
- def install_files(repo, url)
86
+ def install_files(repo, url, options = Hash.new)
85
87
  chdir do |media_dir|
86
- raise PluginIsAlreadyInstalled if File.directory?(repo) # TODO: custom exception class
88
+ if File.directory?(repo) && !options[:force]
89
+ raise PluginIsAlreadyInstalled, "Pupu #{repo} already exist"
90
+ elsif File.directory?(repo) && options[:force]
91
+ FileUtils.rm_r(repo)
92
+ end
87
93
  run("git clone #{url} #{repo}") || abort("Git failed")
88
94
  Dir.chdir(repo) do
89
95
  proceed_files(repo, url)
@@ -17,6 +17,18 @@ module Pupu
17
17
  @@root = path
18
18
  end
19
19
 
20
+ def self.framework
21
+ @@framework
22
+ end
23
+
24
+ def self.framework=(framework)
25
+ @@framework = framework
26
+ end
27
+
28
+ def self.environment?(environment)
29
+ self.environment.eql?(environment)
30
+ end
31
+
20
32
  # @example Pupu.media_prefix("media").url
21
33
  # => "/media/pupu/autocompleter/javascripts/autocompleter.js"
22
34
  def self.media_prefix=(prefix)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Pupu
4
- VERSION = "0.0.4"
4
+ VERSION = "0.0.5"
5
5
  end
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env gem build
2
+ # encoding: utf-8
3
+
4
+ # Run ./<%= @name %>.gemspec or gem build <%= @name %>.gemspec
5
+ # NOTE: we can't use require_relative because when we run gem build, it use eval for executing this file
6
+ require File.join(File.dirname(__FILE__), "lib", "<%= @name %>", "version")
7
+ require "base64"
8
+
9
+ Gem::Specification.new do |s|
10
+ s.name = "<%= @name %>"
11
+ s.version = <%= @constant %>::VERSION
12
+ s.authors = ["<%= @full_name %>"]
13
+ s.homepage = "http://github.com/<%= @github_user %>/<%= @github_repository %>"
14
+ s.summary = "" # TODO: summary
15
+ s.description = "" # TODO: long description
16
+ s.cert_chain = nil
17
+ s.email = Base64.decode64() # TODO: your encrypted e-mail
18
+ s.has_rdoc = true
19
+
20
+ # files
21
+ s.files = `git ls-files`.split("\n")
22
+
23
+ s.executables = Dir["bin/*"].map(&File.method(:basename))
24
+ s.default_executable = "<%= @name %>"
25
+ s.require_paths = ["lib"]
26
+
27
+ # Ruby version
28
+ s.required_ruby_version = ::Gem::Requirement.new(">= 1.9")
29
+
30
+ # runtime dependencies
31
+ # s.add_dependency "my-gem"
32
+
33
+ # development dependencies
34
+ # use gem install <%= @name %> --development if you want to install them
35
+ # s.add_development_dependency "simple-templater"
36
+
37
+ begin
38
+ require "changelog"
39
+ rescue LoadError
40
+ warn "You have to have changelog gem installed for post install message"
41
+ else
42
+ s.post_install_message = CHANGELOG.new.version_changes
43
+ end
44
+
45
+ # RubyForge
46
+ s.rubyforge_project = "<%= @name %>"
47
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env gem build
2
+ # encoding: utf-8
3
+
4
+ # You might think this is a terrible mess and guess what, you're
5
+ # right mate! However say thanks to authors of RubyGems, not me.
6
+ eval(File.read("<%= @name %>.gemspec")).tap do |specification|
7
+ specification.version = "#{specification.version}.pre"
8
+ end
@@ -5,5 +5,8 @@
5
5
  .DS_Store
6
6
  .yardoc
7
7
  .cache
8
- pkg/
9
- nbproject/
8
+
9
+ /*.gem
10
+ script/*
11
+ gems/*
12
+ !gems/cache
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env rip install
2
+
3
+ # Syntax:
4
+ # repository [tag or commit to install]
5
+ git://github.com/botanicus/pupu.git
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ # This file will be loaded automatically when the pupu helper is used
4
+ # If you don't want to load this file, use pupu :whatever, helpers: false
5
+
6
+ $LOAD_PATH.unshift(File.expand_path("lib", __FILE__))
7
+
8
+ begin
9
+ require "<%= @name %>/adapters/#{Pupu.framework}"
10
+ rescue LoadError
11
+ # If you don't have adapter file, everything should work anyway since Pupu::Helpers
12
+ # mixin is included into helper module of your framework, so we can fail silently
13
+ end
14
+
15
+ module Pupu::Helpers
16
+ include <%= @constant %>::Helpers
17
+ end
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+
3
+ module <%= @constant %>
4
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative "spec_helper"
4
+
5
+ describe <%= @constant %> do
6
+ it "should have VERSION constant" do
7
+ <%= @constant %>::VERSION.should be_kind_of(String)
8
+ <%= @constant %>::VERSION.should match(/^\d+\.\d+\.\d+$/)
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ --colour
2
+ --format
3
+ progress
4
+ --loadby
5
+ mtime
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ # dependencies
4
+ require "spec"
5
+
6
+ # setup load paths
7
+ $:.unshift(File.expand_path("../lib"), __FILE__)
@@ -8,4 +8,12 @@ require "simple-templater/hooks/postprocess/git_repository"
8
8
  hook do |generator, context|
9
9
  # simple-templater create rango --full-name="Jakub Stastny"
10
10
  generator.after Hooks::GitRepository
11
+
12
+ unless context[:ruby]
13
+ rm "init.rb"
14
+ rm "deps.rb"
15
+ rm "#{context[:name]}.gemspec"
16
+ rm "#{context[:name]}.pre.gemspec"
17
+ rm_r "lib"
18
+ end
11
19
  end
@@ -10,6 +10,7 @@ require "simple-templater/hooks/preprocess/full_name"
10
10
  # --javascripts=mootools-core,mootools-more | --no-javascripts
11
11
  # --stylesheets=one,two | --no-stylesheets
12
12
  # --dependencies=mootools,blueprint | --no-dependencies
13
+ # --ruby || --no-ruby
13
14
  hook do |generator, context|
14
15
  generator.before Hooks::FullName, Hooks::GithubUser
15
16
  generator.target = "pupu-#{context[:name]}" unless generator.target.match(/^pupu-/) # this is the convention
@@ -22,4 +23,7 @@ hook do |generator, context|
22
23
  unless context[:github_repository] && context[:github_repository].match(/^pupu-/)
23
24
  context[:github_repository] = "pupu-#{context[:github_repository]}"
24
25
  end
26
+ if context[:ruby]
27
+ context[:constant] = context[:name].camel_case
28
+ end
25
29
  end
data/tasks.rb CHANGED
@@ -1,15 +1,14 @@
1
- #!./script/nake
1
+ #!/usr/bin/env nake
2
2
  # encoding: utf-8
3
3
 
4
4
  begin
5
- require_relative "gems/environment.rb"
5
+ require File.expand_path("../.bundle/environment", __FILE__)
6
6
  rescue LoadError
7
- abort "You have to install bundler and run gem bundle first!"
7
+ require "bundler"
8
+ Bundler.setup
8
9
  end
9
10
 
10
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
11
-
12
- ENV["PATH"] = "script:#{ENV["PATH"]}"
11
+ $LOAD_PATH.unshift(File.expand_path("../lib", __FILE__))
13
12
 
14
13
  require "pupu/version"
15
14
  require "nake/tasks/gem"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pupu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.pre
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jakub \xC5\xA0\xC5\xA5astn\xC3\xBD aka Botanicus"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
- date: 2010-01-22 00:00:00 +00:00
11
+ date: 2010-02-24 00:00:00 +00:00
12
12
  default_executable: pupu
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
@@ -364,16 +364,27 @@ files:
364
364
  - spec/pupu/pupu_spec.rb
365
365
  - spec/spec.opts
366
366
  - spec/spec_helper.rb
367
+ - stubs/pupu/content/%name%.gemspec.rbt
368
+ - stubs/pupu/content/%name%.pre.gemspec.rbt
367
369
  - stubs/pupu/content/.gitignore
368
370
  - stubs/pupu/content/CHANGELOG
369
371
  - stubs/pupu/content/LICENSE.rbt
370
372
  - stubs/pupu/content/README.textile.rbt
371
373
  - stubs/pupu/content/TODO.txt
372
374
  - stubs/pupu/content/config.rb.rbt
375
+ - stubs/pupu/content/deps.rip
373
376
  - stubs/pupu/content/images/.gitignore
377
+ - stubs/pupu/content/init.rb.rbt
374
378
  - stubs/pupu/content/initializers/%name%.css
375
379
  - stubs/pupu/content/initializers/%name%.js
376
380
  - stubs/pupu/content/javascripts/%javascript%.js
381
+ - stubs/pupu/content/lib/%name%.rb.rbt
382
+ - stubs/pupu/content/lib/%name%/adapters/rails.rb
383
+ - stubs/pupu/content/lib/%name%/adapters/rango.rb
384
+ - stubs/pupu/content/spec/%name%/.gitignore
385
+ - stubs/pupu/content/spec/%name%_spec.rb.rbt
386
+ - stubs/pupu/content/spec/spec.opts
387
+ - stubs/pupu/content/spec/spec_helper.rb.rbt
377
388
  - stubs/pupu/content/stylesheets/%stylesheet%.css
378
389
  - stubs/pupu/metadata.yml
379
390
  - stubs/pupu/postprocess.rb
@@ -383,7 +394,7 @@ has_rdoc: true
383
394
  homepage: http://github.com/botanicus/pupu
384
395
  licenses: []
385
396
 
386
- post_install_message: "[\e[32mVersion 0.0.4\e[0m] Added Rails example app\n"
397
+ post_install_message: "[\e[32mVersion 0.0.5\e[0m] Added if option to javascript/stylesheet, so you can use styleshett \"ie\", if: \"lt IE 8\"\n"
387
398
  rdoc_options: []
388
399
 
389
400
  require_paths:
@@ -396,9 +407,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
396
407
  version:
397
408
  required_rubygems_version: !ruby/object:Gem::Requirement
398
409
  requirements:
399
- - - ">"
410
+ - - ">="
400
411
  - !ruby/object:Gem::Version
401
- version: 1.3.1
412
+ version: "0"
402
413
  version:
403
414
  requirements: []
404
415