ruby_chopped 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ruby_chopped.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,11 @@
1
+ RubyChopped
2
+
3
+ Modeled after (but certainly not affiliated with) the Chopped show on the Food Network, this gem delivers you a Ruby project (or basket) with 2 gems (ingredients) chosen at random. Your challenge: Make something cool with the given gems.
4
+
5
+ Usage
6
+
7
+ gem install ruby_chopped
8
+
9
+ then
10
+
11
+ ruby_chopped new whyday_basket
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bin/ruby_chopped ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'ruby_chopped'
5
+
6
+ if "new" == ARGV.shift && ARGV.first
7
+ folder = ARGV.shift
8
+
9
+ puts "Creating #{folder} basket..."
10
+
11
+ # TODO: Use Ruby for this
12
+ `mkdir #{folder}`
13
+ `mkdir #{folder}/lib`
14
+ `touch #{folder}/lib/#{folder}.rb`
15
+ File.open("#{folder}/Gemfile", "wb+") do |f|
16
+ f << RubyChopped.gemfile_string
17
+ end
18
+
19
+ puts ""
20
+ puts "Your basket is ready. Open the Gemfile to see what you'll be working with today."
21
+
22
+ puts ""
23
+ puts "You'll want to cd into #{folder} and run 'bundle install' first"
24
+ puts "Enjoy!"
25
+ else
26
+ puts "Unknown Action. Please use 'ruby_chopped new my_new_basket'"
27
+ end
28
+
29
+ exit!
@@ -0,0 +1,55 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+
4
+ module RubyChopped
5
+ def self.gemfile_array
6
+ gas = []
7
+ gas << "source \"http://rubygems.org\""
8
+ gas << ""
9
+
10
+ gems = random_gems
11
+ gems.each do |g|
12
+ # Janky way to pull the name
13
+ g = g.first
14
+ name = g["full_name"].split(/-\d\.\d\.\d/).first
15
+ number = g["number"]
16
+ summary = g["summary"]
17
+
18
+ gas << "# #{name}: #{summary}"
19
+ gas << "gem \"#{name}\", \"#{number}\""
20
+ gas << ""
21
+ end
22
+
23
+ gas << "# ENJOY!"
24
+
25
+ gas
26
+ end
27
+
28
+ def self.gemfile_string
29
+ gemfile_array.join("\n")
30
+ end
31
+
32
+ def self.random_gems(limit=2)
33
+ gems = fetch_gems
34
+ gems = pick_gems(gems, limit)
35
+ end
36
+
37
+ def self.pick_gems(gems, limit)
38
+ limit.to_i.times.collect do
39
+ g = gems.delete_at(rand(gems.size))
40
+
41
+ # Skip bundler and rails
42
+ if g.first["full_name"][/(bundler|rails)/]
43
+ pick_gems(gems, 1).first
44
+ else
45
+ g
46
+ end
47
+ end
48
+ end
49
+
50
+ def self.fetch_gems
51
+ gems_json = JSON.parse(RestClient.get("http://rubygems.org/api/v1/downloads/top.json", :accepts => :json))
52
+ gems = gems_json["gems"]
53
+ gems
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module RubyChopped
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ruby_chopped/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ruby_chopped"
7
+ s.version = RubyChopped::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Mark McSpadden"]
10
+ s.email = ["markmcspadden@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Creates a ruby project with two random gems}
13
+ s.description = %q{Creates a ruby project with two random gems from rubygems.org top downloads of the day}
14
+
15
+ s.rubyforge_project = "ruby_chopped"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency 'rest-client', '1.6.3'
23
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_chopped
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Mark McSpadden
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-08-19 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rest-client
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - "="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 1
30
+ - 6
31
+ - 3
32
+ version: 1.6.3
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: Creates a ruby project with two random gems from rubygems.org top downloads of the day
36
+ email:
37
+ - markmcspadden@gmail.com
38
+ executables:
39
+ - ruby_chopped
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - README
48
+ - Rakefile
49
+ - bin/ruby_chopped
50
+ - lib/ruby_chopped.rb
51
+ - lib/ruby_chopped/version.rb
52
+ - ruby_chopped.gemspec
53
+ has_rdoc: true
54
+ homepage: ""
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ requirements: []
79
+
80
+ rubyforge_project: ruby_chopped
81
+ rubygems_version: 1.3.7
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Creates a ruby project with two random gems
85
+ test_files: []
86
+