codeodor-with 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ == 0.0.2 2009-01-12
2
+
3
+ * 1 minor enhancement:
4
+ * fix gemspec to install without errors
5
+
1
6
  == 0.0.1 2009-01-12
2
7
 
3
8
  * 1 major enhancement:
@@ -1,17 +1,10 @@
1
1
  History.txt
2
2
  Manifest.txt
3
- README
4
3
  README.rdoc
5
4
  Rakefile
6
5
  lib/with.rb
7
6
  lib/with_on_object.rb
8
7
  lib/with_sexp_processor.rb
9
- script/console
10
- script/destroy
11
- script/generate
12
8
  test/foo.rb
13
- test/test_helper.rb
14
9
  test/test_with.rb
15
- test/with_on_object_test.rb
16
- test/with_test.rb
17
- with.tmproj
10
+ test/test_with_on_object.rb
@@ -8,31 +8,31 @@ I sometimes get a little descriptive with my variable names, so when you're doin
8
8
  specifically with one object, it gets especially ugly and repetetive, making the code harder to
9
9
  read than it needs to be:
10
10
 
11
- @contract_participants_on_drugs.contract_id = params[:contract_id]
12
- @contract_participants_on_drugs.participant_name = params[:participant_name]
13
- @contract_participants_on_drugs.drug_conviction = DrugConvictions.find(:wtf => 'this is getting ridiculous')
14
- ...
11
+ @contract_participants_on_drugs.contract_id = params[:contract_id]
12
+ @contract_participants_on_drugs.participant_name = params[:participant_name]
13
+ @contract_participants_on_drugs.drug_conviction = DrugConvictions.find(:wtf => 'this is getting ridiculous')
14
+ ...
15
15
 
16
16
  And so on. It gets ridiculous.
17
17
 
18
18
  Utility Belt implements a with(object) method via a change to Object:
19
19
 
20
- class Object
21
- #utility belt implementation
22
- def with(object, &block)
23
- object.instance_eval &block
20
+ class Object
21
+ #utility belt implementation
22
+ def with(object, &block)
23
+ object.instance_eval &block
24
+ end
24
25
  end
25
- end
26
26
 
27
27
  Unfortunately, that just executes the block in the context of the object, so there isn't any
28
28
  crossover, nor can you perform assignments with attr_accessors (that I was able to do, anyway).
29
29
 
30
30
  So, here's With.object() to fill the void.
31
31
 
32
- With.object(@foo) do
33
- a = "wtf"
34
- b = "this is not as bad"
35
- end
32
+ With.object(@foo) do
33
+ a = "wtf"
34
+ b = "this is not as bad"
35
+ end
36
36
 
37
37
  In the above example, @foo.a and @foo.b are the variables getting set.
38
38
 
@@ -56,19 +56,19 @@ block, and is not on @foo).
56
56
 
57
57
  == SYNOPSIS:
58
58
 
59
- require 'with'
60
- With.object(@foo) do
61
- a = "wtf"
62
- b = "this is not as bad"
63
- end
59
+ require 'with'
60
+ With.object(@foo) do
61
+ a = "wtf"
62
+ b = "this is not as bad"
63
+ end
64
64
 
65
65
  or
66
66
 
67
- require 'with_on_object'
68
- with(@foo) do
69
- a = "wtf"
70
- b = "this is not as bad"
71
- end
67
+ require 'with_on_object'
68
+ with(@foo) do
69
+ a = "wtf"
70
+ b = "this is not as bad"
71
+ end
72
72
 
73
73
  == REQUIREMENTS:
74
74
 
@@ -77,13 +77,13 @@ end
77
77
 
78
78
  == INSTALL:
79
79
 
80
- * sudo gem install codeodor-with -s http://gems. github.com
80
+ sudo gem install codeodor-with -s http://gems.github.com
81
81
 
82
82
  == LICENSE:
83
83
 
84
84
  (The MIT License)
85
85
 
86
- Copyright (c) 2009 FIX
86
+ Copyright (c) 2009 Sammy Larbi
87
87
 
88
88
  Permission is hereby granted, free of charge, to any person obtaining
