ez 0.0.3 → 0.5.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c352179b9a780759c9e923d23de75f162cd94af7
4
- data.tar.gz: b470479273475d5b1d97f5fb392c237faebb54ea
3
+ metadata.gz: bb4add590cb7137b0a864fadaf1190a92cce6caa
4
+ data.tar.gz: 29a59670ea52b992b1dc872208f260f3046a10e8
5
5
  SHA512:
6
- metadata.gz: 67d6a3bbad1b7a2165fbe01f1995117a96c418eb4ac8d74e4016aad8df73df0588ae34554ae961cdc77c5b6ebd603606c202ec16bc7d489512debf9578293dc2
7
- data.tar.gz: c40c452e34c92c013b90a3c18fecc466334ab2044ef4db1a6cbbc40492763e45249011d129647dcd60978fac0370e6b5c2dbae4c102bfd555fdba2bc725cf5e2
6
+ metadata.gz: 91f49da3157c021803916a576b230ec862dae42e8d8ee2f2528f7ca609283335782fab0ab11504e897158e3f581eb4313d6e276543e4281458f7a9cd695ca341
7
+ data.tar.gz: 449d5ca509417f2cca9714272bce6cd61e021accd19dfdf79bbc6910596807c870af2999e71403fbb0fe59fefdb43c401a7b283e52c8a5ff737655e521ca3f33
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Ez
1
+ # EZ
2
2
 
3
- TODO: Write a gem description
3
+ For educational purposes only. Makes Rails a bit more beginner-friendly.
4
4
 
5
5
  ## Installation
6
6
 
@@ -16,14 +16,5 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install ez
18
18
 
19
- ## Usage
20
19
 
21
- TODO: Write usage instructions here
22
20
 
23
- ## Contributing
24
-
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
data/ez.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'ez/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "ez"
8
- spec.version = Ez::VERSION
8
+ spec.version = EZ::VERSION
9
9
  spec.authors = ["Jeff Cohen"]
10
10
  spec.email = ["cohen.jeff@gmail.com"]
11
11
  spec.description = "Gem for easier Rails development."
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = []
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_runtime_dependency 'hirb'
22
+
21
23
  spec.add_development_dependency "bundler", "~> 1.3"
22
24
  spec.add_development_dependency "rake", '~> 10.0', '>= 10.0.0'
23
25
  end
data/lib/ez.rb CHANGED
@@ -4,11 +4,32 @@ require 'ez/mapper.rb'
4
4
  require 'ez/apis.rb'
5
5
  require 'ez/domain_modeler.rb'
6
6
  require 'ez/controller.rb'
7
+ require 'ez/model.rb'
7
8
 
8
- module Ez
9
- class MyRailtie < Rails::Railtie
9
+ module EZ
10
+ class Railtie < Rails::Railtie
10
11
  rake_tasks do
11
12
  load "tasks/ez_tasks.rake"
12
13
  end
14
+
15
+ initializer "ez" do
16
+ module ::Hirb
17
+ # A Formatter object formats an output object (using Formatter.format_output) into a string based on the views defined
18
+ # for its class and/or ancestry.
19
+ class Formatter
20
+ def determine_output_class(output)
21
+ if output.respond_to?(:to_a) && to_a_classes.any? {|e| output.is_a?(e) }
22
+ Array(output)[0].class
23
+ else
24
+ if output.is_a?(ActiveRecord::Base)
25
+ Hash
26
+ else
27
+ output.class
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
13
34
  end
14
35
  end
@@ -1,12 +1,25 @@
1
1
  require 'json'
2
2
  require 'open-uri'
3
3
 
4
- module JSON
4
+ module EZ
5
+
6
+ def self.weather(location = 'Evanston, IL')
7
+ # Only cache up to 30 locations to avoid abuse
8
+ @wx = {} unless @wx && @wx.keys.count < 30
9
+
10
+ # Cache based on location
11
+ @wx[location] ||= begin
12
+ puts "Getting the current weather from openweathermap.org..."
13
+ wx = from_api("http://api.openweathermap.org/data/2.5/weather?q=#{location}&units=imperial")
14
+ @wx[location] = wx[:main]
15
+ end
16
+
17
+ end
5
18
 
6
19
  def self.from_api(uri_string)
7
20
  uri = URI.parse(URI.escape(uri_string))
8
- data = open(uri).read
9
- JSON.parse(data)
21
+ string = open(uri).read
22
+ JSON.parse(string, symbolize_names: true)
10
23
  end
11
24
 
12
25
  end
@@ -56,11 +56,11 @@ class SchemaModifier
56
56
  col_type = column[col_name]
57
57
  if db.column_exists?(table_name, col_name.to_sym)
58
58
  unless db.column_exists?(table_name, col_name.to_sym, col_type.to_sym)
59
- display_change "Detected new column type for '#{col_name}' to #{col_type}"
59
+ display_change "Changing column type for '#{col_name}' to #{col_type}"
60
60
  db.change_column(table_name, col_name.to_sym, col_type.to_sym)
61
61
  end
62
62
  else
63
- display_change "Detected new column '#{col_name}' as #{col_type} for model #{model_name}"
63
+ display_change "Adding new column '#{col_name}' as #{col_type} for model #{model_name}"
64
64
  db.add_column(table_name, col_name.to_sym, col_type.to_sym)
65
65
  end
66
66
  end
@@ -76,12 +76,12 @@ class SchemaModifier
76
76
  col_type = column[name]
77
77
  t.send(col_type, name)
78
78
  end
79
- t.timestamps
79
+ # t.timestamps
80
80
  end
81
81
  end
82
82
  filename = "app/models/#{model_name.underscore}.rb"
83
83
  unless File.exists?(filename)
84
- display_change "Creating model file: #{filename}"
84
+ display_change "Creating new model file: #{filename}"
85
85
  File.open(filename, "w") do |f|
86
86
  f.puts "class #{model_name} < ActiveRecord::Base"
87
87
  f.puts "end"
@@ -104,7 +104,7 @@ class SchemaModifier
104
104
  end
105
105
  dead_columns = columns - spec_columns
106
106
  if dead_columns.any?
107
- display_change "Detected unused columns: #{dead_columns.to_sentence} for model #{model_name}"
107
+ display_change "Removing unused columns: #{dead_columns.to_sentence} for model #{model_name}"
108
108
  db.remove_columns(table_name, *dead_columns)
109
109
  end
110
110
  end
@@ -1,3 +1,3 @@
1
- module Ez
2
- VERSION = "0.0.3"
1
+ module EZ
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ez
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Cohen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-18 00:00:00.000000000 Z
11
+ date: 2014-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hirb
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement