projectionist-projects 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 302e146066c655ecb011646f9e61c5efc91a23c9
4
- data.tar.gz: 0fd50e365ad0e9ad9cea9a39eb3da28420bd56bf
3
+ metadata.gz: d94b54468a1ad385f2304a3fd79eb825367656f5
4
+ data.tar.gz: 08d9a4dec50141c88a7cf1e467e6c0eb53235cbd
5
5
  SHA512:
6
- metadata.gz: ea6adc12a41b568580f513aeb4cbcab3f9f10998b86169ee3b1a362662607fe20c941d58dac3d2c835655b2017e528663bf381235e16d14d723481df1daaa1cc
7
- data.tar.gz: 6f76e6b9a3845f77d173c03f02b8741758e743930caa9215c465b33d3c824c915ec0c37549453d11912d8df76c7f6fba1baf8ba1266ac882eda4150d93bf530f
6
+ metadata.gz: fc99640426ee0002b05fa9dcd97862dcbaba9378e840d41f250a1fc3baf30870de07f6c8e4ab5fb5271304d447b31774cd9f8e6e6bf03a55b3bfe5b56dad84a2
7
+ data.tar.gz: b0f1554a2492b15ce6bb5bb60df039214df38cf4b7d71c91368ec1a8bf4989a0fe13afdacb4762f3f0c8ae0ea7a82de90a30cd5b4c93ea99455672dfb0e44874
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ spec/output
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format p
2
+ --colour
data/Guardfile ADDED
@@ -0,0 +1,13 @@
1
+ guard :rspec, cmd: "./bin/rspec" do
2
+ require "guard/rspec/dsl"
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ rspec = dsl.rspec
6
+ watch(rspec.spec_helper) { rspec.spec_dir }
7
+ watch(rspec.spec_support) { rspec.spec_dir }
8
+ watch(rspec.spec_files)
9
+
10
+ # Ruby files
11
+ ruby = dsl.ruby
12
+ dsl.watch_spec_files_for(ruby.lib_files)
13
+ end
data/bin/rspec ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'rspec')
data/exe/projection CHANGED
@@ -6,60 +6,107 @@ require "highline/import"
6
6
  require "pathname"
7
7
  require "fileutils"
8
8
  require "optparse"
9
+ require "projectionist/projects"
9
10
 
10
11
  include FileUtils
11
12
 
