hydroponics 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ # hydroponics 0.3.1
2
+
3
+ * Added loading graphic
4
+ * Fixed row deletion bug in Dupe
5
+
6
+ # hydroponics 0.3.0 2010-10-29
7
+
8
+ * One table action is built-in: "Dupe"
9
+ * Rails-like tree
10
+ * JQuery interface
11
+ * Rails project database manipulation with Sequel
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
data/app/actions/dupe.rb CHANGED
@@ -8,15 +8,14 @@ module Hydroponics
8
8
 
9
9
  current_count = @db[table].count
10
10
 
11
- time1 = Time.now
12
11
  if target_count > current_count
13
12
  @db[table].multi_insert([first_row] * (target_count - current_count))
14
- else
15
- @db[table].filter("id > #{target_count}").delete
13
+ elsif current_count > target_count
14
+ cutoff_id = @db[table].map(:id)[target_count-1]
15
+ @db[table].filter("id > #{cutoff_id}").delete
16
16
  end
17
- time2 = Time.now
18
17
 
19
- (time2 - time1).to_s + 's'
18
+ @db[table].count.to_s
20
19
  end
21
20
  end
22
21
  end
@@ -8,28 +8,31 @@
8
8
  <script type="text/javascript" src="../vendor/jquery-ui-1.8.5.custom/js/jquery-ui-1.8.5.custom.min.js"></script>
9
9
  <script type="text/javascript">
10
10
  $(function(){
11
- $("#slider").slider({
11
+ $("#slider div").slider({
12
12
  slide: function(event, ui) {
13
- $("#sliderct").html(ui.value);
13
+ $("#sliderct").html("<i>" + ui.value + "</i>");
14
14
  $("button").button("enable");
15
15
  },
16
- max: 25000
16
+ max: 25000,
17
+ value: <%= db[@table].count %>
17
18
  });
18
19
 
19
20
  $("button").button();
20
21
  $("button").button("enable");
21
22
  $("button").click(function(){
22
- $("#slider").slider("disable");
23
+ $("#slider div").slider("disable");
23
24
  $("button").button("disable");
25
+ $(".loader").show();
24
26
  $.ajax({
25
27
  type: "POST",
26
28
  url: "/dupe/<%= @table %>",
27
29
  data: JSON.stringify({
28
- count: $("#slider").slider("value")
30
+ count: $("#slider div").slider("value")
29
31
  }),
30
32
  success: function(data, status, xhr) {
31
33
  $("#sliderct").html("<b>" + data + "</b>");
32
- $("#slider").slider("enable");
34
+ $("#slider div").slider("enable");
35
+ $(".loader").hide();
33
36
  },
34
37
  processData: false
35
38
  });
@@ -37,26 +40,60 @@
37
40
  });
38
41
  </script>
39
42
  <style type="text/css">
40
- .stats {
41
- width: 400px;
43
+ .container {width:950px;margin:0 auto;}
44
+ .dupe h3 {
45
+ margin: 10px 5px 10px 18px;
46
+ color: #444;
47
+ float: left;
42
48
  }
43
- h1, h3 {
49
+ .dupe #slider {
50
+ float: left;
51
+ width: 352px;
52
+ margin: 16px 12px;
53
+ }
54
+ .dupecontainer {
55
+ height: 130px;
56
+ width: 501px;
57
+ }
58
+ .dupe {
59
+ height: 106px;
60
+ width: 500px;
61
+ border: 1px #ddd solid;
62
+ }
63
+ .dupe #button {
64
+ float: right;
65
+ margin: 2px 12px;
66
+ }
67
+ .dupe p {
68
+ padding: 50px 18px;
69
+ font-size: 12px;
70
+ }
71
+ h1, h3, p {
44
72
  font-family: Verdana,Arial,sans-serif
45
73
  }
74
+ .loader {
75
+ background-image: url('../ajax-loader.gif');
76
+ width: 32px;
77
+ height: 16px;
78
+ margin-top:16px;
79
+ float: left;
80
+ }
46
81
  </style>
47
82
  <title>Hydroponics <%= settings.version %></title>
48
83
  </head>
49
84
 
50
- <body>
85
+ <body class="container">
51
86
  <div class="header">
52
87
  <h1>Hydroponics</h1>
53
88
  </div>
54
- <div class="stats">
55
- <h3><%= @table.to_s %></h3>
56
- <div id='slider'></div>
57
- <span id='sliderct'></span>
58
- <button>Dupe</button>
59
- <p>Count: <%= db[@table].count %></p>
89
+ <div class="dupecontainer">
90
+ <div class="dupe">
91
+ <h3>Dupe</h3>
92
+ <div id='slider'><div></div></div>
93
+ <div class="loader" style="display:none;"></div>
94
+ <div id='button'><button>Update</button></div>
95
+ <p><%= @table.to_s.gsub("_"," ") %>: <span id='sliderct'><%= db[@table].count %></span></p>
96
+ </div>
60
97
  </div>
61
98
  </body>
62
99
  </html>
data/hydroponics.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hydroponics}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tyler Boyd"]
@@ -15,12 +15,14 @@ Gem::Specification.new do |s|
15
15
  s.email = %q{tboyd47@gmail.com}
16
16
  s.executables = ["hydro"]
17
17
  s.extra_rdoc_files = [
18
- "LICENSE",
18
+ "ChangeLog.markdown",
19
+ "LICENSE",
19
20
  "README.rdoc"
20
21
  ]
21
22
  s.files = [
22
23
  ".document",
23
24
  ".gitignore",
25
+ "ChangeLog.markdown",
24
26
  "LICENSE",
25
27
  "README.rdoc",
26
28
  "Rakefile",
@@ -37,6 +39,7 @@ Gem::Specification.new do |s|
37
39
  "spec/hydroponics_spec.rb",
38
40
  "spec/spec.opts",
39
41
  "spec/spec_helper.rb",
42
+ "static/ajax-loader.gif",
40
43
  "static/dupe.js",
41
44
  "static/test/dupe_test.js",
42
45
  "static/test/index.html",
@@ -72,6 +72,12 @@ describe "Hydroponics::Actions" do
72
72
  @db[:users].count.should == 2
73
73
  end
74
74
 
75
+ it "should handle non-consecutive id numbers" do
76
+ @db[:users].multi_insert([{:id => 6789, :name => "ABC", :email => "123@example.com"}, {:id => 6790, :name => "ABC", :email => "123@example.com"}])
77
+ dupe(:users, 2)
78
+ @db[:users].count.should == 2
79
+ end
80
+
75
81
  it "should require the table name and count" do
76
82
  lambda { dupe }.should raise_error
77
83
  lambda { dupe(:users) }.should raise_error
Binary file
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydroponics
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tyler Boyd
@@ -126,11 +126,13 @@ executables:
126
126
  extensions: []
127
127
 
128
128
  extra_rdoc_files:
129
+ - ChangeLog.markdown
129
130
  - LICENSE
130
131
  - README.rdoc
131
132
  files:
132
133
  - .document
133
134
  - .gitignore
135
+ - ChangeLog.markdown
134
136
  - LICENSE
135
137
  - README.rdoc
136
138
  - Rakefile
@@ -147,6 +149,7 @@ files:
147
149
  - spec/hydroponics_spec.rb
148
150
  - spec/spec.opts
149
151
  - spec/spec_helper.rb
152
+ - static/ajax-loader.gif
150
153
  - static/dupe.js
151
154
  - static/test/dupe_test.js
152
155
  - static/test/index.html