media-path 0.1.4 → 0.2.pre

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 – 2010 Jakub Stastny aka Botanicus
1
+ Copyright (c) 2009 Jakub Stastny aka Botanicus
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative "lib/media-path/version"
4
+
5
+ # ENV setup for external commands
6
+ ENV["RUBYLIB"] = Dir["vendor/*/lib"].join(":")
7
+ $LOAD_PATH.clear.push(*Dir["vendor/*/lib"])
8
+
9
+ # encoding
10
+ Encoding.default_internal = "utf-8"
11
+ Encoding.default_external = "utf-8"
12
+
13
+ # http://support.runcoderun.com/faqs/builds/how-do-i-run-rake-with-trace-enabled
14
+ Rake.application.options.trace = true
15
+
16
+ # default task for RunCodeRun.com
17
+ task :default => ["submodules:init", :spec]
18
+
19
+ # load tasks
20
+ Dir["tasks/*.rake"].each do |taskfile|
21
+ begin
22
+ load File.join(Dir.pwd, taskfile)
23
+ rescue Exception => exception
24
+ puts "Exception #{exception.class} occured during loading #{taskfile}:"
25
+ puts exception.message
26
+ puts exception.backtrace
27
+ end
28
+ end
@@ -22,30 +22,30 @@ class MediaPath
22
22
 
23
23
  # @since 0.0.1
24
24
  def self.media_root
25
- @media_root
25
+ @@media_root rescue nil
26
26
  end
27
27
 
28
28
  def self.media_root=(path)
29
- @media_root = self.check_directory_path(path)
29
+ @@media_root = self.check_directory_path(path)
30
30
  end
31
31
 
32
32
  # @since 0.0.1
33
33
  def self.root
34
- @root ||= Dir.pwd
34
+ @@root rescue Dir.pwd
35
35
  end
36
36
 
37
37
  # @since 0.0.1
38
38
  def self.root=(path)
39
- @root = self.check_directory_path(path)
39
+ @@root = self.check_directory_path(path)
40
40
  end
41
41
 
42
42
  # @since 0.0.1
43
43
  def self.rewrite_rules
44
- @rewrite_rules ||= Array.new
44
+ @@rewrite_rules rescue Array.new
45
45
  end
46
46
 
47
47
  def self.rewrite_rules=(rules)
48
- @rewrite_rules = rules
48
+ @@rewrite_rules = rules
49
49
  end
50
50
 
51
51
  self.rewrite_rules ||= Array.new
@@ -54,7 +54,7 @@ class MediaPath
54
54
  # @note It make problems in case of reloading
55
55
  def self.rewrite(&rule)
56
56
  # @@rewrite_rules.push(&rule) # WTF?
57
- @rewrite_rules += [rule]
57
+ @@rewrite_rules += [rule]
58
58
  end
59
59
 
60
60
  # @since 0.0.1
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ # NOTE: Do not edit this file manually, this
4
+ # file is regenerated by task rake version:increase
5
+ module MediaPath
6
+ VERSION ||= "0.1.2"
7
+ end
@@ -2,23 +2,26 @@
2
2
  # encoding: utf-8
3
3
 
4
4
  # NOTE: we can't use require_relative because when we run gem build, it use eval for executing this file
5
- require "base64"
5
+ require File.join(File.dirname(__FILE__), "lib", "media-path", "version")
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "media-path"
9
- s.version = "0.1.4"
9
+ s.version = MediaPath::VERSION
10
10
  s.authors = ["Jakub Šťastný aka Botanicus"]
11
11
  s.homepage = "http://github.com/botanicus/media-path"
12
12
  s.summary = "MediaPath abstraction that provides easier interaction with paths and corresponding URLs." # TODO
13
13
  s.description = "" # TODO
14
- s.email = Base64.decode64("c3Rhc3RueUAxMDFpZGVhcy5jeg==\n")
14
+ s.cert_chain = nil
15
+ s.email = ["knava.bestvinensis", "gmail.com"].join("@")
15
16
  s.has_rdoc = true
16
17
 
17
18
  # files
18
- s.files = `git ls-files`.split("\n")
19
-
19
+ s.files = Dir.glob("**/*") - Dir.glob("pkg/*")
20
20
  s.require_paths = ["lib"]
21
21
 