89
89
  a copy of this software and associated documentation files (the
@@ -2,7 +2,7 @@ require 'with_sexp_processor'
2
2
  require 'parse_tree'
3
3
 
4
4
  class With
5
- VERSION = "0.0.1"
5
+ VERSION = "0.0.2"
6
6
  def self.object(the_object, &block)
7
7
  @the_object = the_object
8
8
  @original_context = block.binding
@@ -1,4 +1,4 @@
1
- require '../lib/with_on_object'
1
+ require 'with_on_object'
2
2
  require 'test/unit'
3
3
  require 'foo'
4
4
 
@@ -86,13 +86,13 @@ class TestWithOnObject < Test::Unit::TestCase
86
86
  end
87
87
 
88
88
  def test_With_works_with_method_call_with_args_using_non_literals
89
- def f(x,y)
89
+ def f2(x,y)
90
90
  398
91
91
  end
92
92
  x = 2
93
93
  y = 5
94
94
  with(@foo) do
95
- a = f(x,y)
95
+ a = f2(x,y)
96
96
  end
97
97
  assert(@foo.a == 398)
98
98
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeodor-with
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sammy Larbi
@@ -40,33 +40,24 @@ extensions: []
40
40
  extra_rdoc_files:
41
41
  - History.txt
42
42
  - Manifest.txt
43
- - PostInstall.txt
44
43
  - README.rdoc
45
44
  files:
46
45
  - History.txt
47
46
  - Manifest.txt
48
- - PostInstall.txt
49
- - README
50
47
  - README.rdoc
51
48
  - Rakefile
52
49
  - lib/with.rb
53
50
  - lib/with_on_object.rb
54
51
  - lib/with_sexp_processor.rb
55
- - script/console
56
- - script/destroy
57
- - script/generate
58
52
  - test/foo.rb
59
- - test/test_helper.rb
60
53
  - test/test_with.rb
61
- - test/with_on_object_test.rb
62
- - test/with_test.rb
63
- - with.tmproj
54
+ - test/test_with_on_object.rb
64
55
  has_rdoc: true
65
56
  homepage: http://github.com/codeodor/with/tree/master
66
57
  post_install_message:
67
58
  rdoc_options:
68
59
  - --main
69
- - README
60
+ - README.rdoc
70
61
  require_paths:
71
62
  - lib
72
63
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -89,5 +80,5 @@ signing_key:
89
80
  specification_version: 2
90
81
  summary: "I sometimes get a little descriptive with my variable names, so when you're doing a lot of work specifically with one object, it gets especially ugly and repetetive, making the code harder to read than it needs to be: @contract_participants_on_drugs.contract_id = params[:contract_id] @contract_participants_on_drugs.participant_name = params[:participant_name] @contract_participants_on_drugs.drug_conviction = DrugConvictions.find(:wtf => 'this is getting ridiculous') .."
91
82
  test_files:
92
- - test/test_helper.rb
93
83
  - test/test_with.rb
84
+ - test/test_with_on_object.rb
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/with.rb'}"
9
- puts "Loading with gem"
10
- exec "#{irb} #{libs} --simple-prompt"
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)
@@ -1,3 +0,0 @@
1
- require 'stringio'
2
- require 'test/unit'
3
- require File.dirname(__FILE__) + '/../lib/with'
@@ -1,103 +0,0 @@
1
- require '../lib/with'
2
- require 'test/unit'
3
- require 'foo'
4
-
5
-
6
-
7
- class TestWith < Test::Unit::TestCase
8
-
9
- def setup
10
- @foo = Foo.new
11
- end
12
-
13
- def test_With_works_with_attr_accessor_assignment
14
- foo = Foo.new
15
- With.object(foo) do
16
- get = 'got!'
17
- end
18
- assert(foo.get == "got!")
19
- end
20
-
21
- def test_With_works_with_two_attr_accessor_assignments
22
- # Seems strange, but one line blocks don't show up as blocks after running through ParseTree,
23
- # so this exercises the more common case, whereas the previous test exercises the uncommon one.
24
- With.object(@foo) do
25
- get = 'got!'
26
- a = 'b'
27
- end
28
- assert(@foo.get == "got!")
29
- assert(@foo.a == "b")
30
- end
31
-
32
- def test_With_works_with_method_call_no_args
33
- With.object(@foo) do
34
- get = 'got!'
35
- change
36
- end
37
- assert(@foo.a == "changed!")
38
- end
39
-
40
- def test_With_works_with_method_call_with_args
41
- With.object @foo do
42
- set("c", "d")
43
- set("d", "e")
44
- end
45
- assert @foo.a == "d"
46
- assert @foo.b == "e"
47
- end
48
-
49
- def test_With_ignores_calls_to_methods_where_foo_respond_to?_is_false
50
- With.object(@foo) do
51
- puts
52
- end
53
- assert( true )
54
- end
55
-
56
- def test_With_works_with_assignment_to_outside_method_call_no_args
57
- def outter
58
- 5
59
- end
60
- With.object(@foo) do
61
- a = outter
62
- end
63
-
64
- assert(@foo.a == 5)
65
- end
66
-
67
- def test_With_works_with_assignment_to_outside_lvar
68
- outter = "outside"
69
- With.object(@foo) do
70
- outter = get
71
- end
72
- assert( outter == @foo.get )
73
- #this fails. unsure how / if it should stay as part of the spec
74
- #problem is that (as far as I can tell) it will need to evaluate the post-transformation
75
- #block in the original context, whereas it currently needs to be executed in a diff one
76
- #this would be a lot easier - less transforms on other specs - if we could find the variable
77
- #name of "@foo" within With.object
78
- end
79
-
80
- def test_With_works_with_assignment_to_outside_method_call_with_args
81
- def f(x,y)
82
- 398
83
- end
84
- With.object(@foo) do
85
- a = f(1,3)
86
- end
87
- assert(@foo.a == 398)
88
- end
89
-
90
- def test_With_works_with_method_call_with_args_using_non_literals
91
- def f(x,y)
92
- 398
93
- end
94
- x = 2
95
- y = 5
96
- With.object(@foo) do
97
- a = f(x,y)
98
- end
99
- assert(@foo.a == 398)
100
- end
101
-
102
-
103
- end