12
- terminal_width, _ = HighLine::SystemExtensions.terminal_size
13
- projections_path = File.expand_path("../../projections", __FILE__)
14
- available_files = Dir["#{projections_path}/*.projections.json"]
15
- @names_to_files = Hash[available_files.map do |filename|
13
+ include Projectionist::Projects
14
+ extend Projectionist::Projects
15
+
16
+ AVAILABLE_FILES = Dir["#{DOWNLOAD_DIRECTORY}/*.projections.json"]
17
+ DOWNLOADED_FILES = Hash[AVAILABLE_FILES.map do |filename|
16
18
  name = Pathname.new(filename).basename(".projections.json").to_s
17
19
  [name, filename]
18
20
  end]
19
21
 
22
+ def colorize(string, *colors)
23
+ colors = Array(colors)
24
+ HighLine::String.new(string).color(*colors)
25
+ end
26
+
27
+ def setup_cache_directory
28
+ unless File.exist? DOWNLOAD_DIRECTORY
29
+ puts "create projection-projects cache directory (y/N)? #{DOWNLOAD_DIRECTORY}"
30
+ mkdir_p DOWNLOAD_DIRECTORY if "y" == gets.strip.downcase
31
+ end
32
+ end
33
+
20
34
  def copy_projection(name, source, destination = "#{getwd}/.projections.json")
21
- colored_name = HighLine::String.new(name).color(:red)
22
35
  unless source
23
- puts "#{colored_name} projection was not found. Use `projection -l` to show available projection files."
36
+ puts "#{colorize(name, :red)} projection was not found. Use `projection -l` to show available projection files."
24
37
  exit -1
25
38
  end
26
39
 
27
40
  cp source, destination
28
- puts "Projection #{colored_name} was copied to the current directory."
41
+ puts "Projection #{colorize(name, :red)} was copied to the current directory."
29
42
  end
30
43
 
31
- if ARGV.count > 0
32
- parser = OptionParser.new do |opts|
33
- opts.banner = "Usage: projection [options]"
44
+ def run_interactive_shell
45
+ choose do |menu|
46
+ menu.prompt = "What type of project? "
47
+ menu.choices(*DOWNLOADED_FILES.keys) { |name| copy_projection name, DOWNLOADED_FILES[name] }
48
+ end
49
+ exit
50
+ end
34
51
 
35
- opts.on("-p", "--path [name]", "Lists out the paths for the matching name") do |value|
36
- value ||= ""
37
- filtered = @names_to_files.select { |name| name.downcase.include? value.downcase }
38
- maximum = filtered.keys.map(&:length).max
39
- filtered.each do |name, path|
40
- puts "#{HighLine::String.new(name.ljust(maximum)).color(:bold, :blue)} #{HighLine::String.new("=>").color(:cyan)} #{HighLine::String.new(path).color(:green)}"
41
- end
42
- exit
52
+ run_interactive_shell if ARGV.count == 0
53
+
54
+ parser = OptionParser.new do |opts|
55
+ opts.banner = "Usage: projection [options]"
56
+
57
+ opts.on("-s", "--setup") do
58
+ setup_cache_directory
59
+ exit
60
+ end
61
+
62
+ opts.on("-p", "--path [name]", "Lists out the paths for the matching name") do |value|
63
+ value ||= ""
64
+ filtered = DOWNLOADED_FILES.select { |name| name.downcase.include? value.downcase }
65
+ maximum = filtered.keys.map(&:length).max
66
+ filtered.each do |name, path|
67
+ puts [
68
+ colorize(name.ljust(maximum), :bold, :blue),
69
+ colorize("=>", :cyan),
70
+ colorize(path, :red)
71
+ ].join(" ")
43
72
  end
73
+ exit
74
+ end
75
+
76
+ opts.on("-l", "--list", "List installed projection names") do |list|
77
+ Projectionist::Projects.fetch.each{ |fetched| puts fetched[:project] }
78
+ exit
79
+ end
44
80
 
45
- opts.on("-l", "--list", "List available projection names") do |list|
46
- @names_to_files.each do |name, path|
47
- puts name
81
+ opts.on("-d", "--download=DOWNLOADS", "Download projections from remote") do |downloads|
82
+ downloads = (downloads || "").split(",").map(&:strip)
83
+
84
+ catch(:server_unavailable) do
85
+ results = Projectionist::Projects.fetch
86
+ projects = results.map { |result| result[:project] }
87
+ maximum = results.map(&:length).max
88
+ filtered = downloads.any? ? (downloads & projects) : projects
89
+
90
+ filtered.each do |project|
91
+ puts "downloading: #{colorize(project.ljust(maximum), :bold, :blue)}"
92
+ Projectionist::Projects.download project: project
48
93
  end
49
94
  exit
50
95
  end
51
96
 
52
- opts.on_tail("-h", "--help") do
53
- puts opts
54
- exit
55
- end
97
+ puts "The server is unavailable.. do you haz internets?"
98
+ exit -1
56
99
  end
57
100
 
58
- parser.parse!
59
- copy_projection ARGV.first, @names_to_files[ARGV.first]
60
- else
61
- choose do |menu|
62
- menu.prompt = "What type of project? "
63
- menu.choices(*@names_to_files.keys) { |name| copy_projection name, @names_to_files[name] }
101
+ opts.on("-i", "--interactive", "Run in interactive mode") do
102
+ run_interactive_shell
103
+ end
104
+
105
+ opts.on_tail("-h", "--help") do
106
+ puts opts
107
+ exit
64
108
  end
65
109
  end
110
+
111
+ parser.parse!
112
+ copy_projection ARGV.first.strip, DOWNLOADED_FILES[ARGV.first.strip]
@@ -1,7 +1,40 @@
1
+ require "net/http"
2
+ require "csv"
1
3
  require "projectionist/projects/version"
2
4
 
3
5
  module Projectionist
4
6
  module Projects
5
- # Your code goes here...
7
+ INDEX_ROOT = "jeremywrowe.github.io"
8
+
9
+ if ENV["TEST"]
10
+ DOWNLOAD_DIRECTORY = File.join(File.expand_path("../../..", __FILE__), "spec", "output")
11
+ else
12
+ DOWNLOAD_DIRECTORY = File.join(ENV["HOME"], ".projection-projects")
13
+ end
14
+
15
+ def self.fetch
16
+ csv_contents = Net::HTTP.get INDEX_ROOT, "/projectionist-projects-files/downloads/index.csv"
17
+ CSV.new(csv_contents, headers: true, header_converters: :symbol)
18
+ .map(&:to_hash)
19
+ rescue SocketError
20
+ throw :server_unavailable
21
+ end
22
+
23
+ def self.download(project:, ask_to_overwrite: true, stdin: -> { gets })
24
+ normalized_project = "#{project}.projections.json"
25
+ destination_file = File.join(DOWNLOAD_DIRECTORY, normalized_project)
26
+
27
+ if ask_to_overwrite && File.exist?(destination_file)
28
+ print "Overwrite existing file? (y/N) "
29
+ return unless stdin.call.strip.downcase == "y"
30
+ end
31
+
32
+ json_contents = Net::HTTP.get INDEX_ROOT, "/projectionist-projects-files/downloads/#{normalized_project}"
33
+ File.open(destination_file, "w") do |file|
34
+ file.write json_contents
35
+ end
36
+ rescue SocketError
37
+ throw :server_unavailable
38
+ end
6
39
  end
7
40
  end
@@ -1,5 +1,5 @@
1
1
  module Projectionist
2
2
  module Projects
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
@@ -24,4 +24,8 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.10"
26
26
  spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.3.0"
28
+ spec.add_development_dependency "byebug", "~> 6.0.2"
29
+ spec.add_development_dependency "simplecov", "~> 0.10.0"
30
+ spec.add_development_dependency "guard-rspec"
27
31
  end
@@ -0,0 +1,16 @@
1
+ {
2
+ "exe/*.rb": {
3
+ "command": "exe",
4
+ "alternate": "spec/exe/{}_spec.rb"
5
+ },
6
+
7
+ "lib/*.rb": {
8
+ "command": "lib",
9
+ "alternate": "spec/{}_spec.rb"
10
+ },
11
+
12
+ "spec/*_spec.rb": {
13
+ "command": "spec",
14
+ "alternate": "lib/{}.rb"
15
+ }
16
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: projectionist-projects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy W. Rowe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-14 00:00:00.000000000 Z
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -52,6 +52,62 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.3.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.3.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 6.0.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 6.0.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.10.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.10.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
55
111
  description: Projectionist + vim make it easier to jump between alternate files. Configuration
56
112
  of projectionist is mind numbing, I hope to reduce that by adding projectionist
57
113
  project files over time.
@@ -63,17 +119,21 @@ extensions: []
63
119
  extra_rdoc_files: []
64
120
  files:
65
121
  - ".gitignore"
122
+ - ".rspec"
66
123
  - ".travis.yml"
67
124
  - Gemfile
125
+ - Guardfile
68
126
  - README.md
69
127
  - Rakefile
70
128
  - bin/console
129
+ - bin/rspec
71
130
  - bin/setup
72
131
  - exe/projection
73
132
  - lib/projectionist/projects.rb
74
133
  - lib/projectionist/projects/version.rb
75
134
  - projectionist-projects.gemspec
76
135
  - projections/ember.projections.json
136
+ - projections/gem.projections.json
77
137
  homepage: https://github.com/jeremywrowe/projectionist-projects
78
138
  licenses:
79
139
  - MIT