22
+ # Ruby version
23
+ s.required_ruby_version = ::Gem::Requirement.new("~> 1.9")
24
+
22
25
  # RubyForge
23
26
  s.rubyforge_project = "media-path"
24
27
  end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env gem build
2
+ # encoding: utf-8
3
+
4
+ # NOTE: we can't use require_relative because when we run gem build, it use eval for executing this file
5
+ require File.join(File.dirname(__FILE__), "lib", "media-path", "version")
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "media-path"
9
+ s.version = '0.2.pre'
10
+ s.authors = ["Jakub Šťastný aka Botanicus"]
11
+ s.homepage = "http://github.com/botanicus/media-path"
12
+ s.summary = "MediaPath abstraction that provides easier interaction with paths and corresponding URLs." # TODO
13
+ s.description = "" # TODO
14
+ s.cert_chain = nil
15
+ s.email = ["knava.bestvinensis", "gmail.com"].join("@")
16
+ s.has_rdoc = true
17
+
18
+ # files
19
+ s.files = Dir.glob("**/*") - Dir.glob("pkg/*")
20
+ s.require_paths = ["lib"]
21
+
22
+ # Ruby version
23
+ s.required_ruby_version = ::Gem::Requirement.new("~> 1.9")
24
+
25
+ # RubyForge
26
+ s.rubyforge_project = "media-path"
27
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ Dir[File.join(File.dirname(__FILE__), "..", "vendor", "*")].each do |path|
5
+ if File.directory?(path) && Dir["#{path}/*"].empty?
6
+ warn "Dependency #{File.basename(path)} in vendor seems to be empty. Run git submodule init && git submodule update to checkout it."
7
+ elsif File.directory?(path) && File.directory?(File.join(path, "lib"))
8
+ $:.unshift File.join(path, "lib")
9
+ end
10
+ end
11
+
12
+ ARGV.push("spec") if ARGV.empty?
13
+
14
+ load File.expand_path(File.join(File.dirname(__FILE__), "..", "vendor", "rspec", "bin", "spec"))
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ # http://github.com/somebee/rbench/tree/master
4
+ desc "Run all benchmarks"
5
+ task :bm do
6
+ abort "Benchmarks doesn't work at the moment"
7
+ require "rbench"
8
+ Dir["#{Dir.pwd}/benchmarks/bm/*.rb"].each do |benchmark|
9
+ load benchmark
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ desc "Build the gem"
4
+ task :build do
5
+ sh "gem build media-path.gemspec"
6
+ end
7
+
8
+ namespace :build do
9
+ desc "Build the prerelease gem"
10
+ task :prerelease do
11
+ gemspec = "media-path.gemspec"
12
+ content = File.read(gemspec)
13
+ prename = "#{gemspec.split(".").first}.pre.gemspec"
14
+ # 0.1.1 => 0.2
15
+ version = MediaPath::VERSION.sub(/^(\d+)\.(\d+).*$/) { "#$1.#{$2.to_i + 1}" }
16
+ puts "Current #{MediaPath::VERSION} => #{version} pre"
17
+ File.open(prename, "w") do |file|
18
+ file.puts(content.gsub(/(\w+::VERSION)/, "'#{version}.pre'"))
19
+ end
20
+ sh "gem build #{prename}"
21
+ rm prename
22
+ end
23
+ end
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ desc "Install Git hooks"
4
+ task :hooks do
5
+ if Dir.exist?(".git/hooks")
6
+ abort "You must remove .git/hooks first"
7
+ else
8
+ # do not symlink them, otherwise git will add samples
9
+ # FIXME: permissions
10
+ cp_r "support/hooks", ".git/hooks"
11
+ end
12
+ end
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+
3
+ desc "Release new version of media-path"
4
+ task release: ["version:increase", "release:tag", "release:gemcutter"]
5
+
6
+ namespace :version do
7
+ task :increase do
8
+ puts "Which version are you just releasing (previous version is #{MediaPath::VERSION})"
9
+ version = STDIN.gets.chomp
10
+ File.open("lib/media-path/version.rb", "w") do |file|
11
+ file.puts <<-EOF
12
+ # encoding: utf-8
13
+
14
+ # NOTE: Do not edit this file manually, this
15
+ # file is regenerated by task rake version:increase
16
+ module MediaPath
17
+ VERSION ||= "#{version}"
18
+ end
19
+ EOF
20
+ end
21
+
22
+ MediaPath.const_set("VERSION", version) # so other release tasks will work
23
+ sh "git commit lib/media-path/version.rb -m 'Increased version to #{version}'"
24
+ end
25
+ end
26
+
27
+ namespace :release do
28
+ desc "Create Git tag"
29
+ task :tag do
30
+ puts "Creating new git tag #{MediaPath::VERSION} and pushing it online ..."
31
+ sh "git tag -a -m 'Version #{MediaPath::VERSION}' #{MediaPath::VERSION}"
32
+ sh "git push --tags"
33
+ puts "Tag #{MediaPath::VERSION} was created and pushed to GitHub."
34
+ end
35
+
36
+ desc "Push gem to Gemcutter"
37
+ task :gemcutter => :build do
38
+ puts "Pushing to Gemcutter ..."
39
+ sh "gem push #{Dir["*.gem"].last}"
40
+ end
41
+ end
42
+
43
+ desc "Create and push prerelease gem"
44
+ task :prerelease => "build:prerelease" do
45
+ puts "Pushing to Gemcutter ..."
46
+ sh "gem push #{Dir["*.pre.gem"].last}"
47
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ desc "Run specs"
4
+ task :spec, :path do |task, args|
5
+ exec "./script/spec --options spec/spec.opts #{args.path || "spec"}"
6
+ end
7
+
8
+ desc "Create stubs of all library files."
9
+ task "spec:stubs" do
10
+ Dir.glob("lib/**/*.rb").each do |file|
11
+ specfile = file.sub(/^lib/, "spec").sub(/\.rb$/, '_spec.rb')
12
+ unless File.exist?(specfile)
13
+ %x[mkdir -p #{File.dirname(specfile)}]
14
+ %x[touch #{specfile}]
15
+ puts "Created #{specfile}"
16
+ end
17
+ end
18
+ (Dir.glob("spec/media-path/**/*.rb") + ["spec/media-path_spec.rb"]).each do |file|
19
+ libfile = file.sub(/spec/, "lib").sub(/_spec\.rb$/, '.rb')
20
+ if !File.exist?(libfile) && File.zero?(file)
21
+ %x[rm #{file}]
22
+ puts "Removed empty file #{file}"
23
+ elsif !File.exist?(libfile)
24
+ puts "File exists just in spec, not in lib: #{file}"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ # === Helpers === #
4
+ def submodules(&block)
5
+ File.foreach(File.join(File.dirname(__FILE__), "..", ".gitmodules")) do |line|
6
+ if line.match(%r{submodule "(.+)"})
7
+ block.call($1)
8
+ end
9
+ end
10
+ end
11
+
12
+ # === Tasks === #
13
+ namespace :submodules do
14
+ desc "Init submodules"
15
+ task :init do
16
+ sh "git submodule init"
17
+ end
18
+
19
+ desc "Update submodules"
20
+ task :update do
21
+ submodules do |path|
22
+ if File.directory?(path) && File.directory?(File.join(path, ".git"))
23
+ Dir.chdir(path) do
24
+ puts "=> #{path}"
25
+ sh "git reset --hard"
26
+ sh "git fetch"
27
+ sh "git reset origin/master --hard"
28
+ puts
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ # template, textile or rdoc or md
4
+ # -t: template [available: default, javadoc]
5
+ # -m: markup style used in documentation [available: textile, markdown, rdoc]
6
+ desc "Generate Yardoc documentation for media-path"
7
+ task :yardoc do
8
+ sh "yardoc -r README.textile lib/**/*.rb -t default"
9
+ end
metadata CHANGED
@@ -1,60 +1,73 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: media-path
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.4
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.pre
6
5
  platform: ruby
7
- authors:
8
- - Jakub Šťastný aka Botanicus
6
+ authors:
7
+ - "Jakub \xC5\xA0\xC5\xA5astn\xC3\xBD aka Botanicus"
9
8
  autorequire:
10
9
  bindir: bin
11
- cert_chain: []
12
- date: 2013-04-26 00:00:00.000000000 Z
10
+ cert_chain:
11
+ date: 2010-01-01 00:00:00 +00:00
12
+ default_executable:
13
13
  dependencies: []
14
- description: ''
15
- email: !binary |-
16
- c3Rhc3RueUAxMDFpZGVhcy5jeg==
14
+
15
+ description: ""
16
+ email: knava.bestvinensis@gmail.com
17
17
  executables: []
18
+
18
19
  extensions: []
20
+
19
21
  extra_rdoc_files: []
20
- files:
21
- - .gitignore
22
- - .rspec
22
+
23
+ files:
23
24
  - CHANGELOG
24
- - Gemfile
25
+ - lib/media-path/version.rb
26
+ - lib/media-path.rb
25
27
  - LICENSE
26
28
  - README.textile
27
- - TODO.txt
28
- - lib/media-path.rb
29
29
  - media-path.gemspec
30
+ - media-path.pre.gemspec
30
31
  - script/spec
32
+ - tasks/benchmark.rake
33
+ - tasks/release.rake
34
+ - tasks/yardoc.rake
35
+ - tasks/hooks.rake
36
+ - tasks/gem.rake
37
+ - tasks/spec.rake
38
+ - tasks/submodules.rake
39
+ - Rakefile
40
+ - TODO.txt
31
41
  - spec/media-path_spec.rb
32
- - spec/spec.opts
33
42
  - spec/stubs/blog/public/js/moo.js
34
- - tasks.rb
43
+ - spec/spec.opts
44
+ has_rdoc: true
35
45
  homepage: http://github.com/botanicus/media-path
36
46
  licenses: []
47
+
37
48
  post_install_message:
38
49
  rdoc_options: []
39
- require_paths:
50
+
51
+ require_paths:
40
52
  - lib
41
- required_ruby_version: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
- required_rubygems_version: !ruby/object:Gem::Requirement
48
- none: false
49
- requirements:
50
- - - ! '>='
51
- - !ruby/object:Gem::Version
52
- version: '0'
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: "1.9"
58
+ version:
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">"
62
+ - !ruby/object:Gem::Version
63
+ version: 1.3.1
64
+ version:
53
65
  requirements: []
66
+
54
67
  rubyforge_project: media-path
55
- rubygems_version: 1.8.23
68
+ rubygems_version: 1.3.5
56
69
  signing_key:
57
70
  specification_version: 3
58
- summary: MediaPath abstraction that provides easier interaction with paths and corresponding
59
- URLs.
71
+ summary: MediaPath abstraction that provides easier interaction with paths and corresponding URLs.
60
72
  test_files: []
73
+
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /*.gem
2
- .rvmrc
3
-
4
- .DS_Store
5
- .cache
6
- .yardoc
7
-
8
- script/*
9
- gems/*
10
- !gems/cache
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --colour
2
- --format
3
- progress
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- # configuration
2
- bundle_path "gems"
3
- bin_path "script"
4
- disable_rubygems
5
-
6
- # gems
7
- gem "nake"
8
- gem "rspec", only: "test"
data/tasks.rb DELETED
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env nake
2
- # encoding: utf-8
3
-
4
- begin
5
- require File.expand_path("../.bundle/environment", __FILE__)
6
- rescue LoadError
7
- require "bundler"
8
- Bundler.setup
9
- end
10
-
11
- $LOAD_PATH.unshift(File.expand_path("../lib", __FILE__))
12
-
13
- require "nake/tasks/gem"
14
- require "nake/tasks/spec"
15
- require "nake/tasks/release"
16
-
17
- begin
18
- load "code-cleaner.nake"
19
- Nake::Task["hooks:whitespace:install"].tap do |task|
20
- task.config[:path] = "script"
21
- task.config[:encoding] = "utf-8"
22
- task.config[:whitelist] = '(bin/[^/]+|.+\.(rb|rake|nake|thor|task))$'
23
- end
24
- rescue LoadError
25
- warn "If you want to contribute to MediaPath, please install code-cleaner and then run ./tasks.rb hooks:whitespace:install to get Git pre-commit hook for removing trailing whitespace."
26
- end
27
-
28
- require_relative "lib/media-path"
29
-
30
- # Setup encoding, so all the operations
31
- # with strings from another files will work
32
- Encoding.default_internal = "utf-8"
33
- Encoding.default_external = "utf-8"
34
-
35
- Task[:build].config[:gemspec] = "media-path.gemspec"
36
- Task[:prerelease].config[:gemspec] = "media-path.pre.gemspec"
37
- Task[:release].config[:name] = "media-path"
38
- Task[:release].config[:version] = MediaPath::VERSION